Skip to content

feat(widget): add header menu with conversation and privacy options - #505

Merged
anurag629 merged 7 commits into
codercops:devfrom
anurag2787:add/widget-menu
Oct 31, 2026
Merged

anurag629 merged 7 commits into
codercops:devfrom
anurag2787:add/widget-menu

Conversation

@anurag2787

Copy link
Copy Markdown
Collaborator

What does this change?

Added a More Options menu to the widget header with options to start a new conversation

Closes #496

How I tested this

Ran pnpm test:coverage, pnpm lint, pnpm api, pnpm docs:check and pnpm size. Verified menu interactions, keyboard navigation, transcript download, and privacy URL validation

AI assistance

ChatGPT was used to help with the implementation and tests

Checklist

  • This PR targets dev
  • I was assigned the linked issue
  • pnpm -r build, pnpm test and pnpm -r typecheck pass locally
  • Tests added or updated where it makes sense
  • For a bug fix: the new test fails without my change
  • Changeset added (pnpm changeset) if this changes core, widget or server
  • pnpm api run and api/ committed if an exported type or option changed
  • Docs updated if behavior or options changed

Signed-off-by: Anurag Yadav <anuragyadav2787@gmail.com>
Signed-off-by: Anurag Yadav <anuragyadav2787@gmail.com>
Signed-off-by: Anurag Yadav <anuragyadav2787@gmail.com>
@anurag2787
anurag2787 marked this pull request as draft October 30, 2026 22:10

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @anurag2787. Loading the menu as its own chunk with its own size entry is the right shape. With dev merged in, build, typecheck, api:check, docs:check and coverage pass. Some things need fixing first:

Tests that fail

  1. Your e2e test header menu with keyboard navigation and New conversation (e2e/tests/states.spec.ts:257) fails in light, dark and RTL: after Enter the menu is still visible (line 275). Run E2E_CHANNEL=chrome pnpm e2e (or pnpm e2e with Playwright's Chromium) before pushing.
  2. e2e/tests/loader.spec.ts:168 fails: opening the panel now downloads chunks/menu-*.js, because Panel.show() calls loadMenu(). Chunks load only when they're used (that test is the guard), so drop that line and load the menu on the button's click and keydown. Prefetching on pointerenter/focus of the button is fine if you want it.

Size
3. pnpm size fails: the panel goes from 17.34 to 18.37 kB and the single file to 21.45 kB. A menu in its own chunk should cost the panel a few hundred bytes, not 1 kB. Move what only the menu needs into menu.ts: the label defaults in renderHeader() (moreLabel = 'More options' and so on, which panelLabels() always passes anyway), the open and keyboard wiring, and the escaping. Then the panel only creates the button and calls loadMenu().
4. Please revert the single-file limit in .size-limit.json (20 to 22 kB). Budget changes go in their own PR so they're decided once; the issue asked to talk first. I'm opening one now to make room for this, #504 and #502, and you can update from dev after it.

Code
5. packages/widget/src/i18n.ts: remove the moreOptions alias in getWidgetLocale(). It's a second public name for moreButton that nothing asked for.
6. packages/widget/src/widget.ts, downloadTranscript(): make it private. As it is, it's public API (it shows in api/widget.api.md), and 1.0 freezes that.
7. Same function: URL.revokeObjectURL(a.href) right after a.click() can cancel the download in some browsers. Revoke it in a setTimeout(..., 0) or later.
8. packages/widget/src/styles/menu.css: .cc-menu-item:focus-visible sets outline: none with only a background change, which is too faint to count as a focus indicator. Use box-shadow: var(--cc-focus-ring) like the other controls (see the focus list at the end of widget.css).

Lint
9. Three new Biome warnings, noExplicitAny in packages/widget/tests/dom/menu.test.ts at 186, 199 and 222. Type widget with a small interface for what the test reads, as tests/stop.test.ts does with internals(). pnpm lint should say 38 warnings, the same as dev.

@anurag629

Copy link
Copy Markdown
Member

@anurag2787 #508 has raised the single-file limit to 22 kB and the panel to 19 kB, so drop your .size-limit.json change when you update from dev. The panel still needs trimming (point 3): there's room for all three features, but not 1 kB for the menu button.

anurag2787 and others added 2 commits October 31, 2026 08:29

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @anurag2787, all of it is addressed. With dev merged in:

  • build, typecheck, lint (38), api:check, docs:check and coverage pass
  • pnpm size passes: panel 18.26 of 19 kB, menu chunk 1.7 kB, single file 21.53 of 22 kB
  • all 85 e2e tests pass in Chrome, including the loader chunk check and your menu test

I also checked the first Enter, Space and click on the button, before the chunk has loaded, and each opens the menu once.

@anurag629

Copy link
Copy Markdown
Member

@anurag2787 approved and CI is green, but the PR is still a draft, so it can't be merged. Mark it ready for review when you're done with it and I'll merge.

@anurag2787
anurag2787 marked this pull request as ready for review October 31, 2026 03:39
@anurag2787

Copy link
Copy Markdown
Collaborator Author

Hi @anurag629 i made the PR ready for review
Thanks!

@anurag629
anurag629 merged commit e699c3d into codercops:dev Oct 31, 2026
@anurag629 anurag629 added the hacktoberfest-accepted PR counts for Hacktoberfest label Oct 31, 2026
@anurag629

Copy link
Copy Markdown
Member

Merged, thanks @anurag2787.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted PR counts for Hacktoberfest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Widget: a header menu with New conversation, Download transcript and a privacy link

2 participants