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
feat(workspace): folder projects can keep their canvas in app data
Brandon Bridges6e91d9341fb3
diff --git a/src/core/workspace-files.ts b/src/core/workspace-files.tsindex 1c5e2af8c..79af9d6d9 100644--- a/src/core/workspace-files.ts+++ b/src/core/workspace-files.ts@@ -252,7 +252,13 @@ export interface IndexEntryV3 {/*** This entry is a LOCAL-DATA ref: its content lives in `userData/inline-projects/<id>.json` and* THAT FILE is the source of truth. Absent = the pre-file shape, where `project` below IS the- * content. Never set together with `cwd`/`ssh`.+ * content. Never set together with `ssh`.+ *+ * Set together with `cwd` it is a FOLDER-DATA-REF (issue #1145): a folder project whose canvas+ * is kept here instead of in `<cwd>/.nodeterm/project.json` (`Project.storeInAppData`). The+ * folder is the project's working directory only — nothing reads or writes its `.nodeterm/`, and+ * the watcher does not watch it. `project` (the cache) is stored without `cwd`, so a build that+ * predates the kind opens it as a plain inline canvas instead of writing into the folder.** A build that predates this field ignores it and reads `project`, which is why the two are* written together for one release (the downgrade contract).@@ -301,6 +307,21 @@ export interface IndexEntryV3 {execMigrated?: boolean}+/** A folder project whose canvas lives in app data (issue #1145) — see `IndexEntryV3.dataFile`. */+export function isFolderDataRef(e: Pick<IndexEntryV3, 'cwd' | 'ssh' | 'dataFile'>): boolean {+ return !!(e.dataFile && e.cwd && !e.ssh)+}++/**+ * The folder whose `.nodeterm/project.json` holds this entry's CONTENT, or undefined. Not the same+ * question as "does it have a cwd": a folder-data-ref has a working directory and keeps its canvas+ * in app data, so every reader or writer of the folder FILE asks this, and everything that only+ * needs where terminals run keeps reading `cwd`.+ */+export function folderFileCwd(e: Pick<IndexEntryV3, 'cwd' | 'ssh' | 'dataFile'>): string | undefined {+ return e.cwd && !e.dataFile ? e.cwd : undefined+}+export interface WorkspaceIndexV3 {version: 3activeProjectId: string@@ -859,6 +880,9 @@ export function splitWorkspace(// data. Emit a header-only ref preserving the ref shape — NEVER a file and NEVER an ssh// cache built from the placeholder, so a later save can't clobber the on-disk source.if (p.ssh) entries.push({ ...header, ssh: p.ssh })+ // A folder-data-ref placeholder keeps `dataFile`: without it the next load would read the+ // folder's own `.nodeterm/project.json` — a stale or a teammate's canvas — as this project.+ else if (p.cwd && p.storeInAppData) entries.push({ ...header, cwd: p.cwd, dataFile: true })else if (p.cwd) entries.push({ ...header, cwd: p.cwd })else {const { unavailable: _u, ...inline } = p@@ -883,6 +907,21 @@ export function splitWorkspace(// file. It is no longer identity even there: `fileToProject` is handed `e.id` regardless.cache: projectToFile(p, revOf(p.id), savedAt, p.id)})+ } else if (p.cwd && p.storeInAppData) {+ // The FOLDER-DATA-REF (issue #1145): a folder project whose canvas lives in+ // `userData/inline-projects/<id>.json`, so nothing is written into the folder. It is stored+ // exactly like a cwd-less canvas — the file and its `project` cache both hold the project+ // WITHOUT `cwd`, so node cwds stay absolute and the inline load/write paths serve it+ // unchanged — and the entry adds the `cwd` back. Two consequences are deliberate:+ // - It never claims `files` for its cwd, so it can sit beside a folder ref on the same+ // folder without either being demoted to the second-tab branch below.+ // - A build that predates the kind reads the cwd-less cache and sees an ordinary inline+ // canvas: it loses the folder binding but never writes into the folder.+ // - A hand-edited id we will not turn into a path gets no file — the cache IS the storage,+ // as for the pre-file inline shape — but it still never falls through to the folder.+ const { unavailable: _u, cwd: _cwd, storeInAppData: _s, ...inline } = p+ if (isInlineProjectFileId(p.id)) dataFiles.set(p.id, projectToFile(inline, revOf(p.id), savedAt))+ entries.push({ ...header, ...localState, ...localRef, cwd: p.cwd, dataFile: true, project: inline })} else if (p.cwd && !files.has(p.cwd)) {files.set(p.cwd, projectToFile(p, revOf(p.id), savedAt))entries.push({ ...header, ...localState, ...localRef, cwd: p.cwd })diff --git a/src/core/workspace-store.folder-data.test.ts b/src/core/workspace-store.folder-data.test.tsnew file mode 100644index 000000000..830f0900f--- /dev/null+++ b/src/core/workspace-store.folder-data.test.ts@@ -0,0 +1,196 @@+// A folder project can keep its canvas in app data instead of `<cwd>/.nodeterm/project.json`+// (issue #1145): the FOLDER-DATA-REF, a local-data ref with a working directory. The promise is+// that nothing is written into the folder, and the traps are the ways an existing path would+// break it: the watcher re-reading the folder file, a missing data file falling through to the+// folder branch, an older build writing a fresh file into the folder, and a copy left behind on+// the side a move departs from.+import { describe, it, expect, beforeEach, afterEach } from 'vitest'+import { promises as fs } from 'fs'+import os from 'os'+import path from 'path'+import { initPlatform, resetPlatformForTests } from './platform'+import { fakePlatform } from './platform-fake'+import { WorkspaceStore } from './workspace-store'+import type { CanvasNodeState, Project, Workspace } from '../shared/types'++let userData: string+let folder: string++const node = (id: string, over: Partial<CanvasNodeState> = {}): CanvasNodeState => ({+ id, kind: 'terminal', position: { x: 0, y: 0 }, size: { width: 1, height: 1 },+ title: id, color: '#fff', group: null, ...over+})+const project = (over: Partial<Project> = {}): Project => ({+ id: 'project-p1', name: 'client-repo', color: '#7aa2f7', viewport: { x: 4, y: 5, zoom: 2 },+ cwd: folder, storeInAppData: true, nodes: [node('term-1', { cwd: path.join(folder, 'sub') })], ...over+})+const ws = (projects: Project[], active = projects[0]?.id ?? ''): Workspace =>+ ({ version: 2, activeProjectId: active, projects })++const dataFile = (id: string) => path.join(userData, 'inline-projects', `${id}.json`)+const folderFile = () => path.join(folder, '.nodeterm', 'project.json')+const readIndex = async () =>+ JSON.parse(await fs.readFile(path.join(userData, 'workspace.json'), 'utf-8'))+const writeIndex = async (index: unknown) =>+ fs.writeFile(path.join(userData, 'workspace.json'), JSON.stringify(index))+const readData = async (id: string) => JSON.parse(await fs.readFile(dataFile(id), 'utf-8'))+const exists = (p: string) => fs.access(p).then(() => true, () => false)+const ids = (nodes: CanvasNodeState[]) => nodes.map((n) => n.id)+const foreignFile = (nodeId: string) => JSON.stringify({+ version: 1, rev: 99, savedAt: '2026-01-01T00:00:00.000Z', name: 'teammate', color: '#000',+ viewport: { x: 0, y: 0, zoom: 1 }, nodes: [node(nodeId)]+})++beforeEach(async () => {+ userData = await fs.mkdtemp(path.join(os.tmpdir(), 'nt-folder-data-'))+ folder = await fs.mkdtemp(path.join(os.tmpdir(), 'nt-folder-data-repo-'))+ initPlatform(fakePlatform({ userDataDir: userData }))+})+afterEach(async () => {+ resetPlatformForTests()+ await fs.rm(userData, { recursive: true, force: true })+ await fs.rm(folder, { recursive: true, force: true })+})++describe('a folder project stored in app data', () => {+ it('writes its canvas to app data and nothing into the folder', async () => {+ await new WorkspaceStore().save(ws([project()]))++ expect(await fs.readdir(folder)).toEqual([])+ expect(ids((await readData('project-p1')).nodes)).toEqual(['term-1'])+ const entry = (await readIndex()).entries[0]+ expect(entry).toMatchObject({ id: 'project-p1', cwd: folder, dataFile: true })+ })++ it('round-trips with its folder, the flag and absolute node cwds', async () => {+ await new WorkspaceStore().save(ws([project()]))+ const loaded = (await new WorkspaceStore().load()).projects[0]++ expect(loaded).toMatchObject({ id: 'project-p1', cwd: folder, storeInAppData: true })+ expect(loaded.nodes[0].cwd).toBe(path.join(folder, 'sub'))+ expect(loaded.viewport).toEqual({ x: 4, y: 5, zoom: 2 })+ })++ it('stores the index cache without cwd, so an older build opens an inline canvas', async () => {+ await new WorkspaceStore().save(ws([project()]))+ const index = await readIndex()+ expect(index.entries[0].project.cwd).toBeUndefined()+ expect(index.entries[0].project.storeInAppData).toBeUndefined()++ // A build that predates the kind takes the `e.project` branch: the same as this build reading+ // the entry without its `dataFile` flag.+ delete index.entries[0].dataFile+ await writeIndex(index)+ const old = new WorkspaceStore()+ const loaded = (await old.load()).projects[0]+ expect(loaded.cwd).toBeUndefined()+ expect(ids(loaded.nodes)).toEqual(['term-1'])++ await old.save(ws([loaded]))+ expect(await exists(path.join(folder, '.nodeterm'))).toBe(false)+ })++ it('reads its data file, never the folder file a teammate committed', async () => {+ await new WorkspaceStore().save(ws([project()]))+ await fs.mkdir(path.join(folder, '.nodeterm'))+ await fs.writeFile(folderFile(), foreignFile('term-foreign'))++ const loaded = (await new WorkspaceStore().load()).projects[0]+ expect(ids(loaded.nodes)).toEqual(['term-1'])+ })++ it('falls back to its cache, then a placeholder, never to the folder file', async () => {+ await new WorkspaceStore().save(ws([project()]))+ await fs.mkdir(path.join(folder, '.nodeterm'))+ await fs.writeFile(folderFile(), foreignFile('term-foreign'))+ await fs.rm(dataFile('project-p1'))++ const fromCache = (await new WorkspaceStore().load()).projects[0]+ expect(fromCache).toMatchObject({ cwd: folder, storeInAppData: true })+ expect(ids(fromCache.nodes)).toEqual(['term-1'])++ const index = await readIndex()+ delete index.entries[0].project+ await writeIndex(index)+ const store = new WorkspaceStore()+ const placeholder = (await store.load()).projects[0]+ expect(placeholder).toMatchObject({ unavailable: true, storeInAppData: true, cwd: folder })+ expect(placeholder.nodes).toEqual([])++ // Saving the placeholder back keeps the kind, so the next load still does not read the folder.+ await store.save(ws([placeholder]))+ expect((await readIndex()).entries[0]).toMatchObject({ cwd: folder, dataFile: true })+ expect((await new WorkspaceStore().load()).projects[0].unavailable).toBe(true)+ })++ it('is not watched: its folder file is not a local ref path', async () => {+ const store = new WorkspaceStore()+ await store.save(ws([project(), project({ id: 'project-p2', storeInAppData: undefined, cwd: folder + '-b' })]))+ expect(store.localRefPaths()).toEqual([path.join(folder + '-b', '.nodeterm', 'project.json')])+ expect(await store.readLocalRef('project-p1')).toBeNull()+ await fs.rm(folder + '-b', { recursive: true, force: true })+ })++ it('sits beside a folder ref on the same folder without demoting either', async () => {+ const store = new WorkspaceStore()+ await store.save(ws([+ project({ id: 'project-ref', storeInAppData: undefined, nodes: [node('term-ref')] }),+ project()+ ]))+ const [ref, data] = (await new WorkspaceStore().load()).projects+ expect(ids(ref.nodes)).toEqual(['term-ref'])+ expect(ref.storeInAppData).toBeUndefined()+ expect(ids(data.nodes)).toEqual(['term-1'])+ expect(data.storeInAppData).toBe(true)+ })+})++describe('moving a folder project between the two locations', () => {+ it('to app data: writes the data file and clears an older copy of its own first', async () => {+ const store = new WorkspaceStore()+ // A leftover from an earlier stay in app data: same id, populated.+ await fs.mkdir(path.dirname(dataFile('project-p1')), { recursive: true })+ await fs.writeFile(dataFile('project-p1'), foreignFile('term-stale'))+ await store.save(ws([project({ storeInAppData: undefined, nodes: [] })]))++ await store.save(ws([project({ nodes: [] })]))+ const loaded = (await new WorkspaceStore().load()).projects[0]+ expect(loaded.nodes).toEqual([])+ expect(loaded.storeInAppData).toBe(true)+ })++ it('to the folder: writes the folder file, then deletes the data file', async () => {+ const store = new WorkspaceStore()+ await store.save(ws([project()]))+ await store.save(ws([project({ storeInAppData: undefined })]))++ expect(await exists(dataFile('project-p1'))).toBe(false)+ const file = JSON.parse(await fs.readFile(folderFile(), 'utf-8'))+ expect(ids(file.nodes)).toEqual(['term-1'])+ // The folder file carries portable cwds, as every folder project's does.+ expect(file.nodes[0].cwd).toBe('./sub')+ const loaded = (await new WorkspaceStore().load()).projects[0]+ expect(loaded.storeInAppData).toBeUndefined()+ expect(loaded.nodes[0].cwd).toBe(path.join(folder, 'sub'))+ })++ it('to the folder: keeps the data file while the folder write cannot land', async () => {+ const store = new WorkspaceStore()+ await store.save(ws([project()]))+ // A FILE where the `.nodeterm` directory would go: the folder leg's mkdir fails.+ await fs.writeFile(path.join(folder, '.nodeterm'), 'not a directory')+ await store.save(ws([project({ storeInAppData: undefined })]))++ expect(ids((await readData('project-p1')).nodes)).toEqual(['term-1'])+ })++ it('"Set folder…" on a cwd-less canvas no longer leaves its data file behind', async () => {+ const store = new WorkspaceStore()+ await store.save(ws([project({ cwd: undefined, storeInAppData: undefined })]))+ expect(await exists(dataFile('project-p1'))).toBe(true)++ await store.save(ws([project({ storeInAppData: undefined })]))+ expect(await exists(dataFile('project-p1'))).toBe(false)+ expect(await exists(folderFile())).toBe(true)+ })+})diff --git a/src/core/workspace-store.ts b/src/core/workspace-store.tsindex 4aadd7751..03210129f 100644--- a/src/core/workspace-store.ts+++ b/src/core/workspace-store.ts@@ -12,7 +12,8 @@ import {} from '../shared/types'import { contentOf, type CanvasContent } from '../shared/canvas-content'import {- PROJECT_DIR, PROJECT_FILE, fileToProject, inlineProjectFileRelPath, isInlineProjectFileId,+ PROJECT_DIR, PROJECT_FILE, fileToProject, folderFileCwd, inlineProjectFileRelPath, isFolderDataRef,+ isInlineProjectFileId,projectToFile, resolveNodes, sameProjectContent,sanitizeLoadedClosedSessions, sanitizeNodeTriggers, serializeProjectFile, splitWorkspace,sanitizeHandedOffTo,@@ -569,11 +570,16 @@ export class WorkspaceStore {for (const e of index.entries) {// A LOCAL-DATA ref reads its own file first; `e.project` below is its cache and answers only// when the file is missing or unreadable (and for a pre-file entry, which has no file yet).- const fromDataFile = e.dataFile && !e.cwd && !e.ssh+ // A FOLDER-DATA-REF (issue #1145) is a local-data ref with a working directory: the file and+ // its cache are stored without `cwd` (see splitWorkspace), so the folder is put back here.+ const folderData = isFolderDataRef(e)+ const inFolder = (project: Project): Project =>+ folderData ? { ...project, cwd: e.cwd, storeInAppData: true } : project+ const fromDataFile = e.dataFile && !e.ssh? await this.loadDataFileEntry(e, sideline): nullif (fromDataFile) {- built.push(fromDataFile)+ built.push({ ...fromDataFile, project: inFolder(fromDataFile.project) })} else if (e.project) {// Inline projects are stored verbatim in the index (no fileToProject pass), so apply the// same kanban shape guard here — a v1/hand-edited board would otherwise crash the render —@@ -597,7 +603,7 @@ export class WorkspaceStore {const history = sanitizeLoadedClosedSessions(closedSessions)built.push({entry: e,- project: {+ project: inFolder({...base,nodes: sanitizeNodeTriggers(base.nodes),...(admittedBridges ? { bridges: admittedBridges } : {}),@@ -605,8 +611,13 @@ export class WorkspaceStore {...(history ? { closedSessions: history } : {}),...(admitted ? { layouts: admitted } : {}),...(views ? { layoutViewports: views } : {})- }+ })})+ } else if (folderData) {+ // File AND cache gone. Never fall through to the folder branch below: that reads the+ // folder's own `.nodeterm/project.json` — a stale copy or a teammate's canvas — and the+ // next save would adopt it as this project. The grey placeholder keeps the kind instead.+ built.push({ entry: e, project: { ...unavailableProject(e), storeInAppData: true } })} else if (e.cwd) {if (sideline) await sweepStaleTmp(projectFilePath(e.cwd))const read = await this.readProjectFile(e.cwd, sideline)@@ -830,7 +841,7 @@ export class WorkspaceStore {const local = this.localSettingsByProject.get(projectId)if (e.ssh) return this.readSshSettings(projectId, e.ssh, local)// An inline canvas has no folder, so there is no shared document to have.- if (!e.cwd) return { shared: null, local }+ if (!folderFileCwd(e) || !e.cwd) return { shared: null, local }const read = await readProjectSettingsFile(e.cwd)if (read.status === 'ok') {// The rev source for the next write — a write that skipped the read would restart at rev 1@@ -1026,7 +1037,7 @@ export class WorkspaceStore {const e = this.index?.entries.find((x) => x.id === projectId)if (!e) return falseif (e.ssh) return this.writeSshSettings(projectId, e.ssh, doc)- if (!e.cwd) return false+ if (!folderFileCwd(e) || !e.cwd) return falseconst read = await readProjectSettingsFile(e.cwd)// absent → nothing to lose, start at rev 1. invalid → the read already sidelined the only// copy to `.corrupt-<ts>`, so this write destroys nothing either.@@ -1282,7 +1293,7 @@ export class WorkspaceStore {async readProjectContent(projectId: string): Promise<CanvasContent | null> {const e = this.index?.entries.find((x) => x.id === projectId)if (!e || e.ssh) return null- if (e.cwd) {+ if (folderFileCwd(e) && e.cwd) {const file = await this.knownProjectFile(e.cwd)if (!file) return nullreturn contentOf(fileToProject(file, { id: e.id, cwd: e.cwd, localExec: localExecOverlay(e, file) }))@@ -1338,7 +1349,7 @@ export class WorkspaceStore {const e = this.index?.entries.find((x) => x.id === projectId)if (!e || e.ssh) return falseconst savedAt = new Date().toISOString()- if (e.cwd) return this.writeFolderContent(e, e.cwd, content, savedAt)+ if (folderFileCwd(e) && e.cwd) return this.writeFolderContent(e, e.cwd, content, savedAt)if (e.project) return this.writeInlineContent(e, e.project, content, savedAt)return false}@@ -1507,7 +1518,7 @@ export class WorkspaceStore {// are joined here, through the index entry that owns the folder. At most one ref entry exists// per cwd (splitWorkspace's second tab on a folder becomes an inline entry, no cwd at all).const projectIdForCwd = new Map(- index.entries.filter((e) => e.cwd).map((e) => [e.cwd!, e.id] as const)+ index.entries.filter((e) => folderFileCwd(e)).map((e) => [e.cwd!, e.id] as const))for (const [cwd, candidate] of files) {const projectId = projectIdForCwd.get(cwd) ?? cwd@@ -1536,6 +1547,23 @@ export class WorkspaceStore {// candidate overwrite a populated file this store has not read — plus the one rule only this// leg needs (see `writeDataFile`): a second app instance shares this userData, so a file whose// rev has moved ahead of ours belongs to that instance and is not overwritten.+ // A folder project that has just moved its canvas INTO app data (issue #1145) may find a file+ // of its own already there — litter from an earlier "Set folder…" or move, same id and same+ // lineage. It is never what this project holds now, and left alone it can win: an empty+ // candidate is refused over a populated file this store never read, and the next load would+ // adopt those stale bytes. So it is cleared before the write, for exactly that transition.+ // Only for an id this store already had as a folder ref: a file under an id we never held is+ // another instance's (see `sweepRemovedDataFiles`).+ const wasFolderRef = new Set(+ (previousIndex?.entries ?? []).filter((e) => folderFileCwd(e)).map((e) => e.id)+ )+ for (const e of index.entries) {+ if (!isFolderDataRef(e) || !wasFolderRef.has(e.id) || !isInlineProjectFileId(e.id)) continue+ const file = inlineFilePath(e.id)+ await fs.rm(file, { force: true }).catch(() => undefined)+ this.lastWritten.delete(file)+ this.lastWrittenParsed.delete(file)+ }for (const [projectId, candidate] of dataFiles) await this.writeDataFile(projectId, candidate)// ssh caches: bump rev on change so a later remote write can win; mirror write in Task 8.@@ -1699,9 +1727,25 @@ export class WorkspaceStore {next: WorkspaceIndexV3): Promise<void> {if (!previous) return- const live = new Set(next.entries.map((e) => e.id))+ // Ids whose entry still keeps its content in a data file. An id that is live but no longer a+ // data ref left that storage — "Set folder…" bound it to a folder, or a folder-data-ref moved+ // its canvas back into the folder (issue #1145) — and its file is deleted too: same id, same+ // lineage, and a leftover with a higher rev would win `writeDataFile`'s rev rule (and its stale+ // bytes be adopted) the day the project moved back into app data.+ //+ // Only once the folder holds the canvas, though: the folder leg swallows a failed write (an+ // unmounted or read-only disk), and deleting the data file then would leave the canvas in+ // memory only. Until this store has written or read that folder's file, the leftover stays.+ const nextById = new Map(next.entries.map((e) => [e.id, e] as const))+ const keep = (id: string): boolean => {+ const n = nextById.get(id)+ if (!n) return false+ if (n.dataFile) return true+ const cwd = folderFileCwd(n)+ return !cwd || !this.lastWritten.has(projectFilePath(cwd))+ }for (const e of previous.entries) {- if (!e.dataFile || live.has(e.id) || !isInlineProjectFileId(e.id)) continue+ if (!e.dataFile || keep(e.id) || !isInlineProjectFileId(e.id)) continueconst file = inlineFilePath(e.id)await fs.rm(file, { force: true }).catch(() => undefined)this.lastWritten.delete(file)@@ -1859,7 +1903,7 @@ export class WorkspaceStore {}localRefPaths(): string[] {- return (this.index?.entries ?? []).filter((e) => e.cwd).map((e) => projectFilePath(e.cwd!))+ return (this.index?.entries ?? []).filter((e) => folderFileCwd(e)).map((e) => projectFilePath(e.cwd!))}isSelfWrite(filePath: string, content: string): boolean {@@ -1867,7 +1911,7 @@ export class WorkspaceStore {}async readLocalRef(projectId: string): Promise<Project | null> {- const e = this.index?.entries.find((x) => x.id === projectId && x.cwd)+ const e = this.index?.entries.find((x) => x.id === projectId && folderFileCwd(x))if (!e?.cwd) return nullconst read = await this.readProjectFile(e.cwd, false)if (!read) return null@@ -2084,7 +2128,7 @@ export class WorkspaceStore {let nodes: CanvasNodeState[] | undefinedif (e.project) nodes = e.project.nodeselse if (e.cache) nodes = e.cache.nodes- else if (e.cwd) {+ else if (folderFileCwd(e) && e.cwd) {const raw = this.lastWritten.get(projectFilePath(e.cwd))if (raw) {try {@@ -2099,7 +2143,7 @@ export class WorkspaceStore {if (node)return {node,- root: !e.project && !e.cache && e.cwd ? e.cwd : undefined,+ root: !e.project && !e.cache && folderFileCwd(e) ? e.cwd : undefined,...(!e.project && e.cache && e.ssh ? { ssh: e.ssh } : {})}}@@ -2181,7 +2225,7 @@ export class WorkspaceStore {e.cache,e.cache?.nodes,e.cwd,- e.cwd ? this.lastWritten.get(projectFilePath(e.cwd)) : undefined+ folderFileCwd(e) && e.cwd ? this.lastWritten.get(projectFilePath(e.cwd)) : undefined)}return out@@ -2210,7 +2254,7 @@ export class WorkspaceStore {let nodes: CanvasNodeState[] | undefinedif (e.project) nodes = e.project.nodeselse if (e.cache) nodes = e.cache.nodes- else if (e.cwd) {+ else if (folderFileCwd(e) && e.cwd) {try {nodes = this.parsedLastWritten(projectFilePath(e.cwd))?.nodes} catch {@@ -2277,7 +2321,7 @@ export class WorkspaceStore {bridges: sanitizeLinks(e.cache.bridges),ropes: sanitizeLinks(e.cache.ropes)})- } else if (e.cwd) {+ } else if (folderFileCwd(e) && e.cwd) {const raw = this.lastWritten.get(projectFilePath(e.cwd))if (!raw) continuetry {@@ -2363,7 +2407,7 @@ export class WorkspaceStore {if (e.id !== projectId) continueconst ack = e.capabilityAck ? { capabilityAck: e.capabilityAck } : {}if (e.cache) return { ...readProjectCapabilities(e.cache), ...ack }- if (e.cwd) {+ if (folderFileCwd(e) && e.cwd) {const raw = this.lastWritten.get(projectFilePath(e.cwd))if (!raw) return { ...ack } // file never read this run: no flag known, so nothing grantstry {@@ -2382,7 +2426,7 @@ export class WorkspaceStore {let nodes: CanvasNodeState[] | undefinedif (e.project) nodes = e.project.nodeselse if (e.cache) nodes = e.cache.nodes- else if (e.cwd) {+ else if (folderFileCwd(e) && e.cwd) {const raw = this.lastWritten.get(projectFilePath(e.cwd))if (raw) {try {@@ -2461,7 +2505,7 @@ export class WorkspaceStore {now: Date,accountColor?: string): Promise<boolean> {- const e = this.index?.entries.find((x) => x.id === projectId && x.cwd)+ const e = this.index?.entries.find((x) => x.id === projectId && folderFileCwd(x))if (!e?.cwd) return falseconst file = projectFilePath(e.cwd)let raw: string@@ -2524,7 +2568,7 @@ export class WorkspaceStore {for (const e of this.index?.entries ?? []) {// Local ref projects only, like appendRemoteNode: an ssh ref's file lives on another// machine (and a relay `pty.attach` only ever reaches THIS machine's tmux anyway).- if (!e.cwd || e.ssh) continue+ if (!folderFileCwd(e) || !e.cwd || e.ssh) continueconst file = projectFilePath(e.cwd)let raw: stringtry {@@ -2727,7 +2771,7 @@ export class WorkspaceStore {return { file: parsed, written: true }}- if (!e.cwd) return null+ if (!folderFileCwd(e) || !e.cwd) return nullconst file = projectFilePath(e.cwd)let raw: stringtry {diff --git a/src/shared/types.ts b/src/shared/types.tsindex 6a610a2d6..aec89b979 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -1114,6 +1114,13 @@ export interface Project {icon?: ProjectIcon/** Default working directory for new terminals created in this project. */cwd?: string+ /**+ * MACHINE-LOCAL: this folder project's canvas lives in app data (`userData/inline-projects/<id>.json`),+ * not in `<cwd>/.nodeterm/project.json`, and nothing is written into the folder (issue #1145).+ * Only meaningful beside a local `cwd`; never written to any shared file. See the+ * folder-data-ref kind in core/workspace-files.ts (`IndexEntryV3.dataFile`).+ */+ storeInAppData?: boolean/** When set, this is an SSH project: its terminals run on `server` in `remoteCwd` (remote tmux). */ssh?: { server: import('./ssh').SshConnection; remoteCwd: string }viewport: Viewport