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(canvas): pure edge model — rope look from pendingLaunch, drop-dep, eye hiding

enes861abaa679e5
diff --git a/src/renderer/lib/edgeModel.test.ts b/src/renderer/lib/edgeModel.test.ts
new file mode 100644
index 000000000..f9126aaf3
--- /dev/null
+++ b/src/renderer/lib/edgeModel.test.ts
@@ -0,0 +1,76 @@
+import { describe, it, expect } from 'vitest'
+import {
+ ROPE_NEUTRAL,
+ dropAfterDep,
+ edgeHidden,
+ hiddenEdgeNodeIds,
+ ropeVisual,
+ type RopeNodeInfo
+} from './edgeModel'
+
+const infoOf =
+ (m: Record<string, RopeNodeInfo>) =>
+ (id: string): RopeNodeInfo | undefined =>
+ m[id]
+
+describe('ropeVisual — one rope, its look derived from the target\'s pendingLaunch', () => {
+ it('a rope whose target is still waiting on its source is WAITING', () => {
+ const v = ropeVisual({ source: 'y', target: 'n' }, infoOf({ y: { agentColor: '#d97757' }, n: { pendingAfter: ['y'] } }))
+ expect(v).toEqual({ waiting: true, color: '#d97757' })
+ })
+
+ it('the same rope is solid once the target no longer lists the source (launched, or disarmed)', () => {
+ expect(ropeVisual({ source: 'y', target: 'n' }, infoOf({ y: { agentColor: '#d97757' }, n: { pendingAfter: [] } })).waiting).toBe(false)
+ expect(ropeVisual({ source: 'y', target: 'n' }, infoOf({ y: { agentColor: '#d97757' }, n: {} })).waiting).toBe(false)
+ })
+
+ it('an opener rope is never "waiting" just because the target waits on SOMEONE ELSE', () => {
+ expect(ropeVisual({ source: 'x', target: 'n' }, infoOf({ x: { agentColor: '#10a37f' }, n: { pendingAfter: ['y'] } })).waiting).toBe(false)
+ })
+
+ it('takes the SOURCE\'s agent colour; a source with no agent (browser popup) is neutral grey', () => {
+ expect(ropeVisual({ source: 'x', target: 'n' }, infoOf({ x: { agentColor: '#10a37f' }, n: {} })).color).toBe('#10a37f')
+ expect(ropeVisual({ source: 'b', target: 'n' }, infoOf({ b: {}, n: {} })).color).toBe(ROPE_NEUTRAL)
+ expect(ropeVisual({ source: 'gone', target: 'n' }, infoOf({ n: {} })).color).toBe(ROPE_NEUTRAL)
+ })
+})
+
+describe('dropAfterDep — deleting a waiting rope means "stop waiting on that one"', () => {
+ it('removes exactly that dep and keeps the command', () => {
+ const p = { after: ['a', 'b'], command: 'claude "x"' }
+ expect(dropAfterDep(p, 'a')).toEqual({ after: ['b'], command: 'claude "x"' })
+ })
+
+ it('returns the SAME object when the dep is not listed (no spurious re-render)', () => {
+ const p = { after: ['a'], command: 'c' }
+ expect(dropAfterDep(p, 'zzz')).toBe(p)
+ })
+
+ it('leaves an empty list rather than disarming — launchesToFire fires a vacuous wait', () => {
+ expect(dropAfterDep({ after: ['a'], command: 'c' }, 'a')).toEqual({ after: [], command: 'c' })
+ })
+
+ it('keeps awaitSetupGroup', () => {
+ expect(dropAfterDep({ after: ['a'], command: 'c', awaitSetupGroup: 'g1' }, 'a')).toEqual({ after: [], command: 'c', awaitSetupGroup: 'g1' })
+ })
+})
+
+describe('hiddenEdgeNodeIds / edgeHidden — the eye hides every edge touching the node', () => {
+ const nodes = [
+ { id: 'a', data: { hideFanout: true } },
+ { id: 'b', data: {} },
+ { id: 'c', data: { hideFanout: false } }
+ ]
+ it('collects only nodes whose eye is closed', () => {
+ expect([...hiddenEdgeNodeIds(nodes)]).toEqual(['a'])
+ })
+ it('hides an edge on EITHER end, in either direction', () => {
+ const hidden = hiddenEdgeNodeIds(nodes)
+ expect(edgeHidden({ source: 'a', target: 'b' }, hidden)).toBe(true)
+ expect(edgeHidden({ source: 'b', target: 'a' }, hidden)).toBe(true)
+ expect(edgeHidden({ source: 'b', target: 'c' }, hidden)).toBe(false)
+ })
+ it('an empty set hides nothing', () => {
+ expect(edgeHidden({ source: 'a', target: 'b' }, new Set())).toBe(false)
+ })
+})
diff --git a/src/renderer/lib/edgeModel.ts b/src/renderer/lib/edgeModel.ts
new file mode 100644
index 000000000..4103c57e1
--- /dev/null
+++ b/src/renderer/lib/edgeModel.ts
@@ -0,0 +1,57 @@
+// Pure decisions behind the canvas edge model (spec: docs/superpowers/specs/2026-09-02-canvas-edge-
+// model-design.md). A ROPE is the one visible relation between two nodes — "opened by" and
+// "sequenced after (--after)" — and its LOOK is derived from the target's pendingLaunch, never
+// stored: dashed while the target still waits on the rope's source, solid otherwise. Kept free of
+// React/store imports so Canvas.tsx only wraps these in a memo.
+import type { PendingLaunch } from '@shared/types'
+
+/** Rope colour for a source with no agent (a browser popup, a plain terminal that opened nothing). */
+export const ROPE_NEUTRAL = '#8e8e93'
+/** The waiting rope's label. Canvas appends the removal hint when the rope is selected. */
+export const WAIT_LABEL = '⏳ waits for'
+
+export interface RopeNodeInfo {
+ /** The node's agent colour (AGENT_CONFIG), if it runs an agent. */
+ agentColor?: string
+ /** The node's `pendingLaunch.after`, if it is armed. */
+ pendingAfter?: readonly string[]
+}
+
+export interface RopeVisual {
+ /** The target is armed and still lists this rope's source among its deps. */
+ waiting: boolean
+ color: string
+}
+
+export function ropeVisual(
+ rope: { source: string; target: string },
+ info: (id: string) => RopeNodeInfo | undefined
+): RopeVisual {
+ const waiting = !!info(rope.target)?.pendingAfter?.includes(rope.source)
+ const color = info(rope.source)?.agentColor ?? ROPE_NEUTRAL
+ return { waiting, color }
+}
+
+/**
+ * Deleting a WAITING rope is the user saying "do not wait on that one": drop the dep from the
+ * target's list and keep everything else. Returns the same object when nothing changes so a caller
+ * can skip the state write. An emptied list is left in place — `launchesToFire` treats `[]` as
+ * satisfied and fires the held command, which is exactly what removing the last wait should do.
+ */
+export function dropAfterDep(p: PendingLaunch, depId: string): PendingLaunch {
+ if (!p.after.includes(depId)) return p
+ return { ...p, after: p.after.filter((d) => d !== depId) }
+}
+
+/** Nodes whose eye is closed (`hideFanout`): every edge touching them is hidden from the canvas. */
+export function hiddenEdgeNodeIds(
+ nodes: readonly { id: string; data: { hideFanout?: boolean } }[]
+): Set<string> {
+ const out = new Set<string>()
+ for (const n of nodes) if (n.data.hideFanout) out.add(n.id)
+ return out
+}
+
+export function edgeHidden(e: { source: string; target: string }, hidden: ReadonlySet<string>): boolean {
+ return hidden.size > 0 && (hidden.has(e.source) || hidden.has(e.target))
+}