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(workspace): guard unavailable reopen; read-only load for relay blob
enes27cb03113803
diff --git a/src/core/workspace-store.test.ts b/src/core/workspace-store.test.tsindex 7cc68ebeb..1b2818189 100644--- a/src/core/workspace-store.test.ts+++ b/src/core/workspace-store.test.ts@@ -115,6 +115,17 @@ describe('unavailable & corrupt refs', () => {const dir = await fs.readdir(path.join(projRoot, '.nodeterm'))expect(dir.some((f) => f.startsWith('project.json.corrupt-'))).toBe(true)})++ it('load({ sideline: false }) marks a corrupt ref unavailable WITHOUT sidelining it', async () => {+ const store = new WorkspaceStore()+ await store.save(ws([project({ cwd: projRoot })]))+ const p = path.join(projRoot, '.nodeterm/project.json')+ await fs.writeFile(p, '{ not json') // e.g. a git-conflict-marked file mid-merge+ const loaded = await new WorkspaceStore().load({ sideline: false })+ expect(loaded.projects[0].unavailable).toBe(true)+ const dir = await fs.readdir(path.join(projRoot, '.nodeterm'))+ expect(dir.some((f) => f.startsWith('project.json.corrupt-'))).toBe(false) // left in place+ })})describe('unavailable projects never overwrite real data on save', () => {diff --git a/src/core/workspace-store.ts b/src/core/workspace-store.tsindex a04671ed5..5042ca0d7 100644--- a/src/core/workspace-store.ts+++ b/src/core/workspace-store.ts@@ -56,13 +56,19 @@ export class WorkspaceStore {platform().handle(IPC.workspaceProbeFolder, (folder: string) => this.probeFolder(folder))}- async load(): Promise<Workspace> {- const result = await this.loadInner()+ /**+ * `sideline` (default true) forwards to readProjectFile: an unparsable/wrong-shape local+ * project.json is renamed to `.corrupt-<ts>` so a later save can't overwrite the only copy —+ * correct for boot/renderer loads. Read-only callers (e.g. the relay `projects.list` blob, which+ * a phone can trigger mid git-merge) pass false so a conflict-marked file is left hand-resolvable.+ */+ async load(opts?: { sideline?: boolean }): Promise<Workspace> {+ const result = await this.loadInner(opts?.sideline ?? true)this.onPersist?.()return result}- private async loadInner(): Promise<Workspace> {+ private async loadInner(sideline: boolean): Promise<Workspace> {let raw: stringtry {raw = await fs.readFile(this.indexPath, 'utf-8')@@ -76,21 +82,21 @@ export class WorkspaceStore {return EMPTY_WORKSPACE}const anyParsed = parsed as { version?: number }- if (anyParsed?.version === 3) return this.loadV3(parsed as WorkspaceIndexV3)+ if (anyParsed?.version === 3) return this.loadV3(parsed as WorkspaceIndexV3, sideline)// v1/v2: assemble in memory now; the first save() performs the actual migration.const legacy = migrateLegacy(parsed)if (legacy.projects.length) this.pendingV2Backup = rawreturn legacy}- private async loadV3(index: WorkspaceIndexV3): Promise<Workspace> {+ private async loadV3(index: WorkspaceIndexV3, sideline: boolean): Promise<Workspace> {this.index = indexconst projects: Project[] = []for (const e of index.entries) {if (e.project) {projects.push(e.project)} else if (e.cwd) {- const p = await this.readProjectFile(e.cwd, true)+ const p = await this.readProjectFile(e.cwd, sideline)if (p) {this.revs.set(p.id, p.rev)this.lastWritten.set(projectFilePath(e.cwd), serializeProjectFile(p))diff --git a/src/main/index.ts b/src/main/index.tsindex de73ba50f..0352b8138 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -149,7 +149,9 @@ async function listProjectsOutput(): Promise<string> {// load() re-reads each ref's .nodeterm/project.json and returns {version:2, projects:[…]}; it is// idempotent (and re-syncs the watcher via onPersist), so calling it here is safe.const workspace = await workspaceStore- .load()+ // Read-only: a phone listing projects mid git-merge must NOT sideline a conflict-marked+ // project.json to `.corrupt-<ts>` (the probe/watcher-path fix); sideline is boot/renderer-only.+ .load({ sideline: false }).then((w) => JSON.stringify(w)).catch(() => '')const status = await readFile(join(dir, 'agent-status.json'), 'utf8').catch(() => '')diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex ef5e78136..99614afde 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -375,7 +375,9 @@ export function Canvas() {// "Has projects" = at least one OPEN (non-closed) tab. With only closed projects left, the// welcome screen shows (and lists them under "Recently closed" for reopening).const hasProjects = useProjects((s) => s.projects.some((p) => !p.closed))- const closedProjects = useProjects((s) => s.projects.filter((p) => p.closed))+ // Exclude UNAVAILABLE closed projects (folder missing): reopenProject would activate them+ // unconditionally → a silent-discard empty canvas (the same case the palette guard blocks).+ const closedProjects = useProjects((s) => s.projects.filter((p) => p.closed && !p.unavailable))// The active project's SSH server (if it's an SSH project) — drives the connection banner.const activeSshServer = useProjects((s) => s.projects.find((p) => p.id === s.activeProjectId)?.ssh?.server