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 draggable
enes81fd3ade1aae
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 99be243b2..063ca32b5 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -133,6 +133,7 @@ export function Canvas() {// Ephemeral subagent nodes + edges (driven by Claude hooks; never persisted / no undo).// Laid out fanning below the parent Claude node.const agentById = useAgentNodes((s) => s.byId)+ const ephemeralPos = useAgentNodes((s) => s.positions)const claudeById = useClaudeStatus((s) => s.byId)const { ephemeralNodes, ephemeralEdges } = useMemo(() => {const eNodes: CanvasNode[] = []@@ -147,9 +148,8 @@ export function Canvas() {eNodes.push({id: lid,type: 'loop',- position: { x: parent.position.x - 250, y: parent.position.y + ph + 60 },- draggable: false,- selectable: false,+ position: ephemeralPos[lid] ?? { x: parent.position.x - 250, y: parent.position.y + ph + 60 },+ draggable: true,data: {title: st.loop.prompt ?? '',color: '#bf7af0',@@ -183,12 +183,11 @@ export function Canvas() {eNodes.push({id: cid,type: 'subagent',- position: {+ position: ephemeralPos[cid] ?? {x: parent.position.x + (i % COLS) * COL_W,y: parent.position.y + ph + 60 + Math.floor(i / COLS) * ROW_H},- draggable: false,- selectable: false,+ draggable: true,data: {title: v.label ?? '',color: '#d97757',@@ -213,7 +212,7 @@ export function Canvas() {})}return { ephemeralNodes: eNodes, ephemeralEdges: eEdges }- }, [agentById, claudeById, nodes])+ }, [agentById, claudeById, ephemeralPos, nodes])// 1) Load the whole workspace once and hydrate the projects store.useEffect(() => {@@ -360,13 +359,19 @@ export function Canvas() {// ---- canvas interactions ----const handleNodesChange: typeof onNodesChange = useCallback((changes) => {- // Drop changes targeting ephemeral subagent nodes (they live outside the managed state).+ // Ephemeral nodes (subagent / loop) live outside the managed state. Persist their drag+ // positions to the agent-nodes store; drop their other changes from the managed updater.const eph = useAgentNodes.getState().byId- const filtered = changes.filter(- (c) => !('id' in c && (c.id in eph || c.id.startsWith('loop-')))- )- onNodesChange(filtered)- if (filtered.some((c) => c.type !== 'select')) markDirty()+ const isEph = (id: string) => id in eph || id.startsWith('loop-')+ const managed = changes.filter((c) => {+ if ('id' in c && isEph(c.id)) {+ if (c.type === 'position' && c.position) useAgentNodes.getState().setPosition(c.id, c.position)+ return false+ }+ return true+ })+ onNodesChange(managed)+ if (managed.some((c) => c.type !== 'select')) markDirty()},[onNodesChange, markDirty])diff --git a/src/renderer/state/agentNodes.ts b/src/renderer/state/agentNodes.tsindex 4fb8eb0f3..02633a8da 100644--- a/src/renderer/state/agentNodes.ts+++ b/src/renderer/state/agentNodes.ts@@ -34,6 +34,9 @@ export interface SubagentResult {interface AgentNodesState {byId: Record<string, SubagentViz>+ /** User-dragged position overrides for ephemeral nodes (subagent ids + `loop-<parentId>`). */+ positions: Record<string, { x: number; y: number }>+ setPosition(id: string, pos: { x: number; y: number }): voidstart(toolUseId: string, viz: Omit<SubagentViz, 'state' | 'startedAt'>): voidfinish(toolUseId: string, result: SubagentResult): void/** Append a chunk of the subagent's live transcript. */@@ -44,6 +47,9 @@ interface AgentNodesState {export const useAgentNodes = create<AgentNodesState>((set) => ({byId: {},+ positions: {},++ setPosition: (id, pos) => set((s) => ({ positions: { ...s.positions, [id]: pos } })),start: (toolUseId, viz) =>set((s) => ({@@ -68,9 +74,12 @@ export const useAgentNodes = create<AgentNodesState>((set) => ({clearForParent: (parentNodeId) =>set((s) => {const ids = Object.keys(s.byId).filter((id) => s.byId[id].parentNodeId === parentNodeId)- if (!ids.length) return sconst byId = { ...s.byId }for (const id of ids) delete byId[id]- return { byId }+ // 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 }})}))