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(canvas-control): branch verb — agents can branch a Claude node's conversation
enes0ce0120c8e94
diff --git a/src/main/canvas-control-core.test.ts b/src/main/canvas-control-core.test.tsindex fdf55c633..7d94d8203 100644--- a/src/main/canvas-control-core.test.ts+++ b/src/main/canvas-control-core.test.ts@@ -67,6 +67,15 @@ describe('parseControlRequest', () => {expect(isDestructiveVerb('open-agent')).toBe(false)})+ it('branch requires --node, and is not destructive', () => {+ expect(parseControlRequest('branch', {})).toEqual({ error: 'branch requires --node <id>' })+ expect(parseControlRequest('branch', { node: 'n1' })).toEqual({+ verb: 'branch',+ args: { node: 'n1' }+ })+ expect(isDestructiveVerb('branch')).toBe(false)+ })+it('rename requires --node and --title, and is not destructive', () => {expect(parseControlRequest('rename', {})).toEqual({ error: 'rename requires --node <id>' })expect(parseControlRequest('rename', { node: 'n1' })).toEqual({ error: 'rename requires --title' })diff --git a/src/main/canvas-control-core.ts b/src/main/canvas-control-core.tsindex be0961666..0c1d04f7f 100644--- a/src/main/canvas-control-core.ts+++ b/src/main/canvas-control-core.ts@@ -15,6 +15,7 @@ export type ControlVerb =| 'arrange'| 'align'| 'spawn-team'+ | 'branch'| 'rename'| 'write'| 'close'@@ -37,6 +38,7 @@ const VERBS: ControlVerb[] = ['arrange','align','spawn-team',+ 'branch','rename','write','close'@@ -70,6 +72,7 @@ export function parseControlRequest(if (v === 'align' && !args.nodes) return { error: 'align requires --nodes <id,id>' }if (v === 'align' && !args.edge) return { error: 'align requires --edge' }if (v === 'spawn-team' && !args.team) return { error: 'spawn-team requires --team <json>' }+ if (v === 'branch' && !args.node) return { error: 'branch requires --node <id>' }if (v === 'rename' && !args.node) return { error: 'rename requires --node <id>' }if (v === 'rename' && !args.title) return { error: 'rename requires --title' }return { verb: v, args }@@ -113,7 +116,7 @@ var args = {}for (var i = 1; i < argv.length; i++) {if (argv[i].slice(0, 2) === '--') { args[argv[i].slice(2)] = argv[i + 1] || ''; i++ }else if (!args.path && (verb === 'show-image' || verb === 'show-video')) { args.path = argv[i] }- else if (!args.node && (verb === 'write' || verb === 'close' || verb === 'rename')) { args.node = argv[i] }+ else if (!args.node && (verb === 'write' || verb === 'close' || verb === 'rename' || verb === 'branch')) { args.node = argv[i] }}var ep = endpoint()diff --git a/src/main/canvas-control.ts b/src/main/canvas-control.tsindex 804773962..90f0885e0 100644--- a/src/main/canvas-control.ts+++ b/src/main/canvas-control.ts@@ -69,6 +69,8 @@ Verbs:- \`spawn-team --label "Frontend Team" --team '[{"title":"UI","prompt":"...","agent":"claude"}]'\` —open one agent per role (each prompt starts that member working), arrange them in a grid,wrap them in a labeled group, and connect each to you. Max 8 roles per call.+- \`branch --node <id>\` — branch a Claude node's conversation: the node stays on the new+ branch and a new node opens resuming the original. Target must be a Claude agent node.- \`rename --node <id> --title "New Name"\` — rename any node (terminals, groups, stickies…).- \`write --node <id> --text "..."\` — type text into a terminal node. (Asks the user to confirm.)- \`close --node <id>\` — close a node. (Asks the user to confirm.)diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 65d6f098f..2763e2116 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -1944,9 +1944,9 @@ export function Canvas() {// We already know the current session id from the hooks; only fall back to parsing the// terminal output if it's unknown.const branchClaude = useCallback(- async (nodeId: string) => {+ async (nodeId: string, opts?: { interactive?: boolean }): Promise<{ ok: boolean; error?: string; newNodeId?: string }> => {const source = nodesRef.current.find((n) => n.id === nodeId) as CanvasNode | undefined- if (!source) return+ if (!source) return { ok: false, error: `no node with id ${nodeId}` }const known = useAgentStatus.getState().byId[nodeId]?.sessionIdlet originalId = knownif (known) {@@ -1954,8 +1954,12 @@ export function Canvas() {} else {const res = await branchClaudeSession(nodeId)if (!res.ok || !res.originalId) {- setConfirm({ message: res.error ?? 'Branch failed.', onConfirm: () => setConfirm(null) })- return+ const error = res.error ?? 'Branch failed.'+ // The error dialog is for humans; agent-CLI calls get the error in the reply instead.+ if (opts?.interactive !== false) {+ setConfirm({ message: error, onConfirm: () => setConfirm(null) })+ }+ return { ok: false, error }}originalId = res.originalId}@@ -1972,6 +1976,7 @@ export function Canvas() {copy.selected = truesetNodes((ns) => [...ns.map((n) => ({ ...n, selected: false })), copy])markDirty()+ return { ok: true, newNodeId: copy.id }},[setNodes, markDirty])@@ -2875,6 +2880,26 @@ export function Canvas() {})return}+ case 'branch': {+ const id = args.node ?? ''+ const target = nodesRef.current.find((nd) => nd.id === id)+ if (!target) {+ reply({ ok: false, error: `branch: no node with id ${id}` })+ return+ }+ const targetAgent = target.data.agentId as AgentId | undefined+ if (!targetAgent || !canBranch(targetAgent)) {+ reply({ ok: false, error: 'branch: node is not a branch-capable agent node' })+ return+ }+ const res = await branchClaude(id, { interactive: false })+ reply(+ res.ok+ ? { ok: true, message: `branched ${id}; original resumes in ${res.newNodeId}`, result: { newNodeId: res.newNodeId } }+ : { ok: false, error: res.error }+ )+ return+ }case 'rename': {const id = args.node ?? ''const title = (args.title ?? '').trim()