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.

Merge origin/main (reopen-last-closed) into feat/breadcrumb-trail — union of the appended wiring-pin suites

enes79a23ecaaa91
diff --cc src/renderer/canvas/Canvas.tsx
index 906a0e48e,760189ad9..4ca86b00c
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@@ -5977,10 -5950,9 +6069,11 @@@ export function Canvas()
'panel.explorer': () => { showExplorer('toggle'); return true },
'panel.sourceControl': () => { setScOpen((v) => !v); return true },
'panel.sessions': () => { toggleSessionsPin(); return true },
+ 'app.reopenLastClosed': reopenLastClosedCommand,
'canvas.undo': () => { undo(); return true },
'canvas.redo': () => { redo(); return true },
+ 'canvas.goBack': () => { goBack(); return true },
+ 'canvas.goForward': () => { goForward(); return true },
'canvas.fitAll': () => { fitAll(); return true },
'canvas.tidy': () => { arrangeAllNodes(); return true },
'canvas.deleteSelection': deleteSelectionCommand,
diff --cc src/renderer/canvas/canvas-wiring.test.tsx
index b6f4f2fe4,4ebbb9bb6..4c4104ded
--- a/src/renderer/canvas/canvas-wiring.test.tsx
+++ b/src/renderer/canvas/canvas-wiring.test.tsx
@@@ -127,38 -127,53 +127,89 @@@ describe('the end-session confirm descr
})
})
+describe('breadcrumb wiring the CLAUDE.md bullet calls load-bearing', () => {
+ // Same discipline as the dispatch-map pins above: Canvas has no render harness, and each of
+ // these rules failed silently once (or would) — a source read is the only net.
+
+ it('goToNode refuses to record the ephemeral subagent/loop viz nodes', () => {
+ // A breadcrumb for one is an id nothing can ever resolve (they are cleared on the next turn),
+ // permanently burning one of the 20 slots.
+ expect(CANVAS_SRC).toContain("node.type !== 'subagent' && node.type !== 'loop'")
+ })
+
+ it('stepAndFrame never records — it frames through the shared frameNode, not goToNode', () => {
+ const step = CANVAS_SRC.slice(
+ CANVAS_SRC.indexOf('const stepAndFrame = useCallback'),
+ CANVAS_SRC.indexOf('const goBack = useCallback')
+ )
+ expect(step.length).toBeGreaterThan(0)
+ // Recording inside a step would turn every back-step into a new tip.
+ expect(step).not.toContain('recordBreadcrumb')
+ expect(step).not.toContain('goToNode(')
+ // The single framing implementation — the "Go to node" origin-jump invariant has ONE copy.
+ expect(step).toContain('frameNode(target)')
+ })
+
+ it('there is exactly ONE framing implementation (frameNode) shared by focus and steps', () => {
+ // The measured-check-reads-the-store rule regresses through a second copy first.
+ expect(CANVAS_SRC.match(/isMeasured\(internal\)/g) ?? []).toHaveLength(1)
+ })
+
+ it('the resume card slot is spent only on a card that can render', () => {
+ // Once per app run, only with a live stop, and never under the opaque kanban overlay.
+ expect(CANVAS_SRC).toContain(
+ '!resumeCardShown.has(project.id) && hasLiveStop && !isKanbanOpen(project.id)'
+ )
+ })
+})
++
+ describe('reopen-last-closed records and dispatches through the shared history stack', () => {
+ it('records a project close before hiding it', () => {
+ expect(CANVAS_SRC).toContain('useReopenHistory.getState().push({ kind: \'project\'')
+ })
+
+ it('records a node-delete batch, opting the account-removal cleanup out', () => {
+ expect(CANVAS_SRC).toContain("kind: 'nodes'")
+ expect(CANVAS_SRC).toContain('deleteNodes(loginIds, { record: false })')
+ })
+
+ it('registers the command in the dispatch map', () => {
+ expect(CANVAS_SRC).toContain("'app.reopenLastClosed': reopenLastClosedCommand")
+ })
+
+ it('never live-inserts into a non-active project — routes through applyNodeMutation instead', () => {
+ // The bug this pins: a synchronous setNodes() right after switchProject()/reopenProject()
+ // races the active-project load effect and silently loses the recreated nodes.
+ expect(CANVAS_SRC).toContain('.applyNodeMutation(plan.projectId, {')
+ })
+
+ it('arms a cold-open command before writing a restored node into a non-active project', () => {
+ // The bug this pins: flowToNodeStates alone drops initialCommand, so an agent node restored
+ // into a project that isn't on screen would never launch its command on the eventual cold
+ // open — armForColdOpen is what carries it through serialization.
+ expect(CANVAS_SRC).toContain('node: flowToNodeStates([armForColdOpen(node)])[0]')
+ })
+
+ it('commits the live canvas to the store before every reopenProject call — never a bare switch', () => {
+ // The bug this pins: useProjects.getState().reopenProject(...) is a project SWITCH, and every
+ // switch/add/delete elsewhere in this file calls commitActiveToStore() first so the live
+ // canvas isn't silently lost. Both reopen-a-project call sites inside reopenLastClosedCommand
+ // must do the same, rather than referencing the later `reopenProject` wrapper (a TDZ hazard
+ // from this callback's declaration point).
+ const calls = CANVAS_SRC.match(/useProjects\.getState\(\)\.reopenProject\(/g) ?? []
+ const guarded = CANVAS_SRC.match(/commitActiveToStore\(\)\n\s+useProjects\.getState\(\)\.reopenProject\(/g) ?? []
+ expect(calls.length).toBeGreaterThanOrEqual(2)
+ expect(guarded.length).toBe(calls.length)
+ })
+
+ it('resolves permission mode against the TARGET project being restored into, not the caller\'s active one', () => {
+ expect(CANVAS_SRC).toContain('permissionModeFor: (agentId) => projectPermissionMode(project, agentId)')
+ })
+
+ it('extracts the reopen decision into the pure, tested planReopen', () => {
+ expect(CANVAS_SRC).toContain('const plan = planReopen(')
+ expect(CANVAS_SRC).toContain("case 'insertActive':")
+ expect(CANVAS_SRC).toContain("case 'insertStored':")
+ expect(CANVAS_SRC).toContain("case 'reopenProject':")
+ })
+ })
diff --cc src/shared/keybindings.ts
index 6607ed97c,3922cca86..ad609d7f0
--- a/src/shared/keybindings.ts
+++ b/src/shared/keybindings.ts
@@@ -47,10 -47,9 +47,11 @@@ export type CommandId
| 'panel.explorer'
| 'panel.sourceControl'
| 'panel.sessions'
+ | 'app.reopenLastClosed'
| 'canvas.undo'
| 'canvas.redo'
+ | 'canvas.goBack'
+ | 'canvas.goForward'
| 'canvas.deleteSelection'
| 'canvas.fitAll'
| 'canvas.tidy'