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(projects): choose where folder projects store their canvas
Brandon Bridgese08b85e74cfe
diff --git a/CLAUDE.md b/CLAUDE.mdindex 17c8262ec..99ca1007f 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -313,6 +313,29 @@ Persistence has two layers:| folder-ref | `<cwd>/.nodeterm/project.json` (git-shared) | `cwd` + header + machine-local half || ssh-ref | the same file on the host | `ssh` + header + `cache` (offline copy, rev-reconciled) || local-data-ref | `userData/inline-projects/<id>.json` | `dataFile` + header + `project` (cache) |+ | folder-data-ref | `userData/inline-projects/<id>.json` | `cwd` + `dataFile` + header + `project` (cache, stored WITHOUT `cwd`) |++ **The folder-data-ref (issue #1145)** is a folder project whose canvas is kept in app data+ (`Project.storeInAppData`) so that nothing is written into the folder — for client repos and+ folders the user does not own. It is a local-data ref with a working directory: the file and the+ cache hold the project without `cwd` (node cwds stay absolute), so the inline load and write paths+ serve it unchanged and the entry adds the folder back. Three rules keep the promise:+ `folderFileCwd(e)`, not `e.cwd`, decides every read or write of `<cwd>/.nodeterm/project.json`+ (watcher, content authority, the phone writers, settings); a missing data file falls back to the+ cache and then to a grey placeholder, **never** to the folder branch (that would adopt a stale or+ a teammate's canvas); and the cache's missing `cwd` is the downgrade contract — an older build+ opens it as a plain inline canvas instead of writing a fresh file into the folder. Its side files+ follow it: settings.json and the board log under `userData/project-files/<id>/.nodeterm/`+ (`appDataProjectRoot`; settings still load as `'shared'`), canvas images to the existing+ `userData/canvas-images` fallback (`sideFilesFolderForProject`). `localCwdForProject` still answers+ the folder, because it means where terminals run and what a relay seat is jailed to. Moving+ between the two is the tab menu's "Store canvas in app data / in folder"+ (`lib/projectStorageMove.ts`): into app data = save, then `releaseFolderFiles` (refused until the+ data file holds the canvas; files git tracks are kept unless the user confirms); into the folder =+ `prepareFolderStorage` (refuses an occupied folder, like "Set folder…"), then save; the sweep+ deletes the departed side's copy only once the folder file has landed, and keeps the rev. New+ folder projects follow `settings.newProjectStorage`; a folder that already has a project.json is+ adopted as it is, in its folder.In all three the file carries CONTENT and the entry carries the machine-local half — project`id`, `viewport`, `defaultAccountId`, `breadcrumbs`, `closedSessions`, `localApprovalId`,diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 3a8beda69..7c7baee5f 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -1114,7 +1114,12 @@ account, breadcrumbs, closed-session history, per-node `shell` and held `pendingAnd **`workspace.json` is one file with last-writer-wins semantics, so it may not be the only homeof any content**: that is precisely what let a second app instance erase a cwd-less canvas. Betweentwo instances the arbiter is the file's `rev` — a lower rev never overwrites a higher one — and-there is no merge; if you add a fourth kind, give it a file and say which rev wins.+there is no merge; if you add a fourth kind, give it a file and say which rev wins. The fourth is the+folder-data-ref (issue #1145: a folder project whose canvas lives in app data): its file is the+inline one, `writeDataFile`'s rule decides between instances, and the rev continues across a move+between the folder and app data. Anything that reads or writes `<cwd>/.nodeterm/` must ask+`folderFileCwd(e)` (or the side-file accessors), never `e.cwd` alone — a project can have a cwd and+nothing in its folder.**A project with no folder is a real project — degrade explicitly, never silently.** "New project"creates a cwd-less canvas, so every folder-shaped feature meets one. Keep the affordance anddiff --git a/src/core/settings-store.ts b/src/core/settings-store.tsindex f68d6a5f1..c8bbfd15c 100644--- a/src/core/settings-store.ts+++ b/src/core/settings-store.ts@@ -2,6 +2,7 @@ import { readFileSync } from "fs";import path from "path";import { writeFileAtomic } from "./fs-atomic";import { IPC } from "../shared/ipc";+import { isNewProjectStorage } from "../shared/project-storage";import { platform } from "./platform";import { DEFAULT_SETTINGS, type Settings } from "../shared/types";@@ -91,6 +92,9 @@ function mergeSettings(saved: Partial<Settings> | null | undefined): Settings {}// Keep the mirror in lockstep with the resolved mode so an older build still honors the choice.merged.vanillaLaunchDefault = merged.agentLaunchMode === "subscription";+ // Same rule for where new folder projects keep their canvas (issue #1145).+ if (!isNewProjectStorage(merged.newProjectStorage as unknown))+ merged.newProjectStorage = DEFAULT_SETTINGS.newProjectStorage;// Background mode is hand-editable too: anything but the three known values is the default.const bg = merged.runInBackgroundOnClose as unknown;if (bg !== "auto" && bg !== "on" && bg !== "off")diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 869247831..9275fdf70 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -240,6 +240,7 @@ import {type AddHandlers} from '../lib/addMenuSpec'import { planSetProjectFolder } from '../lib/setProjectFolder'+import { moveProjectToAppData, moveProjectToFolder, type ProjectStorageMoveDeps } from '../lib/projectStorageMove'import { effectiveAccountId, observationIsRemote, type ObservationOrigin } from '../lib/accountChip'import { reopenVariants } from '../lib/reopenVariants'import { modelsForAgent, type GatewayModel } from '@shared/agents/model-gateway'@@ -4142,7 +4143,7 @@ export function Canvas() {useEffect(() => {return api.workspace.onCorruptRecovered((backupFile) => {setMigrationNote(- `The workspace index was corrupted and has been backed up as ${backupFile} (in the app's data folder). Projects with a folder are safe — their canvas is in <folder>/.nodeterm/project.json, so “Open folder…” adds them back. A project with no folder lived only in the index: keep that backup, it is the only copy of its canvas.`+ `The workspace index was corrupted and has been backed up as ${backupFile} (in the app's data folder). Projects stored in their folder are safe — their canvas is in <folder>/.nodeterm/project.json, so “Open folder…” adds them back. A project with no folder, or one stored in app data, has no copy in any folder: keep that backup.`)})}, [])@@ -17610,6 +17611,32 @@ export function Canvas() {[persist, switchProject, reopenProject])+ // Issue #1145: move a folder project's canvas between its folder and app data. The ordering and+ // the refusals live in lib/projectStorageMove.ts; this only hands it the levers.+ const projectStorageMoveDeps = useMemo(+ (): ProjectStorageMoveDeps => ({+ setStoreInAppData: (id, on) => useProjects.getState().setProjectStoreInAppData(id, on),+ persist: async () => (await persist()) === true,+ release: (id, removeTracked) => api.workspace.releaseFolderFiles(id, removeTracked),+ prepare: (id) => api.workspace.prepareFolderStorage(id),+ confirm: (message, confirmLabel) =>+ new Promise<boolean>((resolve) =>+ setConfirm({+ message,+ confirmLabel,+ danger: true,+ onConfirm: () => {+ setConfirm(null)+ resolve(true)+ },+ onCancel: () => resolve(false)+ })+ ),+ notice: (kind, text) => setNotice({ kind, text })+ }),+ [persist, setConfirm]+ )+const setProjectDefaultAccount = useCallback((id: string, accountId: string | undefined) => {useProjects.getState().setProjectDefaultAccount(id, accountId)@@ -17834,6 +17861,23 @@ export function Canvas() {}},{ label: 'Set folder…', icon: <IconProject />, onClick: () => setProjectFolder(projectId) },+ // Issue #1145: a local folder project only — an ssh project's file is on its host, and a+ // relay tab is another machine's project.+ ...(project.cwd && !project.ssh && !project.remote && !project.unavailable+ ? [+ project.storeInAppData+ ? {+ label: 'Store canvas in folder',+ icon: <IconProject />,+ onClick: () => void moveProjectToFolder(projectId, projectStorageMoveDeps)+ }+ : {+ label: 'Store canvas in app data',+ icon: <IconProject />,+ onClick: () => void moveProjectToAppData(projectId, projectStorageMoveDeps)+ }+ ]+ : []),{label: 'Project settings…',icon: <IconGear />,@@ -17872,6 +17916,7 @@ export function Canvas() {switchProject,renameProject,setProjectFolder,+ projectStorageMoveDeps,setProjectColor,closeProject,openProjectSettings,diff --git a/src/renderer/components/settings/sections/BehaviorSection.tsx b/src/renderer/components/settings/sections/BehaviorSection.tsxindex fc4fd2fe3..de2fac67d 100644--- a/src/renderer/components/settings/sections/BehaviorSection.tsx+++ b/src/renderer/components/settings/sections/BehaviorSection.tsx@@ -14,6 +14,7 @@ import { backgroundCloseDescription, backgroundCloseRowVisible } from '@rendererimport type { BackgroundOnCloseSetting } from '@shared/types'import { clampWheelZoomSpeed } from '@renderer/canvas/wheel-zoom'import { DEFAULT_WORKTREE_PATH_TEMPLATE } from '@shared/worktree'+import type { NewProjectStorage } from '@shared/project-storage'const ROWS = {defaultView: {@@ -72,6 +73,10 @@ const ROWS = {title: 'Sidebar: group by',keywords: ['sidebar', 'sessions', 'group', 'status', 'project', 'attention']},+ projectStorage: {+ title: 'New folder projects store their canvas',+ keywords: ['project', 'storage', 'app data', 'nodeterm', 'folder', 'repo', 'project.json', 'git', 'client']+ },worktreePath: {title: 'Worktree path template',keywords: ['worktree', 'git', 'path', 'folder', 'repo', 'branch', 'template']@@ -371,6 +376,22 @@ export function BehaviorSection({ isActive }: { isActive: boolean }): React.JSX.}/></SearchableRow>+ <SearchableRow {...ROWS.projectStorage}>+ <FieldRow+ label="New folder projects store their canvas"+ description="In the folder writes .nodeterm/project.json there, to share through git. In app data writes nothing into the folder. A folder that already has a project.json opens as it is. Move an existing project from its tab menu."+ control={+ <Select+ aria-label="New folder projects store their canvas"+ value={settings.newProjectStorage}+ onChange={(e) => update({ newProjectStorage: e.target.value as NewProjectStorage })}+ >+ <option value="folder">In the folder</option>+ <option value="appData">In app data</option>+ </Select>+ }+ />+ </SearchableRow><SearchableRow {...ROWS.worktreePath}><FieldRowlabel="Worktree path template"diff --git a/src/renderer/components/settings/sections/ProjectSettingsSection.tsx b/src/renderer/components/settings/sections/ProjectSettingsSection.tsxindex 613b7ab37..df0b8e4d2 100644--- a/src/renderer/components/settings/sections/ProjectSettingsSection.tsx+++ b/src/renderer/components/settings/sections/ProjectSettingsSection.tsx@@ -205,7 +205,11 @@ function EditableProjectSection({<SettingsSectionid={projectSectionId(project.id)}title={project.name}- description={`Settings for this project only. Name, color and defaults live in ${project.ssh ? 'the project file on the server' : '.nodeterm/project.json'}, which is shared with anyone who has the repo.`}+ description={+ project.storeInAppData && !project.ssh+ ? 'Settings for this project only. They are stored in app data on this machine, not in the folder.'+ : `Settings for this project only. Name, color and defaults live in ${project.ssh ? 'the project file on the server' : '.nodeterm/project.json'}, which is shared with anyone who has the repo.`+ }isActive={isActive}searchEntries={entries}forceVisible={forceVisible}diff --git a/src/renderer/lib/projectCloseSessions.test.ts b/src/renderer/lib/projectCloseSessions.test.tsindex 0fad0df5d..774a149f4 100644--- a/src/renderer/lib/projectCloseSessions.test.ts+++ b/src/renderer/lib/projectCloseSessions.test.ts@@ -86,6 +86,12 @@ describe('deleteConfirmCopy', () => {expect(c.confirmLabel).toBe('Delete')})+ it('a project stored in app data: says the canvas goes with it (#1145)', () => {+ const c = deleteConfirmCopy({ ...project({ nodes: [{ id: 't1' }] }), storeInAppData: true })+ expect(c.message).toContain('the canvas is: it was stored in app data')+ expect(c.message).not.toContain('.nodeterm/project.json')+ })+it('ssh delete: names the host the sessions end on (label preferred)', () => {const c = deleteConfirmCopy(project({ nodes: [{ id: 't1' }], ssh: { label: 'prod' } }))expect(c.message).toContain('ends its 1 terminal session on prod')diff --git a/src/renderer/lib/projectCloseSessions.ts b/src/renderer/lib/projectCloseSessions.tsindex 8dcbfcb49..bbf426549 100644--- a/src/renderer/lib/projectCloseSessions.ts+++ b/src/renderer/lib/projectCloseSessions.ts@@ -26,7 +26,7 @@import type { Project, SessionMemoryRow } from '@shared/types'-type ProjectLike = Pick<Project, 'name' | 'nodes' | 'remote' | 'ssh'>+type ProjectLike = Pick<Project, 'name' | 'nodes' | 'remote' | 'ssh' | 'storeInAppData'>/** The node ids whose tmux sessions a close-with-end / delete addresses (terminal-kind only). */export function terminalNodeIds(project: Pick<Project, 'nodes'>): string[] {@@ -114,10 +114,12 @@ export function deleteConfirmCopy(project: ProjectLike): DeleteConfirmCopy {? `ends its ${n} terminal session${plural(n)} on ${sshHostLabel(project)} and `: `ends its ${n} terminal session${plural(n)} and `const where = project.ssh ? 'on the server' : 'on disk'+ // A project stored in app data (#1145) has no copy in its folder: removing it deletes the canvas.+ const tail = project.storeInAppData && !project.ssh+ ? `The folder ${where} is not deleted, but the canvas is: it was stored in app data, not in the folder.`+ : `The folder ${where} (including .nodeterm/project.json) is not deleted.`return {- message:- `Delete “${name}”? This ${sessions}removes the project from nodeterm. The folder ${where} ` +- `(including .nodeterm/project.json) is not deleted.`,+ message: `Delete “${name}”? This ${sessions}removes the project from nodeterm. ${tail}`,confirmLabel: 'Delete',danger: true}diff --git a/src/renderer/lib/projectOpen.ts b/src/renderer/lib/projectOpen.tsindex 95d94ab8d..79d22c7b1 100644--- a/src/renderer/lib/projectOpen.ts+++ b/src/renderer/lib/projectOpen.ts@@ -375,12 +375,17 @@ export function nextFreePosition(export type UnavailableRecovery = 'clear' | 'rehydrate' | 'keep'export function unavailableRecovery(- project: { unavailable?: boolean; ssh?: unknown },+ project: { unavailable?: boolean; ssh?: unknown; storeInAppData?: boolean },fileState: 'present' | 'absent' | 'unreadable'): UnavailableRecovery {// Remote projects are not ours to judge from a local stat — their file lives on the host, and// their placeholder is cleared by the reconnect path instead.if (!project.unavailable || project.ssh) return 'keep'+ // A project stored in app data (#1145) never had its canvas in the folder: a project.json there+ // is a stale copy or a teammate's, never this project's to rehydrate from. Its placeholder means+ // its app-data file and cache are both gone, so opening the folder starts it again, empty, in app+ // data — and the store still refuses to write that empty canvas over a data file that reappears.+ if (project.storeInAppData) return 'clear'if (fileState === 'absent') return 'clear'if (fileState === 'present') return 'rehydrate'return 'keep'diff --git a/src/renderer/lib/projectStorageMove.test.ts b/src/renderer/lib/projectStorageMove.test.tsnew file mode 100644index 000000000..4cd9576a6--- /dev/null+++ b/src/renderer/lib/projectStorageMove.test.ts@@ -0,0 +1,85 @@+// Issue #1145: the tab menu's move between a project's folder and app data. What these pin is the+// ORDER — the folder copy goes only after the app-data save landed, the folder is probed before the+// canvas is pointed at it — and that a failed save puts the flag back.+import { describe, expect, it } from 'vitest'+import { moveProjectToAppData, moveProjectToFolder, type ProjectStorageMoveDeps } from './projectStorageMove'+import type { PrepareFolderStorageResult, ReleaseFolderFilesResult } from '@shared/project-storage'++function harness(opts: {+ saves?: boolean[]+ release?: ReleaseFolderFilesResult[]+ prepare?: PrepareFolderStorageResult+ confirm?: boolean+} = {}) {+ const log: string[] = []+ const saves = [...(opts.saves ?? [true])]+ const releases = [...(opts.release ?? [{ ok: true, removed: ['/r/.nodeterm/project.json'], kept: [] }])]+ const notices: Array<{ kind: string; text: string }> = []+ const deps: ProjectStorageMoveDeps = {+ setStoreInAppData: (_id, on) => { log.push(`flag:${on}`) },+ persist: async () => { log.push('save'); return saves.shift() ?? true },+ release: async (_id, removeTracked) => { log.push(`release:${removeTracked}`); return releases.shift()! },+ prepare: async () => { log.push('prepare'); return opts.prepare ?? { ok: true } },+ confirm: async () => { log.push('confirm'); return opts.confirm ?? false },+ notice: (kind, text) => { notices.push({ kind, text }) }+ }+ return { deps, log, notices }+}++describe('moveProjectToAppData', () => {+ it('saves into app data BEFORE releasing the folder files', async () => {+ const h = harness()+ await moveProjectToAppData('p1', h.deps)+ expect(h.log).toEqual(['flag:true', 'save', 'release:false'])+ expect(h.notices).toEqual([{ kind: 'info', text: 'Canvas stored in app data. Nothing of it is left in the folder.' }])+ })++ it('a failed save puts the flag back and removes nothing from the folder', async () => {+ const h = harness({ saves: [false] })+ await moveProjectToAppData('p1', h.deps)+ expect(h.log).toEqual(['flag:true', 'save', 'flag:false'])+ expect(h.notices[0].kind).toBe('error')+ })++ it('asks before deleting files git tracks, and keeps them on no', async () => {+ const h = harness({ release: [{ ok: true, removed: [], kept: ['/r/.nodeterm/project.json'] }], confirm: false })+ await moveProjectToAppData('p1', h.deps)+ expect(h.log).toEqual(['flag:true', 'save', 'release:false', 'confirm'])+ expect(h.notices[0].text).toContain('Kept in the folder: .nodeterm/project.json')+ })++ it('deletes them on yes', async () => {+ const h = harness({+ release: [+ { ok: true, removed: [], kept: ['/r/.nodeterm/project.json'] },+ { ok: true, removed: ['/r/.nodeterm/project.json'], kept: [] }+ ],+ confirm: true+ })+ await moveProjectToAppData('p1', h.deps)+ expect(h.log).toEqual(['flag:true', 'save', 'release:false', 'confirm', 'release:true'])+ expect(h.notices[0].text).toBe('Canvas stored in app data. Nothing of it is left in the folder.')+ })+})++describe('moveProjectToFolder', () => {+ it('probes the folder BEFORE pointing the canvas at it', async () => {+ const h = harness()+ await moveProjectToFolder('p1', h.deps)+ expect(h.log).toEqual(['prepare', 'flag:false', 'save'])+ })++ it('an occupied folder changes nothing and says why', async () => {+ const h = harness({ prepare: { ok: false, reason: 'occupied' } })+ await moveProjectToFolder('p1', h.deps)+ expect(h.log).toEqual(['prepare'])+ expect(h.notices[0]).toMatchObject({ kind: 'error' })+ expect(h.notices[0].text).toContain('already has a .nodeterm/project.json')+ })++ it('a failed save puts the flag back', async () => {+ const h = harness({ saves: [false] })+ await moveProjectToFolder('p1', h.deps)+ expect(h.log).toEqual(['prepare', 'flag:false', 'save', 'flag:true'])+ })+})diff --git a/src/renderer/lib/projectStorageMove.ts b/src/renderer/lib/projectStorageMove.tsnew file mode 100644index 000000000..e12560ab6--- /dev/null+++ b/src/renderer/lib/projectStorageMove.ts@@ -0,0 +1,76 @@+// Moving a folder project's canvas between its folder and app data (issue #1145), from the tab+// menu. Each direction is a save plus one core step, and the ORDER is the safety:+//+// - Into app data: flag → save (the canvas lands in `userData/inline-projects/<id>.json`) → THEN+// `releaseFolderFiles` removes the folder's `.nodeterm` files. The core refuses that step unless+// the data file demonstrably holds the canvas, and keeps any file git tracks until the user+// says otherwise — deleting it is a change in their repo.+// - Into the folder: `prepareFolderStorage` first (refuses a folder that already holds a canvas or+// settings, which the save would overwrite — the "Set folder…" probe-before-bind rule) → flag →+// save. The store deletes the app-data copy only after the folder file has landed.+//+// Pure of React and the stores; Canvas passes the levers.+import {+ PREPARE_FOLDER_STORAGE_REFUSALS,+ type PrepareFolderStorageResult,+ type ReleaseFolderFilesResult+} from '@shared/project-storage'++export interface ProjectStorageMoveDeps {+ setStoreInAppData(projectId: string, on: boolean): void+ /** Saves the workspace; resolves false when the save did not land. */+ persist(): Promise<boolean>+ release(projectId: string, removeTracked: boolean): Promise<ReleaseFolderFilesResult>+ prepare(projectId: string): Promise<PrepareFolderStorageResult>+ confirm(message: string, confirmLabel: string): Promise<boolean>+ notice(kind: 'info' | 'error', text: string): void+}++const baseName = (file: string): string => file.split(/[\\/]/).slice(-2).join('/')++export async function moveProjectToAppData(projectId: string, deps: ProjectStorageMoveDeps): Promise<void> {+ deps.setStoreInAppData(projectId, true)+ if (!(await deps.persist())) {+ // The canvas did not reach app data. Put the flag back so the folder stays the record, and+ // remove nothing from it.+ deps.setStoreInAppData(projectId, false)+ deps.notice('error', 'The canvas could not be saved to app data, so it stays in the folder.')+ return+ }+ let res = await deps.release(projectId, false)+ if (!res.ok) {+ deps.notice('error', 'The canvas is in app data, but its folder files were left in place.')+ return+ }+ if (res.kept.length) {+ const list = res.kept.map(baseName).join(', ')+ const remove = await deps.confirm(+ `The canvas is now stored in app data. Git tracks ${list} in this folder, so deleting ` ++ `${res.kept.length > 1 ? 'them' : 'it'} shows up as a change in the repository. Delete anyway?`,+ 'Delete'+ )+ if (remove) res = await deps.release(projectId, true)+ }+ const kept = res.ok ? res.kept : []+ deps.notice(+ 'info',+ kept.length+ ? `Canvas stored in app data. Kept in the folder: ${kept.map(baseName).join(', ')}.`+ : 'Canvas stored in app data. Nothing of it is left in the folder.'+ )+}++export async function moveProjectToFolder(projectId: string, deps: ProjectStorageMoveDeps): Promise<void> {+ const ready = await deps.prepare(projectId)+ if (!ready.ok) {+ deps.notice('error', PREPARE_FOLDER_STORAGE_REFUSALS[ready.reason])+ return+ }+ deps.setStoreInAppData(projectId, false)+ if (!(await deps.persist())) {+ deps.setStoreInAppData(projectId, true)+ deps.notice('error', 'The canvas could not be written to the folder, so it stays in app data.')+ return+ }+ deps.notice('info', 'Canvas stored in the folder, in .nodeterm/project.json.')+}diff --git a/src/renderer/lib/unavailableRecovery.test.ts b/src/renderer/lib/unavailableRecovery.test.tsindex 14370faaf..81e39af9c 100644--- a/src/renderer/lib/unavailableRecovery.test.ts+++ b/src/renderer/lib/unavailableRecovery.test.ts@@ -31,6 +31,15 @@ describe('unavailableRecovery', () => {expect(unavailableRecovery({ unavailable: false }, 'absent')).toBe('keep')})+ it('never rehydrates a project stored in app data from its folder (#1145)', () => {+ // Whatever the folder holds is a stale copy or a teammate's canvas, never this project's.+ const appData = { unavailable: true, storeInAppData: true }+ expect(unavailableRecovery(appData, 'present')).toBe('clear')+ expect(unavailableRecovery(appData, 'absent')).toBe('clear')+ expect(unavailableRecovery(appData, 'unreadable')).toBe('clear')+ expect(unavailableRecovery({ storeInAppData: true }, 'present')).toBe('keep')+ })+it('never judges a REMOTE project from a local stat — its file lives on the host', () => {expect(unavailableRecovery({ unavailable: true, ssh: { server: {} } }, 'absent')).toBe('keep')})diff --git a/src/renderer/state/projects.ts b/src/renderer/state/projects.tsindex 71637e819..3eb737c06 100644--- a/src/renderer/state/projects.ts+++ b/src/renderer/state/projects.ts@@ -32,6 +32,7 @@ import { applyOwnCanvasMutation, createProject, reorderGroupWithinParent } fromimport { registerCodexRelayProjectCheck } from './codexCli'import { markWorkspaceDirty } from './workspaceDirty'import { folderName } from '../lib/projectOpen'+import { useSettings } from './settings'// One order-independent key for an edge's endpoints — the SAME rule `hiddenLinkIds` uses, so a// rope and the bridge it covers are recognized as one relationship here too.import { pairKey as bridgePairKey } from '../lib/noteLink'@@ -95,6 +96,9 @@ interface ProjectsState {* on `Project.icon` and git-shared via project.json like name/color. No-op for an unknown id. */setProjectIcon(id: string, icon: ProjectIcon | undefined): voidsetProjectCwd(id: string, cwd: string): void+ /** Issue #1145: where this folder project's canvas is stored. Only the flag — the move itself+ * (save, then the core step) is `lib/projectStorageMove`. */+ setProjectStoreInAppData(id: string, on: boolean): void/** Grey (or un-grey) a project tab as "unavailable" WITHOUT dropping it — runtime-only, never* persisted (see the toWorkspace tripwire). Set true when a relay tab's socket drops (Stage 4* Task 7) so it stays reconnectable; cleared when it reconnects. */@@ -322,6 +326,16 @@ interface ProjectsState {toWorkspace(): Workspace}+/**+ * A local folder project CREATED from now on (never one adopted from an existing project.json)+ * keeps its canvas where Settings → Behavior says (issue #1145).+ */+function withNewProjectStorage(project: Project): Project {+ return project.cwd && !project.ssh && useSettings.getState().settings.newProjectStorage === 'appData'+ ? { ...project, storeInAppData: true }+ : project+}+/** A persisted node's position in ROOT space: its own plus every ancestor frame's origin. */function rootStatePosition(node: CanvasNodeState,@@ -514,7 +528,7 @@ export const useProjects = create<ProjectsState>((set, get) => ({// Every new project's name — a folder's own name, an SSH label, a relay host's project// name — gets the same cap as a rename (issue #940). A blank one keeps createProject's default.const clean = name === undefined ? undefined : clampProjectName(name) || undefined- const project = createProject(get().projects.length, clean, cwd, ssh)+ const project = withNewProjectStorage(createProject(get().projects.length, clean, cwd, ssh))set((s) => ({ projects: [...s.projects, project] }))return project},@@ -597,6 +611,17 @@ export const useProjects = create<ProjectsState>((set, get) => ({}))},+ setProjectStoreInAppData(id, on) {+ set((s) => ({+ projects: s.projects.map((p) => {+ if (p.id !== id) return p+ if (on) return { ...p, storeInAppData: true }+ const { storeInAppData: _drop, ...rest } = p+ return rest+ })+ }))+ },+setProjectUnavailable(id, unavailable) {set((s) => ({projects: s.projects.map((p) => (p.id === id ? { ...p, unavailable } : p))@@ -1126,7 +1151,7 @@ export const useProjects = create<ProjectsState>((set, get) => ({const fallbackName = clampProjectName(folderName(cwd)) || 'Project'// `name` is the agent's `--name`, free text like a rename: same cap (issue #940).const project = {- ...createProject(get().projects.length, clampProjectName(name ?? '') || fallbackName, cwd),+ ...withNewProjectStorage(createProject(get().projects.length, clampProjectName(name ?? '') || fallbackName, cwd)),...(color ? { color } : {})}set((s) => ({ projects: [...s.projects, project] }))diff --git a/src/shared/types.ts b/src/shared/types.tsindex 50b1afd17..2ec4ec493 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -1982,6 +1982,11 @@ export interface Settings {* (`$reponame` and `$defaultFolderName` aliases) plus `$branch`; both `$x` and `${x}` forms.* A missing branch token is appended automatically. */worktreePathTemplate: string+ /** Issue #1145. Where a folder project created from now on keeps its canvas: `'folder'` (the+ * default — `<cwd>/.nodeterm/project.json`, git-shareable) or `'appData'` (nothing written into+ * the folder; see `Project.storeInAppData`). A folder that already has a project.json is adopted+ * as it is, in its folder, whatever this says. Existing projects move from the tab menu. */+ newProjectStorage: import('./project-storage').NewProjectStorage/** ms to dwell over a terminal before it takes pointer focus (pan-across guard). */panHoverDelay: number/** Issue #757. Whether a terminal node's keyboard focus follows the POINTER (the long-standing@@ -2469,6 +2474,7 @@ export const DEFAULT_SETTINGS: Settings = {omniKanbanEnabled: false,omniKanbanAsDefault: false,worktreePathTemplate: DEFAULT_WORKTREE_PATH_TEMPLATE,+ newProjectStorage: 'folder',panHoverDelay: 600,terminalFocusFollowsPointer: true,doubleClickFocus: true,