Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(tabbar): give the name priority as tabs shrink — measured density sheds furniture first
enes6fa7e52c9880
diff --git a/CLAUDE.md b/CLAUDE.mdindex 8232f267d..51624537f 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -4031,9 +4031,17 @@ the Settings section and ShortcutsPanel start disagreeing about what a chord measurface below — which is also the kanban overlay's colour, so it merges under both views. InLIGHT the strip steps back to `--surface-deep` (`--tabbar-bg`), because `--panel` and`--canvas-bg` are one value apart there and a canvas-coloured tab would vanish. Tabs share one- flex basis (`--tab-w`) and shrink together; the name is `flex: 1 1 0; width: 0` under a mask fade- (never an ellipsis), and `width: 0` is what keeps a tab's automatic minimum at its fixed parts- instead of the whole label. **The bar's height is ONE number in two places that cannot read each+ flex basis (`--tab-w`, the active one wider by its board toggle so its name shrinks in step) and+ shrink together; the name is `flex: 1 1 0; width: 0; min-width: var(--tab-name-min)` under a mask+ fade (never an ellipsis), and `width: 0` is what keeps a tab's automatic minimum at its fixed+ parts instead of the whole label. **The name has priority as tabs shrink** (the #789 regression:+ at 8 tabs / 1340px the ACTIVE name was 24px — 0 characters — because it carried the most+ furniture and hit its floor first; at 12 every name was). `renderer/lib/tabDensity.ts` derives a+ per-strip level from the measured strip width ÷ tab count (TabBar stamps it as `data-density`):+ `compact` hides the SSH chip, `tight` makes the inactive caret hover-only (kept while its menu is+ open, `tab--menu-open`); the active tab keeps both buttons at every level, and the 60px name floor+ is the one place the strip decides to scroll instead of squeezing. Thresholds are derived from+ the measured furniture, not chosen — change a padding and update the constants. **The bar's height is ONE number in two places that cannot read eachother**: `--tabbar-h` in styles.css (every top-anchored panel, the kanban overlay and the usagepopover position against it) and `TABBAR_HEIGHT_PX` in `@shared/window-chrome-metrics`, fromwhich main derives the traffic-light `y` (`trafficLightY`) — a literal 15 for a 44px bar wasdiff --git a/docs/assets/tabstrip-12-tabs-1340-hover.png b/docs/assets/tabstrip-12-tabs-1340-hover.pngnew file mode 100644index 000000000..c0ae8ef42Binary files /dev/null and b/docs/assets/tabstrip-12-tabs-1340-hover.png differdiff --git a/docs/assets/tabstrip-12-tabs-1340.png b/docs/assets/tabstrip-12-tabs-1340.pngnew file mode 100644index 000000000..bb6b090dcBinary files /dev/null and b/docs/assets/tabstrip-12-tabs-1340.png differdiff --git a/docs/assets/tabstrip-8-tabs-1340.png b/docs/assets/tabstrip-8-tabs-1340.pngnew file mode 100644index 000000000..8af1ad49dBinary files /dev/null and b/docs/assets/tabstrip-8-tabs-1340.png differdiff --git a/docs/assets/tabstrip-before-12-tabs-1340.png b/docs/assets/tabstrip-before-12-tabs-1340.pngnew file mode 100644index 000000000..6316ad403Binary files /dev/null and b/docs/assets/tabstrip-before-12-tabs-1340.png differdiff --git a/docs/assets/tabstrip-dark-12-tabs-900px.png b/docs/assets/tabstrip-dark-12-tabs-900px.pngdeleted file mode 100644index 736536743..000000000Binary files a/docs/assets/tabstrip-dark-12-tabs-900px.png and /dev/null differdiff --git a/docs/assets/tabstrip-dark-12-tabs.png b/docs/assets/tabstrip-dark-12-tabs.pngdeleted file mode 100644index 6a308ed56..000000000Binary files a/docs/assets/tabstrip-dark-12-tabs.png and /dev/null differdiff --git a/src/renderer/components/TabBar.test.tsx b/src/renderer/components/TabBar.test.tsxindex 3473f9bf5..2d8650b55 100644--- a/src/renderer/components/TabBar.test.tsx+++ b/src/renderer/components/TabBar.test.tsx@@ -336,3 +336,62 @@ describe('TabBar options button', () => {expect(document.querySelector('.tab-menu')).not.toBeNull()})})++describe('TabBar density', () => {+ let root: Root+ let host: HTMLElement++ // jsdom lays nothing out (`clientWidth` is 0), so the observer's measurement cannot be driven+ // here; what CAN be pinned is the contract the stylesheet reads: the strip carries a density+ // attribute, it starts at `roomy` (the pre-density rendering), and the tab whose menu is open+ // is marked so a tight strip keeps its caret on screen.+ beforeEach(async () => {+ const { TabBar, useProjects } = await load()+ host = document.createElement('div')+ document.body.appendChild(host)+ useProjects.setState({+ projects: [project(), project({ id: 'p2', name: 'Beta' })],+ activeProjectId: 'p1'+ })+ root = createRoot(host)+ await act(async () => {+ root.render(+ <TabBar+ onSwitch={vi.fn()}+ onReconnect={vi.fn()}+ onReorder={vi.fn()}+ onOpenWelcome={vi.fn()}+ onRename={vi.fn()}+ onSetFolder={vi.fn()}+ onCloseProject={vi.fn()}+ onRemoteAccess={vi.fn()}+ onSetDefaultAccount={vi.fn()}+ onSetDefaultPermissionMode={vi.fn()}+ onOpenProjectSettings={vi.fn()}+ />+ )+ })+ })++ afterEach(() => {+ act(() => root.unmount())+ host.remove()+ })++ it('stamps the strip with a density the stylesheet can read, roomy until measured', () => {+ // jsdom reports a 0px strip, which the rule reads as "tight"; either way the attribute is one+ // of the three levels and present from the first render.+ const strip = host.querySelector('.tabbar__tabs')!+ expect(['roomy', 'compact', 'tight']).toContain(strip.getAttribute('data-density'))+ })++ it('marks the tab whose menu is open, so a tight strip does not hide the caret under its own menu', async () => {+ const carets = host.querySelectorAll<HTMLButtonElement>('.tab__caret')+ await click(carets[1])+ const tabs = host.querySelectorAll('.tab')+ expect(tabs[1].classList.contains('tab--menu-open')).toBe(true)+ expect(tabs[0].classList.contains('tab--menu-open')).toBe(false)+ await click(carets[1])+ expect(tabs[1].classList.contains('tab--menu-open')).toBe(false)+ })+})diff --git a/src/renderer/components/TabBar.tsx b/src/renderer/components/TabBar.tsxindex f52b74f0e..f44a1c364 100644--- a/src/renderer/components/TabBar.tsx+++ b/src/renderer/components/TabBar.tsx@@ -12,6 +12,7 @@ import { sessionCount, sessionForProject, useProjectSession } from '../session/simport { tabClickAction } from '../session/relay-tab'import { useMenuFlip } from '../ui/useMenuFlip'import { commandTooltip } from '../lib/keybindingOverrides'+import { tabDensity, type TabDensity } from '../lib/tabDensity'import { IconCanvasView, IconKanban, IconMoreVertical, IconPlus } from './icons'import { ProjectGlyph } from './ProjectGlyph'import {@@ -212,6 +213,27 @@ export function TabBar({?.scrollIntoView({ behavior: 'smooth', inline: 'nearest', block: 'nearest' })}, [activeId, projects.length])+ // How much furniture a tab may carry at the width the strip can give it (see lib/tabDensity):+ // measured on the strip itself and stamped on it as `data-density`, so the stylesheet sheds the+ // SSH chip, then the inactive caret, BEFORE the name is squeezed. The strip is content-sized, so+ // its clientWidth is the tabs' full width while they fit and the available width once they+ // shrink — either way the per-tab share the rule wants. Its padding is the flares' room.+ const [density, setDensity] = useState<TabDensity>('roomy')+ const tabCount = projects.length+ useEffect(() => {+ const el = tabsRef.current+ if (!el || typeof ResizeObserver === 'undefined') return+ const measure = (): void => {+ const cs = getComputedStyle(el)+ const inner = el.clientWidth - parseFloat(cs.paddingLeft) - parseFloat(cs.paddingRight)+ setDensity(tabDensity(Number.isFinite(inner) ? inner : null, tabCount))+ }+ measure()+ const ro = new ResizeObserver(measure)+ ro.observe(el)+ return () => ro.disconnect()+ }, [tabCount])+// The backdrop deliberately sits BELOW the bar, so a click on another tab switches to it in one// go instead of being swallowed as a dismiss — which leaves the bar itself (its empty stretch,// the brand, the +) unable to close the menu. This covers exactly that gap, and it closes@@ -276,6 +298,7 @@ export function TabBar({><divclassName="tabbar__tabs"+ data-density={density}ref={tabsRef}onWheel={(e) => {// Translate a vertical mouse wheel into horizontal strip scrolling (trackpads@@ -290,7 +313,7 @@ export function TabBar({return (<divkey={p.id}- className={`tab${active ? ' active' : ''}${swimlaneHighlight ? ' tab--swimlane-highlight' : ''}${p.unavailable ? ' unavailable' : ''}${dropId === p.id ? ' is-drop-before' : ''}`}+ className={`tab${active ? ' active' : ''}${swimlaneHighlight ? ' tab--swimlane-highlight' : ''}${p.unavailable ? ' unavailable' : ''}${dropId === p.id ? ' is-drop-before' : ''}${menuId === p.id ? ' tab--menu-open' : ''}`}// The project colour rides the GLYPH (below), not the label: `.tab.active` is// neutral text on the page's own surface, like a browser tab. The one exception is// the swimlane highlight, whose underline is `currentColor` and is meant to be thediff --git a/src/renderer/lib/tabDensity.test.ts b/src/renderer/lib/tabDensity.test.tsnew file mode 100644index 000000000..9367d3b57--- /dev/null+++ b/src/renderer/lib/tabDensity.test.ts@@ -0,0 +1,47 @@+import { describe, expect, it } from 'vitest'+import {+ COMPACT_MIN_TAB_PX,+ ROOMY_MIN_TAB_PX,+ TAB_BASE_FURNITURE_PX,+ TAB_CARET_PX,+ TAB_NAME_MIN_PX,+ TAB_SSH_CHIP_PX,+ tabDensity+} from './tabDensity'++describe('tabDensity', () => {+ // The strip inner width a 1340px macOS window leaves 8 tabs, measured before the fix: 1114 minus+ // 16px of flare padding. Every number below is from that run or derived from its furniture.+ const STRIP_1340_MAC = 1114 - 16++ it('answers roomy until measured', () => {+ expect(tabDensity(null, 8)).toBe('roomy')+ expect(tabDensity(Number.NaN, 8)).toBe('roomy')+ expect(tabDensity(1000, 0)).toBe('roomy')+ })++ it('keeps everything while a tab can hold chip + caret + a readable name', () => {+ expect(ROOMY_MIN_TAB_PX).toBe(TAB_BASE_FURNITURE_PX + TAB_SSH_CHIP_PX + TAB_CARET_PX + TAB_NAME_MIN_PX)+ expect(tabDensity(ROOMY_MIN_TAB_PX * 4, 4)).toBe('roomy')+ // 4 projects at their 168px basis: what a typical window shows.+ expect(tabDensity(168 * 4, 4)).toBe('roomy')+ })++ it('drops the SSH chip first: the field report at 8 tabs in 1340px is compact, not tight', () => {+ // 1098 / 8 = 137px per tab — enough for caret + 60px of name, not for the chip as well.+ expect(tabDensity(STRIP_1340_MAC, 8)).toBe('compact')+ expect(tabDensity(ROOMY_MIN_TAB_PX * 8 - 8, 8)).toBe('compact')+ })++ it('hides the inactive caret only when the caret itself would squeeze the name', () => {+ // 1098 / 12 = 91.5px per tab: below the caret floor, above the bare floor.+ expect(tabDensity(STRIP_1340_MAC, 12)).toBe('tight')+ expect(tabDensity(COMPACT_MIN_TAB_PX * 12 - 12, 12)).toBe('tight')+ expect(tabDensity(COMPACT_MIN_TAB_PX * 12, 12)).toBe('compact')+ })++ it('never lets the name floor fall below the width of a short word', () => {+ // Below this the fade zone (18px) eats most of what is left; 24px was the reported bug.+ expect(TAB_NAME_MIN_PX).toBeGreaterThanOrEqual(56)+ })+})diff --git a/src/renderer/lib/tabDensity.ts b/src/renderer/lib/tabDensity.tsnew file mode 100644index 000000000..b298f21d5--- /dev/null+++ b/src/renderer/lib/tabDensity.ts@@ -0,0 +1,53 @@+/**+ * How much furniture a project tab may carry at the width the strip can give it.+ *+ * MEASURED, 8 projects in a 1340px macOS window (86px traffic-light reservation), on the first+ * Chrome-style strip: every tab got ~137px, and the pieces of an INACTIVE tab were+ *+ * padding 10+4 · colour dot 9 · gap 6 · [SSH chip 30 · gap 6] · [badge 17 · gap 6] · caret 22+2+ *+ * so a plain tab kept 77px of name (9 readable characters), an SSH tab 41px (2–5), and the ACTIVE+ * tab — the one the user most needs to read — 24px (0 characters): it carries the board toggle as+ * well, hit its floor first, and the name absorbed the loss. At 12 tabs everything sat on the 83px+ * floor and every name was 24px. The name has to be the thing that survives, so this decides, per+ * strip, which furniture to shed BEFORE the name is squeezed — and the strip only starts scrolling+ * once a tab cannot hold `TAB_NAME_MIN_PX` of name with the furniture that is left.+ *+ * Three levels, each dropping one thing, cheapest first:+ * roomy — everything shown.+ * compact — the SSH chip is hidden (the tab's tooltip still carries user@host).+ * tight — the options caret on INACTIVE tabs shows only on hover (and while its menu is open);+ * the active tab keeps both its buttons at every width.+ *+ * One rule for the whole strip rather than per tab, so neighbours never disagree about which+ * furniture is on show. The thresholds are derived from the measured furniture, not chosen.+ */++/** Left/right padding + colour dot + the gap after it: what every tab carries. */+export const TAB_BASE_FURNITURE_PX = 10 + 4 + 9 + 6+/** The options caret (22px box) and the actions cluster's step from the name. */+export const TAB_CARET_PX = 22 + 2+/** The SSH chip plus its gap. */+export const TAB_SSH_CHIP_PX = 30 + 6+/** The least name a tab may show before the strip scrolls instead: ~6–7 characters at 12.5px. */+export const TAB_NAME_MIN_PX = 60++export type TabDensity = 'roomy' | 'compact' | 'tight'++/** A tab can show everything (chip and caret) and still keep a readable name at this width. */+export const ROOMY_MIN_TAB_PX = TAB_BASE_FURNITURE_PX + TAB_SSH_CHIP_PX + TAB_CARET_PX + TAB_NAME_MIN_PX+/** A tab can show the caret (no chip) and keep a readable name at this width. */+export const COMPACT_MIN_TAB_PX = TAB_BASE_FURNITURE_PX + TAB_CARET_PX + TAB_NAME_MIN_PX++/**+ * @param stripInnerWidth the strip's width minus its own padding, in CSS px; `null`/non-finite+ * means "not measured yet", which answers `roomy` — the pre-density rendering.+ * @param tabCount how many tabs share it.+ */+export function tabDensity(stripInnerWidth: number | null, tabCount: number): TabDensity {+ if (stripInnerWidth == null || !Number.isFinite(stripInnerWidth) || tabCount <= 0) return 'roomy'+ const perTab = stripInnerWidth / tabCount+ if (perTab >= ROOMY_MIN_TAB_PX) return 'roomy'+ if (perTab >= COMPACT_MIN_TAB_PX) return 'compact'+ return 'tight'+}diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex cd35c5241..eb33c7497 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -82,6 +82,13 @@--tab-radius: 8px;--tab-flare: 8px;--tab-w: 168px;+ /* The active tab's basis is wider by its board toggle. Flex shrink is weighted by basis, so with+ ONE basis the tab carrying the most furniture hit its floor first and its NAME took the loss —+ measured at 8 tabs / 1340px: inactive names 77px, the active name 24px (0 characters). */+ --tab-active-extra: 23px;+ /* The least name a tab may show; below it the strip scrolls rather than squeezing. Mirrors+ TAB_NAME_MIN_PX in renderer/lib/tabDensity.ts (pinned by styles.tabbar.test.ts). */+ --tab-name-min: 60px;--tab-fade: 18px;--tab-divider-h: 16px;/* The strip behind the tabs. In dark it is the panel colour (#282828 over a #000 canvas, the@@ -439,6 +446,9 @@ body,/* Square bottom, sitting ON the bar's bottom edge, so the fill runs straight into the canvas. */margin-bottom: 0;border-radius: var(--tab-radius) var(--tab-radius) 0 0;+ /* Wider by its board toggle, so its name shrinks in step with the inactive names instead of+ absorbing the toggle's width (see --tab-active-extra). */+ width: calc(var(--tab-w) + var(--tab-active-extra));/* Above `.tabbar::after` and the neighbouring tabs, so the tab's own bottom pixels and itsflares replace the separator line, and the flares paint over the neighbours' edges. */z-index: 1;@@ -547,19 +557,46 @@ body,/* The name takes whatever width the tab's fixed parts leave, and gives it back first when thetab shrinks. `width: 0` is what keeps the TAB's automatic minimum from being the whole label:a flex item's min-content contribution is its definite width when it has one, so the tab's- floor counts 24px of name (the `min-width`), not the full text. The text then runs under a+ floor counts `--tab-name-min` of name, not the full text. That floor is the ONE place the strip+ decides to scroll: a tab that cannot hold it with the furniture the density level left (see+ `[data-density]` below) stops shrinking, and the strip overflows. It was 24px, which at 12 tabs+ read as three letters and a fade on every tab (the #789 regression). The text runs under amask that fades the last `--tab-fade` px — a fade, not an ellipsis, because the fade shows theletters that DO fit at every width while "…" spends three characters saying it cut something. Aname that fits ends before the fade zone, so it is untouched. */.tab__name {flex: 1 1 0;width: 0;- min-width: 24px;+ min-width: var(--tab-name-min);overflow: hidden;-webkit-mask-image: linear-gradient(90deg, #000 calc(100% - var(--tab-fade)), transparent);mask-image: linear-gradient(90deg, #000 calc(100% - var(--tab-fade)), transparent);}+/* Density: which furniture a tab sheds so the NAME survives, decided per strip by TabBar+ (`lib/tabDensity.ts`, from the strip's measured width and the tab count) and stamped as+ `data-density`. Cheapest first — the chip, then the inactive caret — and the active tab keeps+ both its buttons at every level: the board toggle belongs to the tab you are looking at. */+.tabbar__tabs[data-density='compact'] .tab__ssh,+.tabbar__tabs[data-density='tight'] .tab__ssh {+ display: none;+}++/* Tight: an inactive tab's caret is there on hover (Chrome's close button does the same at this+ width) and stays while its menu is open — the pointer is on the menu then, not the tab, and a+ caret that vanished under an open menu would read as the menu having come from nowhere. It is+ `display: none`, not `visibility`, so the freed width goes to the name — and it is the whole+ actions CLUSTER that goes, not the caret inside it: on an inactive tab the cluster holds only+ the caret, and an emptied cluster still costs its margin and the tab's gap (8px measured). */+.tabbar__tabs[data-density='tight'] .tab:not(.active):not(:hover):not(.tab--menu-open) .tab__actions {+ display: none;+}++/* A shorter fade on a tight strip: 18px of a 60px name is a third of it under the gradient. */+.tabbar__tabs[data-density='tight'] .tab__name {+ --tab-fade: 12px;+}+.tab__edit {flex: 1 1 0;width: 0;diff --git a/src/renderer/styles.tabbar.test.ts b/src/renderer/styles.tabbar.test.tsindex a7eb10765..d9ea2589d 100644--- a/src/renderer/styles.tabbar.test.ts+++ b/src/renderer/styles.tabbar.test.ts@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest'import { readFileSync } from 'node:fs'import { join } from 'node:path'import { TABBAR_HEIGHT_PX } from '@shared/window-chrome-metrics'+import { TAB_NAME_MIN_PX } from './lib/tabDensity'/*** The tab bar's height used to be a literal in four places — the bar's own rule, the kanban@@ -84,4 +85,21 @@ describe('tab strip geometry', () => {// `width: 0` is what keeps the tab's automatic minimum from being the whole label.expect(name).toMatch(/width:\s*0;/)})++ it('keeps a readable name floor, the same number the density rule reasons from', () => {+ expect(token('--tab-name-min')).toBe(`${TAB_NAME_MIN_PX}px`)+ expect(rule('.tab__name')).toMatch(/min-width:\s*var\(--tab-name-min\)/)+ // The active tab's basis is wider by its board toggle, so its name shrinks in step with the+ // inactive names instead of absorbing the toggle (the 24px active name at 8 tabs).+ expect(rule('.tab.active')).toMatch(/width:\s*calc\(var\(--tab-w\) \+ var\(--tab-active-extra\)\)/)+ })++ it('sheds furniture by density before the name is squeezed, and never the active tab\'s buttons', () => {+ const compactChip = CSS.match(/\.tabbar__tabs\[data-density='compact'\] \.tab__ssh,\s*\.tabbar__tabs\[data-density='tight'\] \.tab__ssh \{[^}]*display:\s*none/)+ expect(compactChip).not.toBeNull()+ const tightCaret = CSS.match(/\.tabbar__tabs\[data-density='tight'\] \.tab:not\(\.active\):not\(:hover\):not\(\.tab--menu-open\) \.tab__actions \{[^}]*display:\s*none/)+ expect(tightCaret).not.toBeNull()+ // Nothing hides the board toggle at any density.+ expect(CSS).not.toMatch(/\[data-density[^\]]*\][^{]*\.tab__board-toggle[^{]*\{[^}]*display:\s*none/)+ })})