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(project): the one-time clone notice, decided once for every capability
Claude Code6c748abe3419
diff --git a/src/core/project-capability-consent.test.ts b/src/core/project-capability-consent.test.tsnew file mode 100644index 000000000..a54cea1a4--- /dev/null+++ b/src/core/project-capability-consent.test.ts@@ -0,0 +1,103 @@+import { describe, it, expect } from 'vitest'+import type { Project } from '../shared/types'+import {+ needsCapabilityNotice,+ projectCapabilityGranted,+ recordCapabilityAck+} from './project-capability-consent'+import * as shared from '../shared/project-capability-consent'+import { projectToFile, type IndexEntryV3 } from './workspace-files'++const baseProject: Project = {+ id: 'p1',+ name: 'p',+ color: '#fff',+ viewport: { x: 0, y: 0, zoom: 1 },+ nodes: []+}++describe('needsCapabilityNotice', () => {+ const cap = 'agentBrowserControl' as const+ it('off in the file ⇒ never a notice', () => {+ expect(needsCapabilityNotice({ capability: cap, enabledInFile: false, acknowledged: false })).toBe(false)+ })+ it('on in the file and never acknowledged ON THIS MACHINE ⇒ notice', () => {+ expect(needsCapabilityNotice({ capability: cap, enabledInFile: true, acknowledged: false })).toBe(true)+ })+ it('on and acknowledged ⇒ silent forever after', () => {+ expect(needsCapabilityNotice({ capability: cap, enabledInFile: true, acknowledged: true })).toBe(false)+ })+})++describe('projectCapabilityGranted — a pending notice is a refusal, not a grant', () => {+ const cap = 'agentBrowserControl' as const+ it('a switch that is on but unanswered grants nothing', () => {+ // This is what the ledger (browser PR 4) and messagingEnabled (messaging PR 6) consult: the+ // window between a hostile clone's `agentBrowserControl: true` arriving and the user answering+ // the notice must be a refusal. Deleting the `acknowledged` condition makes this red.+ expect(projectCapabilityGranted({ capability: cap, enabledInFile: true, acknowledged: false })).toBe(false)+ })+ it('off in the file grants nothing, acknowledged or not', () => {+ expect(projectCapabilityGranted({ capability: cap, enabledInFile: false, acknowledged: true })).toBe(false)+ })+ it('on and acknowledged is the one granting combination', () => {+ expect(projectCapabilityGranted({ capability: cap, enabledInFile: true, acknowledged: true })).toBe(true)+ })+})++describe('the acknowledgment is MACHINE-LOCAL', () => {+ it('recordCapabilityAck writes to the index entry, never to the project file', () => {+ const e = recordCapabilityAck({ id: 'p1', name: 'p', color: '#fff' } as IndexEntryV3, 'agentBrowserControl')+ expect(e.capabilityAck).toEqual({ agentBrowserControl: true })+ // The shared file must not learn about it: projectToFile writes only the capability FIELDS.+ expect(Object.keys(projectToFile({ ...baseProject, agentBrowserControl: true }, 1, 't', 'l')))+ .not.toContain('capabilityAck')+ })++ it('does not mutate its input and keeps earlier acks', () => {+ const before: IndexEntryV3 = {+ id: 'p1',+ name: 'p',+ color: '#fff',+ capabilityAck: { agentBrowserControl: true }+ }+ const after = recordCapabilityAck(before, 'agentBrowserControl')+ expect(after).not.toBe(before)+ expect(before.capabilityAck).toEqual({ agentBrowserControl: true })+ expect(after.capabilityAck).toEqual({ agentBrowserControl: true })+ })++ it('a SECOND WORKTREE of the same repo notifies again', () => {+ // node ids and project.json re-materialise in a second folder (git worktree add / checkout /+ // reset --hard), and workspace-files.ts is explicit that the index entry id is the only+ // authority for project identity. A second folder is a second entry, hence a second notice —+ // which is correct: it is a different working copy the user has not vetted.+ const a = recordCapabilityAck({ id: 'p1', name: 'p', color: '#fff' } as IndexEntryV3, 'agentBrowserControl')+ const b = { id: 'p2', name: 'p', color: '#fff' } // same repo, second worktree, fresh entry+ expect(+ needsCapabilityNotice({+ capability: 'agentBrowserControl',+ enabledInFile: true,+ acknowledged: !!a.capabilityAck?.agentBrowserControl+ })+ ).toBe(false)+ expect(+ needsCapabilityNotice({+ capability: 'agentBrowserControl',+ enabledInFile: true,+ acknowledged: !!(b as IndexEntryV3).capabilityAck?.agentBrowserControl+ })+ ).toBe(true)+ })+})++describe('one decider, two consumers', () => {+ it('core re-exports the SAME functions the renderer imports from @shared — no drift possible', () => {+ // Same rule as isSafeNodeId: the renderer may not import src/core, so the implementation lives+ // in @shared/project-capability-consent and this core path re-exports it for main/core callers+ // (agent-messaging PR 6 Task 6.2 must not reimplement either function).+ expect(needsCapabilityNotice).toBe(shared.needsCapabilityNotice)+ expect(recordCapabilityAck).toBe(shared.recordCapabilityAck)+ expect(projectCapabilityGranted).toBe(shared.projectCapabilityGranted)+ })+})diff --git a/src/core/project-capability-consent.ts b/src/core/project-capability-consent.tsnew file mode 100644index 000000000..9f1aaac1f--- /dev/null+++ b/src/core/project-capability-consent.ts@@ -0,0 +1,14 @@+/**+ * Core/main-side path to the clone-notice decider. The IMPLEMENTATION lives in+ * `@shared/project-capability-consent` because the renderer raises the dialog and may not import+ * `src/core`; this re-export exists so core/main callers (agent-messaging PR 6 Task 6.2 among+ * them) have a core-local name without a second implementation.+ * `project-capability-consent.test.ts` pins that both paths are the same function objects.+ */+export {+ needsCapabilityNotice,+ projectCapabilityGranted,+ recordCapabilityAck,+ type CapabilityAckMap,+ type CapabilityConsentState+} from '../shared/project-capability-consent'diff --git a/src/core/workspace-files.test.ts b/src/core/workspace-files.test.tsindex 6a27d125c..c58db6369 100644--- a/src/core/workspace-files.test.ts+++ b/src/core/workspace-files.test.ts@@ -84,6 +84,25 @@ describe('per-project capability fields in the shared file', () => {expect('agentBrowserControl' in f).toBe(false)expect(serializeProjectFile(f)).not.toContain('agentBrowserControl')})+ it('the ack is machine-local: index entry carries it, the shared file never does', () => {+ const p = project({ cwd: '/a/foo', agentBrowserControl: true, capabilityAck: { agentBrowserControl: true } })+ const { index, files } = splitWorkspace(+ { version: 2, activeProjectId: 'p1', projects: [p] },+ () => 1,+ '2026-08-15T00:00:00.000Z'+ )+ expect(index.entries[0].capabilityAck).toEqual({ agentBrowserControl: true })+ expect(serializeProjectFile(files.get('/a/foo')!)).not.toContain('capabilityAck')+ // Load: the ack comes from the entry; a file-borne `capabilityAck` (forgery — a repo carrying+ // its own consent) is never read.+ const restored = fileToProject(files.get('/a/foo')!, { id: 'p1', cwd: '/a/foo', capabilityAck: { agentBrowserControl: true } })+ expect(restored.capabilityAck).toEqual({ agentBrowserControl: true })+ const forged = fileToProject(+ { ...files.get('/a/foo')!, capabilityAck: { agentBrowserControl: true } } as never,+ { id: 'p1', cwd: '/a/foo' }+ )+ expect(forged.capabilityAck).toBeUndefined()+ })})describe('sameProjectContent', () => {diff --git a/src/core/workspace-files.ts b/src/core/workspace-files.tsindex 37022bf3e..a4a86fc74 100644--- a/src/core/workspace-files.ts+++ b/src/core/workspace-files.ts@@ -99,6 +99,13 @@ export interface IndexEntryV3 {/** MACHINE-LOCAL default managed Claude account for a ref'd project: the id names a credential* dir in THIS machine's userData, so it is meaningless in anyone else's checkout. */defaultAccountId?: string+ /**+ * MACHINE-LOCAL record that this machine's user has acknowledged each capability switch for THIS+ * entry (the one-time clone notice, @shared/project-capability-consent). Never copied into the+ * shared project file — a repo must not be able to carry its own consent — and keyed to the+ * entry, so a second worktree of the same repo (a second entry) notifies again, on purpose.+ */+ capabilityAck?: import('../shared/project-capability-consent').CapabilityAckMapcwd?: stringssh?: Project['ssh']cache?: ProjectFileV1@@ -231,6 +238,8 @@ export function fileToProject(viewport?: Viewport/** This machine's default managed account; falls back to the file's legacy value. */defaultAccountId?: string+ /** This machine's clone-notice acknowledgments for this entry (never from the file). */+ capabilityAck?: import('../shared/project-capability-consent').CapabilityAckMap/** This machine's own exec values for these nodes (from the local index entry). A file read* WITHOUT them — an adopted/cloned folder, a probe — gets the safe defaults, never the file's* own `shell`/`ssh.extraArgs`. */@@ -257,7 +266,10 @@ export function fileToProject(...(validKanban(f.kanban) ? { kanban: f.kanban } : {}),...(base.cwd ? { cwd: base.cwd } : {}),...(base.ssh ? { ssh: base.ssh } : {}),- ...(base.closed ? { closed: true } : {})+ ...(base.closed ? { closed: true } : {}),+ // Machine-local, from the index entry ONLY: a file field named `capabilityAck` is a forgery+ // attempt (the shared file cannot carry this machine's consent) and is simply never read.+ ...(base.capabilityAck ? { capabilityAck: base.capabilityAck } : {})}}@@ -343,7 +355,10 @@ export function splitWorkspace(// Inline entries need none of this: they store the whole Project verbatim.const localState = {...(p.viewport ? { viewport: p.viewport } : {}),- ...(p.defaultAccountId ? { defaultAccountId: p.defaultAccountId } : {})+ ...(p.defaultAccountId ? { defaultAccountId: p.defaultAccountId } : {}),+ // The clone-notice acknowledgment rides the machine-local entry, never the shared file+ // (projectToFile does not emit it — pinned by project-capability-consent.test.ts).+ ...(p.capabilityAck ? { capabilityAck: p.capabilityAck } : {})}if (p.unavailable) {// Placeholder (folder missing / server unreachable at load): its nodes:[] is not realdiff --git a/src/core/workspace-store.ts b/src/core/workspace-store.tsindex a3bc30a84..63633ab86 100644--- a/src/core/workspace-store.ts+++ b/src/core/workspace-store.ts@@ -244,6 +244,7 @@ export class WorkspaceStore {closed: e.closed,viewport: e.viewport,defaultAccountId: e.defaultAccountId,+ capabilityAck: e.capabilityAck,localExec: this.execOverlay(e, p)})})@@ -262,6 +263,7 @@ export class WorkspaceStore {closed: e.closed,viewport: e.viewport,defaultAccountId: e.defaultAccountId,+ capabilityAck: e.capabilityAck,localExec: this.execOverlay(e, e.cache)})})@@ -482,6 +484,9 @@ export class WorkspaceStore {// moment a folder is briefly unmounted.if (old?.viewport) e.viewport = old.viewportif (old?.defaultAccountId) e.defaultAccountId = old.defaultAccountId+ // The clone-notice acknowledgment must also survive an unavailable window: forgetting it+ // would re-raise a notice the user already answered the moment the folder remounts.+ if (old?.capabilityAck) e.capabilityAck = old.capabilityAck}}@@ -615,6 +620,7 @@ export class WorkspaceStore {closed: e.closed,viewport: e.viewport,defaultAccountId: e.defaultAccountId,+ capabilityAck: e.capabilityAck,localExec: e.localExec})}@@ -860,6 +866,7 @@ export class WorkspaceStore {closed: e.closed,viewport: e.viewport,defaultAccountId: e.defaultAccountId,+ capabilityAck: e.capabilityAck,localExec: e.localExec}))@@ -921,7 +928,8 @@ export class WorkspaceStore {this.revs.set(e.id, e.cache.rev)return fileToProject(e.cache, {id: e.id, ssh: e.ssh, closed: e.closed,- viewport: e.viewport, defaultAccountId: e.defaultAccountId, localExec: e.localExec+ viewport: e.viewport, defaultAccountId: e.defaultAccountId,+ capabilityAck: e.capabilityAck, localExec: e.localExec})}@@ -1027,7 +1035,8 @@ export class WorkspaceStore {else this.unmirrored.delete(e.id) // pure adopt: the server copy IS the truth now — nothing owedreturn fileToProject(adopted, {id: e.id, ssh: e.ssh, closed: e.closed,- viewport: e.viewport, defaultAccountId: e.defaultAccountId, localExec: e.localExec+ viewport: e.viewport, defaultAccountId: e.defaultAccountId,+ capabilityAck: e.capabilityAck, localExec: e.localExec})}// Our cache stood. Before it clobbers the server, merge in any remote-only session nodes (the@@ -1041,7 +1050,8 @@ export class WorkspaceStore {this.unmirrored.add(e.id) // the merged set must land on the servermerged = fileToProject(e.cache, {id: e.id, ssh: e.ssh, closed: e.closed,- viewport: e.viewport, defaultAccountId: e.defaultAccountId, localExec: e.localExec+ viewport: e.viewport, defaultAccountId: e.defaultAccountId,+ capabilityAck: e.capabilityAck, localExec: e.localExec})}}diff --git a/src/shared/project-capability-consent.ts b/src/shared/project-capability-consent.tsnew file mode 100644index 000000000..b44e85783--- /dev/null+++ b/src/shared/project-capability-consent.ts@@ -0,0 +1,59 @@+/**+ * The one-time clone notice, decided ONCE for every capability — pure, shared, and the only+ * decider either feature may use (browser control here in PR 3; agent messaging adopts it in its+ * PR 6 without reimplementing anything).+ *+ * A switch that arrives from a clone is not the same thing as a switch the user set:+ * `.nodeterm/project.json` is git-shared and hand-editable, so `agentBrowserControl: true` in a+ * freshly cloned repo is a stranger's decision until this machine's user has seen it. The+ * acknowledgment is therefore recorded MACHINE-LOCALLY (`IndexEntryV3.capabilityAck` — the index+ * entry is the only authority for project identity), never in the shared file; a second worktree+ * of the same repo is a second entry, hence a second notice, on purpose.+ *+ * Lives in `src/shared` for the same reason as `safe-id.ts`: the renderer raises the dialog and may+ * not import `src/core`; `core/project-capability-consent.ts` re-exports these for main/core+ * callers, and its test pins that the two paths are the same function objects.+ */+import type { ProjectCapability } from './project-capabilities'++/** The machine-local ack record, keyed like the capability fields but never written to the shared+ * project file (`projectToFile` does not know this shape exists — pinned by the consent test). */+export type CapabilityAckMap = Partial<Record<ProjectCapability, true>>++export interface CapabilityConsentState {+ capability: ProjectCapability+ /** The strict read of the shared file's switch (`projectCapabilityEnabled` — literal true only). */+ enabledInFile: boolean+ /** Has THIS MACHINE's user answered the notice for this project entry (or personally set the+ * switch, which is its own acknowledgment)? */+ acknowledged: boolean+}++/** On in the file + never acknowledged on this machine ⇒ notice. Everything else is silence:+ * off needs no warning, and an answered notice is answered forever (per index entry). */+export function needsCapabilityNotice(s: CapabilityConsentState): boolean {+ return s.enabledInFile === true && s.acknowledged !== true+}++/**+ * May the capability act RIGHT NOW? A pending notice is a refusal, not a grant: the window between+ * a hostile clone's `agentBrowserControl: true` arriving and the user answering the notice must+ * refuse (`project-capability-consent.test.ts` — "a switch that is on but unanswered grants+ * nothing"). This is the predicate the browser ledger's admission check (PR 4) and messaging's+ * `messagingEnabled` wiring (PR 6) consult per call — never cached at lease start.+ */+export function projectCapabilityGranted(s: CapabilityConsentState): boolean {+ return s.enabledInFile === true && !needsCapabilityNotice(s)+}++/**+ * Returns `entry` with the capability acknowledged — a new object, input untouched. Works on any+ * entry-shaped record (`IndexEntryV3` in main, the renderer's `Project` mirror of the same+ * machine-local field) so both sides record the ack through the one function.+ */+export function recordCapabilityAck<E extends { capabilityAck?: CapabilityAckMap }>(+ entry: E,+ cap: ProjectCapability+): E {+ return { ...entry, capabilityAck: { ...entry.capabilityAck, [cap]: true } }+}