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): let a deleted file-manager node actually reopen

albaneselorenzo61b43fef033b
diff --git a/src/renderer/lib/reopenNode.test.ts b/src/renderer/lib/reopenNode.test.ts
index 48d62c698..a9238eb52 100644
--- a/src/renderer/lib/reopenNode.test.ts
+++ b/src/renderer/lib/reopenNode.test.ts
@@ -124,4 +124,56 @@ describe('recreateNodeFromSnapshot', () => {
)
expect(node!.data.highScore).toBe(42)
})
+
+ // A kind in neither UNRESTORABLE nor buildBase's switch is the trap the 'trigger' comment in
+ // reopenNode.ts warns about: snapshotNode happily records it, the ⇧⌘T entry and its persisted
+ // closedSessions twin are both written, and buildBase's `default` then returns null — a dead,
+ // clickable history entry that typechecks. So the pairing is asserted from BOTH ends.
+ it('recreates a files node from its cwd (a deleted file manager is not a dead reopen entry)', () => {
+ const node = recreateNodeFromSnapshot(
+ snap({
+ type: 'files',
+ data: { title: 'nodes', color: '#ffd60a', group: null, cwd: '/repo/src/renderer/nodes' }
+ }),
+ baseCtx()
+ )
+ expect(node).not.toBeNull()
+ expect(node!.type).toBe('files')
+ expect(node!.data.cwd).toBe('/repo/src/renderer/nodes')
+ expect(node!.data.title).toBe('nodes')
+ })
+
+ it('carries a files node’s sshFs flag, so a remote listing does not come back local', () => {
+ const node = recreateNodeFromSnapshot(
+ snap({
+ type: 'files',
+ data: { title: 'src', color: '#ffd60a', group: null, cwd: '/srv/app/src', sshFs: true }
+ }),
+ baseCtx()
+ )
+ expect(node!.data.sshFs).toBe(true)
+ })
+
+ it('returns null for a files snapshot missing cwd (never a silently blank listing)', () => {
+ const node = recreateNodeFromSnapshot(
+ snap({ type: 'files', data: { title: 'x', color: '#fff', group: null } }),
+ baseCtx()
+ )
+ expect(node).toBeNull()
+ })
+
+ it('snapshots a files node rather than treating it as unrestorable', () => {
+ const snapshot = snapshotNode(
+ {
+ type: 'files',
+ position: { x: 0, y: 0 },
+ width: 340,
+ height: 460,
+ data: { title: 'docs', color: '#ffd60a', group: null, cwd: '/repo/docs' }
+ },
+ []
+ )
+ expect(snapshot).not.toBeNull()
+ expect(snapshot!.type).toBe('files')
+ })
})
diff --git a/src/renderer/lib/reopenNode.ts b/src/renderer/lib/reopenNode.ts
index dfbb05980..cbd59a23c 100644
--- a/src/renderer/lib/reopenNode.ts
+++ b/src/renderer/lib/reopenNode.ts
@@ -12,6 +12,7 @@ import {
createDiffNode,
createStickyNode,
createDinoNode,
+ createFilesNode,
isAccountLoginNode
} from '@renderer/state/workspace'
import { absolutePosition, type FocusableNode } from './nodeFocus'
@@ -167,6 +168,13 @@ function buildBase(snapshot: ReopenNodeSnapshot, ctx: RecreateContext): CanvasNo
return d.filePath ? createEditorNode(0, d.filePath, undefined, d.sshFs) : null
case 'video':
return d.filePath ? createVideoNode(0, d.filePath, undefined, d.sshFs) : null
+ // A files node IS restorable — its whole state is the directory it shows — so it gets a case
+ // here rather than a seat in UNRESTORABLE beside 'trigger'. Registering it in neither list is
+ // the trap the 'trigger' comment above warns about: the snapshot is taken, the reopen entry is
+ // written, and `default: return null` then makes it a dead click. Compiles and typechecks
+ // either way, which is why the rule is written down rather than left to be noticed.
+ case 'files':
+ return d.cwd ? createFilesNode(0, d.cwd, undefined, d.sshFs) : null
case 'diff':
return d.cwd && d.filePath ? createDiffNode(0, d.cwd, d.filePath, !!d.diffStaged, undefined, d.commitOid) : null
case 'web':