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(md-view): file paste/drop respects the ⌘M cover; SLEEPING in the card modal; editor chord gate
reviewcf69354e6679
diff --git a/CLAUDE.md b/CLAUDE.mdindex 2854fcc45..7fe7f47d3 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -1264,7 +1264,11 @@ session.(`terminal/useMdModeFocus.ts`). While the view is open, every "take the keyboard" path (hoverdwell, click, sidebar/notification jump) goes through `focusXtermUnlessCovered` and leaves thehidden xterm unfocused — the overlay sits inside the node body, so a dwell over it used to route- keystrokes into a pane nobody could see (source-pinned in `useMdModeFocus.test.tsx`). Tag chips via `NodeTags`.+ keystrokes into a pane nobody could see. The body's file DROP / file PASTE handlers (which focus+ the xterm and paste paths into it) are the other way in, and they stand aside while covered+ (`terminalOwnsFileInput`): a screenshot pasted into the ChatPanel composer used to be caught in+ the capture phase and typed as a path into the hidden pane. Both are source-pinned in+ `useMdModeFocus.test.tsx`. Tag chips via `NodeTags`.**Selection + copy is tmux's** (its mouse is on — see the tmux section): drag to select, wheel toscroll tmux's history. A drag copies via copy-mode, and tmux emits **OSC 52** to the client, whosehandler writes the **system clipboard** — the one copy path on every platform *and* over SSH (no@@ -4756,9 +4760,11 @@ the Settings section and ShortcutsPanel start disagreeing about what a chord meastays MOUNTED underneath (covered, not swapped, so its co-attach never detaches/re-attaches) andgets the same focus hand-off as the node (`ModalTerminal`'s `covered` → `useMdModeFocus`); and thechord reaches the modal through `window.nodeTerminal.onMarkdownToggle` only while it is the top- dialog, while the canvas node's own subscription refuses the chord whenever a board is up- (`lib/markdownChord.ts` `canvasOwnsMarkdownChord` — a hover flag can go stale under the opaque- board, so one press could otherwise flip both). The overlay sits at z 5 in the pane, BELOW the+ dialog, while the canvas terminal AND editor nodes' own subscriptions refuse the chord whenever a+ board is up (`lib/markdownChord.ts` `canvasOwnsMarkdownChord` — a hover flag can go stale under+ the opaque board, so one press could otherwise flip both). The header also carries the node's+ pause chips — DROPPED, PAUSED and SLEEPING (Eco, with the refused-wake sentence) — each clicking+ through the same `wakeHibernatedNode` trigger as the canvas chip. The overlay sits at z 5 in the pane, BELOW thesheet's resize handles (z 6/7, issue #389) — pinned in `styles.kanban.test.ts`.**The 💬 icon means COMMENTS on both surfaces** (repurposed from the markdown view — ⌘M stilltoggles markdown/chat on the canvas node, and on the card modal): on a terminal node it opens a right-side commentsdiff --git a/src/renderer/components/kanban/CardModal.test.tsx b/src/renderer/components/kanban/CardModal.test.tsxindex 9b640ad70..d296cea4d 100644--- a/src/renderer/components/kanban/CardModal.test.tsx+++ b/src/renderer/components/kanban/CardModal.test.tsx@@ -72,6 +72,14 @@ vi.mock('../../nodes/ChatPanel', () => ({)}))+// The wake trigger the header's DROPPED / PAUSED / SLEEPING chips click through, spied so a test can+// prove the chip reaches the SAME trigger the canvas node's chip uses (not a bespoke resume path).+const wakeMock = vi.hoisted(() => ({ calls: [] as string[] }))+vi.mock('../../nodes/TerminalNode', async (importOriginal) => ({+ ...(await importOriginal<typeof import('../../nodes/TerminalNode')>()),+ wakeHibernatedNode: (nodeId: string) => void wakeMock.calls.push(nodeId)+}))+vi.mock('../../nodes/BrowserSurface', () => ({BrowserSurface: ({ nodeId }: { nodeId: string }) => (<div className="browser-surface" data-node-id={nodeId}>@@ -628,6 +636,36 @@ describe('CardModal', () => {act(() => root.unmount())})+ it('a hibernated session shows a SLEEPING chip in the header that wakes it (the placeholder names it)', () => {+ // The ChatPanel's asleep placeholder tells the user to click SLEEPING "in the header" — true+ // on the canvas node, and it has to be true here too, or the modal user is sent looking for a+ // chip that does not exist.+ const root = createRoot(host)+ wakeMock.calls.length = 0+ useAgentStatus.setState({ byId: { 'node-md-1': { hibernated: true } } } as never)+ render(root, termSession())+ const chip = () =>+ Array.from(document.body.querySelectorAll<HTMLButtonElement>('button.kanban-badge')).find((b) =>+ b.textContent?.startsWith('SLEEPING')+ )+ expect(chip()).toBeTruthy()+ act(() => chip()!.click())+ expect(wakeMock.calls).toEqual(['node-md-1'])+ // A refused wake carries its sentence on the chip, exactly as on the canvas node.+ act(() =>+ useAgentStatus.setState({ byId: { 'node-md-1': { hibernated: true, wakeBlocked: 'Pane is busy' } } } as never)+ )+ expect(chip()!.textContent).toBe('SLEEPING — NOT RESUMED')+ expect(chip()!.title).toBe('Pane is busy')+ // Mutually exclusive with PAUSED / DROPPED, in the canvas node's order: one chip, never two.+ act(() => useAgentStatus.setState({ byId: { 'node-md-1': { hibernated: true, paused: true } } } as never))+ expect(chip()).toBeUndefined()+ expect(document.body.textContent).toContain('PAUSED')+ act(() => useAgentStatus.setState({ byId: { 'node-md-1': {} } } as never))+ expect(chip()).toBeUndefined()+ act(() => root.unmount())+ })+it('search is disabled while the view covers the terminal it searches', () => {const root = createRoot(host)render(root, termSession({ agentId: undefined, spawn: {} }))diff --git a/src/renderer/components/kanban/CardModal.tsx b/src/renderer/components/kanban/CardModal.tsxindex 0a2daeffc..5a827f600 100644--- a/src/renderer/components/kanban/CardModal.tsx+++ b/src/renderer/components/kanban/CardModal.tsx@@ -93,6 +93,8 @@ export function CardModal({ session, columnTitle, board, onChangeBoard, onClose,const observedAgentId = useAgentStatus((st) => st.byId[session.id]?.agentId)const paused = useAgentStatus((st) => !!st.byId[session.id]?.paused)const dropped = useAgentStatus((st) => !!st.byId[session.id]?.dropped)+ const hibernated = useAgentStatus((st) => !!st.byId[session.id]?.hibernated)+ const wakeBlocked = useAgentStatus((st) => st.byId[session.id]?.wakeBlocked)// Same chip as the card and the canvas node header — the modal is where a user checks WHICH// session this is, so the account belongs in its header chips, not only two views away.const observedAccount = useAgentStatus((st) => st.byId[session.id]?.account)@@ -370,6 +372,22 @@ export function CardModal({ session, columnTitle, board, onChangeBoard, onClose,PAUSED</button>)}+ {isTerminal && hibernated && !paused && !dropped && (+ // Eco's SLEEPING chip, the canvas node's third pause chip (ranked after DROPPED and+ // PAUSED there too — they are mutually exclusive by construction, the guard only mirrors+ // the node's JSX order). Opening the card usually wakes the session on its own, so this+ // is mostly seen for the moment that takes — and for a REFUSED wake, which is exactly+ // when the user needs it: the ChatPanel's asleep placeholder sends them to "SLEEPING in+ // the header", and the refusal's sentence lives on the chip, as on the canvas node.+ <button+ className="kanban-badge kanban-badge--sleeping"+ style={{ cursor: 'pointer', border: 'none' }}+ title={wakeBlocked ?? 'Agent hibernated to save memory — click to resume'}+ onClick={() => wakeHibernatedNode(session.id)}+ >+ {wakeBlocked ? 'SLEEPING — NOT RESUMED' : 'SLEEPING'}+ </button>+ )}{isTerminal && (<>{/* Same context-window pill + popover as the node header (null until usage data). */}diff --git a/src/renderer/lib/markdownChord.test.ts b/src/renderer/lib/markdownChord.test.tsindex b8bae2e51..247c9d8e0 100644--- a/src/renderer/lib/markdownChord.test.ts+++ b/src/renderer/lib/markdownChord.test.ts@@ -23,4 +23,13 @@ describe('canvasOwnsMarkdownChord', () => {/onMarkdownToggle\(\(\) => \{\s*if \(!canvasOwnsMarkdownChord\(hoveredRef\.current, isGlobalKanbanOpen\(\) \|\| isKanbanOpen\(/)})++ it('the editor node asks the same question (a stale-hovered editor under the board refuses too)', () => {+ // The editor's preview flip was gated on hover alone, so a press meant for the card modal also+ // flipped the hidden preview of whichever editor was under the pointer when the board opened.+ const src = readFileSync(resolve(__dirname, '../nodes/EditorNode.tsx'), 'utf8').replace(/\r\n/g, '\n')+ expect(src).toMatch(+ /onMarkdownToggle\(\(\) => \{\s*if \(canvasOwnsMarkdownChord\(hoveredRef\.current, isGlobalKanbanOpen\(\) \|\| isKanbanOpen\(/+ )+ })})diff --git a/src/renderer/lib/markdownChord.ts b/src/renderer/lib/markdownChord.tsindex 9d3ac5f54..ecf86a122 100644--- a/src/renderer/lib/markdownChord.ts+++ b/src/renderer/lib/markdownChord.ts@@ -1,5 +1,6 @@/**- * Whether the CANVAS terminal node owns a ⌘M (`node.toggleMarkdown`) press.+ * Whether a CANVAS node (the terminal node's ⌘M view, the editor node's preview) owns a ⌘M+ * (`node.toggleMarkdown`) press.** Only a hovered node takes the chord — and never while a kanban board is up. The board is an* opaque overlay over a still-mounted canvas, and a node's hover flag is driven by mouseenter /diff --git a/src/renderer/nodes/EditorNode.tsx b/src/renderer/nodes/EditorNode.tsxindex aebce78dd..037f74f64 100644--- a/src/renderer/nodes/EditorNode.tsx+++ b/src/renderer/nodes/EditorNode.tsx@@ -8,6 +8,8 @@ import { monacoTheme } from '../lib/appTheme'import { useAppTheme } from '../state/useAppTheme'import { renderMarkdown } from '../lib/markdown'import { opensInPreview } from '../lib/markdownPreview'+import { canvasOwnsMarkdownChord } from '../lib/markdownChord'+import { isGlobalKanbanOpen, isKanbanOpen } from '../state/viewMode'import { useSettings } from '../state/settings'import { sshFs } from '../terminal/ssh-fs'import { useProjects } from '../state/projects'@@ -247,9 +249,11 @@ export function EditorNode({ id, data, selected }: NodeProps<CanvasNode>) {// eslint-disable-next-line react-hooks/exhaustive-deps}, [])- // Cmd/Ctrl+M toggles a rendered markdown preview when this node is hovered.+ // Cmd/Ctrl+M toggles a rendered markdown preview when this node is hovered — and never while a+ // board is up: the hover flag can be stale under the opaque board, whose card modal owns the+ // chord there (same rule as the terminal node; see `canvasOwnsMarkdownChord`).useEffect(() => window.nodeTerminal.onMarkdownToggle(() => {- if (hoveredRef.current) toggleRef.current()+ if (canvasOwnsMarkdownChord(hoveredRef.current, isGlobalKanbanOpen() || isKanbanOpen(useProjects.getState().activeProjectId ?? ''))) toggleRef.current()}), [])// Whatever the markdown toggle is bound to; '' when the user unbound it, in which case thediff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex 0340ec3b5..94144ea2b 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -174,7 +174,7 @@ import { coldSelfHealVerdict } from '../terminal/cold-self-heal'import { WakeInputBuffer } from '../terminal/wake-input-buffer'import { FindBar } from '../components/FindBar'import { TerminalMarkdownView } from './TerminalMarkdownView'-import { focusXtermUnlessCovered, useMdModeFocus } from '../terminal/useMdModeFocus'+import { focusXtermUnlessCovered, terminalOwnsFileInput, useMdModeFocus } from '../terminal/useMdModeFocus'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'@@ -5078,6 +5078,7 @@ export function TerminalNode({// ---- file drop: paste dropped file paths into the terminal (native-terminal behavior) ----const onBodyDragOver = (e: React.DragEvent) => {+ if (!terminalOwnsFileInput(mdModeRef.current)) return // the ⌘M view is on top: no drop overlayif (!Array.from(e.dataTransfer.types).includes('Files')) returne.preventDefault()e.dataTransfer.dropEffect = 'copy'@@ -5156,6 +5157,7 @@ export function TerminalNode({}const onBodyDrop = async (e: React.DragEvent) => {+ if (!terminalOwnsFileInput(mdModeRef.current)) return // covered by the ⌘M view (see predicate)const files = Array.from(e.dataTransfer.files)setDropping(false)if (!files.length) return@@ -5169,6 +5171,7 @@ export function TerminalNode({// CAPTURE phase: xterm listens on its own textarea below us, so stopping here is the only way to// keep it from also pasting whatever text the clipboard happened to carry alongside the file.const onBodyPaste = (e: React.ClipboardEvent) => {+ if (!terminalOwnsFileInput(mdModeRef.current)) return // the ChatPanel composer takes its own pasteconst files = pastedFiles(e.clipboardData)if (files.length) {e.preventDefault()diff --git a/src/renderer/terminal/useMdModeFocus.test.tsx b/src/renderer/terminal/useMdModeFocus.test.tsxindex 24a5a8ae1..37b23a7b7 100644--- a/src/renderer/terminal/useMdModeFocus.test.tsx+++ b/src/renderer/terminal/useMdModeFocus.test.tsx@@ -4,7 +4,13 @@ import { createRoot, type Root } from 'react-dom/client'import { act } from 'react'import { readFileSync } from 'node:fs'import { resolve } from 'node:path'-import { focusXtermUnlessCovered, mayRestoreFocus, useMdModeFocus, type FocusableTerm } from './useMdModeFocus'+import {+ focusXtermUnlessCovered,+ mayRestoreFocus,+ terminalOwnsFileInput,+ useMdModeFocus,+ type FocusableTerm+} from './useMdModeFocus';(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true@@ -170,3 +176,24 @@ describe('focusXtermUnlessCovered', () => {expect(src).toMatch(/focusXtermUnlessCovered\(term, coveredRef\.current\)/)})})++describe('terminalOwnsFileInput', () => {+ it('hands dropped / pasted files to the terminal only while the ⌘M view is not covering it', () => {+ expect(terminalOwnsFileInput(false)).toBe(true)+ expect(terminalOwnsFileInput(true)).toBe(false)+ })++ it("gates every TerminalNode file-input handler on the node's ⌘M cover", () => {+ // Source pin: the handlers sit on `.term-node__body`, which ALSO hosts the ⌘M overlay — so a+ // screenshot pasted into the ChatPanel composer (or a file dropped on the view) was caught in+ // the capture phase and pasted as a path into the hidden pane, with focus stolen to match.+ // The handlers are closures in a component that cannot be mounted here.+ const src = readFileSync(resolve(__dirname, '../nodes/TerminalNode.tsx'), 'utf8').replace(/\r\n/g, '\n')+ for (const handler of ['onBodyDragOver', 'onBodyDrop', 'onBodyPaste']) {+ const start = src.indexOf(`const ${handler} = `)+ expect(start, handler).toBeGreaterThan(-1)+ const head = src.slice(start, src.indexOf('\n', src.indexOf('\n', start) + 1))+ expect(head, handler).toMatch(/if \(!terminalOwnsFileInput\(mdModeRef\.current\)\) return/)+ }+ })+})diff --git a/src/renderer/terminal/useMdModeFocus.ts b/src/renderer/terminal/useMdModeFocus.tsindex 65787ff82..a7860323f 100644--- a/src/renderer/terminal/useMdModeFocus.ts+++ b/src/renderer/terminal/useMdModeFocus.ts@@ -73,3 +73,19 @@ export function mayRestoreFocus(export function focusXtermUnlessCovered(term: FocusableTerm | null | undefined, covered: boolean): void {if (!covered) term?.focus()}++/**+ * Whether a file DROP or PASTE on the node body belongs to the terminal. The file handlers sit on+ * `.term-node__body`, which also hosts the ⌘M face — so while the view covers the xterm, a+ * screenshot pasted into the ChatPanel composer (or a file dropped on the output view) was caught+ * in the capture phase, written as a path into the hidden pane, and the xterm focused to match.+ * Covered, the handlers stand aside and the event behaves natively for whatever is under the+ * pointer / caret: a paste lands in the composer, a drop falls to the window-level guard.+ *+ * Keyed on the same cover flag as `focusXtermUnlessCovered`, not on the event target: the overlay+ * spans the whole body, so "covered" already answers "is this event aimed at the view", and one+ * flag cannot drift from the focus rule the way a second list of overlay selectors could.+ */+export function terminalOwnsFileInput(covered: boolean): boolean {+ return !covered+}