Skip to content

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.

feat(control): open agent nodes below source + visible connecting rope

enesed4dd832e925
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 1ac1fdc78..4fc483ea9 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -1999,11 +1999,27 @@ export function Canvas() {
}
const srcTitle = (src.data.title as string) || sourceNodeId
const srcCwd = src.data.cwd as string | undefined
- const center = { x: src.position.x + 360, y: src.position.y }
+ // Place opened nodes BELOW the source and rope them to it (source flow-out → target
+ // flow-in), mirroring how subagent/loop nodes attach — so they read as "hanging off" the
+ // conversation instead of landing on top of unrelated nodes. `placeBelow` returns a node
+ // centerpoint; `i` fans multiple nodes out horizontally so they don't stack.
+ const srcW = src.measured?.width ?? (src.width as number) ?? 600
+ const srcH = src.measured?.height ?? (src.height as number) ?? 400
+ const belowY = src.position.y + srcH + 80
+ const edgeColor = agentConfig((src.data.agentId as string) ?? 'claude')?.color ?? '#d97757'
+ const placeBelow = (i = 0) => ({ x: src.position.x + srcW / 2 + i * 460, y: belowY + 210 })
const connect = (newId: string) =>
setControlEdges((es) => [
...es,
- { id: `ctrl-${sourceNodeId}-${newId}`, source: sourceNodeId, target: newId, type: 'default' }
+ {
+ id: `ctrl-${sourceNodeId}-${newId}`,
+ source: sourceNodeId,
+ sourceHandle: 'flow-out',
+ target: newId,
+ targetHandle: 'flow-in',
+ style: { stroke: edgeColor, strokeWidth: 1.5 },
+ markerEnd: { type: MarkerType.ArrowClosed, color: edgeColor, width: 14, height: 14 }
+ }
])
// Append a freshly-created node, draw its connecting edge, and mark the canvas dirty so it
// persists. Returns the new node id.
@@ -2031,7 +2047,7 @@ export function Canvas() {
}
case 'open-terminal': {
const id = addAndConnect(
- createTerminalNode(nodesRef.current.length, args.cwd || srcCwd, center, args.cmd)
+ createTerminalNode(nodesRef.current.length, args.cwd || srcCwd, placeBelow(), args.cmd)
)
reply({ ok: true, message: `opened terminal ${id}`, result: { id } })
return
@@ -2046,7 +2062,7 @@ export function Canvas() {
'claude',
nodesRef.current.length + i,
args.cwd || srcCwd,
- { x: center.x, y: center.y + i * 80 },
+ placeBelow(i),
args.prompt
)
)
@@ -2066,7 +2082,7 @@ export function Canvas() {
}
// EditorNode renders images via fs:read-binary → base64 data URL (not nt-media://),
// so no media allowlist entry is needed here.
- const id = addAndConnect(createEditorNode(nodesRef.current.length, args.path, center))
+ const id = addAndConnect(createEditorNode(nodesRef.current.length, args.path, placeBelow()))
reply({ ok: true, message: `showing image ${id}`, result: { id } })
return
}
@@ -2076,7 +2092,7 @@ export function Canvas() {
return
}
await window.nodeTerminal.media.allow(args.path)
- const id = addAndConnect(createVideoNode(nodesRef.current.length, args.path, center))
+ const id = addAndConnect(createVideoNode(nodesRef.current.length, args.path, placeBelow()))
reply({ ok: true, message: `showing video ${id}`, result: { id } })
return
}
@@ -2094,7 +2110,7 @@ export function Canvas() {
}
// For an agent-provided --file (not html we just wrote), allowlist it first.
if (webSrc.filePath && args.file) await window.nodeTerminal.media.allow(webSrc.filePath)
- const id = addAndConnect(createWebNode(nodesRef.current.length, webSrc, center))
+ const id = addAndConnect(createWebNode(nodesRef.current.length, webSrc, placeBelow()))
reply({ ok: true, message: `showing web ${id}`, result: { id } })
return
}
diff --git a/src/renderer/nodes/EditorNode.tsx b/src/renderer/nodes/EditorNode.tsx
index 91a6efcac..d910c076c 100644
--- a/src/renderer/nodes/EditorNode.tsx
+++ b/src/renderer/nodes/EditorNode.tsx
@@ -1,5 +1,5 @@
import { useEffect, useRef, useState } from 'react'
-import { NodeResizer, useReactFlow, type NodeProps } from '@xyflow/react'
+import { Handle, NodeResizer, Position, useReactFlow, type NodeProps } from '@xyflow/react'
import { monaco } from '../editor/monaco-setup'
import { renderMarkdown } from '../lib/markdown'
import { useSettings } from '../state/settings'
@@ -155,6 +155,14 @@ export function EditorNode({ id, data, selected }: NodeProps<CanvasNode>) {
onMouseLeave={() => (hoveredRef.current = false)}
>
<NodeResizer minWidth={320} minHeight={200} isVisible={selected} color={data.color} />
+ {/* Invisible target handle so a rope from an agent node that opened this can attach. */}
+ <Handle
+ id="flow-in"
+ type="target"
+ position={Position.Top}
+ isConnectable={false}
+ style={{ opacity: 0, pointerEvents: 'none', top: 0 }}
+ />
<div className="term-node__header">
<span className="term-node__title-text" title={filePath}>
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index 145d94271..5f4523b67 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -686,6 +686,14 @@ export function TerminalNode({ id, data, selected, parentId }: NodeProps<CanvasN
isConnectable={false}
style={{ opacity: 0, pointerEvents: 'none', bottom: 0 }}
/>
+ {/* Invisible target handle so a rope from an agent node that opened this can attach. */}
+ <Handle
+ id="flow-in"
+ type="target"
+ position={Position.Top}
+ isConnectable={false}
+ style={{ opacity: 0, pointerEvents: 'none', top: 0 }}
+ />
{/* Context-link handles (context-link-capable nodes only): drag right→left to link two
sessions. Vertically centered on the side edges; raised above the body so they're never buried. */}
{showLink && (
diff --git a/src/renderer/nodes/VideoNode.tsx b/src/renderer/nodes/VideoNode.tsx
index 0843fe788..8a2efb333 100644
--- a/src/renderer/nodes/VideoNode.tsx
+++ b/src/renderer/nodes/VideoNode.tsx
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react'
-import { NodeResizer, useReactFlow, type NodeProps } from '@xyflow/react'
+import { Handle, NodeResizer, Position, useReactFlow, type NodeProps } from '@xyflow/react'
import type { CanvasNode } from '../state/workspace'
/**
@@ -37,6 +37,14 @@ export default function VideoNode({ id, data, selected }: NodeProps<CanvasNode>)
style={{ borderTopColor: data.color }}
>
<NodeResizer minWidth={320} minHeight={200} isVisible={selected} color={data.color} />
+ {/* Invisible target handle so a rope from the agent node that opened this can attach. */}
+ <Handle
+ id="flow-in"
+ type="target"
+ position={Position.Top}
+ isConnectable={false}
+ style={{ opacity: 0, pointerEvents: 'none', top: 0 }}
+ />
<div className="term-node__header">
<span className="term-node__title-text" title={filePath}>
diff --git a/src/renderer/nodes/WebNode.tsx b/src/renderer/nodes/WebNode.tsx
index b56adc07a..a19e08a05 100644
--- a/src/renderer/nodes/WebNode.tsx
+++ b/src/renderer/nodes/WebNode.tsx
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react'
-import { NodeResizer, useReactFlow, type NodeProps } from '@xyflow/react'
+import { Handle, NodeResizer, Position, useReactFlow, type NodeProps } from '@xyflow/react'
import type { CanvasNode } from '../state/workspace'
import { httpUrl } from './webUrl'
@@ -47,6 +47,14 @@ export default function WebNode({ id, data, selected }: NodeProps<CanvasNode>) {
style={{ borderTopColor: data.color }}
>
<NodeResizer minWidth={320} minHeight={200} isVisible={selected} color={data.color} />
+ {/* Invisible target handle so a rope from the agent node that opened this can attach. */}
+ <Handle
+ id="flow-in"
+ type="target"
+ position={Position.Top}
+ isConnectable={false}
+ style={{ opacity: 0, pointerEvents: 'none', top: 0 }}
+ />
<div className="term-node__header">
<span className="term-node__title-text" title={url || filePath}>