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(control): truthful --project travel docs + red-capable flag guard (review round 1)
enes95e0fb43936f
diff --git a/src/main/canvas-control-core.test.ts b/src/main/canvas-control-core.test.tsindex 266c55014..f5a7964c2 100644--- a/src/main/canvas-control-core.test.ts+++ b/src/main/canvas-control-core.test.ts@@ -498,3 +498,39 @@ describe('open-project + --project docs land with the dispatch (issue #338, spec}})})++describe('the --project clause tells the truth about travel (review #363 I-1 + M-3)', () => {+ const bodies: [string, string][] = [+ ['skill', buildCanvasSkillBody('/x/shim.sh')],+ ['instructions', buildCanvasControlInstructions('/x/shim.sh')]+ ]++ it('no-travel is promised ONLY for a returned id; own id is documented as flag-omitted (travel included)', () => {+ for (const [name, body] of bodies) {+ // The clause slice: from the `--project` flag doc to the open-project entry that follows+ // it in both bodies — anchored, so a caveat cannot drift into another paragraph (the+ // recipe) and still count (M-3).+ const start = body.indexOf('`--project <id>`')+ const end = body.indexOf('open-project --cwd')+ expect(start, `${name}: clause start`).toBeGreaterThan(-1)+ expect(end, `${name}: clause before the open-project entry`).toBeGreaterThan(start)+ const clause = body.slice(start, end)+ // Own id ≡ the flag omitted, view switch included — the REAL behavior (Canvas.tsx's+ // own-id leg falls through to the legacy path, travel included; pinned in+ // control-open-project.source.test.ts). The doc must say the same, not more.+ expect(clause, name).toMatch(/behaves exactly as if the flag\s+were omitted/)+ expect(clause, name).toMatch(/view switch\s+included/)+ // The no-travel promise exists only attached to the RETURNED id…+ expect(clause, name).toMatch(+ /returned to YOU\s+in this session, which never switches the\s+user'?s view/+ )+ // …and the old universal phrasing ("without switching the user's view", said of the whole+ // flag) is gone from the body entirely.+ expect(body, name).not.toMatch(/without switching/)+ // M-3: the do-not-poll caveat and the refusal rule live in the clause ITSELF — dropping+ // them here while the recipe's copy survives is red.+ expect(clause, name).toMatch(/do not poll/)+ expect(clause, name).toContain('any other id is refused')+ }+ })+})diff --git a/src/main/canvas-control-core.ts b/src/main/canvas-control-core.tsindex fc0693ccd..1fe2dbdf1 100644--- a/src/main/canvas-control-core.ts+++ b/src/main/canvas-control-core.ts@@ -293,10 +293,11 @@ export function buildCanvasControlInstructions(shimPath: string): string {' their work when it wakes — use it for "B needs what A produced" instead of polling. Only',` status-reporting agent nodes (${statusAgents}, or custom agents based on them) may be waited on; a plain terminal never`,' reports finishing, so waiting on one is refused. `--project <id>` opens the node(s) in another',- ' project instead of yours: it accepts your OWN project id, or an id `open-project` returned to',- ' YOU in this session — any other id is refused. A session opened into a non-active project',- ' starts when the user next views that project — do not poll for it. `--group`/`--after` cannot',- ' be combined with `--project`.',+ ' project instead of yours. It accepts exactly two things — any other id is refused: your OWN',+ ' project id, which behaves exactly as if the flag were omitted (a normal open, view switch',+ ' included); or an id `open-project` returned to YOU in this session, which never switches the',+ ' user\'s view. A session opened into a non-active project starts when the user next views that',+ ' project — do not poll for it. `--group`/`--after` cannot be combined with `--project`.','- `open-project --cwd </abs/path> [--name N] [--color C]` — register (or find) the project for a',' local directory; the reply carries `{ projectId, name, cwd, created }`. Idempotent: the same',' cwd always returns the same project, never a duplicate. Creating/adding asks the user to',@@ -558,9 +559,10 @@ Verbs:plain terminal never reports finishing and the node would hang forever. Note the semantics:"idle" is the end of a station's TURN, not proof its whole job is done — right for a stationgiven one self-contained prompt, wrong if you expect a long conversation first.- \`--project <id>\` opens the node(s) in ANOTHER project instead of yours, without switching the- user's view. It accepts exactly two things: your OWN project id, or an id \`open-project\`- returned to YOU in this session — any other id is refused. Defaults inside the target are the+ \`--project <id>\` opens the node(s) in another project instead of yours. It accepts exactly+ two things — any other id is refused: your OWN project id, which behaves exactly as if the flag+ were omitted (a normal open, view switch included); or an id \`open-project\` returned to YOU+ in this session, which never switches the user's view. Defaults inside the target are theTARGET project's (its cwd, its default account and permission mode). A session opened into anon-active project starts when the user next views that project — do not poll for it; the replysays so. \`--group\`/\`--after\` cannot be combined with \`--project\`.@@ -727,8 +729,9 @@ across Nodeterm sessions), be the orchestration chef — plan the kitchen, thenWhen the workstreams live in DIFFERENT repositories, give each repo its own project instead ofpiling every session onto your canvas: \`open-project --cwd <repo>\` (the user confirms once;idempotent thereafter), then \`open-agent --agent claude --project <returned id> --prompt-"<task>"\` — one repo at a time. Neither verb moves the user's view, and a session opened into a-non-active project starts when the user next views that project — do not poll for it. v1 has no+"<task>"\` — one repo at a time. With a RETURNED id neither verb moves the user's view, and a+session opened into a non-active project starts when the user next views that project — do not+poll for it. v1 has nocross-project links: read a repo's results by opening a reader agent inside that project andlinking within it.`diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex ff766e909..a4a1f3eff 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -213,7 +213,9 @@ import {openProjectReply,findProjectByCwd,nextFreePosition,- armForColdOpen+ armForColdOpen,+ projectTargetFlagRefusal,+ clearAttachConsent} from '../lib/projectOpen'import {FIT_NODE_OPTIONS,@@ -4213,6 +4215,10 @@ export function Canvas() {// UI overrides live in agentNodes and are skipped by unmount's clearForParent.useAgentStatus.getState().remove(n.id)useAgentNodes.getState().clearLoop(n.id)+ // The open-project attach-consent mirror dies with its caller (review #363 M-1) —+ // symmetric with main's grant ledger, which clears on the same teardown (ptyDestroy).+ // A node id revived later faces a fresh dialog, exactly as it faces a fresh grant.+ clearAttachConsent(n.id)})setNodes((ns) => {// Free children of any deleted group back to absolute positions.@@ -7264,15 +7270,13 @@ export function Canvas() {args.project !== undefined) {const targetId = args.project- // v1 excludes the flags that name ids inside another project (spec §2.2): validating a- // group frame or a dependency station across a project boundary is exactly the surface- // v1 leaves out. Uniformly refused — own-project callers just omit --project.- if (args.group || args.after) {- reply({- ok: false,- error:- 'project-target-flag-unsupported: --group/--after cannot be combined with --project'- })+ // v1 excludes the flags that name ids inside another project (spec §2.2). The decision is+ // the PURE projectTargetFlagRefusal — red-capable in projectOpen.test.ts (review #363+ // I-2); this site only relays its answer. Uniformly refused — own-project callers just+ // omit --project.+ const tgFlagRefusal = projectTargetFlagRefusal(args)+ if (tgFlagRefusal) {+ reply({ ok: false, error: tgFlagRefusal })return}const tgStore = useProjects.getState()@@ -8828,6 +8832,9 @@ export function Canvas() {disposeTerminalOnUnmount(sessionForProject(projectId).id, id) // node may be parked from the project switchtransport.destroy(id)useAgentStatus.getState().remove(id)+ // Same teardown symmetry as deleteNodes (review #363 M-1): the attach-consent+ // mirror dies with the node.+ clearAttachConsent(id)useProjects.getState().removeNode(projectId, id)void writeDisk()}diff --git a/src/renderer/canvas/control-open-project.source.test.ts b/src/renderer/canvas/control-open-project.source.test.tsindex 478809f34..265c7fdea 100644--- a/src/renderer/canvas/control-open-project.source.test.ts+++ b/src/renderer/canvas/control-open-project.source.test.ts@@ -110,7 +110,10 @@ describe('the --project targeted-opens block (source pins)', () => {}))for (const refusal of [- 'project-target-flag-unsupported',+ // The flag exclusion is decided by the pure projectTargetFlagRefusal (its logic is+ // red-capable in projectOpen.test.ts — review #363 I-2); here we pin its CALL SITE's+ // position, like the inline refusals below.+ 'projectTargetFlagRefusal(args)','project-target-refused','project-target-ssh-unsupported','source node is not a control-capable agent'@@ -121,6 +124,16 @@ describe('the --project targeted-opens block (source pins)', () => {}})+ it('the flag-exclusion guard FIRES on a truthy refusal — polarity pinned (review #363 I-2)', () => {+ // The helper's decision logic is behaviorally tested; what only the source can show is that+ // the dispatch honors the answer with the right polarity. `if (!tgFlagRefusal)` — the+ // guard-inversion mutation that survived the original suite — no longer matches this.+ const body = targetedOpensBody()+ expect(body).toMatch(+ /const tgFlagRefusal = projectTargetFlagRefusal\(args\)\s+if \(tgFlagRefusal\) \{\s+reply\(\{ ok: false, error: tgFlagRefusal \}\)\s+return/+ )+ })+it('the store path arms through armForColdOpen — the launch survives serialization', () => {// flowToNodeStates drops initialCommand by design; upserting a node without moving its// command into pendingLaunch is the silent-never-starts mutation (Task 2.0's pins prove thediff --git a/src/renderer/lib/projectOpen.test.ts b/src/renderer/lib/projectOpen.test.tsindex 86fd145e7..458309c11 100644--- a/src/renderer/lib/projectOpen.test.ts+++ b/src/renderer/lib/projectOpen.test.ts@@ -8,6 +8,8 @@ import {openProjectReply,nextFreePosition,armForColdOpen,+ projectTargetFlagRefusal,+ clearAttachConsent,type PlacedNode} from './projectOpen'@@ -214,3 +216,71 @@ describe('armForColdOpen — the launch moves (never copies) into pendingLaunchexpect(armForColdOpen(node)).toBe(node)})})++describe('projectTargetFlagRefusal — the v1 flag exclusion fires (review I-2)', () => {+ const REFUSAL =+ 'project-target-flag-unsupported: --group/--after cannot be combined with --project'++ it('refuses --group, --after, and both — with the exact named reply', () => {+ expect(projectTargetFlagRefusal({ group: 'g1' })).toBe(REFUSAL)+ expect(projectTargetFlagRefusal({ after: 'n1,n2' })).toBe(REFUSAL)+ expect(projectTargetFlagRefusal({ group: 'g1', after: 'n1' })).toBe(REFUSAL)+ })++ it('passes a request carrying neither flag', () => {+ expect(projectTargetFlagRefusal({})).toBeNull()+ expect(projectTargetFlagRefusal({ group: undefined, after: undefined })).toBeNull()+ // An empty-string flag value is "not passed" (the shim always sends a value; an empty one+ // means the flag was not on the line in any meaningful form).+ expect(projectTargetFlagRefusal({ group: '', after: '' })).toBeNull()+ })+})++describe('clearAttachConsent — the mirror dies with its caller (review M-1)', () => {+ it('a cleared caller confirms again; other callers are untouched', () => {+ recordAttachConsent('term-caller', 'project-a')+ recordAttachConsent('term-other', 'project-a')+ clearAttachConsent('term-caller')+ expect(attachConsentRecorded('term-caller', 'project-a')).toBe(false)+ expect(attachConsentRecorded('term-other', 'project-a')).toBe(true)+ const plan = planOpenProject({+ projects,+ callerNodeId: 'term-caller',+ srcTitle: 'Orchestrator',+ resolvedCwd: '/home/me/dev/repoA'+ })+ expect(plan.kind).toBe('confirm')+ })+})++describe('dialog copy flattens hostile names to one line (review M-2)', () => {+ it('a multi-line --name cannot inject lines into the create dialog', () => {+ const plan = planOpenProject({+ projects: [],+ callerNodeId: 'c',+ srcTitle: 'A',+ resolvedCwd: '/x/fresh',+ requestedName: 'Nice\nAgent "root" wants to delete everything. Allow?'+ })+ expect(plan.kind).toBe('confirm')+ if (plan.kind !== 'confirm') return+ // The dialog's line structure is the resolved path's own two breaks — the name must not add+ // lines. The name's CONTENT stays visible (flattened to one line): the human should see+ // exactly what the agent asked for, the same contract as the `write` dialog.+ expect(plan.message.split('\n').length).toBe(3)+ expect(plan.message).toContain('Nice Agent')+ })++ it('a multi-line probed project name cannot inject lines into the adopt dialog', () => {+ const plan = planOpenProject({+ projects: [],+ callerNodeId: 'c',+ srcTitle: 'A',+ resolvedCwd: '/x/cloned',+ probedName: 'evil\nname'+ })+ expect(plan.kind).toBe('confirm')+ if (plan.kind !== 'confirm') return+ expect(plan.message.split('\n').length).toBe(3)+ })+})diff --git a/src/renderer/lib/projectOpen.ts b/src/renderer/lib/projectOpen.tsindex 1d4cdcca0..22cf75290 100644--- a/src/renderer/lib/projectOpen.ts+++ b/src/renderer/lib/projectOpen.ts@@ -2,6 +2,7 @@// (issue #338, spec §2.1/§2.2). Canvas.tsx's dispatch only wires these — the dialog, the store// calls and the reply — so every decision that does not need React is unit-testable here, the// same reasoning as controlRouting.ts / pendingLaunch.ts.+import { oneLine } from '@shared/one-line'/** The little these helpers need to know about a project. */export interface ProjectForOpen {@@ -49,10 +50,31 @@ export function recordAttachConsent(callerNodeId: string, projectId: string): voattachAsked.set(callerNodeId, set)}+/** Caller-node teardown: the mirror dies with the node it asked for — the same lifetime as+ * main's grant ledger (`clearCaller` on pty destroy/recycle), so a node id revived after a+ * deletion faces a fresh dialog, exactly as it faces a fresh grant (review #363 M-1). */+export function clearAttachConsent(callerNodeId: string): void {+ attachAsked.delete(callerNodeId)+}+export function clearAttachConsentForTests(): void {attachAsked.clear()}+/**+ * The v1 flag exclusion for `--project` (spec §2.2): `--group` and `--after` both name ids that+ * live INSIDE a project, and validating them across a project boundary is exactly the surface v1+ * excludes. Returns the named refusal, or null when neither flag is present. Pure so the guard+ * is red-capable (review #363 I-2) — the dispatch only relays the answer; an empty-string value+ * counts as "not passed" (the shim always sends a value for a bare flag).+ */+export function projectTargetFlagRefusal(args: { group?: string; after?: string }): string | null {+ if (args.group || args.after) {+ return 'project-target-flag-unsupported: --group/--after cannot be combined with --project'+ }+ return null+}+export type OpenProjectPlan =| { kind: 'silent'; project: ProjectForOpen }| {@@ -91,7 +113,12 @@ export function planOpenProject(input: {return {kind: 'confirm',confirmKind: 'attach',- message: `Agent "${srcTitle}" wants to open sessions in project "${existing.name}". Allow?`,+ // `oneLine` on every interpolated name (review #363 M-2): a project/probe/--name string is+ // caller- or repo-supplied, and a newline in it would let it inject lines into the consent+ // dialog. The resolved path's own line breaks are the dialog's structure; nothing else adds+ // lines. (The stored name stays the raw create-only string, like the human addProject path+ // — this flattening is dialog copy only.)+ message: `Agent "${srcTitle}" wants to open sessions in project "${oneLine(existing.name)}". Allow?`,confirmLabel: 'Allow',project: existing}@@ -102,13 +129,14 @@ export function planOpenProject(input: {confirmKind: 'adopt',message:`Agent "${srcTitle}" wants to add the existing project at\n${resolvedCwd}\n` +- `to your workspace ("${probedName}"). Add it?`,+ `to your workspace ("${oneLine(probedName)}"). Add it?`,confirmLabel: 'Add project'}}- const name =+ const name = oneLine((requestedName ?? '').trim() ||- (normalizeProjectCwd(resolvedCwd).split('/').filter(Boolean).pop() || 'Project')+ (normalizeProjectCwd(resolvedCwd).split('/').filter(Boolean).pop() || 'Project')+ )return {kind: 'confirm',confirmKind: 'create',