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(terminal): the ⌘M hint can never add a line to the label row
review9efade9fdcf4
diff --git a/src/renderer/components/MdViewHintButton.test.tsx b/src/renderer/components/MdViewHintButton.test.tsxindex 72db9c3a8..bf8e2bdee 100644--- a/src/renderer/components/MdViewHintButton.test.tsx+++ b/src/renderer/components/MdViewHintButton.test.tsx@@ -41,34 +41,93 @@ describe('MdViewHintButton', () => {})describe('NodeLabels trailing slot', () => {- it('renders the trailing node at the END of the label row, after the "+ Label" button', () => {- act(() => root.render(<NodeLabels nodeId="n1" trailing={<span className="probe">x</span>} />))+ it('renders the real hint button at the END of the label row, outside the chips\' wrapping group; a click toggles', () => {+ const onToggle = vi.fn()+ act(() =>+ root.render(+ <NodeLabels+ nodeId="n1"+ trailing={<MdViewHintButton hint={{ chip: '⌘M', label: 'Markdown view' }} tooltip="t" onToggle={onToggle} />}+ />+ )+ )const row = host.querySelector('.term-node__labelrow') as HTMLElement- const last = row.lastElementChild as HTMLElement- expect(last.classList.contains('term-node__labeltrail')).toBe(true)- expect(last.querySelector('.probe')).toBeTruthy()+ const main = row.querySelector(':scope > .term-node__labelmain') as HTMLElement+ const trail = row.lastElementChild as HTMLElement+ expect(main.querySelector('.term-node__labeladd')).toBeTruthy()+ expect(trail.classList.contains('term-node__labeltrail')).toBe(true)+ expect(main.contains(trail)).toBe(false)+ const btn = trail.querySelector('button.term-node__mdhint') as HTMLButtonElement+ expect(btn.textContent).toBe('⌘M Markdown view')+ act(() => btn.click())+ expect(onToggle).toHaveBeenCalledTimes(1)})it('renders no trailing slot when none is given (other callers unchanged)', () => {act(() => root.render(<NodeLabels nodeId="n1" />))expect(host.querySelector('.term-node__labeltrail')).toBeNull()+ expect(host.querySelector('.term-node__labelmain .term-node__labeladd')).toBeTruthy()})})describe('TerminalNode wiring', () => {const src = readFileSync(join(__dirname, '../nodes/TerminalNode.tsx'), 'utf8').replace(/\r\n/g, '\n')- it('passes the hint into the label row through NodeLabels\' trailing slot', () => {- expect(src).toMatch(/<NodeLabels\s+nodeId=\{id\}\s+trailing=\{/)- })- it('derives the chat/markdown label from the SAME rule that picks the ⌘M face', () => {+ it('builds useChat from chatAvailable — the one value the hint label is also fed', () => {expect(src).toContain('const useChat = mdMode && chatAvailable')- expect(src).toMatch(/mdViewHint\(\{[^}]*chatAvailable[^}]*\}\)/s)})})-describe('trailing slot CSS', () => {- const css = readFileSync(join(__dirname, '../styles.css'), 'utf8').replace(/\r\n/g, '\n').replace(/\/\*[\s\S]*?\*\//g, '')- it('is pushed to the right end of the row without moving the chips', () => {- expect(css).toMatch(/\n\.term-node__labeltrail\s*{[^}]*margin-left:\s*auto;/)+// The hint must NEVER add a line to the label row: a taller row shrinks the terminal body, which+// refits xterm and SIGWINCHes tmux — on every ⌘M toggle at a wrap boundary.+describe('label row: the trailing slot cannot wrap or grow the row', () => {+ const css = readFileSync(join(__dirname, '../styles.css'), 'utf8')+ .replace(/\r\n/g, '\n')+ .replace(/\/\*[\s\S]*?\*\//g, '')+ const rule = (sel: string): string => {+ const esc = sel.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')+ const m = css.match(new RegExp(`\\n${esc}\\s*{([^}]*)}`))+ expect(m, `rule not found: ${sel}`).toBeTruthy()+ return m![1]+ }+ const decl = (body: string, prop: string): string | undefined =>+ body.match(new RegExp(`(?:^|[;\\s])${prop}:\\s*([^;]+);`))?.[1].trim()++ it('the row itself never wraps and has no gap (the chips group carries the old gap and wrapping)', () => {+ const row = rule('.term-node__labelrow')+ expect(decl(row, 'flex-wrap')).toBe('nowrap')+ expect(decl(row, 'gap')).toBe('0')+ const main = rule('.term-node__labelmain')+ expect(decl(main, 'display')).toBe('flex')+ expect(decl(main, 'flex-wrap')).toBe('wrap')+ expect(decl(main, 'gap')).toBe('4px')+ // Basis = its content, never grows: it wraps against the row's width exactly as the row did.+ expect(decl(main, 'flex')).toBe('0 1 auto')+ expect(decl(main, 'min-width')).toBe('0')+ })++ it('the trailing slot has a ZERO basis: it only ever takes space the chips left over, and clips', () => {+ const trail = rule('.term-node__labeltrail')+ expect(decl(trail, 'flex')).toBe('1 1 0')+ expect(decl(trail, 'min-width')).toBe('0')+ expect(decl(trail, 'overflow')).toBe('hidden')+ expect(decl(trail, 'margin-left')).toBeUndefined() // no margin: it would narrow the chips\' room+ })++ it('the hint shrinks by ellipsis on one line', () => {+ const hint = rule('.term-node__mdhint')+ expect(decl(hint, 'white-space')).toBe('nowrap')+ expect(decl(hint, 'overflow')).toBe('hidden')+ expect(decl(hint, 'text-overflow')).toBe('ellipsis')+ expect(decl(hint, 'min-width')).toBe('0')+ })++ it('the hint\'s box is exactly "+ Label"\'s — same font size, vertical padding, border width and font', () => {+ const add = rule('.term-node__labeladd')+ const hint = rule('.term-node__mdhint')+ expect(decl(hint, 'font-size')).toBe(decl(add, 'font-size'))+ expect(decl(hint, 'padding')?.split(/\s+/)[0]).toBe(decl(add, 'padding')?.split(/\s+/)[0])+ expect(decl(hint, 'border')?.split(/\s+/)[0]).toBe(decl(add, 'border')?.split(/\s+/)[0])+ // A different font family inside (a monospace chord) brings its own, taller line box.+ expect(css).not.toMatch(/\n\.term-node__mdhint-chip\s*{[^}]*font-family/)})})diff --git a/src/renderer/components/kanban/NodeLabels.tsx b/src/renderer/components/kanban/NodeLabels.tsxindex 1d2bfbe62..ccb9f0148 100644--- a/src/renderer/components/kanban/NodeLabels.tsx+++ b/src/renderer/components/kanban/NodeLabels.tsx@@ -13,9 +13,10 @@ import { LabelPicker } from './LabelPicker'* workspace-dirty seam (this component lives outside Canvas). A node only ever renders in the* active project, so the active project's board is the right one.*- * `trailing` is an optional slot pinned to the row's RIGHT end (the terminal node's ⌘M hint). It- * is a slot rather than something the caller positions over the row, so the row's own flex layout- * owns the placement: the chips never shift, and a wrapping row still keeps it on the last line.+ * `trailing` is an optional slot at the row's RIGHT end (the terminal node's ⌘M hint). It is a+ * slot rather than something the caller positions over the row, so the row's own flex layout owns+ * the placement — and that layout guarantees the slot can never add a line or move a chip: it only+ * occupies width the chips left unused, clipped to it (see `.term-node__labeltrail`).*/export function NodeLabels({ nodeId, trailing }: { nodeId: string; trailing?: ReactNode }): React.JSX.Element {const [open, setOpen] = useState(false)@@ -34,14 +35,18 @@ export function NodeLabels({ nodeId, trailing }: { nodeId: string; trailing?: Rereturn (<div className="term-node__labelrow nodrag">- <LabelChips labels={labels} size="sm" />- <button- className="term-node__labeladd"- title="Add label"- onClick={() => setOpen((v) => !v)}- >- + Label- </button>+ {/* The chips + "+ Label" wrap inside their OWN group; the row never wraps. That is what+ keeps the trailing slot out of the wrap flow — see `.term-node__labeltrail`. */}+ <div className="term-node__labelmain">+ <LabelChips labels={labels} size="sm" />+ <button+ className="term-node__labeladd"+ title="Add label"+ onClick={() => setOpen((v) => !v)}+ >+ + Label+ </button>+ </div>{trailing != null && <span className="term-node__labeltrail">{trailing}</span>}{open && (<>diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex a51cc491f..ae7720050 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -11140,13 +11140,17 @@ button.group-node__setup:disabled {.term-node__labels {padding: 0 8px 4px;}-/* Canvas node label row (unified with kanban labels): chips + an add button + the picker popover. */+/* Canvas node label row (unified with kanban labels): chips + an add button + the picker popover,+ plus an optional trailing slot (the ⌘M hint). The row itself NEVER wraps and has no gap; the+ chips + "+ Label" wrap inside `.term-node__labelmain` instead, against the full row width — so+ they break exactly where they did when they were the row's own items. See `__labeltrail` for why+ the trailing slot cannot change that. */.term-node__labelrow {position: relative;display: flex;- flex-wrap: wrap;+ flex-wrap: nowrap;align-items: center;- gap: 4px;+ gap: 0;padding: 2px 8px 5px;/* Its OWN background, not one inherited from the node root. Visually identical to what it hadbefore (the root is var(--panel) too) — but the shared glyph renderer makes that root@@ -11173,34 +11177,54 @@ button.group-node__setup:disabled {background: rgba(var(--tint-rgb), 0.12);color: var(--text-strong);}-/* Trailing slot of the label row (NodeLabels `trailing`): `margin-left: auto` takes the row's free- space, pinning the slot to the right end while the chips and "+ Label" keep their place. */-.term-node__labeltrail {- margin-left: auto;- display: inline-flex;+/* The chips group: its basis is its content and it never grows, so free space goes to the+ trailing slot; when the content is wider than the row it shrinks to the row and wraps, exactly as+ the row's own items did before the slot existed. It keeps the row's old 4px gap. */+.term-node__labelmain {+ display: flex;+ flex-wrap: wrap;align-items: center;+ gap: 4px;+ flex: 0 1 auto;+ min-width: 0;+}+/* Trailing slot of the label row (NodeLabels `trailing`). A ZERO flex basis is the whole trick: it+ contributes nothing to the width the chips are measured against (so it can never make them wrap,+ i.e. never add a line — a taller row shrinks the terminal body, refits xterm and SIGWINCHes+ tmux, which a state-dependent hint width would otherwise do on every ⌘M toggle at a wrap+ boundary), then grows into whatever width the chips left over and clips to it. Content is+ right-aligned in that space; no margin/gap, which would narrow the chips' room by those pixels. */+.term-node__labeltrail {+ flex: 1 1 0;min-width: 0;+ overflow: hidden;+ display: flex;+ justify-content: flex-end;+ align-items: center;}-/* The ⌘M hint in that slot (`components/MdViewHintButton.tsx`): deliberately quieter than- "+ Label" — no border, no fill until hover, dimmer text — a discoverability cue, not a control- competing for attention. nowrap so it never breaks into two lines under a narrow node. */+/* The ⌘M hint in that slot (`components/MdViewHintButton.tsx`). Quieter than "+ Label" — a+ transparent border, no fill until hover, dimmer text — but the SAME box: font size, vertical+ padding, border width and font family all match, so it can never be the row's tallest item and+ change the row's height. When the slot is narrow it ellipsizes on one line ("⌘M Mark…", then+ "…"), and at zero width it is simply clipped away. */.term-node__mdhint {+ flex: 0 1 auto;+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;background: none;- border: 0;+ border: 1px solid transparent;border-radius: 4px;- padding: 1px 4px;+ padding: 1px 4px 1px 6px;font-size: 10.5px;color: rgba(var(--tint-rgb), 0.38);- white-space: nowrap;cursor: pointer;}.term-node__mdhint:hover {background: rgba(var(--tint-rgb), 0.08);color: rgba(var(--tint-rgb), 0.75);}-.term-node__mdhint-chip {- font-family: ui-monospace, monospace;-}.kanban-meta__row--labels {position: relative;align-items: center;