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.

fix(canvas): undo/redo heal the dep ropes their history step cannot restore

enes9f63113a567f
diff --git a/CLAUDE.md b/CLAUDE.md
index f58d27a64..0c4323eb9 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -928,8 +928,10 @@ session.
- **trigger** (`TriggerNode.tsx`) — a canvas-owned schedule (cron / interval / once) that
delivers a payload into a connected terminal/agent node when due (issue #493 — the inverse of
the ephemeral loop/cron cards, which visualize AGENT-initiated recurrence). The card shows the
- schedule + next-run countdown, the target (a derived, never-persisted edge — same rule as the
- pending-launch dep edges), the payload, an honest ARMED/DISARMED/CHANGED/SET-UP chip with the
+ schedule + next-run countdown, the target (a derived, never-persisted edge — the
+ pending-launch dep edge is NO longer one: since the 2026-09-02 edge model it is a persisted rope,
+ `ctrl-<dep>-<node>`, whose dashed ⏳ LOOK is what is derived), the payload, an honest
+ ARMED/DISARMED/CHANGED/SET-UP chip with the
"definitions travel with the repo, consent never does" narrative, Run-now, and the last runs
(fired / delivered-late / queued / missed / failed / expired). Arming passes a ConfirmDialog
showing the exact schedule+payload+target being consented to; all decisions are the pure,
@@ -2444,6 +2446,9 @@ the Settings section and ShortcutsPanel start disagreeing about what a chord mea
connections") hides its subagent/loop cards AND every edge touching that node — display only:
the links still authorise reads and an `--after` still waits. See the `--after` bullet under
Canvas control for the rope model the eye hides.
+ **Surfaces:** Desktop + Server Edition are identical (pure renderer + React Flow internals — no
+ new IPC or bridge member); the kanban board is N/A (it shows cards, never edges); mobile is N/A
+ (the transport protocol carries no edges).
- **Undo/redo**: debounced snapshot of the nodes array on settle (drag/edit), `pastRef`/
`futureRef` stacks, ⌘Z / ⌘⇧Z + dock buttons. History resets per project load; skipped
while typing in inputs/terminals.
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index b073ebd8e..9c7c99bf0 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -2989,9 +2989,18 @@ export function Canvas() {
committedRef.current = prev
nodesRef.current = prev
setNodes(prev)
+ // Ropes are not in the history stack (they live in `controlEdges`), but the arming a rope
+ // explains IS — `disarmDepsFor` writes both, and only the node write is snapshotted. So a step
+ // that re-arms a node would leave it waiting with no arrow saying what for until the next
+ // project load. Same pair-keyed, idempotent healer the load site uses: a step that re-arms
+ // nothing adds nothing, and a rope the step did not remove is never duplicated.
+ setControlEdges((es) => {
+ const add = missingDepRopes(prev, es)
+ return add.length ? [...es, ...add.map((r) => ropeEdge(r.id, r.source, r.target))] : es
+ })
bumpDirty() // an undo is an edit: it must count toward the in-flight-save generation too
bumpHist((v) => v + 1)
- }, [setNodes, bumpDirty])
+ }, [setNodes, setControlEdges, bumpDirty])
const redo = useCallback(() => {
if (!futureRef.current.length) return
@@ -3000,9 +3009,18 @@ export function Canvas() {
committedRef.current = next
nodesRef.current = next
setNodes(next)
+ // Ropes are not in the history stack (they live in `controlEdges`), but the arming a rope
+ // explains IS — `disarmDepsFor` writes both, and only the node write is snapshotted. So a step
+ // that re-arms a node would leave it waiting with no arrow saying what for until the next
+ // project load. Same pair-keyed, idempotent healer the load site uses: a step that re-arms
+ // nothing adds nothing, and a rope the step did not remove is never duplicated.
+ setControlEdges((es) => {
+ const add = missingDepRopes(next, es)
+ return add.length ? [...es, ...add.map((r) => ropeEdge(r.id, r.source, r.target))] : es
+ })
bumpDirty() // a redo is an edit: same reasoning as undo
bumpHist((v) => v + 1)
- }, [setNodes, bumpDirty])
+ }, [setNodes, setControlEdges, bumpDirty])
// ---- canvas interactions ----
diff --git a/src/renderer/canvas/edge-model.source.test.ts b/src/renderer/canvas/edge-model.source.test.ts
index 8e271b6b3..e75cdd4c4 100644
--- a/src/renderer/canvas/edge-model.source.test.ts
+++ b/src/renderer/canvas/edge-model.source.test.ts
@@ -53,4 +53,31 @@ describe('canvas edge model (source pins)', () => {
it('an armed node with no dep rope heals at project load, not only where --after ran', () => {
expect(src).toContain('missingDepRopes(')
})
+
+ it('undo and redo heal the dep ropes their own history step cannot restore', () => {
+ // Deleting a waiting rope writes BOTH the node (disarmDepsFor — snapshotted into the undo
+ // stack) and the control edges (not snapshotted). So a ⌘Z that re-arms a node would otherwise
+ // leave it waiting with no arrow saying what for until the next project load. Same pair-keyed,
+ // idempotent healer the load site uses: a history step that changes nothing adds nothing.
+ expect((src.match(/missingDepRopes\(/g) ?? []).length).toBe(3) // project load + undo + redo
+ const undoBody = src.slice(src.indexOf('const undo = useCallback'), src.indexOf('const redo = useCallback'))
+ const redoBody = src.slice(src.indexOf('const redo = useCallback'), src.indexOf('// ---- canvas interactions ----'))
+ expect(undoBody).toContain('missingDepRopes(prev, es)')
+ expect(redoBody).toContain('missingDepRopes(next, es)')
+ })
+
+ it('the composed edge labels are pinned — the sentence the user reads names what ⌫ does', () => {
+ expect(src).toContain('`${WAIT_LABEL} · ⌫ to stop waiting`')
+ expect(src).toContain("'⇄ context · ⌫ to remove'")
+ expect(src).toContain("'⌫ to remove'")
+ })
+
+ it("verify's panel arms through the same dep ropes, and --after dedupes its ids", () => {
+ // The two ruled deviations from `ropeDeps(ids, after)`: the reviewers wait on the target and
+ // the judge waits on the reviewers, both ids that exist only in that tick.
+ expect(src).toContain('ropeDeps([rid], [targetId])')
+ expect(src).toContain('ropeDeps([judge.id], reviewerIds)')
+ // `--after a,a` is one wait: two dep ropes for one pair would collide on one rope id.
+ expect(src).toContain("[...new Set((args.after ?? '').split(',').map((s) => s.trim()).filter(Boolean))]")
+ })
})
diff --git a/src/renderer/lib/edgeModel.test.ts b/src/renderer/lib/edgeModel.test.ts
index 9f0c185d4..af4917cbf 100644
--- a/src/renderer/lib/edgeModel.test.ts
+++ b/src/renderer/lib/edgeModel.test.ts
@@ -7,6 +7,7 @@ import {
missingDepRopes,
ropeInfoOf,
ropeVisual,
+ WAIT_LABEL,
type RopeNodeInfo
} from './edgeModel'
@@ -15,6 +16,15 @@ const infoOf =
(id: string): RopeNodeInfo | undefined =>
m[id]
+describe('WAIT_LABEL', () => {
+ it('is the one wording the waiting rope and its selected removal hint are both composed from', () => {
+ // Canvas renders it bare while the rope is idle and as `${WAIT_LABEL} · ⌫ to stop waiting`
+ // while it is selected, so the two sentences cannot drift apart (pinned in
+ // canvas/edge-model.source.test.ts).
+ expect(WAIT_LABEL).toBe('⏳ waits for')
+ })
+})
+
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'] } }))