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(kanban): a wait rope is never a team leader, even after the canvas prunes the opener's
reviewc3e3e3f5f904
diff --git a/CLAUDE.md b/CLAUDE.mdindex 00e2f2aaa..186820fed 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -1586,7 +1586,7 @@ session.the ephemeral loop/cron cards, which visualize AGENT-initiated recurrence). The card shows theschedule + next-run countdown, the target (a derived, never-persisted edge — thepending-launch dep edge is NO longer one: since the 2026-09-02 edge model it is a persisted rope,- `ctrl-<dep>-<node>`, whose dashed ⏳ LOOK is what is derived), the payload, an honest+ `ctrl-after-<dep>-<node>`, whose dashed ⏳ LOOK is what is derived), the payload, an honestARMED/DISARMED/CHANGED/SET-UP chip with the"definitions travel with the repo, consent never does" narrative, Run-now, and the last runs(fired / delivered-late / queued / missed / failed / expired). Arming passes a ConfirmDialog@@ -3378,8 +3378,10 @@ command-bearing opens; this does not add a human-confirm dialog or change mobile(6) Canvas subscribes to `armedDepSig`, NOT `useAgentStatus(s => s.byId)` —the same discipline as `loopSig`; the full map re-renders the canvas on every hook event.Pure logic + refusal matrix in `renderer/lib/pendingLaunch.ts` (unit-tested);- the dep→node edge is a **rope** (`ctrl-<dep>-<node>`, persisted in `project.ropes` like the- opener's) whose LOOK is derived: dashed + ⏳ while the node's `pendingLaunch.after` still lists the+ the dep→node edge is a **rope** (`ctrl-after-<dep>-<node>` — `waitRopeId`, marked so it can+ never be mistaken for the opener's `ctrl-<source>-<node>` once the canvas prunes that one; ropes+ saved before the mark are re-marked by append order at load, `markLegacyWaitRopes` — persisted in+ `project.ropes` like the opener's) whose LOOK is derived: dashed + ⏳ while the node's `pendingLaunch.after` still lists thedep, solid once it has launched (`lib/edgeModel.ts` `ropeVisual`, over the ONE `ropeInfoOf` lookupthe render and BOTH delete paths ask — two builders would be two answers, and the label the userreads would stop describing what the delete does). The fan-in bridge `--after` also writes hides@@ -5891,17 +5893,25 @@ the Settings section and ShortcutsPanel start disagreeing about what a chord meaopened stations shows "N of M done" as a small ring on its board card, its card modal headerAND its canvas node header — ONE component, so three views of one node cannot countdifferently; clicking it lists the stations and a row travels to that node. A station is a- session node that is the target of the FIRST rope into it in `project.ropes` order: ropes carry- two relations with one `ctrl-<source>-<target>` id shape ("opened by" and an `--after` / verify- wait), nothing on the node records the opener, and every writer appends the opener's rope- before the same command's dep ropes (`connect` then `ropeDeps`; `missingDepRopes` heals after- the file's own ropes). Without that rule every `--after` upstream read as a team leader. Rules- the count keeps: **unknown is unknown, never done** (state is transient; after a restart a- station reads `unknown` until it reports), paused/hibernated count as a finished turn (both are- written only by an exit that refused a busy session), a held launch reads `queued`, `done` +- `lastTurnError` reads `errored` (the `--after` verdict), a station that can never report (plain- terminal, hook-less agent) is listed as "no status" and kept OUT of M (it would pin the ring- below complete forever — the line `--after` draws), and a deleted station is not a station.+ session node that is the target of an OPENER rope. Ropes carry two relations — "opened by"+ (`ctrl-<source>-<node>`) and a wait (`--after`, the verify panel), which is minted+ `ctrl-after-<dep>-<node>` (`waitRopeId`, `lib/edgeModel.ts`) and skipped. **The mark is what+ makes this hold, not rope order**: the canvas prunes every rope with an endpoint off the canvas,+ so deleting an orchestrator (or the user deleting its rope, or a `--project` open whose opener+ lives in another project) removed the opener's rope, and under the old "first rope is the+ opener" rule the first surviving wait read as the opener — a pipeline's upstream station showed+ the next one as its team, a verify panel's reviewed node showed its reviewers. Canvases saved+ before the mark are re-marked at LOAD by append order (`markLegacyWaitRopes`: every rope into a+ node after its first is a wait), which must run before the prune; one already pruned and saved+ has lost that evidence (residual). Tests run the canvas's load → heal → prune steps before+ `stationsByOpener`. Rules the count keeps: **unknown is unknown, never done** (state is+ transient; after a restart a station reads `unknown` until it reports), paused/hibernated count+ as a finished turn (both come only from an exit that refuses a working or blocked session), a+ CLI that announced its exit (`sessionEnded`) reads `ended` and counts (it is not running and+ never will be on its own — `unknown` would hold the ring below complete forever), a held launch+ reads `queued`, `done` + `lastTurnError` reads `errored` (the `--after` verdict), a station that+ can never report (plain terminal, hook-less agent) is listed as "no status" and kept OUT of M+ (the line `--after` draws), and a deleted station is not a station.Subscriptions: each chip reads `teamProgressSig` — one character per station, no ids — never`byId`; the per-project board gets the teams as a prop from Canvas, the Omni lanes derivetheirs from the stored `p.ropes`/`p.nodes`, and the canvas node header reads `useTeamStations`@@ -5920,7 +5930,9 @@ the Settings section and ShortcutsPanel start disagreeing about what a chord meawhat an idle card in In Progress needs distinguished.- **`bridges` / `ropes` are admitted through `sanitizeLinks`** (`core/workspace-files.ts`) on thesame seams as `sanitizeKanban` — `fileToProject`, `projectToFile`, the inline-project branch- and the legacy v2 path of the store. They are git-shared, hand-editable input that every reader+ and the legacy v2 path of the store — and on `persistedCanvases`, which reads the RAW index entry+ and last-written file for the context-link map (`buildBackgroundLinkMaps` iterates every+ bridge). They are git-shared, hand-editable input that every readermaps as `BridgeLink[]`, and the canvas's rope restore threw on one `null` entry at project load.A non-list is dropped, an entry without non-empty string `id`/`source`/`target` is dropped, and aclean list comes back BY IDENTITY.diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 3f9065bcb..bbcba45c4 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -143,7 +143,10 @@ A card chip that reads agent state subscribes to a **primitive signature** of thon every hook event of every node. Before a card shows a fact, check that its place on the boarddoes not already say it (`lib/cardRedundancy.ts`); the card modal keeps every fact the card drops.`project.ropes` / `bridges` are hostile input like the board: they are admitted through-`sanitizeLinks` on every load and save seam, and a reader still tolerates anything.+`sanitizeLinks` on every load and save seam, and a reader still tolerates anything. A wait rope+(`--after`, the verify panel) is minted with `waitRopeId` (`ctrl-after-<dep>-<node>`), never with the+opener's `ctrl-<source>-<node>` shape: rope ORDER does not survive the canvas pruning ropes to+deleted nodes, so the id is the only thing that tells a wait from an opener.Before adding a GitHub read, check what the existing poll already fetches. Pull request cardsneeded no new request at all: `/repos/{repo}/issues` returns pull requests, and the client used todiff --git a/src/core/workspace-store.links.test.ts b/src/core/workspace-store.links.test.tsindex 0408b3d34..7dbdd4259 100644--- a/src/core/workspace-store.links.test.ts+++ b/src/core/workspace-store.links.test.ts@@ -80,4 +80,35 @@ describe('the canvas links are admitted on every load seam', () => {const loaded = await new WorkspaceStore().load()expect(loaded.projects[0].ropes).toEqual([rope('a', 'b')])})++ it('persistedCanvases hands the context-link map only readable bridges (inline and folder legs)', async () => {+ await fs.mkdir(path.join(projRoot, '.nodeterm'), { recursive: true })+ await fs.writeFile(+ path.join(projRoot, '.nodeterm', 'project.json'),+ JSON.stringify({+ version: 1, rev: 3, savedAt: '2026-09-29T00:00:00.000Z', id: 'legacy', name: 'bar',+ color: '#7aa2f7', viewport: { x: 0, y: 0, zoom: 1 }, nodes: [], bridges: HOSTILE+ }),+ 'utf-8'+ )+ await writeIndex({+ version: 3,+ activeProjectId: 'p1',+ entries: [+ {+ id: 'p1', name: 'foo', color: '#7aa2f7',+ project: {+ id: 'p1', name: 'foo', color: '#7aa2f7', viewport: { x: 0, y: 0, zoom: 1 }, nodes: [],+ bridges: HOSTILE+ }+ },+ { id: 'p2', name: 'bar', color: '#7aa2f7', cwd: projRoot }+ ]+ })+ const store = new WorkspaceStore()+ await store.load()+ const canvases = store.persistedCanvases()+ expect(canvases.map((c) => c.id)).toEqual(['p1', 'p2'])+ for (const c of canvases) expect(c.bridges).toEqual([rope('a', 'b')])+ })})diff --git a/src/core/workspace-store.ts b/src/core/workspace-store.tsindex a63f8a24f..6fd32a20b 100644--- a/src/core/workspace-store.ts+++ b/src/core/workspace-store.ts@@ -1634,13 +1634,16 @@ export class WorkspaceStore {* project.json, so a project whose file has never been read this run is simply absent (it* appears after the next load/save, which is also what re-derives the map).*/+ // `bridges` goes through `sanitizeLinks` on all three legs: the index entry and the last-written+ // file are the raw, hand-editable JSON (not the admitted project), and the context-link map+ // built from this (`buildBackgroundLinkMaps`) iterates every entry.persistedCanvases(): Array<{ id: string; nodes: CanvasNodeState[]; bridges?: BridgeLink[] }> {const out: Array<{ id: string; nodes: CanvasNodeState[]; bridges?: BridgeLink[] }> = []for (const e of this.index?.entries ?? []) {if (e.project) {- out.push({ id: e.project.id, nodes: e.project.nodes, bridges: e.project.bridges })+ out.push({ id: e.project.id, nodes: e.project.nodes, bridges: sanitizeLinks(e.project.bridges) })} else if (e.cache) {- out.push({ id: e.id, nodes: e.cache.nodes, bridges: e.cache.bridges })+ out.push({ id: e.id, nodes: e.cache.nodes, bridges: sanitizeLinks(e.cache.bridges) })} else if (e.cwd) {const raw = this.lastWritten.get(projectFilePath(e.cwd))if (!raw) continue@@ -1650,7 +1653,7 @@ export class WorkspaceStore {// a caller sees the same absolute paths the desktop's renderer would have handed it.// Keyed by the ENTRY id — the map's consumers look projects up by the id the renderer// knows, which is never the git-shared file's (it no longer has one).- out.push({ id: e.id, nodes: resolveNodes(f.nodes, e.cwd), bridges: f.bridges })+ out.push({ id: e.id, nodes: resolveNodes(f.nodes, e.cwd), bridges: sanitizeLinks(f.bridges) })} catch {// Corrupt cached content: skip this entry, keep scanning the others.}diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 4f3cac81a..36f6f56c0 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -514,7 +514,10 @@ import {LAUNCH_STALL_MS,type ArmedNode} from '../lib/pendingLaunch'-import { WAIT_LABEL, dropAfterDep, edgeHidden, hiddenEdgeNodeIds, missingDepRopes, ropeInfoOf, ropeVisual } from '../lib/edgeModel'+import {+ WAIT_LABEL, dropAfterDep, edgeHidden, hiddenEdgeNodeIds, markLegacyWaitRopes, missingDepRopes, pruneRopes,+ ropeInfoOf, ropeVisual, waitRopeId+} from '../lib/edgeModel'import { triggerEdges } from '../lib/triggerCard'import {freeSpot,@@ -2748,7 +2751,10 @@ export function Canvas() {// A wait with no rope is a wait nothing on screen explains. Ropes for `--after` are written by// the verbs that arm a node, so an arming that predates them (persisted `pendingLaunch`, no// persisted rope) — or any future path that forgets one — is healed here on the next load.- const restoredRopes = (project.ropes ?? []).map((r) => ropeEdge(r.id, r.source, r.target))+ // `markLegacyWaitRopes` first: a canvas saved before waits carried their own id marks them by+ // append order, and it must run before the prune below can delete an opener's rope — after+ // that, nothing left says which rope into a node was its opener (lib/teamProgress reads it).+ const restoredRopes = markLegacyWaitRopes(project.ropes ?? []).map((r) => ropeEdge(r.id, r.source, r.target))setControlEdges([...restoredRopes,...missingDepRopes(flow, restoredRopes).map((r) => ropeEdge(r.id, r.source, r.target))@@ -3876,10 +3882,7 @@ export function Canvas() {// identity), and most canvases have no ropes at all.if (!controlEdgesRef.current.length) returnconst ids = new Set(nodes.map((n) => n.id))- setControlEdges((es) => {- const valid = es.filter((e) => ids.has(e.source) && ids.has(e.target))- return valid.length === es.length ? es : valid- })+ setControlEdges((es) => pruneRopes(es, ids))}, [nodes])useContextLinkSync({ projectId: nodesProjectIdRef.current, nodes, edges: linkEdges })@@ -11578,7 +11581,7 @@ export function Canvas() {const ropeDeps = (ids: string[], after: string[] | undefined): void => {if (!after?.length) returnconst ropes = ids.flatMap((nid) =>- after.filter((dep) => dep !== sourceNodeId).map((dep) => ropeEdge(`ctrl-${dep}-${nid}`, dep, nid))+ after.filter((dep) => dep !== sourceNodeId).map((dep) => ropeEdge(waitRopeId(dep, nid), dep, nid)))if (ropes.length) setControlEdges((es) => [...es, ...ropes])}diff --git a/src/renderer/canvas/edge-model.source.test.ts b/src/renderer/canvas/edge-model.source.test.tsindex 844a9dd66..088a53234 100644--- a/src/renderer/canvas/edge-model.source.test.ts+++ b/src/renderer/canvas/edge-model.source.test.ts@@ -31,9 +31,10 @@ describe('canvas edge model (source pins)', () => {})it('--after writes a rope from each dep to each opened node, beside the hidden bridge', () => {- // One helper, three verbs: the rope id shape is what hiddenLinkIds / delete key on.+ // One helper, three verbs. The id is the marked WAIT id (`waitRopeId`, still `ctrl-`-routed):+ // an opener rope and a wait rope must be told apart once the canvas prunes the opener's.expect(src).toMatch(/const ropeDeps = \(ids: string\[\], after: string\[\] \| undefined\)/)- expect(src).toContain('ropeEdge(`ctrl-${dep}-${nid}`, dep, nid)')+ expect(src).toContain('ropeEdge(waitRopeId(dep, nid), dep, nid)')expect((src.match(/ropeDeps\(ids, after\)/g) ?? []).length).toBe(2)})diff --git a/src/renderer/components/kanban/KanbanView.teamProgress.test.tsx b/src/renderer/components/kanban/KanbanView.teamProgress.test.tsxindex 45f4654ad..90e9111ac 100644--- a/src/renderer/components/kanban/KanbanView.teamProgress.test.tsx+++ b/src/renderer/components/kanban/KanbanView.teamProgress.test.tsx@@ -10,6 +10,7 @@ import type { ProjectKanban } from '@shared/types'import { useProjects } from '../../state/projects'import { useAgentStatus, type AgentNodeStatus } from '../../state/agentStatus'import { stationsByOpener, type StationNodeLike } from '../../lib/teamProgress'+import { waitRopeId } from '../../lib/edgeModel'vi.mock('../../session/session', () => ({useSession: () => ({ source: 'local', api: window.nodeTerminal })@@ -60,12 +61,12 @@ afterEach(() => {})function mount(opts: { onOpenNode?: (id: string) => void } = {}): void {- // orch opened a, b, c, d, gone and a plain terminal; d also waits on a (an `--after` rope, which- // must not make `a` a team leader); `gone` was deleted.+ // orch opened a, b, c, d, gone and a plain terminal; d also waits on a (an `--after` rope, minted+ // with its wait id, which must not make `a` a team leader); `gone` was deleted.const nodes = [term('orch'), term('a'), term('b'), term('c'), term('d'), term('plain', { agentId: undefined })]const teams = stationsByOpener(- [rope('orch', 'a'), rope('orch', 'b'), rope('orch', 'c'), rope('orch', 'd'), rope('a', 'd'),- rope('orch', 'gone'), rope('orch', 'plain')],+ [rope('orch', 'a'), rope('orch', 'b'), rope('orch', 'c'), rope('orch', 'd'),+ { id: waitRopeId('a', 'd'), source: 'a', target: 'd' }, rope('orch', 'gone'), rope('orch', 'plain')],nodes)host = document.createElement('div')diff --git a/src/renderer/lib/edgeModel.test.ts b/src/renderer/lib/edgeModel.test.tsindex af4917cbf..a15d79df4 100644--- a/src/renderer/lib/edgeModel.test.ts+++ b/src/renderer/lib/edgeModel.test.ts@@ -8,7 +8,11 @@ import {ropeInfoOf,ropeVisual,WAIT_LABEL,- type RopeNodeInfo+ type RopeNodeInfo,+ isWaitRope,+ markLegacyWaitRopes,+ pruneRopes,+ waitRopeId} from './edgeModel'const infoOf =@@ -125,7 +129,7 @@ describe('missingDepRopes — a wait with no rope is a wait nothing on screen exit('synthesizes dep -> node for an armed node whose rope was never written', () => {expect(missingDepRopes([{ id: 'a', data: {} }, armed('b', ['a'])], [])).toEqual([- { id: 'ctrl-a-b', source: 'a', target: 'b' }+ { id: 'ctrl-after-a-b', source: 'a', target: 'b' }])})@@ -135,7 +139,7 @@ describe('missingDepRopes — a wait with no rope is a wait nothing on screen exit('an OPPOSITE rope is not the same relation — the dep rope is still owed', () => {expect(missingDepRopes([{ id: 'a', data: {} }, armed('b', ['a'])], [{ source: 'b', target: 'a' }])).toEqual([- { id: 'ctrl-a-b', source: 'a', target: 'b' }+ { id: 'ctrl-after-a-b', source: 'a', target: 'b' }])})@@ -149,7 +153,38 @@ describe('missingDepRopes — a wait with no rope is a wait nothing on screen exit('a repeated dep yields ONE rope — two edges with one id would be a React Flow collision', () => {expect(missingDepRopes([{ id: 'a', data: {} }, armed('b', ['a', 'a'])], [])).toEqual([- { id: 'ctrl-a-b', source: 'a', target: 'b' }+ { id: 'ctrl-after-a-b', source: 'a', target: 'b' }])})})++describe('wait ropes carry their own id', () => {+ const r = (id: string, source: string, target: string) => ({ id, source, target })++ it('a wait is recognized by its exact id, never by prefix alone', () => {+ expect(waitRopeId('a', 'b')).toBe('ctrl-after-a-b')+ expect(isWaitRope(r('ctrl-after-a-b', 'a', 'b'))).toBe(true)+ expect(isWaitRope(r('ctrl-a-b', 'a', 'b'))).toBe(false)+ // An opener whose own id starts with `after-`: its rope id begins `ctrl-after-` but is no wait.+ expect(isWaitRope(r('ctrl-after-x-b', 'after-x', 'b'))).toBe(false)+ })++ it('marks every legacy rope into a node after the first, by append order', () => {+ const ropes = [r('ctrl-o-b', 'o', 'b'), r('ctrl-o-c', 'o', 'c'), r('ctrl-b-c', 'b', 'c')]+ expect(markLegacyWaitRopes(ropes).map((x) => x.id)).toEqual(['ctrl-o-b', 'ctrl-o-c', 'ctrl-after-b-c'])+ })++ it('leaves a canvas that needs nothing by identity, and never duplicates an id', () => {+ const clean = [r('ctrl-o-b', 'o', 'b'), r('ctrl-after-b-c', 'b', 'c'), r('ctrl-o-c', 'o', 'c')]+ expect(markLegacyWaitRopes(clean)).toBe(clean)+ // The same pair twice, the later one legacy: re-minting it would collide with the marked one.+ const dup = [r('ctrl-o-c', 'o', 'c'), r('ctrl-after-b-c', 'b', 'c'), r('ctrl-b-c', 'b', 'c')]+ expect(markLegacyWaitRopes(dup).map((x) => x.id)).toEqual(['ctrl-o-c', 'ctrl-after-b-c'])+ })++ it('pruneRopes drops a rope with a missing endpoint and keeps identity otherwise', () => {+ const ropes = [r('ctrl-o-b', 'o', 'b'), r('ctrl-after-b-c', 'b', 'c')]+ expect(pruneRopes(ropes, new Set(['o', 'b', 'c']))).toBe(ropes)+ expect(pruneRopes(ropes, new Set(['b', 'c'])).map((x) => x.id)).toEqual(['ctrl-after-b-c'])+ })+})diff --git a/src/renderer/lib/edgeModel.ts b/src/renderer/lib/edgeModel.tsindex e6c6564ff..2ef3ad0e7 100644--- a/src/renderer/lib/edgeModel.ts+++ b/src/renderer/lib/edgeModel.ts@@ -79,6 +79,75 @@ export function ropeInfoOf(}}+/**+ * The id of a WAIT rope (`--after`, the verify panel's sequencing): `ctrl-after-<dep>-<node>`.+ *+ * A rope carries two relations — "opened by" and "waits for" — and for a long time both were minted+ * as `ctrl-<source>-<target>`, so nothing could tell them apart except ORDER (every writer appends+ * the opener's rope before the same command's waits). Order does not survive the canvas's own+ * pruning: deleting the opener deletes its rope, and the first wait into the node then looked like+ * its opener (team progress showed a pipeline's upstream station as the next one's team leader).+ * A wait now says what it is in its id. Still `ctrl-`, so every path that routes on that prefix+ * (edge changes, deletion, the store's pair-keyed dedupe) treats it exactly as before.+ */+export function waitRopeId(dep: string, node: string): string {+ return `ctrl-after-${dep}-${node}`+}++/** Is this rope a wait? Exact match on the rope's own endpoints, so an opener rope whose SOURCE id+ * happens to begin with `after-` is never mistaken for one. */+export function isWaitRope(rope: { id?: unknown; source: string; target: string }): boolean {+ return rope.id === waitRopeId(rope.source, rope.target)+}++/**+ * Canvases saved before waits were marked: every rope into a node AFTER the first one is a wait+ * (the append-order rule above), so it is re-minted with `waitRopeId` — once, at load, BEFORE the+ * prune can delete the opener's rope and erase the only evidence of which one it was. A marked+ * rope and the first unmarked rope into each node are left alone. A re-minted id that already+ * exists (the same pair twice) is dropped rather than duplicated — React Flow renders two edges+ * with one id as one, and the next removal breaks. Returns the same array when nothing changed.+ *+ * Residual: a canvas that was pruned AND saved before this ran has already lost its opener rope;+ * its first surviving wait still reads as the opener, and nothing left in the file can say+ * otherwise.+ */+export function markLegacyWaitRopes<R extends { id: string; source: string; target: string }>(+ ropes: readonly R[]+): R[] {+ const opened = new Set<string>()+ const ids = new Set(ropes.map((r) => r.id))+ let changed = false+ const out: R[] = []+ for (const r of ropes) {+ if (isWaitRope(r)) {+ out.push(r)+ continue+ }+ if (!opened.has(r.target)) {+ opened.add(r.target)+ out.push(r)+ continue+ }+ const id = waitRopeId(r.source, r.target)+ changed = true+ if (ids.has(id)) continue+ ids.add(id)+ out.push({ ...r, id })+ }+ return changed ? out : (ropes as R[])+}++/** The canvas's rope prune, as a pure step: a rope whose endpoint is not on the canvas goes. Same+ * array back when nothing did. */+export function pruneRopes<R extends { source: string; target: string }>(+ ropes: readonly R[],+ nodeIds: ReadonlySet<string>+): R[] {+ const valid = ropes.filter((e) => nodeIds.has(e.source) && nodeIds.has(e.target))+ return valid.length === ropes.length ? (ropes as R[]) : valid+}+/*** The dep ropes an armed node is owed but does not have. A rope is what makes a wait VISIBLE, and* only the `open-*`/`verify` verbs write one — so a node armed by any other path, or armed by a@@ -100,7 +169,7 @@ export function missingDepRopes(for (const dep of n.data.pendingLaunch?.after ?? []) {if (!live.has(dep) || have.has(`${dep} ${n.id}`)) continuehave.add(`${dep} ${n.id}`)- out.push({ id: `ctrl-${dep}-${n.id}`, source: dep, target: n.id })+ out.push({ id: waitRopeId(dep, n.id), source: dep, target: n.id })}}return outdiff --git a/src/renderer/lib/teamProgress.test.ts b/src/renderer/lib/teamProgress.test.tsindex 5f3865093..c5f2aff5a 100644--- a/src/renderer/lib/teamProgress.test.ts+++ b/src/renderer/lib/teamProgress.test.ts@@ -10,6 +10,7 @@ import {type TeamStation} from './teamProgress'import type { AgentNodeStatus } from '../state/agentStatus'+import { markLegacyWaitRopes, missingDepRopes, pruneRopes, waitRopeId } from './edgeModel'const term = (id: string, extra: Partial<StationNodeLike> = {}): StationNodeLike => ({id,@@ -19,6 +20,24 @@ const term = (id: string, extra: Partial<StationNodeLike> = {}): StationNodeLike...extra})const rope = (source: string, target: string) => ({ id: `ctrl-${source}-${target}`, source, target })+const wait = (source: string, target: string) => ({ id: waitRopeId(source, target), source, target })++/**+ * The ropes as the LIVE canvas holds them, in the order its effects run: load (legacy waits+ * re-marked) → heal (`missingDepRopes`) → prune against the nodes still on the canvas. Every+ * scenario below goes through this before `stationsByOpener`, because the canvas's prune is what+ * broke the old "first rope is the opener" rule.+ */+function canvasRopes(+ fileRopes: ReturnType<typeof rope>[],+ nodes: { id: string; data: { pendingLaunch?: { after: string[]; command: string } } }[]+): ReturnType<typeof rope>[] {+ const restored = markLegacyWaitRopes(fileRopes)+ const held = [...restored, ...missingDepRopes(nodes, restored)]+ return pruneRopes(held, new Set(nodes.map((n) => n.id)))+}+const live = (id: string, after?: string[]) =>+ ({ id, data: after ? { pendingLaunch: { after, command: 'go' } } : {} })const st = (patch: Partial<AgentNodeStatus>): AgentNodeStatus => ({ unread: false, ...patch }) as AgentNodeStatusdescribe('stationsByOpener', () => {@@ -28,27 +47,29 @@ describe('stationsByOpener', () => {expect(map.get('o')?.[0]).toEqual({ id: 'a', title: 'A', agentId: 'claude', queued: false })})- it('a later rope into the same target is a wait, not a second opener (pipeline + verify panel)', () => {- // o opened a, b, c; b waits on a, c waits on b (`--after` writes its dep rope AFTER the opener's).- const ropes = [rope('o', 'a'), rope('o', 'b'), rope('a', 'b'), rope('o', 'c'), rope('b', 'c')]+ it('a wait rope is never an opener (pipeline as the canvas mints it)', () => {+ // o opened a, b, c; b waits on a, c waits on b.+ const ropes = [rope('o', 'a'), rope('o', 'b'), wait('a', 'b'), rope('o', 'c'), wait('b', 'c')]const map = stationsByOpener(ropes, [term('o'), term('a'), term('b'), term('c')])expect(map.get('o')?.map((s) => s.id)).toEqual(['a', 'b', 'c'])expect(map.has('a')).toBe(false)expect(map.has('b')).toBe(false)})- it('a deleted station is not a station, and its wait rope is not promoted to opener', () => {- const ropes = [rope('o', 'a'), rope('o', 'gone'), rope('a', 'gone')]+ it('a deleted opener in an UNPRUNED stored file does not hand its station to a later rope', () => {+ // The Omni board reads the store's copy, which keeps ropes to deleted nodes until a canvas+ // load prunes them — the first rope still claims its target there.+ const map = stationsByOpener([rope('gone', 'a'), rope('b', 'a')], [term('a'), term('b')])+ expect(map.size).toBe(0)+ })++ it('a deleted station is not a station', () => {+ const ropes = [rope('o', 'a'), rope('o', 'gone'), wait('a', 'gone')]const map = stationsByOpener(ropes, [term('o'), term('a')])expect(map.get('o')?.map((s) => s.id)).toEqual(['a'])expect(map.has('a')).toBe(false)})- it('a deleted opener shows nowhere, and does not hand its station to the next rope', () => {- const map = stationsByOpener([rope('gone', 'a'), rope('b', 'a')], [term('a'), term('b')])- expect(map.size).toBe(0)- })-it('only session nodes are stations (a browser popup rope is lineage, not a team member)', () => {const map = stationsByOpener([rope('o', 'web'), rope('o', 'note'), rope('o', 'a')],@@ -141,6 +162,13 @@ describe('stationKind', () => {expect(stationKind(s(), st({ hibernated: true }))).toBe('paused')})+ it('a CLI that announced its exit is ended — not unknown, so the ring can complete', () => {+ expect(stationKind(s(), st({ sessionEnded: true }))).toBe('ended')+ expect(summarizeTeam(['done', 'ended'])).toMatchObject({ done: 2, total: 2, attention: null })+ // A live turn after a resume wins over the stale flag.+ expect(stationKind(s(), st({ sessionEnded: true, state: 'working' }))).toBe('working')+ })+it('a held launch outranks idle readings but not live ones', () => {expect(stationKind(s({ queued: true }), undefined)).toBe('queued')expect(stationKind(s({ queued: true }), st({ state: 'done' }))).toBe('queued')@@ -201,3 +229,54 @@ describe('teamProgressSig / summarizeTeam', () => {expect(parseTeamProgressSig('dZ')).toEqual(['done', 'unknown'])})})++describe('team membership survives the canvas pruning its ropes', () => {+ const stations = (ropes: ReturnType<typeof rope>[], ids: string[]) =>+ stationsByOpener(ropes, ids.map((id) => term(id)))++ it('(a) deleting the orchestrator does not make an upstream station the next one\'s leader', () => {+ // O opened B and C; C runs --after B.+ const file = [rope('O', 'B'), rope('O', 'C'), wait('B', 'C')]+ const before = canvasRopes(file, [live('O'), live('B'), live('C', ['B'])])+ expect(stations(before, ['O', 'B', 'C']).get('O')?.map((s) => s.id)).toEqual(['B', 'C'])+ const after = canvasRopes(before, [live('B'), live('C', ['B'])])+ expect(stations(after, ['B', 'C']).size).toBe(0)+ })++ it('(a) the same canvas saved before waits were marked (legacy ids), loaded then pruned', () => {+ const legacy = [rope('O', 'B'), rope('O', 'C'), rope('B', 'C')]+ const loaded = canvasRopes(legacy, [live('O'), live('B'), live('C')])+ expect(stations(loaded, ['O', 'B', 'C']).get('O')?.map((s) => s.id)).toEqual(['B', 'C'])+ const pruned = canvasRopes(loaded, [live('B'), live('C')])+ expect(stations(pruned, ['B', 'C']).size).toBe(0)+ })++ it('(a) a verify panel: closing the caller does not give the reviewed node a team of reviewers', () => {+ // K verified T: reviewers R1, R2 wait on T; judge J waits on both. K opened all three.+ const file = [+ rope('K', 'R1'), rope('K', 'R2'), rope('K', 'J'),+ wait('T', 'R1'), wait('T', 'R2'), wait('R1', 'J'), wait('R2', 'J')+ ]+ const nodes = [live('T'), live('R1', ['T']), live('R2', ['T']), live('J', ['R1', 'R2'])]+ const withCaller = canvasRopes(file, [live('K'), ...nodes])+ expect(stations(withCaller, ['K', 'T', 'R1', 'R2', 'J']).get('K')?.map((s) => s.id)).toEqual(['R1', 'R2', 'J'])+ const closed = canvasRopes(withCaller, nodes)+ expect(stations(closed, ['T', 'R1', 'R2', 'J']).size).toBe(0)+ })++ it('(b) the user removing the opener rope does not promote the wait', () => {+ const held = canvasRopes([rope('O', 'B'), rope('O', 'C'), wait('B', 'C')], [live('O'), live('B'), live('C', ['B'])])+ const removed = held.filter((r) => r.id !== 'ctrl-O-C')+ const map = stations(removed, ['O', 'B', 'C'])+ expect(map.get('O')?.map((s) => s.id)).toEqual(['B'])+ expect(map.has('B')).toBe(false)+ })++ it('(c) a cross-project open whose opener rope is pruned on first load: the healed wait is no opener', () => {+ // `--project` + `--after`: the file holds only the opener's rope, and its source lives in+ // another project; the load heals the wait rope, the prune drops the opener's.+ const loaded = canvasRopes([rope('elsewhere', 'N')], [live('B'), live('N', ['B'])])+ expect(loaded.map((r) => r.id)).toEqual([waitRopeId('B', 'N')])+ expect(stations(loaded, ['B', 'N']).size).toBe(0)+ })+})diff --git a/src/renderer/lib/teamProgress.ts b/src/renderer/lib/teamProgress.tsindex bf58acc67..3e329ef15 100644--- a/src/renderer/lib/teamProgress.ts+++ b/src/renderer/lib/teamProgress.ts@@ -1,24 +1,28 @@/*** Team progress: how far along the stations an orchestrator session opened are.*- * A STATION is a session node this node opened — a target of one of the project's ropes+ * A STATION is a session node this node opened — the target of one of the project's OPENER ropes* (`project.ropes`, `ctrl-<source>-<target>`). The orchestrator's card, its card modal and its* canvas node header show "N of M done" over those stations, and clicking the ring lists them.** Four rules decided here, each with its reason:*- * 1. **A rope names an opener only when it is the FIRST rope into its target.** Ropes carry two- * relations with one id shape: "opened by" and "waits for" (`--after`, and the `verify` panel's- * sequencing). Nothing on the node records which rope was the opener, but every writer appends- * the opener's rope BEFORE the dep ropes of the same command (`connect` then `ropeDeps`; the- * load-time `missingDepRopes` heal appends after whatever the file already holds). So the first- * incoming rope is the opener, and a later one is a wait. Without this, every `--after`- * dependency would read as a team leader: in a pipeline A → B → C each station would show the- * next one as its team, and in a verify panel each reviewer would show the judge.+ * 1. **Only an opener rope names an opener, and only the first one into a node.** Ropes carry two+ * relations: "opened by" and "waits for" (`--after`, and the `verify` panel's sequencing). A+ * wait rope is minted `ctrl-after-<dep>-<node>` (`waitRopeId`, lib/edgeModel) and is skipped+ * here; a canvas saved before that is re-marked at load by `markLegacyWaitRopes`, BEFORE the+ * canvas prunes ropes to deleted nodes. The id is what makes this hold: the canvas deletes the+ * opener's rope when the opener is deleted, and before waits were marked the first surviving+ * wait then read as the opener — a pipeline's upstream station showed the next one as its team,+ * and a verify panel's reviewed node showed its reviewers. Among the remaining (opener) ropes+ * the first into a node wins, so a duplicate cannot put one station on two teams.* 2. **Unknown is unknown, never done.** Agent state is transient; after an app restart nobody has- * reported yet. A station with no state reads `unknown` and does not count toward N. The only- * idle facts that survive a restart are `paused` / `hibernated`, and both are written only by an- * exit that refused a busy session — so they count as a finished turn (`paused`).+ * reported yet. A station with no state reads `unknown` and does not count toward N. The idle+ * facts that survive a restart — `paused` / `hibernated` — count as a finished turn: both are+ * written only by an exit that runs when the session is idle (it refuses a working or blocked+ * one). A CLI that announced its own exit (`sessionEnded`) reads `ended` and counts too: it is+ * not running and never will be again on its own, so leaving it `unknown` would hold the ring+ * below complete forever.* 3. **A station that can never report is not in M.** A plain terminal (a dev server an orchestrator* started) or an agent with no hooks never says `done`; counting it would pin the ring below* complete forever. It is listed as `untracked` and left out of the fraction — the same line@@ -31,15 +35,18 @@* the whole `byId` map (the `armedDepSig` / `loopSig` discipline). The signature carries no node* ids, so a hostile id cannot forge an entry for another station.*- * `project.ropes` comes out of a git-shared, hand-editable file and is not sanitized on load, so- * `stationsByOpener` accepts `unknown` and skips every entry it cannot read rather than throwing.+ * `project.ropes` comes out of a git-shared, hand-editable file. It is admitted through+ * `sanitizeLinks` on every load seam, but this reader is also handed the live canvas's edges and+ * the Omni board's stored copy, so it still accepts `unknown` and skips every entry it cannot read.*/import { capabilityAgentId, hasHooks, type AgentId } from '@shared/agents/config'+import { isWaitRope } from './edgeModel'import type { AgentNodeStatus } from '../state/agentStatus'export type StationKind =| 'done'| 'paused'+ | 'ended'| 'working'| 'needs'| 'errored'@@ -70,11 +77,13 @@ export interface StationNodeLike {/** Shared empty list, so a card with no stations keeps a stable prop. */export const NO_STATIONS: readonly TeamStation[] = Object.freeze([])-function readRope(r: unknown): { source: string; target: string } | null {+/** An OPENER rope, or null — for anything unreadable and for a wait rope (rule 1). */+function readOpenerRope(r: unknown): { source: string; target: string } | null {if (!r || typeof r !== 'object') return null- const { source, target } = r as { source?: unknown; target?: unknown }+ const { id, source, target } = r as { id?: unknown; source?: unknown; target?: unknown }if (typeof source !== 'string' || typeof target !== 'string') return nullif (!source || !target || source === target) return null+ if (isWaitRope({ id, source, target })) return nullreturn { source, target }}@@ -107,10 +116,10 @@ export function stationsByOpener(if (Array.isArray(ropes) && sessions.size > 0) {const opened = new Set<string>()for (const raw of ropes) {- const rope = readRope(raw)+ const rope = readOpenerRope(raw)if (!rope || opened.has(rope.target)) continue- // The first rope into a target is its opener's, whether or not that target is still here —- // a later rope into the same target is a wait, and must not be promoted by a deletion.+ // The first opener rope into a target claims it, whether or not its source is still here —+ // a stored (unpruned) file can still hold the rope of an opener that was deleted.opened.add(rope.target)const node = sessions.get(rope.target)if (!node || !sessions.has(rope.source)) continue@@ -138,7 +147,7 @@ export function stationsByOpener(}type StatusLike = Pick<AgentNodeStatus, 'state'> &- Partial<Pick<AgentNodeStatus, 'dropped' | 'paused' | 'hibernated' | 'lastTurnError' | 'agentId'>>+ Partial<Pick<AgentNodeStatus, 'dropped' | 'paused' | 'hibernated' | 'lastTurnError' | 'agentId' | 'sessionEnded'>>function reports(agentId: string | undefined): boolean {if (!agentId) return false@@ -164,12 +173,14 @@ export function stationKind(station: TeamStation, status: StatusLike | undefinedif (station.queued) return 'queued'if (state === 'done') return status?.lastTurnError ? 'errored' : 'done'if (status?.paused || status?.hibernated) return 'paused'+ if (status?.sessionEnded) return 'ended'return reports(station.agentId ?? status?.agentId) ? 'unknown' : 'untracked'}const CHAR: Record<StationKind, string> = {done: 'd',paused: 'p',+ ended: 'z',working: 'w',needs: 'n',errored: 'e',@@ -198,7 +209,7 @@ export function parseTeamProgressSig(sig: string): StationKind[] {}export interface TeamProgress {- /** Stations whose last turn ended cleanly (`done`, or paused/hibernated after one). */+ /** Stations with nothing left in flight: `done`, paused/hibernated, or a CLI that exited. */done: number/** Stations that can report — everything but `untracked`. The denominator. */total: number@@ -210,7 +221,7 @@ export interface TeamProgress {export function summarizeTeam(kinds: readonly StationKind[]): TeamProgress {const counts = Object.fromEntries(Object.keys(CHAR).map((k) => [k, 0])) as Record<StationKind, number>for (const k of kinds) counts[k]++- const done = counts.done + counts.paused+ const done = counts.done + counts.paused + counts.endedconst total = kinds.length - counts.untrackedconst attention =counts.errored + counts.dropped > 0@@ -226,6 +237,7 @@ export function summarizeTeam(kinds: readonly StationKind[]): TeamProgress {export const STATION_LABEL: Record<StationKind, string> = {done: 'done',paused: 'done · paused',+ ended: 'exited',working: 'working',needs: 'needs you',errored: 'last turn failed',@@ -237,12 +249,13 @@ export const STATION_LABEL: Record<StationKind, string> = {/** Order of the breakdown in the tooltip and the list header — attention first. */const BREAKDOWN: readonly StationKind[] = [- 'dropped', 'errored', 'needs', 'working', 'queued', 'unknown', 'done', 'paused', 'untracked'+ 'dropped', 'errored', 'needs', 'working', 'queued', 'unknown', 'done', 'paused', 'ended', 'untracked']/** "2 of 5 done — 1 working, 1 needs you, 1 unknown" (+ the untracked count, outside M). */export function teamProgressText(p: TeamProgress): string {- const parts = BREAKDOWN.filter((k) => k !== 'done' && k !== 'paused' && k !== 'untracked' && p.counts[k] > 0).map(+ const finished: readonly StationKind[] = ['done', 'paused', 'ended', 'untracked']+ const parts = BREAKDOWN.filter((k) => !finished.includes(k) && p.counts[k] > 0).map((k) => `${p.counts[k]} ${STATION_LABEL[k]}`)const head = `${p.done} of ${p.total} done`diff --git a/src/renderer/state/teamStations.test.ts b/src/renderer/state/teamStations.test.tsindex 091369ffd..56e89fab3 100644--- a/src/renderer/state/teamStations.test.ts+++ b/src/renderer/state/teamStations.test.ts@@ -55,6 +55,14 @@ describe('wiring', () => {expect(canvas).toContain('useTeamStations.getState().set(teamStations)')expect(canvas).toContain('teams={teamStations}')})+ it('Canvas marks legacy wait ropes at load, before its prune can erase the order, and mints marked waits', () => {+ const canvas = read('../canvas/Canvas.tsx')+ expect(canvas).toContain('const restoredRopes = markLegacyWaitRopes(project.ropes ?? [])')+ expect(canvas).toContain('setControlEdges((es) => pruneRopes(es, ids))')+ expect(canvas).toContain('ropeEdge(waitRopeId(dep, nid), dep, nid)')+ // No wait rope is minted with the opener's id shape anywhere on the canvas.+ expect(canvas).not.toContain('ropeEdge(`ctrl-${dep}-')+ })it("the node header reads its OWN team from the store, never the whole status map", () => {const node = read('../nodes/TerminalNode.tsx')expect(node).toContain('useTeamStations((s) => s.byNode.get(id))')diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 68ccae9dc..09ae96649 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -11157,7 +11157,8 @@ button.pull-checks__name {border: 1px solid rgba(var(--tint-rgb), 0.35);}.team-progress__dot--done,-.team-progress__dot--paused {+.team-progress__dot--paused,+.team-progress__dot--ended {background: var(--state-success);border-color: transparent;}