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): tidy placement for orchestration
enes715daac54706
diff --git a/src/main/canvas-control-core.ts b/src/main/canvas-control-core.tsindex a2dbecac8..408027cc2 100644--- a/src/main/canvas-control-core.ts+++ b/src/main/canvas-control-core.ts@@ -145,7 +145,9 @@ export function buildCanvasControlInstructions(shimPath: string): string {'Orchestration ("Build with Nodeterm orchestration"): break the task into 2-5 independent','workstreams; per stream `open-worktree --branch <slug>` then `open-agent --agent claude','--group <groupId> --prompt "<concrete task>"` (each stream on its own branch, no tree',- 'conflicts); `rename`/`arrange` the groups; the user merges when a stream is done, and',+ 'conflicts). Members land in grid slots inside the frame automatically; align the frames',+ 'themselves with `arrange --nodes <groupId,…> --layout row` (pass GROUP ids — arrange/align',+ 'are top-level only) and `rename` each by subject. The user merges when a stream is done;','`close-worktree --group <id>` releases a finished station.'].join('\n')}diff --git a/src/main/canvas-control.ts b/src/main/canvas-control.tsindex 86718cb4f..450422bc6 100644--- a/src/main/canvas-control.ts+++ b/src/main/canvas-control.ts@@ -114,8 +114,11 @@ across Nodeterm sessions), be the orchestration chef — plan the kitchen, then\`open-worktree --branch <slug>\` → note the returned \`groupId\`, then\`open-agent --agent claude --group <groupId> --prompt "<concrete, self-contained task>"\`.Each stream now works on its own branch in its own worktree group — no tree conflicts.-3. \`rename\` each group by subject and \`arrange\` its members; open extra sessions into the- same group with \`--group\` as a stream grows.+3. Keep the kitchen tidy: members opened with \`--group\` land in neat grid slots inside the+ frame automatically (the frame grows to fit), and successive \`open-worktree\` frames fan+ out side by side — after opening all stations, align the frames with+ \`arrange --nodes <groupId,groupId,…> --layout row\` (arrange/align work on top-level+ nodes, so pass the GROUP ids, not the children). \`rename\` each group by subject.4. Track progress (their status badges show working/waiting) and coordinate: when a streamfinishes, the user merges from the group's chip (never merge for them); release a finishedstation with \`close-worktree --group <id>\` (unbind keeps the directory).diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex b5816ff94..1a9b968e9 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -2577,7 +2577,10 @@ export function Canvas() {// carries no cwd of its own — the worktree's path is what its children inherit// (`cwdForNewNodeIn`), so the frame IS the binding.const attachWorktree = useCallback(- (target: { groupId: string | null; at?: { x: number; y: number } }, wt: GroupWorktree): string => {+ (+ target: { groupId: string | null; at?: { x: number; y: number }; size?: { width: number; height: number } },+ wt: GroupWorktree+ ): string => {let groupId = target.groupIdif (groupId) {setNodes((ns) =>@@ -3831,12 +3834,32 @@ export function Canvas() {// (parentInto converts back to group-relative coords), so the control fan-out stays inside// the frame and moves with it.const addAndConnect = (node: CanvasNode) => {- const placed = src.parentId ? parentInto(node, src.parentId) : node+ // A node that arrives ALREADY parented (open-agent --group placed it into a frame with+ // relative coords) must pass through untouched — re-running parentInto would read its+ // relative position as absolute and land it off-frame.+ const placed = node.parentId ? node : src.parentId ? parentInto(node, src.parentId) : nodesetNodes((ns) => [...ns, placed])connect(placed.id)markDirty()return placed.id}+ // Grid slots INSIDE a group frame (open-agent --group): 2 columns of terminal-sized+ // cells under the header. Pure geometry — the frame is grown to fit before children land.+ const GROUP_PAD_X = 24+ const GROUP_PAD_TOP = 56+ const GROUP_GAP = 24+ const groupSlot = (slot: number, w: number, h: number) => ({+ x: GROUP_PAD_X + (slot % 2) * (w + GROUP_GAP),+ y: GROUP_PAD_TOP + Math.floor(slot / 2) * (h + GROUP_GAP)+ })+ const groupSizeFor = (children: number, w: number, h: number) => {+ const cols = Math.min(2, Math.max(1, children))+ const rows = Math.max(1, Math.ceil(children / 2))+ return {+ width: GROUP_PAD_X * 2 + cols * w + (cols - 1) * GROUP_GAP,+ height: GROUP_PAD_TOP + rows * h + (rows - 1) * GROUP_GAP + GROUP_PAD_X+ }+ }try {switch (verb) {@@ -3889,6 +3912,11 @@ export function Canvas() {projStore.getProject(projStore.activeProjectId ?? ''),useSettings.getState().settings.claudeAccounts)+ // Members land in tidy 2-column grid slots inside the frame (after existing+ // children), and the frame is grown FIRST so extent:'parent' cannot clamp them.+ const existingChildren = intoGroupId+ ? nodesRef.current.filter((nd) => nd.parentId === intoGroupId).length+ : 0const ids: string[] = []for (let i = 0; i < count; i++) {const node = createAgentNode(@@ -3901,7 +3929,33 @@ export function Canvas() {account,activePermissionMode())- ids.push(addAndConnect(intoGroupId ? parentInto(node, intoGroupId) : node))+ if (intoGroupId) {+ const w = (node.width as number) ?? 600+ const h = (node.height as number) ?? 400+ if (i === 0) {+ const need = groupSizeFor(existingChildren + count, w, h)+ setNodes((ns) =>+ ns.map((nd) =>+ nd.id === intoGroupId+ ? {+ ...nd,+ width: Math.max((nd.width as number) ?? 0, need.width),+ height: Math.max((nd.height as number) ?? 0, need.height),+ style: {+ ...nd.style,+ width: Math.max((nd.width as number) ?? 0, need.width),+ height: Math.max((nd.height as number) ?? 0, need.height)+ }+ }+ : nd+ )+ )+ }+ node.position = groupSlot(existingChildren + i, w, h)+ node.parentId = intoGroupId+ node.extent = 'parent'+ }+ ids.push(addAndConnect(node))}reply({ok: true,@@ -4125,8 +4179,17 @@ export function Canvas() {reply({ ok: false, error: `open-worktree: ${res.message}` })return}+ // Fan successive frames out horizontally (frame width + gap) so several+ // open-worktree calls in one orchestration land side by side, not stacked.+ const groupFan = nodesRef.current.filter(+ (nd) => nd.type === 'group' && !nd.parentId+ ).length+ const frameAt = {+ x: placeBelow(0).x + groupFan * (WORKTREE_GROUP_SIZE.width + 60),+ y: placeBelow(0).y+ }const groupId = worktreeControlRef.current.attachWorktree(- { groupId: bindGroupId, at: placeBelow() },+ { groupId: bindGroupId, at: frameAt },worktreeFromCreate({ repoPath: repoRoot, mode: 'new', branch, baseRef, path: wtPath }))reply({