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
feat(terminal): quiet ⌘M hint at the end of the node's label row
review51ae911a98e1
diff --git a/src/renderer/components/MdViewHintButton.test.tsx b/src/renderer/components/MdViewHintButton.test.tsxnew file mode 100644index 000000000..72db9c3a8--- /dev/null+++ b/src/renderer/components/MdViewHintButton.test.tsx@@ -0,0 +1,74 @@+// @vitest-environment jsdom+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { readFileSync } from 'node:fs'+import { join } from 'node:path'+import { createRoot, type Root } from 'react-dom/client'+import { act } from 'react'+import { MdViewHintButton } from './MdViewHintButton'+import { NodeLabels } from './kanban/NodeLabels'+;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true++let host: HTMLDivElement+let root: Root+beforeEach(() => {+ host = document.createElement('div')+ document.body.appendChild(host)+ root = createRoot(host)+})+afterEach(() => {+ act(() => root.unmount())+ host.remove()+})++describe('MdViewHintButton', () => {+ it('shows the chord and the label, carries its tooltip, and is not a drag handle', () => {+ act(() =>+ root.render(<MdViewHintButton hint={{ chip: '⌘M', label: 'Markdown view' }} tooltip="Open markdown view (⌘M)" onToggle={() => {}} />)+ )+ const btn = host.querySelector('button.term-node__mdhint') as HTMLButtonElement+ expect(btn.classList.contains('nodrag')).toBe(true)+ expect(btn.querySelector('.term-node__mdhint-chip')?.textContent).toBe('⌘M')+ expect(btn.textContent).toBe('⌘M Markdown view')+ expect(btn.title).toBe('Open markdown view (⌘M)')+ })++ it('clicking toggles the view', () => {+ const onToggle = vi.fn()+ act(() => root.render(<MdViewHintButton hint={{ chip: '⌘M', label: 'Terminal' }} tooltip="t" onToggle={onToggle} />))+ act(() => (host.querySelector('button') as HTMLButtonElement).click())+ expect(onToggle).toHaveBeenCalledTimes(1)+ })+})++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>} />))+ 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()+ })++ 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()+ })+})++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', () => {+ 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;/)+ })+})diff --git a/src/renderer/components/MdViewHintButton.tsx b/src/renderer/components/MdViewHintButton.tsxnew file mode 100644index 000000000..05a73022b--- /dev/null+++ b/src/renderer/components/MdViewHintButton.tsx@@ -0,0 +1,22 @@+import type { MdViewHint } from '../lib/mdViewHint'++/**+ * Presentational half of the label-row ⌘M hint (the decision is `lib/mdViewHint.ts`). A button,+ * not a span: clicking it does exactly what the chord does, so a user who found the hint by eye+ * does not also have to learn the chord. `nodrag` so a click is a click, never a node move.+ */+export function MdViewHintButton({+ hint,+ tooltip,+ onToggle+}: {+ hint: MdViewHint+ tooltip: string+ onToggle: () => void+}) {+ return (+ <button type="button" className="term-node__mdhint nodrag" title={tooltip} onClick={onToggle}>+ <span className="term-node__mdhint-chip">{hint.chip}</span> {hint.label}+ </button>+ )+}diff --git a/src/renderer/components/kanban/NodeLabels.tsx b/src/renderer/components/kanban/NodeLabels.tsxindex c96b2114c..1d2bfbe62 100644--- a/src/renderer/components/kanban/NodeLabels.tsx+++ b/src/renderer/components/kanban/NodeLabels.tsx@@ -1,4 +1,4 @@-import { useMemo, useState } from 'react'+import { useMemo, useState, type ReactNode } from 'react'import type { ProjectKanban } from '@shared/types'import { useProjects } from '../../state/projects'import { markWorkspaceDirty } from '../../state/workspaceDirty'@@ -12,8 +12,12 @@ import { LabelPicker } from './LabelPicker'* create/assign/edit labels. Edits go to the active project's kanban and persist via the shared* 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.*/-export function NodeLabels({ nodeId }: { nodeId: string }): React.JSX.Element {+export function NodeLabels({ nodeId, trailing }: { nodeId: string; trailing?: ReactNode }): React.JSX.Element {const [open, setOpen] = useState(false)const kanban = useProjects((s) => s.projects.find((p) => p.id === s.activeProjectId)?.kanban)// Adding the first label seeds the default board (To Do / In Progress / Done), exactly like the@@ -38,6 +42,7 @@ export function NodeLabels({ nodeId }: { nodeId: string }): React.JSX.Element {>+ Label</button>+ {trailing != null && <span className="term-node__labeltrail">{trailing}</span>}{open && (<><div className="label-picker__scrim" onMouseDown={() => setOpen(false)} />diff --git a/src/renderer/lib/mdViewHint.test.ts b/src/renderer/lib/mdViewHint.test.tsnew file mode 100644index 000000000..746cbad2c--- /dev/null+++ b/src/renderer/lib/mdViewHint.test.ts@@ -0,0 +1,39 @@+import { describe, expect, it } from 'vitest'+import { MD_VIEW_HINT_ID, mdViewHint } from './mdViewHint'+import { HIDEABLE_HEADER_BUTTONS, isHidden } from './ui-visibility'++const base = { chip: '⌘M', open: false, chatAvailable: false, hidden: [] as string[] }++describe('mdViewHint', () => {+ it('names the markdown view on a node whose ⌘M opens the output view', () => {+ expect(mdViewHint(base)).toEqual({ chip: '⌘M', label: 'Markdown view' })+ })++ it('names the chat view when ⌘M opens the transcript (chat-capable node, known session)', () => {+ expect(mdViewHint({ ...base, chatAvailable: true })).toEqual({ chip: '⌘M', label: 'Chat view' })+ })++ it('while the view is open, names what the chord returns to', () => {+ expect(mdViewHint({ ...base, open: true })).toEqual({ chip: '⌘M', label: 'Terminal' })+ expect(mdViewHint({ ...base, open: true, chatAvailable: true })).toEqual({ chip: '⌘M', label: 'Terminal' })+ })++ it('renders the user\'s own chord verbatim (platform / override aware)', () => {+ expect(mdViewHint({ ...base, chip: 'Ctrl+Shift+M' })?.chip).toBe('Ctrl+Shift+M')+ })++ it('shows nothing when the chord is unbound — never promise a chord that does not fire', () => {+ expect(mdViewHint({ ...base, chip: '' })).toBeNull()+ expect(mdViewHint({ ...base, chip: '', open: true })).toBeNull()+ })++ it('shows nothing when the user hid it in Settings → Appearance', () => {+ expect(mdViewHint({ ...base, hidden: [MD_VIEW_HINT_ID] })).toBeNull()+ })++ it('is in the terminal-header hideable inventory, shown by default', () => {+ expect(HIDEABLE_HEADER_BUTTONS.some((r) => r.id === MD_VIEW_HINT_ID)).toBe(true)+ expect(isHidden(MD_VIEW_HINT_ID, [])).toBe(false)+ expect(isHidden(MD_VIEW_HINT_ID, [MD_VIEW_HINT_ID])).toBe(true)+ })+})diff --git a/src/renderer/lib/mdViewHint.ts b/src/renderer/lib/mdViewHint.tsnew file mode 100644index 000000000..f5908308e--- /dev/null+++ b/src/renderer/lib/mdViewHint.ts@@ -0,0 +1,34 @@+import { isHidden } from './ui-visibility'++/**+ * The quiet "⌘M Markdown view" hint at the right end of a terminal node's label row — the one+ * on-canvas sign that the ⌘M face exists at all (it was otherwise reachable only from the context+ * menu or by knowing the chord).+ *+ * Pure so the decision is testable without mounting a TerminalNode. Rules:+ * - `chip` is `chipFor('node.toggleMarkdown')`: the user's EFFECTIVE binding, platform-aware.+ * `''` = unbound ⇒ no hint at all. A hint that names a chord which does nothing is worse than+ * none (same rule the view's own bar follows).+ * - The label names what the chord does on THIS node: while the view is open it returns to the+ * terminal; otherwise it opens the chat transcript when `chatAvailable` (the node's own+ * chat-vs-markdown rule — TerminalNode passes the very value its `useChat` is built from, so the+ * hint cannot promise one face and the chord open the other), else the markdown-of-output view.+ * - User-hideable through Settings → Appearance (`MD_VIEW_HINT_ID` in the header inventory).+ */+export const MD_VIEW_HINT_ID = 'md-hint'++export interface MdViewHint {+ chip: string+ label: string+}++export function mdViewHint(input: {+ chip: string+ open: boolean+ chatAvailable: boolean+ hidden: readonly string[]+}): MdViewHint | null {+ if (!input.chip || isHidden(MD_VIEW_HINT_ID, input.hidden)) return null+ const label = input.open ? 'Terminal' : input.chatAvailable ? 'Chat view' : 'Markdown view'+ return { chip: input.chip, label }+}diff --git a/src/renderer/lib/ui-visibility.test.ts b/src/renderer/lib/ui-visibility.test.tsindex be8f8efbc..f6adfd17a 100644--- a/src/renderer/lib/ui-visibility.test.ts+++ b/src/renderer/lib/ui-visibility.test.ts@@ -27,7 +27,7 @@ describe('hideable inventories', () => {'markdown-view', 'refresh-terminal', 'vanilla-restart'])expect(HIDEABLE_HEADER_BUTTONS.map((r) => r.id)).toEqual([- 'maximize', 'refresh', 'mic', 'ai-name', 'comments', 'hide-fanout', 'tidy-fanout'+ 'maximize', 'refresh', 'mic', 'ai-name', 'comments', 'hide-fanout', 'tidy-fanout', 'md-hint'])})it('gives every entry a user-facing label', () => {diff --git a/src/renderer/lib/ui-visibility.ts b/src/renderer/lib/ui-visibility.tsindex 9171f262c..d54e8a3f0 100644--- a/src/renderer/lib/ui-visibility.ts+++ b/src/renderer/lib/ui-visibility.ts@@ -39,7 +39,10 @@ export const HIDEABLE_HEADER_BUTTONS: readonly HideableRow[] = [{ id: 'ai-name', label: 'Name with AI' },{ id: 'comments', label: 'Comments' },{ id: 'hide-fanout', label: 'Hide cards & connections' },- { id: 'tidy-fanout', label: 'Tidy subagent cards' }+ { id: 'tidy-fanout', label: 'Tidy subagent cards' },+ // Not in the header proper but the label row right under it (`lib/mdViewHint.ts`); it is the+ // same kind of quiet per-node affordance, so it lives in the same Settings list.+ { id: 'md-hint', label: 'Markdown / chat view hint' }]/** Every id the user may hide — the guard that makes everything else unhideable. */diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex f1c624ee5..90447a31d 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -181,6 +181,8 @@ import { focusXtermUnlessCovered, terminalOwnsFileInput, useMdModeFocus } from 'import { canvasOwnsMarkdownChord } from '../lib/markdownChord'import { IconChat, IconChevronDown, IconChevronRight, IconClose, IconEye, IconEyeOff, IconGrid, IconMic, IconMoveTo, IconPlay, IconReload, IconSearch, IconSparkle } from '../components/icons'import { NodeLabels } from '../components/kanban/NodeLabels'+import { MdViewHintButton } from '../components/MdViewHintButton'+import { mdViewHint } from '../lib/mdViewHint'import { Tooltip } from '../components/Tooltip'import { useTerminalSearch } from '../terminal/useTerminalSearch'import { useCopyFeedback } from '../terminal/useCopyFeedback'@@ -238,6 +240,7 @@ import { ensureActivePermissionMode } from '../state/permissionMode'import { buildSshArgs, sshConnectionIdForProject, sshHostKey, type SshConnection } from '@shared/ssh'import {chipFor,+ commandTooltip,effectiveBindings,terminalChordBubbles,terminalShortcutPolicy@@ -1922,7 +1925,10 @@ export function TerminalNode({: ''// Use the chat panel only for a chat-capable agent with a known session; otherwise the// markdown-of-output view (computed in the capture effect below) is shown as a fallback.- const useChat = mdMode && showChat && !!status?.sessionId+ // `chatAvailable` is split out because the label-row ⌘M hint names the face BEFORE it is open:+ // one value feeds both, so the hint cannot say "Chat view" while the chord opens markdown.+ const chatAvailable = showChat && !!status?.sessionId+ const useChat = mdMode && chatAvailableuseContextEnsure(session.api.context, id, agentId, status?.sessionId, (data.cwd as string) || undefined, accountForReads)const updateNodeInternals = useUpdateNodeInternals()@@ -5337,6 +5343,7 @@ export function TerminalNode({// Whatever the markdown toggle is bound to; '' when the user unbound it, in which case the// markdown view's hint names the action instead of promising a chord that never fires.const mdChip = chipFor('node.toggleMarkdown')+ const mdHint = mdViewHint({ chip: mdChip, open: mdMode, chatAvailable, hidden: hiddenHeaderButtons })// The experimental shared glyph renderer paints text on a canvas BELOW the nodes, so a glass// tint would sit on top of every glyph: glass stands down while a grid is mounted.@@ -5855,7 +5862,21 @@ export function TerminalNode({/>)}- {!collapsed && <NodeLabels nodeId={id} />}+ {!collapsed && (+ <NodeLabels+ nodeId={id}+ trailing={+ mdHint && (+ <MdViewHintButton+ hint={mdHint}+ tooltip={commandTooltip(mdMode ? 'Back to the terminal' : `Open ${mdHint.label.toLowerCase()}`, 'node.toggleMarkdown')}+ // The same flip as the chord handler and the context-menu item.+ onToggle={() => updateNodeData(id, (n) => ({ mdMode: !n.data.mdMode }))}+ />+ )+ }+ />+ )}{/* Body always mounted (keeps xterm alive); hidden via CSS when collapsed. */}<divdiff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex c87a10a89..a51cc491f 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -11173,6 +11173,34 @@ 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;+ align-items: center;+ min-width: 0;+}+/* 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. */+.term-node__mdhint {+ background: none;+ border: 0;+ border-radius: 4px;+ padding: 1px 4px;+ 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;