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(claude): make subagent/loop nodes first-class (select, drag, resize)
enes8c5b65f29f46
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex a72114818..34d367a37 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -134,10 +134,21 @@ export function Canvas() {// Laid out fanning below the parent Claude node.const agentById = useAgentNodes((s) => s.byId)const ephemeralPos = useAgentNodes((s) => s.positions)+ const ephSizes = useAgentNodes((s) => s.sizes)+ const ephExpanded = useAgentNodes((s) => s.expanded)const claudeById = useClaudeStatus((s) => s.byId)// Selection state for ephemeral nodes (they live outside React Flow's managed nodes).const [ephSel, setEphSel] = useState<Record<string, boolean>>({})const { ephemeralNodes, ephemeralEdges } = useMemo(() => {+ // Explicit width/height for an ephemeral node (so it resizes like any other node).+ // Defaults switch with expand; a user resize override wins.+ const dims = (id: string, baseW: number, expW: number, baseH: number, expH: number) => {+ const sz = ephSizes[id]+ const exp = !!ephExpanded[id]+ const width = sz?.width ?? (exp ? expW : baseW)+ const height = sz?.height ?? (exp ? expH : baseH)+ return { width, height, style: { width, height } }+ }const eNodes: CanvasNode[] = []const eEdges: Edge[] = []// Loop nodes: one per terminal node currently running a /loop, placed below-left.@@ -153,6 +164,7 @@ export function Canvas() {position: ephemeralPos[lid] ?? { x: parent.position.x - 250, y: parent.position.y + ph + 60 },draggable: true,selected: !!ephSel[lid],+ ...dims(lid, 230, 460, 92, 320),data: {title: st.loop.task ?? '',color: '#bf7af0',@@ -162,7 +174,8 @@ export function Canvas() {loopActive: st.state === 'working',loopKind: st.loop.kind,loopSchedule: st.loop.schedule,- loopTask: st.loop.task+ loopTask: st.loop.task,+ ephExpanded: !!ephExpanded[lid]}} as CanvasNode)eEdges.push({@@ -195,6 +208,7 @@ export function Canvas() {},draggable: true,selected: !!ephSel[cid],+ ...dims(cid, 230, 480, 96, 340),data: {title: v.label ?? '',color: '#d97757',@@ -206,7 +220,8 @@ export function Canvas() {subagentTokens: v.tokens,subagentToolUses: v.toolUses,subagentResult: v.result,- subagentActivity: v.activity+ subagentActivity: v.activity,+ ephExpanded: !!ephExpanded[cid]}} as CanvasNode)eEdges.push({@@ -219,7 +234,7 @@ export function Canvas() {})}return { ephemeralNodes: eNodes, ephemeralEdges: eEdges }- }, [agentById, claudeById, ephemeralPos, ephSel, nodes])+ }, [agentById, claudeById, ephemeralPos, ephSizes, ephExpanded, ephSel, nodes])// 1) Load the whole workspace once and hydrate the projects store.useEffect(() => {@@ -374,6 +389,8 @@ export function Canvas() {if ('id' in c && isEph(c.id)) {if (c.type === 'position' && c.position) useAgentNodes.getState().setPosition(c.id, c.position)else if (c.type === 'select') setEphSel((prev) => ({ ...prev, [c.id]: c.selected }))+ else if (c.type === 'dimensions' && c.dimensions && c.resizing)+ useAgentNodes.getState().setSize(c.id, c.dimensions)return false}return true@@ -1224,6 +1241,7 @@ export function Canvas() {draggingRef.current = falsemarkDirty()}}+ onPaneClick={() => setEphSel({})}onPaneContextMenu={onPaneContextMenu}onNodeContextMenu={onNodeContextMenu}onSelectionContextMenu={onSelectionContextMenu}diff --git a/src/renderer/nodes/LoopNode.tsx b/src/renderer/nodes/LoopNode.tsxindex 5ad58e9aa..488890377 100644--- a/src/renderer/nodes/LoopNode.tsx+++ b/src/renderer/nodes/LoopNode.tsx@@ -1,13 +1,14 @@-import { useEffect, useRef, useState } from 'react'-import { Handle, Position, type NodeProps } from '@xyflow/react'+import { useEffect, useRef } from 'react'+import { Handle, NodeResizer, Position, type NodeProps } from '@xyflow/react'import type { CanvasNode } from '../state/workspace'+import { useAgentNodes } from '../state/agentNodes'/**- * Ephemeral node visualizing a /loop, /schedule or /cron set up on a Claude terminal.- * Shows the kind, schedule, full task, and (for in-session loops) per-iteration summaries.- * The Play button re-issues the task to the parent terminal (manual trigger).+ * Loop/schedule/cron node — first-class (select/drag/resize). Shows the kind, schedule, full+ * task, and (for in-session loops) per-iteration summaries. Play re-issues the task to the+ * parent terminal (manual trigger).*/-export function LoopNode({ id, data }: NodeProps<CanvasNode>) {+export function LoopNode({ id, data, selected }: NodeProps<CanvasNode>) {const count = (data.loopCount as number) ?? 0const items = (data.loopItems as string[]) ?? []const active = !!data.loopActive@@ -15,8 +16,9 @@ export function LoopNode({ id, data }: NodeProps<CanvasNode>) {const task = (data.loopTask as string) || ''const kind = (data.loopKind as string) || 'loop'const label = kind.charAt(0).toUpperCase() + kind.slice(1)- const [expanded, setExpanded] = useState(false)+ const expanded = !!data.ephExpandedconst bodyRef = useRef<HTMLDivElement>(null)+ const toggle = () => useAgentNodes.getState().toggleExpanded(id)useEffect(() => {if (expanded && bodyRef.current) bodyRef.current.scrollTop = bodyRef.current.scrollHeight@@ -29,13 +31,19 @@ export function LoopNode({ id, data }: NodeProps<CanvasNode>) {return (<div className={`loop-node${active ? ' working' : ''}`}>+ <NodeResizer isVisible={selected} minWidth={180} minHeight={84} color="#bf7af0" /><Handle type="target" position={Position.Top} isConnectable={false} />- <div- className="loop-node__head nodrag"- onClick={() => setExpanded((v) => !v)}- title={expanded ? 'Collapse' : 'Click to expand'}- style={{ cursor: 'pointer' }}- >+ <div className="loop-node__head nodrag" onClick={toggle} style={{ cursor: 'pointer' }}>+ <button+ className="loop-node__expand"+ title={expanded ? 'Collapse' : 'Open'}+ onClick={(e) => {+ e.stopPropagation()+ toggle()+ }}+ >+ {expanded ? '▾' : '▸'}+ </button><span className="loop-node__dot" /><span className="loop-node__type">{label}</span>{count > 0 && <span className="loop-node__count">×{count}</span>}@@ -46,9 +54,7 @@ export function LoopNode({ id, data }: NodeProps<CanvasNode>) {</button>)}</div>- {(task || schedule) && !expanded && (- <div className="loop-node__task">{task || schedule}</div>- )}+ {(task || schedule) && !expanded && <div className="loop-node__task">{task || schedule}</div>}{expanded && (<div className="loop-node__items nodrag nowheel" ref={bodyRef}>{task ? <div className="loop-node__task-full">{task}</div> : null}diff --git a/src/renderer/nodes/SubagentNode.tsx b/src/renderer/nodes/SubagentNode.tsxindex f47675ba1..74f20d935 100644--- a/src/renderer/nodes/SubagentNode.tsx+++ b/src/renderer/nodes/SubagentNode.tsx@@ -1,6 +1,7 @@import { useEffect, useRef, useState } from 'react'-import { Handle, Position, type NodeProps } from '@xyflow/react'+import { Handle, NodeResizer, Position, type NodeProps } from '@xyflow/react'import type { CanvasNode } from '../state/workspace'+import { useAgentNodes } from '../state/agentNodes'function fmtDur(ms: number): string {const s = Math.round(ms / 1000)@@ -13,11 +14,11 @@ function fmtTokens(n: number): string {}/**- * Display-only node visualizing a subagent a Claude session spawned. Shows type + task +- * a live timer while working and duration/tokens/tool-uses when done. Click to expand and- * read what it produced (subagents have no terminal — this is their result content).+ * Subagent node — a first-class canvas node (select/drag/resize) visualizing a subagent the+ * Claude session spawned. Shows type + task + live timer / duration-tokens; expand to read+ * its live transcript in a terminal-styled panel (subagents have no PTY).*/-export function SubagentNode({ data }: NodeProps<CanvasNode>) {+export function SubagentNode({ id, data, selected }: NodeProps<CanvasNode>) {const working = data.subagentState !== 'done'const startedAt = (data.subagentStartedAt as number) || 0const durationMs = data.subagentDurationMs as number | undefined@@ -26,15 +27,14 @@ export function SubagentNode({ data }: NodeProps<CanvasNode>) {const result = (data.subagentResult as string) || ''const activity = (data.subagentActivity as string) || ''const body = activity || result- const [expanded, setExpanded] = useState(false)+ const expanded = !!data.ephExpandedconst bodyRef = useRef<HTMLDivElement>(null)+ const toggle = () => useAgentNodes.getState().toggleExpanded(id)- // Auto-scroll the live transcript to the bottom as it grows (while expanded).useEffect(() => {if (expanded && bodyRef.current) bodyRef.current.scrollTop = bodyRef.current.scrollHeight}, [body, expanded])- // Live elapsed timer while working.const [now, setNow] = useState(() => Date.now())useEffect(() => {if (!working) return@@ -52,20 +52,16 @@ export function SubagentNode({ data }: NodeProps<CanvasNode>) {.join(' · ')return (- <div className={`subagent-node${working ? ' working' : ' done'}${expanded ? ' expanded' : ''}`}>+ <div className={`subagent-node${working ? ' working' : ' done'}`}>+ <NodeResizer isVisible={selected} minWidth={180} minHeight={84} color="#d97757" /><Handle type="target" position={Position.Top} isConnectable={false} />- <div- className="subagent-node__head nodrag"- onClick={() => setExpanded((v) => !v)}- title={expanded ? 'Collapse' : 'Open output'}- style={{ cursor: 'pointer' }}- >+ <div className="subagent-node__head nodrag" onClick={toggle} style={{ cursor: 'pointer' }}><buttonclassName="subagent-node__expand"title={expanded ? 'Collapse' : 'Open output'}onClick={(e) => {e.stopPropagation()- setExpanded((v) => !v)+ toggle()}}>{expanded ? '▾' : '▸'}@@ -74,9 +70,7 @@ export function SubagentNode({ data }: NodeProps<CanvasNode>) {<span className="subagent-node__type">{(data.subagentType as string) || 'subagent'}</span><span className="subagent-node__state">{working ? 'working' : 'done'}</span></div>- {data.title && !expanded && (- <div className="subagent-node__task">{data.title as string}</div>- )}+ {data.title && !expanded && <div className="subagent-node__task">{data.title as string}</div>}{meta && <div className="subagent-node__meta">{meta}</div>}{expanded && (<div className="subagent-node__term nodrag nowheel" ref={bodyRef}>diff --git a/src/renderer/state/agentNodes.ts b/src/renderer/state/agentNodes.tsindex 02633a8da..1c020c7e6 100644--- a/src/renderer/state/agentNodes.ts+++ b/src/renderer/state/agentNodes.ts@@ -34,9 +34,13 @@ export interface SubagentResult {interface AgentNodesState {byId: Record<string, SubagentViz>- /** User-dragged position overrides for ephemeral nodes (subagent ids + `loop-<parentId>`). */+ /** Per-ephemeral-node UI overrides (keyed by node id: subagent ids + `loop-<parentId>`). */positions: Record<string, { x: number; y: number }>+ sizes: Record<string, { width: number; height: number }>+ expanded: Record<string, boolean>setPosition(id: string, pos: { x: number; y: number }): void+ setSize(id: string, size: { width: number; height: number }): void+ toggleExpanded(id: string): voidstart(toolUseId: string, viz: Omit<SubagentViz, 'state' | 'startedAt'>): voidfinish(toolUseId: string, result: SubagentResult): void/** Append a chunk of the subagent's live transcript. */@@ -48,8 +52,12 @@ interface AgentNodesState {export const useAgentNodes = create<AgentNodesState>((set) => ({byId: {},positions: {},+ sizes: {},+ expanded: {},setPosition: (id, pos) => set((s) => ({ positions: { ...s.positions, [id]: pos } })),+ setSize: (id, size) => set((s) => ({ sizes: { ...s.sizes, [id]: size } })),+ toggleExpanded: (id) => set((s) => ({ expanded: { ...s.expanded, [id]: !s.expanded[id] } })),start: (toolUseId, viz) =>set((s) => ({@@ -75,11 +83,16 @@ export const useAgentNodes = create<AgentNodesState>((set) => ({set((s) => {const ids = Object.keys(s.byId).filter((id) => s.byId[id].parentNodeId === parentNodeId)const byId = { ...s.byId }- for (const id of ids) delete byId[id]- // Also drop position overrides for those subagents and the parent's loop node.const positions = { ...s.positions }- for (const id of ids) delete positions[id]- delete positions[`loop-${parentNodeId}`]- return { byId, positions }+ const sizes = { ...s.sizes }+ const expanded = { ...s.expanded }+ const drop = [...ids, `loop-${parentNodeId}`]+ for (const id of ids) delete byId[id]+ for (const id of drop) {+ delete positions[id]+ delete sizes[id]+ delete expanded[id]+ }+ return { byId, positions, sizes, expanded }})}))diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex f3444c3f0..f987cd0bd 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -2552,7 +2552,11 @@ body,/* ---- Subagent (ephemeral, hook-driven) node ---- */.subagent-node {- width: 210px;+ width: 100%;+ height: 100%;+ box-sizing: border-box;+ display: flex;+ flex-direction: column;padding: 10px 12px;background: #1c1c1e;border: 1px solid var(--border);@@ -2561,11 +2565,7 @@ body,box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);font-size: 12px;color: var(--text);-}--/* Expanded = a wider terminal-like view of the subagent's live transcript. */-.subagent-node.expanded {- width: 480px;+ overflow: hidden;}.subagent-node__expand {@@ -2591,11 +2591,12 @@ body,.subagent-node__term {margin-top: 8px;+ flex: 1;+ min-height: 0;padding: 10px;border-radius: 8px;background: #0e0e0e;border: 1px solid var(--border);- max-height: 420px;overflow: auto;font-family: 'SF Mono', Menlo, Monaco, monospace;font-size: 11.5px;@@ -2683,7 +2684,11 @@ body,/* ---- Loop (ephemeral, hook-driven) node ---- */.loop-node {- width: 230px;+ width: 100%;+ height: 100%;+ box-sizing: border-box;+ display: flex;+ flex-direction: column;padding: 10px 12px;background: #1c1c1e;border: 1px solid var(--border);@@ -2692,6 +2697,28 @@ body,box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);font-size: 12px;color: var(--text);+ overflow: hidden;+}++.loop-node__expand {+ width: 16px;+ height: 16px;+ flex: none;+ display: inline-flex;+ align-items: center;+ justify-content: center;+ padding: 0;+ background: transparent;+ border: none;+ border-radius: 4px;+ color: var(--muted);+ font-size: 10px;+ cursor: pointer;+}++.loop-node__expand:hover {+ background: rgba(255, 255, 255, 0.08);+ color: var(--text);}.loop-node__head {@@ -2763,9 +2790,10 @@ body,.loop-node__items {margin-top: 8px;+ flex: 1;+ min-height: 0;padding-top: 8px;border-top: 1px solid var(--border);- max-height: 240px;overflow: auto;font-size: 11.5px;line-height: 1.5;