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
fix(canvas): commit the live canvas again after the open gate
reviewb1bfd567f331
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 922780d35..8e024c681 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -6395,6 +6395,9 @@ export function Canvas() {// tab: the user chose Cancel.const g = opensProject(useProjects.getState().projects, { kind: 'new' }) ? gateProjectOpen() : trueif (g !== true && !(await g)) return+ // Again: a Close in the limit dialog switches the active canvas, and the switch below would+ // drop whatever was written live into that one. Same tick as the gate when it allows at once.+ commitActiveToStore()const project = probed? useProjects.getState().adoptProject({ ...probed, closed: false }): useProjects.getState().addProject(name, clonedPath)@@ -17892,6 +17895,9 @@ export function Canvas() {// The project limit is the LAST await before the store write (lib/projectLimitGate.ts).const g = opensProject(useProjects.getState().projects, { kind: 'folder', folder }) ? gateProjectOpen() : trueif (g !== true && !(await g)) return false+ // Again, after the awaits above: a Close in the limit dialog switches the active canvas, and+ // the open below would drop whatever was written live into that one (as onRepoCloned).+ commitActiveToStore()takeBack?.()useProjects.getState().openFolderProject(folder)// An `unavailable` placeholder never recovers on its own: a save emits a header-only ref@@ -17916,6 +17922,7 @@ export function Canvas() {const action: OpenAction = probed ? { kind: 'new' } : { kind: 'folder', folder }const g = opensProject(useProjects.getState().projects, action) ? gateProjectOpen() : trueif (g !== true && !(await g)) return false+ commitActiveToStore()if (probed) useProjects.getState().adoptProject({ ...probed, closed: false })else useProjects.getState().openFolderProject(folder)}diff --git a/src/renderer/canvas/project-limit-opens.source.test.ts b/src/renderer/canvas/project-limit-opens.source.test.tsindex 04a1f31c2..6c9317b53 100644--- a/src/renderer/canvas/project-limit-opens.source.test.ts+++ b/src/renderer/canvas/project-limit-opens.source.test.ts@@ -38,6 +38,16 @@ function expectGateRightBefore(body: string, action: string, mutation: string, freturn gate}+/** In `body`, between the awaited gate at `gate` and `mutation`, the live canvas is committed again.+ * A path that committed before an await of its own (a probe, a question) needs it: the limit+ * dialog's Close switches the active canvas, and the post-gate switch would otherwise drop whatever+ * was written live into the newly active one. Synchronous, so a dormant open stays in one tick. */+function expectCommitAfterGate(body: string, gate: number, mutation: string): void {+ const awaited = body.indexOf(AWAIT_GATE, gate)+ const mutated = body.indexOf(mutation, awaited)+ expect(body.slice(awaited + AWAIT_GATE.length, mutated), mutation).toContain('commitActiveToStore()')+}+describe('project-limit gate placement in Canvas', () => {it('New project: the gate comes first, then the synchronous add', () => {const body = between('const addProject = useCallback(', '}, [commitActiveToStore, writeDisk])')@@ -49,6 +59,7 @@ describe('project-limit gate placement in Canvas', () => {const body = between('const onRepoCloned = useCallback(', CALLBACK_END)const gate = expectGateRightBefore(body, "{ kind: 'new' }", 'useProjects.getState().adoptProject(')expect(body.indexOf('await api.workspace.probeFolder(clonedPath)')).toBeLessThan(gate)+ expectCommitAfterGate(body, gate, 'useProjects.getState().adoptProject(')})it('SSH open: the gate comes after the handed-off question, immediately before openSshProject', () => {@@ -63,6 +74,8 @@ describe('project-limit gate placement in Canvas', () => {expect(body.indexOf('await confirmHandedOffReopen(existing.id)')).toBeLessThan(reuse)const fresh = expectGateRightBefore(body, 'action', '.adoptProject({ ...probed, closed: false })', reuse + 1)expect(body.indexOf('await api.workspace.probeFolder(folder)')).toBeLessThan(fresh)+ expectCommitAfterGate(body, reuse, '.openFolderProject(folder)')+ expectCommitAfterGate(body, fresh, '.adoptProject({ ...probed, closed: false })')// A declined open says so to its caller (no toast here, and none there either).expect(body.match(/if \(g !== true && !\(await g\)\) return false/g)).toHaveLength(2)})