Skip to content

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.

fix(tabbar): keep the project pill hugging tabs and the title bar draggable

Krishna2fe90bd71c78
diff --git a/CLAUDE.md b/CLAUDE.md
index 79efb14cf..9be12ee61 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -2039,7 +2039,9 @@ the Settings section and ShortcutsPanel start disagreeing about what a chord mea
bar (`TabBar.tsx`) is the drag region with the `nodeterm` logo + a rounded pill of project
tabs. The New-project `+` is a **sibling** of `.tabbar__tabs`, not its last child — inside
the scroller it vanished once the strip overflowed (no visible scrollbar to hint it was
- still there). Cmd+M is intercepted in `main/keydown-intercept.ts` (`before-input-event`, installed from
+ still there). The wrapping `.tabbar__projects` is `flex: 1` and stays a drag region (not
+ `no-drag`); the pill itself must not be `flex: 1` or it inflates into an empty capsule.
+ Cmd+M is intercepted in `main/keydown-intercept.ts` (`before-input-event`, installed from
`main/index.ts` — else macOS minimizes) and forwarded to the renderer via `app:toggle-markdown`;
Cmd+W (`app:close-node`) and Cmd+0 (`app:zoom-actual-size`) are taken back the same way. **The
application menu is OURS**: `buildAppMenu` (`main/index.ts`) calls `Menu.setApplicationMenu` and
diff --git a/src/renderer/components/TabBar.test.tsx b/src/renderer/components/TabBar.test.tsx
index 4da6dcb0e..2a79d818e 100644
--- a/src/renderer/components/TabBar.test.tsx
+++ b/src/renderer/components/TabBar.test.tsx
@@ -3,8 +3,6 @@ import { act } from 'react'
import { createRoot, type Root } from 'react-dom/client'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type { Project } from '@shared/types'
-import { useProjects } from '../state/projects'
-import { TabBar } from './TabBar'
;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
@@ -14,6 +12,20 @@ class NoopResizeObserver {
disconnect(): void {}
}
+function memStorage(seed: Record<string, string> = {}): Storage {
+ const m = new Map(Object.entries(seed))
+ return {
+ getItem: (k: string) => m.get(k) ?? null,
+ setItem: (k: string, v: string) => void m.set(k, v),
+ removeItem: (k: string) => void m.delete(k),
+ clear: () => m.clear(),
+ key: () => null,
+ get length() {
+ return m.size
+ }
+ } as Storage
+}
+
function project(over: Partial<Project> = {}): Project {
return {
id: 'p1',
@@ -26,27 +38,45 @@ function project(over: Partial<Project> = {}): Project {
}
}
+async function load(): Promise<{
+ TabBar: typeof import('./TabBar').TabBar
+ useProjects: typeof import('../state/projects').useProjects
+}> {
+ const { TabBar } = await import('./TabBar')
+ const { useProjects } = await import('../state/projects')
+ return { TabBar, useProjects }
+}
+
+beforeEach(() => {
+ vi.resetModules()
+ vi.stubGlobal('localStorage', memStorage())
+ ;(globalThis as { ResizeObserver?: unknown }).ResizeObserver = NoopResizeObserver
+ Element.prototype.scrollIntoView = (): void => {}
+ ;(window as unknown as { nodeTerminal: Record<string, never> }).nodeTerminal = {}
+})
+
+afterEach(() => {
+ vi.unstubAllGlobals()
+})
+
+const click = async (el: HTMLElement): Promise<void> => {
+ await act(async () => {
+ el.dispatchEvent(new MouseEvent('click', { bubbles: true }))
+ })
+}
+
describe('TabBar caret menu', () => {
let root: Root
let host: HTMLElement
let onOpenProjectSettings: ReturnType<typeof vi.fn<(id: string) => void>>
- const click = async (el: HTMLElement): Promise<void> => {
- await act(async () => {
- el.dispatchEvent(new MouseEvent('click', { bubbles: true }))
- })
- }
-
const menuButton = (label: string): HTMLButtonElement | undefined =>
Array.from(document.querySelectorAll<HTMLButtonElement>('.tab-menu button')).find(
(b) => b.textContent?.trim() === label
)
beforeEach(async () => {
- // jsdom implements neither; TabBar uses both purely for presentation.
- ;(globalThis as { ResizeObserver?: unknown }).ResizeObserver = NoopResizeObserver
- Element.prototype.scrollIntoView = (): void => {}
- ;(window as unknown as { nodeTerminal: any }).nodeTerminal = {}
+ const { TabBar, useProjects } = await load()
host = document.createElement('div')
document.body.appendChild(host)
useProjects.setState({ projects: [project()], activeProjectId: 'p1' })
@@ -75,7 +105,6 @@ describe('TabBar caret menu', () => {
afterEach(() => {
act(() => root.unmount())
host.remove()
- useProjects.setState({ projects: [], activeProjectId: '' })
})
it('offers "Project settings…" and deep-links the project it was opened on', async () => {
@@ -87,3 +116,64 @@ describe('TabBar caret menu', () => {
expect(document.querySelector('.tab-menu')).toBeNull()
})
})
+
+describe('TabBar New-project pin', () => {
+ let root: Root
+ let host: HTMLElement
+ let onOpenWelcome: ReturnType<typeof vi.fn>
+
+ beforeEach(async () => {
+ const { TabBar, useProjects } = await load()
+ host = document.createElement('div')
+ document.body.appendChild(host)
+ useProjects.setState({
+ projects: [
+ project({ id: 'p1', name: 'One' }),
+ project({ id: 'p2', name: 'Two' }),
+ project({ id: 'p3', name: 'Three' }),
+ project({ id: 'p4', name: 'Four' })
+ ],
+ activeProjectId: 'p1'
+ })
+ onOpenWelcome = vi.fn()
+ root = createRoot(host)
+ await act(async () => {
+ root.render(
+ <TabBar
+ onSwitch={vi.fn()}
+ onReconnect={vi.fn()}
+ onReorder={vi.fn()}
+ onOpenWelcome={onOpenWelcome}
+ 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('keeps the + outside the scrolling tab strip', () => {
+ const add = host.querySelector('.tab__add')
+ const scroller = host.querySelector('.tabbar__tabs')
+ expect(add).toBeTruthy()
+ expect(scroller).toBeTruthy()
+ expect(scroller!.contains(add)).toBe(false)
+ expect(host.querySelector('.tabbar__projects')!.contains(add)).toBe(true)
+ })
+
+ it('opens the start screen from +', async () => {
+ await act(async () => {
+ host.querySelector<HTMLButtonElement>('.tab__add')!.click()
+ })
+ expect(onOpenWelcome).toHaveBeenCalledTimes(1)
+ })
+})
diff --git a/src/renderer/components/TabBar.tsx b/src/renderer/components/TabBar.tsx
index 7127955c0..b324be74a 100644
--- a/src/renderer/components/TabBar.tsx
+++ b/src/renderer/components/TabBar.tsx
@@ -181,8 +181,10 @@ export function TabBar({
setEditingId(null)
}
- // Drop-at-end: the strip's empty area AND the pinned + (which used to live inside the
- // scroller, so a drop on it already meant "after the last tab").
+ // Drop-at-end: the wrapper (gap between pill and +, empty title-bar to the right of +,
+ // and the + itself). Per-tab handlers stopPropagation, so a drop ON a tab is still
+ // insert-before. The + used to live inside the scroller, so a drop on it already meant
+ // "after the last tab".
const onEndZoneDragOver = (e: DragEvent) => {
if (!dragId) return
e.preventDefault()
@@ -243,20 +245,22 @@ export function TabBar({
</div>
{/* Projects group: the pill scrolls; the + is a SIBLING so it cannot scroll away
- with the tabs (issue #375). min-width:0 on this wrapper is what lets the pill
- shrink instead of pushing the + off the window. */}
- <div className="tabbar__projects">
+ with the tabs (issue #375). End-zone drop lives on this wrapper (covers the
+ 4px gap and the +); per-tab handlers still stopPropagation. */}
<div
- className="tabbar__tabs"
- ref={tabsRef}
- onWheel={(e) => {
- // Translate a vertical mouse wheel into horizontal strip scrolling (trackpads
- // already produce deltaX). Nothing above the canvas scrolls vertically anyway.
- if (Math.abs(e.deltaY) > Math.abs(e.deltaX)) e.currentTarget.scrollLeft += e.deltaY
- }}
+ className="tabbar__projects"
onDragOver={onEndZoneDragOver}
onDrop={onEndZoneDrop}
>
+ <div
+ className="tabbar__tabs"
+ ref={tabsRef}
+ onWheel={(e) => {
+ // Translate a vertical mouse wheel into horizontal strip scrolling (trackpads
+ // already produce deltaX). Nothing above the canvas scrolls vertically anyway.
+ if (Math.abs(e.deltaY) > Math.abs(e.deltaX)) e.currentTarget.scrollLeft += e.deltaY
+ }}
+ >
{projects.map((p) => {
const active = p.id === activeId
const unreadCount = p.nodes.filter((n) => unreadSet.has(n.id)).length
@@ -388,15 +392,13 @@ export function TabBar({
</div>
)
})}
- </div>
+ </div>
<button
type="button"
className="tab__add"
title="New project"
aria-label="New project"
onClick={onOpenWelcome}
- onDragOver={onEndZoneDragOver}
- onDrop={onEndZoneDrop}
>
+
</button>
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index de1822598..359971919 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -212,8 +212,7 @@ body,
.tabbar button,
.tabbar input,
.tab,
-.tabbar__tabs,
-.tabbar__projects {
+.tabbar__tabs {
-webkit-app-region: no-drag;
}
@@ -237,15 +236,15 @@ body,
letter-spacing: 0.2px;
}
-/* Tabs as a single rounded pill of segments. Lives in `.tabbar__projects` with the +
- as a sibling — the + used to be the last child of this scroller, so enough tabs
- hid it with no scrollbar to say it was still there (issue #375). */
+/* Tabs as a single rounded pill of segments. The + is a sibling in `.tabbar__projects`
+ so it cannot scroll away with the tabs (issue #375). The wrapper is flex:1 and is
+ NOT in the no-drag list — it is the remaining title-bar drag region. Do not put
+ flex:1 on the pill itself: that inflates an empty capsule for every 2-tab window. */
.tabbar__projects {
display: flex;
align-items: center;
gap: 4px;
flex: 1;
- min-width: 0; /* shrink the pill, never shove the + off the window */
}
.tabbar__tabs {
display: flex;
@@ -257,8 +256,6 @@ body,
border: 1px solid var(--border);
border-radius: 17px;
overflow-x: auto;
- flex: 1;
- min-width: 0;
/* Scrollable but without the native scrollbar (foreign-looking in a title-bar tab strip);
trackpad swipe / wheel still scroll, and the active tab is scrolled into view. */
scrollbar-width: none;
@@ -412,6 +409,8 @@ body,
align-items: center;
justify-content: center;
align-self: center;
+ /* Load-bearing once the pill no longer has flex:1: without this a squeezed bar
+ shrinks the 28px + instead of scrolling the tabs. */
flex-shrink: 0;
width: 28px;
height: 28px;
diff --git a/src/renderer/styles.tabbar.test.ts b/src/renderer/styles.tabbar.test.ts
deleted file mode 100644
index e6140b996..000000000
--- a/src/renderer/styles.tabbar.test.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { describe, expect, it } from 'vitest'
-import { readFileSync } from 'node:fs'
-import { join } from 'node:path'
-
-const CSS = readFileSync(join(__dirname, 'styles.css'), 'utf8')
-
-function ruleBody(selector: string): string {
- for (const chunk of CSS.split('}')) {
- const brace = chunk.indexOf('{')
- if (brace < 0) continue
- const head = chunk
- .slice(0, brace)
- .replace(/\/\*[\s\S]*?\*\//g, '')
- .trim()
- if (head === selector) return chunk.slice(brace + 1)
- }
- throw new Error(`no rule for ${selector}`)
-}
-
-describe('tab bar New-project pin', () => {
- it('lets the tab pill shrink so the + stays in the window', () => {
- // Without min-width:0 the flex item won't shrink below its tab content, so the +
- // (now a sibling) is shoved off the right edge — the same bug at a different layer.
- expect(ruleBody('.tabbar__projects')).toMatch(/min-width:\s*0/)
- expect(ruleBody('.tabbar__tabs')).toMatch(/min-width:\s*0/)
- expect(ruleBody('.tab__add')).toMatch(/flex-shrink:\s*0/)
- })
-})