Repository navigation
fix(tab-bar): keep tab menu items on one line and give every item an icon - #10882
Conversation
…icon The editor tab menu was pinned to `w-48`, so "Close All Editor Tabs" plus its shortcut chip wrapped onto a second line. This is worse off macOS, where the chip renders `Ctrl+Alt+W` instead of the much narrower `⌘⌥W`, and in locales with longer copy. Size the three tab context menus from a shared rule that grows to fit content and caps at the viewport, and fill in the icons that "Close Others" and "Close Tabs To The Left" were missing.
📝 WalkthroughWalkthroughTab context menus now use shared sizing constants for content and submenu surfaces, including single-line rendering and bounded widths. Close-action entries use updated Lucide icons and translation keys. Related test mocks include the new icons, and a consistency test verifies icon presence, shared sizing usage, and width constraints across tab context menu implementations. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/renderer/src/components/tab-bar/tab-context-menu-consistency.test.tsx (1)
53-60: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the shared rule is applied to the menu surface itself.
This test only checks that the file imports the sizing module and lacks a literal
className="w-N". It will miss regressions such asclassName={cn('w-56', TAB_CONTEXT_MENU_CONTENT_CLASS)}or an unused import. Assert that eachDropdownMenuContent/DropdownMenuSubContentopening tag uses the expected shared constant and inspect width classes within those tags.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6d87205e-01fd-4260-9bfd-064b1ca2247f
📒 Files selected for processing (12)
src/renderer/src/components/tab-bar/BrowserTab.test.tsxsrc/renderer/src/components/tab-bar/BrowserTab.tsxsrc/renderer/src/components/tab-bar/EditorFileTab.test.tsxsrc/renderer/src/components/tab-bar/EditorFileTabContextMenu.test.tsxsrc/renderer/src/components/tab-bar/EditorFileTabContextMenu.tsxsrc/renderer/src/components/tab-bar/SortableTab.rename-shortcut.test.tsxsrc/renderer/src/components/tab-bar/SortableTabContextMenu.test.tsxsrc/renderer/src/components/tab-bar/SortableTabContextMenu.tsxsrc/renderer/src/components/tab-bar/TabWorkspaceLayoutMenuSection.tsxsrc/renderer/src/components/tab-bar/TerminalTabSplitMenuSection.tsxsrc/renderer/src/components/tab-bar/tab-context-menu-consistency.test.tsxsrc/renderer/src/components/tab-bar/tab-context-menu-sizing.ts
The previous check only looked for the module import and a literal
`className="w-N"`, so it would pass on `cn('w-56', SHARED)` or an import that
nothing uses. Inspect each DropdownMenuContent/SubContent opening tag instead.
|
Good catch — fixed in a23a523. You were right that the old check was hollow: it only asserted the file imported the sizing module and lacked a literal I verified it fails rather than passing vacuously, against exactly the two regressions you named:
Also seeded a removed icon to confirm the icon assertion still catches that. Full tab-bar suite: 255 passing. |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0f83099f-f029-48ed-875f-f7b668c91b40
📒 Files selected for processing (1)
src/renderer/src/components/tab-bar/tab-context-menu-consistency.test.tsx
| if (surfaces.length === 0) { | ||
| return | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Do not let empty extraction vacuously pass.
If the matcher breaks or a source filename becomes stale, this return makes the consistency test pass without validating any menu surface. Assert that each listed source contains at least one surface, or explicitly allow such files.
Proposed fix
- if (surfaces.length === 0) {
- return
- }
+ expect(surfaces, `No menu surfaces found in ${fileName}`).not.toHaveLength(0)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (surfaces.length === 0) { | |
| return | |
| } | |
| expect(surfaces, `No menu surfaces found in ${fileName}`).not.toHaveLength(0) |
| expect(tag, `<${name}> in ${fileName} pins a fixed width:\n${tag}`).not.toMatch( | ||
| /(?:^|[\s'"`])w-(?:\d+|\[)/ | ||
| ) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Match every w-* utility class.
This regex catches only numeric and bracketed widths; w-full, w-auto, w-fit, w-px, and variant-prefixed widths can bypass the test, despite the PR’s stated no-hardcoded-width invariant.
Proposed fix
- /(?:^|[\s'"`])w-(?:\d+|\[)/
+ /(?:^|[\s'"`])(?:[^\s'"`]*:)*w-[^\s'"`]+/📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| expect(tag, `<${name}> in ${fileName} pins a fixed width:\n${tag}`).not.toMatch( | |
| /(?:^|[\s'"`])w-(?:\d+|\[)/ | |
| ) | |
| expect(tag, `<${name}> in ${fileName} pins a fixed width:\n${tag}`).not.toMatch( | |
| /(?:^|[\s'"`])(?:[^\s'"`]*:)*w-[^\s'"`]+/ | |
| ) |
Summary
Two inconsistencies in the tab context menus:
w-48(192px), which isn't wide enough for that label plus its⌘⌥Wshortcut chip.Close OthersandClose Tabs To The Leftrendered as bare text while their neighbours all had one.The wrap is worse off macOS: the chip is built by
formatKeybinding, which rendersCtrl+Alt+Won Windows/Linux instead of the narrower⌘⌥W, so a fixed width that barely fits on Mac clips harder everywhere else. Longer locales compound it (esrenders "Cerrar todas las pestañas del editor").Fix: replaced the fixed
w-48/w-56widths with a shared rule intab-context-menu-sizing.ts—min-w-[13rem] max-w-[calc(100vw-1rem)] whitespace-nowrap— so menus grow to fit content instead of wrapping, bounded by the viewport. Submenus get the same rule explicitly since they portal out and don't inherit the parent'swhitespace-nowrap. AddedCopyXfor "Close Others" andPanelLeftClosefor "Close Tabs To The Left".Applied across all three tab context menus (editor, terminal, browser) — the browser menu had the same two missing icons.
Screenshots
Captured from a dev build of this branch, CDP-attached to this worktree.
Before — wrapped label, two items with no icon:
After — editor tab menu:
Terminal and browser tab menus — same treatment:
Measured from the live DOM — all 12 editor items report
lines: 1at a uniform 28px height, each with at least one svg.Move Tab to Splithas 2 (leading icon + chevron).Testing
pnpm lint— oxlint + oxfmt clean;verify:localization-catalogverified parity acrosses/ja/ko/zhpnpm typecheck—tsc --noEmitcleanpnpm test— tab-bar suite: 255 passed (35 files)pnpm build— not run; this is a CSS-class + icon change with no build-surface impact, and CI covers ittab-context-menu-consistency.test.tsx, asserting every action item has an icon and every menu surface applies the shared sizing ruleI verified the new test fails rather than passing vacuously, against three seeded regressions: removing an icon,
cn('w-56', SHARED), and an import left in place while the surface stops using it.AI Review Report
Reviewed for correctness, cross-platform behavior, and blast radius.
Cross-platform — explicitly checked, since this PR is about width:
formatKeybinding, which emitsCtrl+Alt+W/Ctrl/Alt/Shifton Windows/Linux vs⌘⌥⇧glyphs on Mac. Probed against the live menu: withCtrl+Alt+Wthe menu grows to 231px and stays single-line.Reveal in Finder/Open Containing Folder/Reveal in File Explorerlabel already branches per platform and is unchanged; the longest variant stays on one line.metaKeyhardcoding, path handling, or shell behavior — the change is CSS classes plus two icon imports.Flagged and addressed: the review noted my first sizing test only checked for the module import and a literal
className="w-N", so it would pass oncn('w-56', SHARED). Fixed in a23a523 — it now inspects eachDropdownMenuContent/SubContentopening tag directly.Flagged and assessed as not actionable: a concern that
whitespace-nowrap+ the viewport cap could clip long labels against the primitives'overflow-x-hidden. I tested this rather than assuming. Clipping requires a ~200-character label; real labels top out at 364px against an 884px cap. Every interpolation in these three menus is either a static translated string or an event handler — there is no user-controlled text in any tab menu label, so the unbounded case can't occur. Adding truncation would trade a real fixed bug for defensive code against an unreachable input. Noted as follow-up below rather than fixed here.Deliberately scoped out: the
whitespace-nowrapis on the tab menus, not the sharedDropdownMenuItemprimitive. A primitive-level change would hit ~56 usages, some with genuinely unbounded dynamic labels (browser profile names, model descriptions) — a larger cleanup than this bug warrants, and the case where truncation would be the right call.Security Audit
No security surface. The change is Tailwind class strings and two
lucide-reacticon imports. No input handling, command execution, path handling, auth, secrets, or IPC changes. No new dependencies. The existingwindow.api.shell.openPathcall in the reveal item is untouched, including itsshouldBlockEditorTabLocalOpenguard.Notes