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(agents): gate Claude-only UI on capabilities; registry-generated agent menus
enesed8efb589169
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 73716850b..713e45da9 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -62,14 +62,22 @@ import { useAgentNodes } from '../state/agentNodes'import { SubagentNode } from '../nodes/SubagentNode'import { LoopNode } from '../nodes/LoopNode'import type { NormalizedAgentEvent } from '@shared/agents/normalize'-import { agentConfig } from '@shared/agents/config'+import {+ agentConfig,+ hasHooks,+ canBranch,+ canBridge,+ AGENT_CONFIG,+ BUILTIN_AGENT_IDS,+ type AgentId+} from '@shared/agents/config'import { branchClaudeSession } from '../lib/claudeBranch'import { useSettings } from '../state/settings'import { useContextWindow } from '../state/contextWindow'import {claudeLaunchCommand,COLLAPSED_HEIGHT,- createClaudeNode,+ createAgentNode,createDiffNode,createEditorNode,createStickyNode,@@ -488,16 +496,30 @@ export function Canvas() {[onNodesChange, markDirty])- const isClaudeNode = useCallback((id: string) => {+ // Resolve a node's agent id, with a tags fallback for not-yet-migrated legacy nodes.+ const agentIdOf = useCallback((id: string): AgentId | undefined => {const n = nodesRef.current.find((x) => x.id === id)- return n?.type === 'terminal' && ((n.data.tags as string[]) ?? []).includes('claude')+ if (!n || n.type !== 'terminal') return undefined+ return (+ (n.data.agentId as AgentId | undefined) ??+ (((n.data.tags as string[]) ?? []).includes('claude') ? 'claude' : undefined)+ )}, [])- // Draw a bridge link between two Claude nodes (the connection that lets them message).+ // Bridge links connect two bridge-capable agent sessions (currently Claude only).+ const canBridgeNode = useCallback(+ (id: string) => {+ const a = agentIdOf(id)+ return !!a && canBridge(a)+ },+ [agentIdOf]+ )++ // Draw a bridge link between two bridge-capable nodes (the connection that lets them message).const onConnect = useCallback((c: Connection) => {if (!c.source || !c.target || c.source === c.target) return- if (!isClaudeNode(c.source) || !isClaudeNode(c.target)) return+ if (!canBridgeNode(c.source) || !canBridgeNode(c.target)) return// No duplicate link (in either direction).const exists = bridgeEdgesRef.current.some((e) =>@@ -513,7 +535,7 @@ export function Canvas() {)markDirty()},- [isClaudeNode, setBridgeEdges, markDirty]+ [canBridgeNode, setBridgeEdges, markDirty])// Double-click a bridge link to remove it (ephemeral subagent/loop edges are left alone).@@ -695,14 +717,19 @@ export function Canvas() {[setNodes, markDirty, viewCenter])- const addClaude = useCallback(- (center?: { x: number; y: number }) => {+ const addAgentNode = useCallback(+ (agentId: AgentId, center?: { x: number; y: number }) => {const cwd = useProjects.getState().getProject(activeProjectId)?.cwd- setNodes((ns) => [...ns, createClaudeNode(ns.length, cwd, center ?? viewCenter())])+ setNodes((ns) => [...ns, createAgentNode(agentId, ns.length, cwd, center ?? viewCenter())])markDirty()},[setNodes, markDirty, activeProjectId, viewCenter])+ // Kept as a thin wrapper so existing callers + the ⌘⇧C shortcut keep working.+ const addClaude = useCallback(+ (center?: { x: number; y: number }) => addAgentNode('claude', center),+ [addAgentNode]+ )// ⌘T = new terminal, ⌘⇧C = new Claude Code (ignored while typing in a field/terminal).useEffect(() => {@@ -1005,10 +1032,10 @@ export function Canvas() {{ type: 'colors', onPick: (c) => setNodesColor(ids, c) },{ type: 'separator' },{ label: 'Duplicate', icon: <IconDuplicate />, onClick: () => duplicateNodes(ids) },- ...(ids.length === 1 &&- ((nodesRef.current.find((n) => n.id === ids[0])?.data.tags as string[]) ?? []).includes(- 'claude'- )+ ...(ids.length === 1 && (() => {+ const a = agentIdOf(ids[0])+ return !!a && canBranch(a)+ })()? ([{label: 'Branch conversation',@@ -1032,6 +1059,7 @@ export function Canvas() {setNodesColor,duplicateNodes,branchClaude,+ agentIdOf,alignToGrid,toggleCollapseNodes,toggleMarkdown,@@ -1059,7 +1087,13 @@ export function Canvas() {y: e.clientY,items: [{ label: 'New terminal', icon: <IconTerminal />, onClick: () => addTerminal(at) },- { label: 'New Claude Code', icon: <IconClaude />, onClick: () => addClaude(at) },+ ...BUILTIN_AGENT_IDS.map(+ (aid): MenuItem => ({+ label: `New ${AGENT_CONFIG[aid].label}`,+ icon: aid === 'claude' ? <IconClaude /> : <IconTerminal />,+ onClick: () => addAgentNode(aid, at)+ })+ ),{ label: 'New sticky note', icon: <IconNote />, onClick: () => addSticky(at) },{ label: 'Open file…', icon: <IconEditor />, onClick: () => void openFileDialog(at) },{ type: 'separator' },@@ -1068,7 +1102,7 @@ export function Canvas() {]})},- [screenToFlowPosition, addTerminal, addClaude, addSticky, openFileDialog, selectAll, fitView]+ [screenToFlowPosition, addTerminal, addAgentNode, addSticky, openFileDialog, selectAll, fitView])const onNodeContextMenu = useCallback(@@ -1360,7 +1394,14 @@ export function Canvas() {const buildCommands = useCallback((): Command[] => {const cmds: Command[] = [{ id: 'new-term', label: 'New terminal', section: 'Create', icon: <IconTerminal />, run: () => addTerminal() },- { id: 'new-claude', label: 'New Claude Code', icon: <IconClaude />, run: () => addClaude() },+ ...BUILTIN_AGENT_IDS.map(+ (aid): Command => ({+ id: `new-${aid}`,+ label: `New ${AGENT_CONFIG[aid].label}`,+ icon: aid === 'claude' ? <IconClaude /> : <IconTerminal />,+ run: () => addAgentNode(aid)+ })+ ),{ id: 'new-sticky', label: 'New sticky note', icon: <IconNote />, run: () => addSticky() },{ id: 'open-file', label: 'Open file…', icon: <IconEditor />, run: () => void openFileDialog() },{ id: 'new-project', label: 'New project', icon: <IconProject />, run: () => addProject() },@@ -1384,12 +1425,14 @@ export function Canvas() {.filter((n) => n.type !== 'group').forEach((n) => {const tags = (n.data.tags as string[]) ?? []- const isClaude = tags.includes('claude')- const session = isClaude ? cs.byId[n.id]?.session : undefined+ const a =+ (n.data.agentId as AgentId | undefined) ?? (tags.includes('claude') ? 'claude' : undefined)+ const isAgent = !!a && hasHooks(a)+ const session = isAgent ? cs.byId[n.id]?.session : undefinedcmds.push({id: `node-${n.id}`,label: `Go to ${n.data.title}`,- hint: [tags.join(' '), session, isClaude ? `nt-${n.id}` : '']+ hint: [tags.join(' '), session, isAgent ? `nt-${n.id}` : ''].filter(Boolean).join(' '),icon: <IconJump />,@@ -1400,7 +1443,7 @@ export function Canvas() {return cmds}, [addTerminal,- addClaude,+ addAgentNode,addSticky,openFileDialog,addProject,@@ -1582,7 +1625,7 @@ export function Canvas() {onRedo={redo}onAddTerminal={addTerminal}onAddSticky={addSticky}- onAddClaude={addClaude}+ onAddAgent={(aid) => addAgentNode(aid)}onOpenFile={() => void openFileDialog()}onSave={persist}onFitView={() => fitView({ padding: 0.2, duration: 300 })}diff --git a/src/renderer/components/Dock.tsx b/src/renderer/components/Dock.tsxindex 9c0706f90..db7ec8d7c 100644--- a/src/renderer/components/Dock.tsx+++ b/src/renderer/components/Dock.tsx@@ -1,5 +1,6 @@import { useState } from 'react'import claudeIcon from '../assets/claude.svg'+import { AGENT_CONFIG, BUILTIN_AGENT_IDS, type AgentId } from '@shared/agents/config'interface DockProps {dirty: boolean@@ -8,7 +9,7 @@ interface DockProps {canRedo: booleanonAddTerminal: () => voidonAddSticky: () => void- onAddClaude: () => void+ onAddAgent: (agentId: AgentId) => voidonOpenFile: () => voidonUndo: () => voidonRedo: () => void@@ -29,7 +30,7 @@ export function Dock({canRedo,onAddTerminal,onAddSticky,- onAddClaude,+ onAddAgent,onOpenFile,onUndo,onRedo,@@ -56,10 +57,12 @@ export function Dock({<TerminalIcon /><span>Terminal</span></button>- <button onClick={pick(onAddClaude)}>- <ClaudeIcon />- <span>Claude Code</span>- </button>+ {BUILTIN_AGENT_IDS.map((aid) => (+ <button key={aid} onClick={pick(() => onAddAgent(aid))}>+ {aid === 'claude' ? <ClaudeIcon /> : <TerminalIcon />}+ <span>{AGENT_CONFIG[aid].label}</span>+ </button>+ ))}<button onClick={pick(onAddSticky)}><NoteIcon /><span>Sticky Note</span>diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex 22c5525fd..83505a3a3 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -19,6 +19,7 @@ import { useSettings } from '../state/settings'import { useAgentStatus } from '../state/agentStatus'import { useAgentNodes } from '../state/agentNodes'import { COLLAPSED_HEIGHT, NODE_COLORS, type CanvasNode } from '../state/workspace'+import { hasHooks, canRecur, canBridge, hasUsage, type AgentId } from '@shared/agents/config'/** Backslash-escape shell-special characters, like a native terminal does on file drop. */function escapeDroppedPath(p: string): string {@@ -54,15 +55,22 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {const mdMode = !!data.mdModeconst collapsed = !!data.collapsedconst tags = (data.tags as string[]) ?? []- const isClaude = tags.includes('claude')+ // Derive the node's agent once. The `tags` fallback keeps not-yet-migrated legacy+ // claude nodes working until they're re-serialized with `agentId`.+ const agentId = (data.agentId as AgentId | undefined) ?? (tags.includes('claude') ? 'claude' : undefined)+ // Gate each former `isClaude` site by the capability it actually represents.+ const showStatus = !!agentId && hasHooks(agentId) // status badge + session-title capture+ const showLoop = !!agentId && canRecur(agentId) // /loop · /schedule · /cron chrome+ const showBridge = !!agentId && canBridge(agentId) // bridge link handles+ const showUsage = !!agentId && hasUsage(agentId) // per-node context-window meterconst status = useAgentStatus((s) => s.byId[id])const updateNodeInternals = useUpdateNodeInternals()- // The bridge handles are added/positioned dynamically for Claude nodes; make React Flow- // re-measure them so edges anchor to the (centered) handle, not a stale position.+ // The bridge handles are added/positioned dynamically for bridge-capable nodes; make+ // React Flow re-measure them so edges anchor to the (centered) handle, not a stale position.useEffect(() => {- if (isClaude) updateNodeInternals(id)- }, [isClaude, id, updateNodeInternals])+ if (showBridge) updateNodeInternals(id)+ }, [showBridge, id, updateNodeInternals])// Terminal lifecycle — set up exactly once.useEffect(() => {@@ -104,7 +112,7 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {// Claude Code state (busy/idle/attention) comes from Claude's own hooks via the// claude:status IPC (handled centrally in Canvas) — not from parsing the output here.// We only surface the conversation topic from the terminal title, when Claude sets one.- if (isClaude) {+ if (showStatus) {cleanups.push(term.onTitleChange((t) => {const title = t.trim()@@ -320,9 +328,9 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {isConnectable={false}style={{ opacity: 0, pointerEvents: 'none', bottom: 0 }}/>- {/* Bridge link handles (Claude nodes only): drag right→left to connect two sessions.- Vertically centered on the side edges; raised above the body so they're never buried. */}- {isClaude && (+ {/* Bridge link handles (bridge-capable nodes only): drag right→left to connect two+ sessions. Vertically centered on the side edges; raised above the body so they're never buried. */}+ {showBridge && (<><Handleid="bridge-out"@@ -391,14 +399,14 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {{status.session}</span>)}- {isClaude && <ContextMeter sessionId={status?.sessionId ?? null} />}+ {showUsage && <ContextMeter sessionId={status?.sessionId ?? null} />}{status?.state === 'working' && (<span className="term-node__status term-node__status--busy" title="Claude is working"><span className="term-node__status-dot" />RUNNING</span>)}- {status?.loop && (+ {showLoop && status?.loop && (<spanclassName="term-node__status term-node__status--loop"title={`Running /${status.loop.kind}`}