Skip to content

The agent that grows with you

fix(desktop): pane tab ✕ costs a min-width floor, not 36px of dead padding

Brooklyn Nicholson87e78d668b1c
diff --git a/apps/desktop/src/components/ui/pane-tab.test.tsx b/apps/desktop/src/components/ui/pane-tab.test.tsx
index 69b7e39663d..fbd11c552fe 100644
--- a/apps/desktop/src/components/ui/pane-tab.test.tsx
+++ b/apps/desktop/src/components/ui/pane-tab.test.tsx
@@ -5,6 +5,10 @@ import { PaneTab, PaneTabLabel } from './pane-tab'
afterEach(cleanup)
+/** The tab shell's own classes (the label's grandparent), split for set diffs. */
+const classesOf = (label: string): string[] =>
+ screen.getByText(label).parentElement!.parentElement!.className.split(/\s+/).filter(Boolean)
+
describe('PaneTab close gestures', () => {
it('middle-click closes — pointer events only, no auxclick', () => {
const onClose = vi.fn()
@@ -124,25 +128,50 @@ describe('PaneTab hover close button', () => {
expect(screen.queryByRole('button', { name: 'Close' })).toBeNull()
})
- it('reserves a close-button runway only on closeable horizontal tabs', () => {
+ it('floors a closeable horizontal tab instead of padding a runway onto it', () => {
const onClose = vi.fn()
- const { rerender } = render(
+ const closeable = render(
<PaneTab onClose={onClose}>
<PaneTabLabel>BROWSER</PaneTabLabel>
</PaneTab>
)
+ const withClose = classesOf('BROWSER')
+ closeable.unmount()
- const horizontalTab = screen.getByText('BROWSER').parentElement?.parentElement
- expect(horizontalTab?.className).toContain('pr-9')
+ render(
+ <PaneTab>
+ <PaneTabLabel>BROWSER</PaneTabLabel>
+ </PaneTab>
+ )
+ const withoutClose = classesOf('BROWSER')
+
+ // The ✕ is paid for with a min-width FLOOR, not right padding: a short
+ // label can't be swallowed by its own chip, and a tab whose label already
+ // clears the floor pays nothing — so no tab carries dead runway at rest.
+ const added = withClose.filter(cls => !withoutClose.includes(cls))
+ expect(added.some(cls => /^min-w-/.test(cls))).toBe(true)
+ expect(withClose.some(cls => /^pr-/.test(cls))).toBe(false)
+ })
- rerender(
+ it('a vertical rail tab gets no floor — it has no ✕ to make room for', () => {
+ const onClose = vi.fn()
+
+ const railed = render(
<PaneTab onClose={onClose} vertical>
<PaneTabLabel>BROWSER</PaneTabLabel>
</PaneTab>
)
- const verticalTab = screen.getByText('BROWSER').parentElement?.parentElement
- expect(verticalTab?.className).not.toContain('pr-9')
+ const withClose = classesOf('BROWSER')
+ railed.unmount()
+
+ render(
+ <PaneTab vertical>
+ <PaneTabLabel>BROWSER</PaneTabLabel>
+ </PaneTab>
+ )
+
+ expect(withClose).toEqual(classesOf('BROWSER'))
})
it('a closeable horizontal tab always shows its ✕ — the chip and the pointer gestures are one affordance', () => {
diff --git a/apps/desktop/src/components/ui/pane-tab.tsx b/apps/desktop/src/components/ui/pane-tab.tsx
index 8b0703a9e25..d7b4a967bc6 100644
--- a/apps/desktop/src/components/ui/pane-tab.tsx
+++ b/apps/desktop/src/components/ui/pane-tab.tsx
@@ -23,6 +23,11 @@ const TAB =
// leave uncovered, so tabs fill the bar and no sliver of gutter shows through.
const TAB_HORIZONTAL = 'h-full min-w-0 max-w-48 not-first:border-l not-first:border-l-(--ui-stroke-quaternary)'
+// A closeable tab's floor: 8px label inset + the ~19px opaque ✕ chip, so the
+// shortest labels (FILES, REVIEW) clear the chip and pass under nothing but the
+// gradient. A floor, not padding — a tab already wider than it pays nothing.
+const TAB_CLOSEABLE = 'min-w-13'
+
const TAB_VERTICAL =
'w-full max-h-48 justify-center not-first:border-t not-first:border-t-(--ui-stroke-quaternary) [writing-mode:vertical-rl]'
@@ -102,7 +107,7 @@ export const PaneTab = React.forwardRef<HTMLDivElement, PaneTabProps>(function P
className={cn(
TAB,
vertical ? TAB_VERTICAL : TAB_HORIZONTAL,
- !vertical && onClose && 'pr-9',
+ !vertical && onClose && TAB_CLOSEABLE,
edge,
active
? cn(TAB_ACTIVE, !vertical && TAB_ACTIVE_UNDERLINE)
@@ -164,9 +169,11 @@ export const PaneTab = React.forwardRef<HTMLDivElement, PaneTabProps>(function P
</span>
)}
{onClose && !vertical && (
- // Hover ✕ stays absolutely positioned so hover never shifts the tab.
- // The tab reserves a fixed right runway for this overlay, keeping the
- // label clear of the gradient/button even for short labels like BROWSER.
+ // Hover ✕, painted OVER the label's right edge as an overlay (no
+ // layout shift, tab width never jumps on hover). The runway is a tiny
+ // transparent→`--tab-face` gradient, so the button melts into the
+ // tab's effective surface instead of hard-clipping the text under it.
+ // Short labels are kept legible by TAB_CLOSEABLE, not by padding.
// Rendered after the dirty dot: on hover the ✕ takes the dot's spot,
// VS Code-style.
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-stretch opacity-0 transition-opacity group-hover/tab:pointer-events-auto group-hover/tab:opacity-100">