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): tell someone once when a cloned repo arrives with a capability switched on
Claude Codee59c8c1866f9
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex bc01569b9..689305977 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -145,6 +145,7 @@ import { TmuxBanner } from '../components/TmuxBanner'import { PtyPressureBanner } from '../components/PtyPressureBanner'import { ConflictBar } from '../components/ConflictBar'import { ConfirmDialog } from '../components/ConfirmDialog'+import { CapabilityNotice } from '../components/CapabilityNotice'import { ConsentNotice } from '../remote/ConsentNotice'import { peerApprovalView } from '@shared/remote/approval'import { promptDialog } from '../components/promptDialog'@@ -9063,6 +9064,12 @@ export function Canvas() {onMouseLeave={closeSessionsPeekSoon}/>+ {/* The one-time clone notice for a project whose git-shared capability switch arrived+ already on (PR 3 Task 3.4). Self-contained against the projects store: it re-evaluates on+ every active-project change (the project-load path), is click-only, and records its+ answer machine-locally — see components/CapabilityNotice.tsx and its test. */}+ <CapabilityNotice />+{confirm && (<ConfirmDialogmessage={confirm.message}diff --git a/src/renderer/components/CapabilityNotice.tsx b/src/renderer/components/CapabilityNotice.tsxnew file mode 100644index 000000000..455fb9b98--- /dev/null+++ b/src/renderer/components/CapabilityNotice.tsx@@ -0,0 +1,86 @@+import { useProjects } from '../state/projects'+import type { Project } from '@shared/types'+import {+ PROJECT_CAPABILITIES,+ PROJECT_CAPABILITY_COPY,+ projectCapabilityEnabled,+ type ProjectCapability+} from '@shared/project-capabilities'+import { needsCapabilityNotice } from '@shared/project-capability-consent'+import { ConfirmDialog } from './ConfirmDialog'++/**+ * The first capability whose git-shared switch is on for this project while this machine's user+ * has never answered for it. Pure and per-capability so agent messaging's switch (its PR 6) gets+ * this dialog by adding a copy entry — there is nothing per-feature below.+ */+export function pendingCapabilityNotice(p: Project | undefined): ProjectCapability | null {+ if (!p) return null+ for (const cap of PROJECT_CAPABILITIES) {+ const pending = needsCapabilityNotice({+ capability: cap,+ // Strict read: a hand-edited "true"/1/{} is off, so it can never raise (or need) a notice.+ enabledInFile: projectCapabilityEnabled(p, cap),+ acknowledged: p.capabilityAck?.[cap] === true+ })+ if (pending) return cap+ }+ return null+}++/**+ * THE ONE-TIME CLONE NOTICE — the one thing standing between a hostile `.nodeterm/project.json`+ * and a grant, so every property here is security-shaped and test-named:+ *+ * - It exists because a capability switch is git-shared: a teammate (or a stranger's repo) can+ * commit `agentBrowserControl: true`, and the user who cloned it was never asked. The warning+ * at the point of SETTING (Settings → Agents) cannot reach them; this dialog can.+ * - CLICK-ONLY (`enterConfirms={false}` — confirm-key.ts's rule for dialogs the user did not+ * open): it was raised by a FILE, and an Enter aimed at a terminal must not answer it.+ * capability-notice.test.tsx "is CLICK-ONLY" fails if this prop is dropped.+ * - Once per project EVER, proven by persistence, not by session state: the answer lands in+ * `Project.capabilityAck` → `IndexEntryV3.capabilityAck` (machine-local), never in the shared+ * file — "a second open does not re-notify" and workspace-files.test.ts pin both halves.+ * - While it is unanswered the capability GRANTS NOTHING: every consumer reads+ * `projectCapabilityGranted`, which refuses a pending notice ("does not grant while+ * unanswered"). This component never needs to race anyone.+ *+ * Renders against the ACTIVE project (the project-load path re-evaluates it on every switch), so+ * a background project's hostile file cannot pop a dialog about a canvas the user is not looking+ * at — they are told when they actually open it.+ */+export function CapabilityNotice(): React.JSX.Element | null {+ const activeProjectId = useProjects((s) => s.activeProjectId)+ const projects = useProjects((s) => s.projects)+ const setProjectCapability = useProjects((s) => s.setProjectCapability)+ const recordProjectCapabilityAck = useProjects((s) => s.recordProjectCapabilityAck)+ const project = projects.find((p) => p.id === activeProjectId)+ const cap = project ? pendingCapabilityNotice(project) : null+ if (!project || !cap) return null+ const copy = PROJECT_CAPABILITY_COPY[cap]+ return (+ <ConfirmDialog+ body={+ <div className="confirm__msg">+ <p>{copy.description}</p>+ <p>{copy.cloneWarning}</p>+ </div>+ }+ message={`The project "${project.name}" arrived with "${copy.label}" already switched on — it came from the project file, not from you. Keep it on?`}+ confirmLabel="Keep it on"+ cancelLabel="Turn it off"+ // "Keep it on" is the grant, so it carries the danger styling and — per ConfirmDialog's+ // rule — never the autofocus; Escape and the overlay click take the safe "Turn it off" path.+ danger+ enterConfirms={false}+ onConfirm={() => recordProjectCapabilityAck(project.id, cap)}+ onCancel={() => {+ // Answered too: the ack makes "once per project ever" true for this entry, and clearing+ // the field means the capability stays a refusal (and the file sheds the stranger's grant+ // on the next save this user makes).+ recordProjectCapabilityAck(project.id, cap)+ setProjectCapability(project.id, cap, false)+ }}+ />+ )+}diff --git a/src/renderer/components/capability-notice.test.tsx b/src/renderer/components/capability-notice.test.tsxnew file mode 100644index 000000000..bb09785ac--- /dev/null+++ b/src/renderer/components/capability-notice.test.tsx@@ -0,0 +1,157 @@+// @vitest-environment jsdom+//+// THE one thing standing between a hostile project.json and a grant (PR 3 Task 3.4): a cloned repo+// can arrive with `agentBrowserControl: true` already in its git-shared file. The notice must+// - appear on the project whose switch is on and whose machine-local entry holds no ack,+// - name the project and what the switch permits (the capability's own copy, not a paraphrase),+// - be CLICK-ONLY (it was raised by a file, not by the user — confirm-key.ts's enterConfirms rule),+// - record the answer machine-locally (Project.capabilityAck → IndexEntryV3.capabilityAck; the+// shared file's bytes are pinned unchanged by workspace-files.test.ts "the ack is machine-local"+// and project-capability-consent.test.ts — the renderer cannot import src/core to re-assert it),+// - never grant while unanswered: projectCapabilityGranted is false until the click.+import { describe, it, expect, beforeEach, afterEach } from 'vitest'+import { act } from 'react'+import { createRoot, type Root } from 'react-dom/client'+import type { Project } from '@shared/types'+import { PROJECT_CAPABILITY_COPY, projectCapabilityEnabled } from '@shared/project-capabilities'+import { projectCapabilityGranted } from '@shared/project-capability-consent'+import { useProjects } from '../state/projects'+import { CONFIRM_ARM_MS } from './confirm-key'+import { CapabilityNotice } from './CapabilityNotice'++;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true++const cap = 'agentBrowserControl' as const++const project = (over: Partial<Project> = {}): Project => ({+ id: 'p1',+ name: 'cloned-repo',+ color: '#7aa2f7',+ viewport: { x: 0, y: 0, zoom: 1 },+ nodes: [],+ ...over+})++let root: Root+let host: HTMLElement++function mount(): void {+ host = document.createElement('div')+ document.body.appendChild(host)+ root = createRoot(host)+ act(() => root.render(<CapabilityNotice />))+}++function unmount(): void {+ act(() => root.unmount())+ host.remove()+}++function dialog(): HTMLElement | null {+ return document.querySelector('.confirm')+}++function button(label: string): HTMLButtonElement {+ const el = [...document.querySelectorAll<HTMLButtonElement>('.confirm button')].find(+ (b) => b.textContent === label+ )+ expect(el, `button "${label}"`).toBeTruthy()+ return el!+}++/** The grantedness the ledger/messaging wiring would compute from the live store, per call. */+function grantedNow(): boolean {+ const p = useProjects.getState().getProject('p1')+ return projectCapabilityGranted({+ capability: cap,+ enabledInFile: projectCapabilityEnabled(p, cap),+ acknowledged: p?.capabilityAck?.[cap] === true+ })+}++beforeEach(() => {+ useProjects.setState({+ projects: [project({ [cap]: true })],+ activeProjectId: 'p1',+ reloadNonce: 0+ })+})++afterEach(() => {+ unmount()+ useProjects.setState({ projects: [], activeProjectId: '' })+})++describe('the one-time clone notice', () => {+ it('renders for an on-in-file, never-acknowledged project, naming the project and the grant', () => {+ mount()+ expect(dialog()).toBeTruthy()+ const text = dialog()!.textContent ?? ''+ expect(text).toContain('cloned-repo')+ expect(text).toContain(PROJECT_CAPABILITY_COPY[cap].description)+ expect(text).toContain(PROJECT_CAPABILITY_COPY[cap].cloneWarning)+ })++ it('is CLICK-ONLY: Enter aimed into the dialog confirms nothing', async () => {+ mount()+ // Outwait CONFIRM_ARM_MS first: a fresh dialog ignores Enter for 500ms REGARDLESS of+ // enterConfirms, so dispatching immediately would pass even if the click-only prop were+ // dropped. Past the arm window, only `enterConfirms={false}` stands between this Enter and a+ // confirmation — which is exactly the mutation this test exists to catch.+ await new Promise((r) => setTimeout(r, CONFIRM_ARM_MS + 150))+ const box = dialog()!+ act(() => {+ box.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }))+ window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }))+ })+ expect(dialog()).toBeTruthy()+ expect(useProjects.getState().getProject('p1')?.capabilityAck).toBeUndefined()+ })++ it('does not grant while unanswered — the switch alone is not consent', () => {+ mount()+ expect(grantedNow()).toBe(false)+ })++ it('"Keep it on": records the machine-local ack, leaves the shared field untouched, then grants', () => {+ mount()+ act(() => button('Keep it on').click())+ const p = useProjects.getState().getProject('p1')!+ expect(p.capabilityAck).toEqual({ [cap]: true })+ expect(p[cap]).toBe(true) // the git-shared half did not change — no bytes moved in the file+ expect(grantedNow()).toBe(true)+ expect(dialog()).toBeNull()+ })++ it('"Turn it off": clears the field, records the answer, and still grants nothing', () => {+ mount()+ act(() => button('Turn it off').click())+ const p = useProjects.getState().getProject('p1')!+ expect(p[cap]).toBeUndefined()+ expect(p.capabilityAck).toEqual({ [cap]: true })+ expect(grantedNow()).toBe(false)+ expect(dialog()).toBeNull()+ })++ it('a second open does not re-notify — the ack is once per project ever', () => {+ mount()+ act(() => button('Keep it on').click())+ unmount()+ mount()+ expect(dialog()).toBeNull()+ })++ it('never appears for a switch the user set personally — the setter is its own acknowledgment', () => {+ useProjects.setState({ projects: [project()], activeProjectId: 'p1' })+ useProjects.getState().setProjectCapability('p1', cap, true)+ mount()+ expect(dialog()).toBeNull()+ expect(grantedNow()).toBe(true)+ })++ it('stays silent when the switch is off', () => {+ useProjects.setState({ projects: [project()], activeProjectId: 'p1' })+ mount()+ expect(dialog()).toBeNull()+ })+})diff --git a/src/renderer/state/projects.ts b/src/renderer/state/projects.tsindex bfda03d21..6835337c5 100644--- a/src/renderer/state/projects.ts+++ b/src/renderer/state/projects.ts@@ -10,6 +10,8 @@ import type {Workspace} from '@shared/types'import { collisionSeed, derivedProjectId } from '@shared/project-id'+import type { ProjectCapability } from '@shared/project-capabilities'+import { recordCapabilityAck } from '@shared/project-capability-consent'import { applyCanvasMutation, createProject, reorderGroupWithinParent } from './workspace'interface ProjectsState {@@ -66,6 +68,19 @@ interface ProjectsState {/** Sets (or clears, with undefined = fall back to the global setting) the project's default* permission mode for new Claude terminal (CLI) sessions. Chat nodes are not covered. */setProjectDefaultPermissionMode(id: string, mode: AgentPermissionMode | undefined): void+ /**+ * THE strict per-project capability setter (@shared/project-capabilities). `on` writes the+ * literal `true` the validators accept AND records the machine-local ack — setting a switch+ * yourself is its own acknowledgment, so the clone notice never fires on your own decision.+ * `off` deletes the field outright (an off capability adds no bytes to the shared file); the+ * ack, once earned, stays. */+ setProjectCapability(id: string, cap: ProjectCapability, on: boolean): void+ /**+ * Records this machine's answer to the one-time clone notice. MACHINE-LOCAL by construction:+ * `Project.capabilityAck` rides `IndexEntryV3.capabilityAck` through splitWorkspace on the next+ * save and is never written into .nodeterm/project.json (workspace-files.test.ts pins the file+ * bytes; capability-notice.test.tsx pins this path). */+ recordProjectCapabilityAck(id: string, cap: ProjectCapability): void/** Raises the project's dino high score (never lowers it). */setDinoHighScore(id: string, score: number): void/** Replaces the project's kanban board (the UI computes the next board via lib/kanban). */@@ -333,6 +348,24 @@ export const useProjects = create<ProjectsState>((set, get) => ({}))},+ setProjectCapability(id, cap, on) {+ set((s) => ({+ projects: s.projects.map((p) => {+ if (p.id !== id) return p+ if (on) return recordCapabilityAck({ ...p, [cap]: true }, cap)+ const next = { ...p }+ delete next[cap]+ return next+ })+ }))+ },++ recordProjectCapabilityAck(id, cap) {+ set((s) => ({+ projects: s.projects.map((p) => (p.id === id ? recordCapabilityAck(p, cap) : p))+ }))+ },+setDinoHighScore(id, score) {// Raise-only: a stale/lower report (e.g. a second dino node) must never shrink the record.set((s) => ({