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
Merge origin/main into test/pendinglaunch-trust-behaviour
reviewbdbde42bb4b2
diff --cc src/renderer/canvas/Canvas.tsxindex eff76ce4c,2261495b1..c2b55f95c--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@@ -652,11 -672,24 +672,23 @@@ import { focusTargetId } from '../lib/fimport {createCanvasPublisher,isEphemeralNodeId,- publishableStates,+ publishableScene,type CanvasPublisher} from '@shared/canvas-publish'- import { createCanvasOrder, createReconnectWatch, type CanvasOrder } from '@shared/canvas-order'- import { createMutationGuard } from '@shared/canvas-mutations'+ import {+ createCanvasOrder,+ createReconnectWatch,+ isRemoveOp,+ mutationKey,+ type CanvasOrder+ } from '@shared/canvas-order'+ import {+ applyEdgeMutationToScene,+ createMutationGuard,+ isEdgeMutation,+ type CanvasScene+ } from '@shared/canvas-mutations'+ import { isKanbanOp } from '@shared/kanban-ops'-import { withoutCoreOrigin } from '@shared/node-exec'import { chordHeld, isHoldChord, isModifierEventKey, matchesShortcut } from '@shared/shortcut'// The dispatch below is the CONSUMER of the confirm-gated set. Before this import the set named@@@ -3774,10 -4064,84 +4063,84 @@@ export function Canvas()// dial-capable SSH connection onto this machine (session/relay-ssh.ts).const relay = activeSession.source === 'relay'return activeSession.api.canvas.onMutation((projectId, received) => {- const mutation = relay ? sanitizeRelayMutation(withoutCoreOrigin(received)) : received+ const mutation = receivedCanvasMutation(received, relay)- hasPeersRef.current = true // proof of a peer, whatever the presence table says- if (!orderRef.current?.accept(mutation)) return- if (projectId !== useProjects.getState().activeProjectId) {+ // Proof of a peer, whatever the presence table says — but only a cast from ANOTHER client+ // (`provesPeer`): our own echo is our ack, and a lone client that casts on a governed project+ // must not start publishing every project on this core.+ if (provesPeer(mutation, canvasSrcRef.current)) hasPeersRef.current = true+ const order = orderRef.current+ if (!order) return+ // Counted over EVERY key, before and after: an echo of ours releases its own key's gate, and+ // also any EARLIER remove of ours whose echo was lost on the way back (canvas-order, FIFO).+ const heldBefore = order.pendingRemoveCount()+ const apply = order.accept(mutation, projectId)+ if (order.pendingRemoveCount() < heldBefore) queueMicrotask(releaseHeld)+ if (!apply) return+ // ---- the board (kanban) ----+ // Into the projects STORE, for the active project and a background one alike: the board, the+ // column pills and the card modal all read the store live, and React Flow holds no board. The+ // store reducer, never `setProjectKanban` — its publish hook would re-cast a peer's op as ours+ // — and no board-log entry: only the client that made the change records it (spec §5).+ if (isKanbanOp(mutation)) {+ applyToStored(projectId, mutation)+ return+ }+ // ---- edges (context links + "spawned by" ropes) ----+ // They live outside React Flow's `nodes` array, in their own state, so they take their own+ // apply path — but everything around it is the node path's contract, unchanged: the ordering+ // gate above has already decided this mutation wins, `adopt` is still the loop guard, and a+ // background project is still patched in the store so our next save cannot delete the edge.+ if (isEdgeMutation(mutation)) {+ // Live only while React Flow holds that project (the epoch tag), not merely while it is the+ // active one — the same rule as the node branch below (`liveCanvasHolds`).+ if (!liveCanvasHolds(nodesProjectIdRef.current, useProjects.getState().activeProjectId, projectId)) {+ applyToStored(projectId, mutation)+ return+ }+ // One id is one edge (`applyEdgeMutationToScene`): an upsert of one kind also takes that id+ // out of the other list, and a remove drops it from both — the same identity the ordering+ // gate above keys on (`mutationKey` leaves the kind out).+ const prevBridges = linkEdgesRef.current+ const prevRopes = controlEdgesRef.current+ const base = { bridges: prevBridges.map(toBridgeLink), ropes: prevRopes.map(toBridgeLink) }+ const next = applyEdgeMutationToScene(base, mutation)+ // Nothing to do — a remove for an edge we do not have, or the edge we already hold (every+ // Server Edition tab re-casts a server-written edge): no setState, no markDirty, no save.+ if (next.bridges === base.bridges && next.ropes === base.ropes) return+ // Rebuilt EDGE-BY-EDGE, reusing the existing object whenever its three ids are unchanged —+ // the same discipline `applyMutationToFlow` follows for nodes, and for the same reason: a+ // freshly built object loses `selected`, so re-creating the whole list would wipe the+ // user's edge selection every time a teammate touched any OTHER edge.+ const keep = <T extends Edge>(prev: T[], link: BridgeLink): T | undefined => {+ const e = prev.find((x) => x.id === link.id)+ return e && e.source === link.source && e.target === link.target ? e : undefined+ }+ if (next.bridges !== base.bridges) {+ // No `type`: a bridge carries none in state — `displayEdges` makes every link `floating`.+ const edges = next.bridges.map(+ (b) => keep(prevBridges, b) ?? { id: b.id, source: b.source, target: b.target }+ )+ linkEdgesRef.current = edges+ setLinkEdges(edges)+ }+ if (next.ropes !== base.ropes) {+ // Nothing but the three ids travels: a rope's colour and its waiting look are derived at+ // render time from this client's own nodes (`displayEdges` / `ropeVisual`).+ const edges = next.ropes.map((r) => keep(prevRopes, r) ?? ropeEdge(r.id, r.source, r.target))+ controlEdgesRef.current = edges+ setControlEdges(edges)+ }+ // The loop guard, AFTER both refs moved: publishableLater captures them as of this call.+ publisherRef.current?.adopt(publishableLater(nodesRef.current))+ markDirty()+ return+ }+ // Live only while React Flow holds that project's canvas (`liveCanvasHolds` — the epoch tag+ // AND the active id). During a switch the store already says B while React Flow still holds+ // A, or nothing after a bail-out; B's op applied to that array ended the canvas on A's nodes+ // plus the op, tagged B, and the next commit wrote them into B's file (Task 2 review, risk+ // E). In that case B's serialized nodes are the right target: the load reads them.+ if (!liveCanvasHolds(nodesProjectIdRef.current, useProjects.getState().activeProjectId, projectId)) {// Not on screen (a parked / background project): no terminal is mounted, but one may be// PARKED from a recent project switch — dispose it, as an active-project remove does.if (mutation.op === 'remove') {diff --cc src/server/headless-node-factory.test.tsindex 147bdbf37,0fc7b05b9..eab324aaf--- a/src/server/headless-node-factory.test.ts+++ b/src/server/headless-node-factory.test.ts@@@ -239,11 -250,14 +250,16 @@@ describe('HeadlessNodeFactory', () =>ownership,stateOf: (id) => states[id],outcomeOf: (id) => outcomes[id],+ handedOver: (id) => handedOver.has(id),launchTiming: { quietMs: 0, capMs: 0 },- // A snapshot, as the real publisher (publishCanvasMutation) takes one at call time: the factory+ // Every content op the factory casts; `published` / `removed` keep the node halves these+ // tests assert on (edges and board ops are cast too — see the cast-before-save suite).++ // `published` holds a SNAPSHOT, as the real publisher takes one at call time: the factory+ // goes on to update the same node object in place after it publishes.- publishNode: (_projectId, node) => published.push(structuredClone(node)),- publishRemoval: (_projectId, nodeId) => removed.push(nodeId),+ publishMutation: (_projectId, m) => {- if (m.op === 'upsert') published.push(m.node)++ if (m.op === 'upsert') published.push(structuredClone(m.node))+ else if (m.op === 'remove') removed.push(m.id)+ },publishProject: (project) => publishedProjects.push(structuredClone(project))})})