Skip to content

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.

fix(kanban-sync): the rendered project's live set is React Flow's, Omni board included (N4)

review1b08cae5343d
diff --git a/CLAUDE.md b/CLAUDE.md
index a49e81c17..359362934 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -7398,7 +7398,7 @@ The invariants, each with its reason:
- **Prune removals are never cast** (`diffKanbanOps`' `liveNodeIds`). Every board commit prunes the
cards of nodes that are not live locally, and a client whose node op has not arrived yet would
otherwise cast the removal of a fresh card for everyone. `liveNodeIds` is one project's nodes
- (for the rendered project, React Flow ∩ store while the Omni board is open). Card and meta
+ (React Flow's for the rendered project, the Omni board's live lane included). Card and meta
removals are last-writer-wins VALUES; only node, edge, column, label and view removals are rule-4
deletions.
diff --git a/docs/hosted-team-relay.md b/docs/hosted-team-relay.md
index 9365bbc6f..9b14e6149 100644
--- a/docs/hosted-team-relay.md
+++ b/docs/hosted-team-relay.md
@@ -429,10 +429,6 @@ it is a new way to use it.
- **Board edits reach only the active tab's core.** A client casts only to the core its active tab
is on. An edit on the Omni board to a lane of a project on another core (a hosted lane while a
local tab is active, or the reverse) is not cast, so on a hosted core it is not written either.
-- **The Omni board and a brand-new node.** While the Omni board is open, removing the card of a node
- created moments ago in the project on screen is not cast (teammates keep the card). For that
- project only, the nodes that are both on the canvas and in the stored copy count as live then,
- which can only ever cast fewer removals.
- **The card modal's comments on a relay tab** (`BoardLogPanel`) still read and write the local core's
board log, not the host's, because the modal renders outside the tab's session. This predates the
authority; it is a follow-up.
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 6aa62e364..0b6e57fdf 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -3878,14 +3878,13 @@ export function Canvas() {
* (`boardLiveNodeIds`): the project React Flow holds answers from the epoch pair (`nodesRef` is
* that project's canvas exactly while `nodesProjectIdRef` names it — useNodesEpoch), every other
* project from its stored copy (a project mid-load is still the store's until the load installs
- * it) — and while the Omni board is open, whose lanes prune against the stored copy, the rendered
- * project answers from React Flow ∩ store (ruling R6).
+ * it). The Omni board's active lane prunes against React Flow too (`globalKanbanLive`), so it
+ * needs no case of its own.
*/
const liveNodeIdsFor = (projectId: string): ReadonlySet<string> =>
boardLiveNodeIds({
rendered: nodesProjectIdRef.current === projectId ? nodesRef.current.map((n) => n.id) : null,
- stored: (useProjects.getState().getProject(projectId)?.nodes ?? []).map((n) => n.id),
- omniOpen: isGlobalKanbanOpen()
+ stored: (useProjects.getState().getProject(projectId)?.nodes ?? []).map((n) => n.id)
})
/**
* THE ONE CAST on canvas:mut, for every family this Canvas publishes — nodes and edges (the
diff --git a/src/renderer/canvas/kanban-sync-wiring.test.ts b/src/renderer/canvas/kanban-sync-wiring.test.ts
index 2a74caf0b..b6110514f 100644
--- a/src/renderer/canvas/kanban-sync-wiring.test.ts
+++ b/src/renderer/canvas/kanban-sync-wiring.test.ts
@@ -64,8 +64,9 @@ describe('kanban sync wiring', () => {
expect(body).toContain('boardLiveNodeIds({')
expect(body).toMatch(/rendered: nodesProjectIdRef\.current === projectId \? nodesRef\.current\.map\(\(n\) => n\.id\) : null/)
expect(body).toMatch(/stored: \(useProjects\.getState\(\)\.getProject\(projectId\)\?\.nodes \?\? \[\]\)\.map\(\(n\) => n\.id\)/)
- // R6: while the Omni board is open its lanes prune against the STORED nodes.
- expect(body).toContain('omniOpen: isGlobalKanbanOpen()')
+ // N4: no Omni term — the Omni board's active lane prunes against React Flow too.
+ expect(body).not.toContain('omniOpen')
+ expect(body).not.toContain('isGlobalKanbanOpen')
})
// R7: the solo path (~20 Hz while dragging) asks the cheap question first.
diff --git a/src/renderer/canvas/kanban-sync.test.ts b/src/renderer/canvas/kanban-sync.test.ts
index 516f40fa2..733ee7e32 100644
--- a/src/renderer/canvas/kanban-sync.test.ts
+++ b/src/renderer/canvas/kanban-sync.test.ts
@@ -4,6 +4,9 @@ import { applyKanbanOp } from '@shared/kanban-ops'
import { defaultKanbanFor } from '@shared/kanban-default-board'
import type { CanvasMutation, KanbanOp, ProjectKanban } from '@shared/types'
import { setKanbanPublishHook, useProjects } from '../state/projects'
+import { nodeStatesToFlow } from '../state/workspace'
+import { pruneAssignments } from '../lib/kanban'
+import { kanbanSessionsFrom } from './toKanbanSession'
const P = 'project-1'
const todo = defaultKanbanFor(P).columns[0].id
@@ -155,45 +158,46 @@ describe('createKanbanPublisher', () => {
})
})
-// RULING R6. The Omni board prunes each lane against the STORED nodes, and for the project React Flow
-// holds that copy lags the canvas while the board is open (a peer's node op, a "+ New" or an agent
-// spawn lands in React Flow only). A card the Omni board just pruned because its node is not stored
-// yet must not read as a live card someone took off the board — that removal would delete it for
-// everyone. So while the Omni board is open the rendered project's live set is React Flow ∩ store.
-describe('boardLiveNodeIds (R6)', () => {
+// N4 (supersedes ruling R6). The Omni board's active lane is fed from React Flow (Canvas's
+// `globalKanbanLive`, the same live cards as the project board), so its commit prunes against the
+// canvas, not the stored copy that lags it. R6's React Flow ∩ store answer only removed live ids the
+// store had not caught up with: an explicit Ungroup of a fresh card was then never cast, peers kept
+// the card, and on a governed project the next overlaid save wrote it back.
+describe('boardLiveNodeIds (N4)', () => {
+ const state = (id: string, kind: 'terminal' | 'sticky' = 'terminal') =>
+ ({ id, kind, title: id, color: '#fff', group: '', position: { x: 0, y: 0 }, size: { width: 10, height: 10 } }) as never
+
it('a project React Flow does not hold answers from its stored nodes', () => {
- expect([...boardLiveNodeIds({ rendered: null, stored: ['a', 'b'], omniOpen: true })]).toEqual(['a', 'b'])
- expect([...boardLiveNodeIds({ rendered: null, stored: ['a'], omniOpen: false })]).toEqual(['a'])
+ expect([...boardLiveNodeIds({ rendered: null, stored: ['a', 'b'] })]).toEqual(['a', 'b'])
})
- it('the rendered project answers from React Flow while the Omni board is closed', () => {
- expect([...boardLiveNodeIds({ rendered: ['a', 'n'], stored: ['a'], omniOpen: false })].sort()).toEqual(['a', 'n'])
+ it('the rendered project answers from React Flow, a node not stored yet included', () => {
+ expect([...boardLiveNodeIds({ rendered: ['a', 'n'], stored: ['a', 'gone'] })].sort()).toEqual(['a', 'n'])
})
- it('…and from React Flow ∩ store while it is open', () => {
- expect([...boardLiveNodeIds({ rendered: ['a', 'n'], stored: ['a', 'gone'], omniOpen: true })]).toEqual(['a'])
+ it('with the live lane, the Omni writer prunes against exactly the set the publisher treats as live', () => {
+ // `fresh` is on the canvas (a "+ New", a peer's node op) and not in the stored copy yet.
+ const rendered = nodeStatesToFlow([state('a'), state('fresh', 'sticky')])
+ const stored = ['a', 'gone']
+ // What the Omni lane prunes against: the live lane's card ids (GlobalKanbanView `sessionIds`).
+ const omniKeeps = new Set(kanbanSessionsFrom(rendered, { ssh: false }).map((s) => s.id))
+ const publisherLive = boardLiveNodeIds({ rendered: rendered.map((n) => n.id), stored })
+ expect([...omniKeeps].sort()).toEqual([...publisherLive].sort())
})
- it('a card the Omni board pruned because its node is not stored yet is never removed for everyone', () => {
- // n is on the canvas (a peer's node op landed in React Flow) but not in the stored copy the Omni
- // lane prunes against. The peer's card for n arrived; the Omni user moved another card.
+ it('an explicit Ungroup of a fresh card is cast; a card the lane pruned for a dead node is not', () => {
const sent: CanvasMutation[] = []
- const live = { rendered: ['m', 'n'], stored: ['m'] }
const pub = createKanbanPublisher({
send: (_id, m) => { sent.push(m); return true },
- liveNodeIds: () => boardLiveNodeIds({ ...live, omniOpen: true }),
+ liveNodeIds: () => boardLiveNodeIds({ rendered: ['m', 'fresh'], stored: ['m', 'dead'] }),
shouldPublish: () => true,
applyLocal: () => {}
})
- const prev: ProjectKanban = {
- ...withCard(withCard(undefined, 'm', todo), 'n', todo),
- meta: [{ nodeId: 'n', priority: 'high' }]
- }
- // What the Omni lane commits: m moved, and n's card + meta pruned (n is not a stored session).
- const next: ProjectKanban = { ...withCard(prev, 'm', doing), assignments: [{ nodeId: 'm', columnId: doing }], meta: [] }
+ const prev: ProjectKanban = withCard(withCard(withCard(undefined, 'm', todo), 'fresh', todo), 'dead', todo)
+ // The Omni lane commits: `fresh` taken off the board by hand, `dead` pruned (not on the canvas).
+ const next = pruneAssignments({ ...prev, assignments: prev.assignments.filter((a) => a.nodeId !== 'fresh') }, ['m', 'fresh'])
pub.publish(P, prev, next)
- expect(sent.filter((m) => m.op === 'kb-card-remove' || m.op === 'kb-meta-remove')).toEqual([])
- expect(sent).toContainEqual({ op: 'kb-card', assignment: { nodeId: 'm', columnId: doing } })
+ expect(sent).toEqual([{ op: 'kb-card-remove', nodeId: 'fresh' }])
})
})
diff --git a/src/renderer/canvas/kanban-sync.ts b/src/renderer/canvas/kanban-sync.ts
index cb5d29e94..4d62da8c2 100644
--- a/src/renderer/canvas/kanban-sync.ts
+++ b/src/renderer/canvas/kanban-sync.ts
@@ -64,22 +64,16 @@ function stable(v: unknown): string {
* The node ids a board write may treat as LIVE in one project — what the prune rule asks
* (`liveNodeIds` above). One project's ids, never a mix:
* - a project React Flow does not hold (`rendered` null) answers from its stored nodes;
- * - the project React Flow holds answers from React Flow, whose array is ahead of the stored copy;
- * - …except while the Omni board is open (ruling R6): its lanes prune against the STORED nodes, and
- * for the rendered project that copy lags React Flow for as long as the board is up (a peer's node
- * op, a "+ New" or an agent spawn lands in React Flow only, and the store catches up at the next
- * commit). A card the Omni board pruned because its node is not stored yet would read as a live
- * card someone took off the board, and its removal would delete it for every client. So the
- * answer there is React Flow ∩ store — both describe the same project, and a smaller live set
- * can only ever cast fewer removals.
+ * - the project React Flow holds answers from React Flow, whose array is ahead of the stored copy.
+ * The Omni board needs no case of its own: its active lane is fed from React Flow as well
+ * (`globalKanbanLive`), so it prunes against the same set. (An earlier answer, React Flow ∩ store
+ * while the Omni board was open, dated from when its lanes read the store; it left an explicit
+ * Ungroup of a card whose node was not stored yet uncast, so peers kept the card and a governed
+ * project's next overlaid save wrote it back.)
*/
export function boardLiveNodeIds(src: {
rendered: readonly string[] | null
stored: readonly string[]
- omniOpen: boolean
}): ReadonlySet<string> {
- if (!src.rendered) return new Set(src.stored)
- if (!src.omniOpen) return new Set(src.rendered)
- const stored = new Set(src.stored)
- return new Set(src.rendered.filter((id) => stored.has(id)))
+ return new Set(src.rendered ?? src.stored)
}