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
perf(dino): gate the snapshot cast on hasPeers — presence is free when solo (dino Task 4 review)
enes5bff01315347
diff --git a/src/renderer/state/presence.test.ts b/src/renderer/state/presence.test.tsindex b4d13de11..90c82f077 100644--- a/src/renderer/state/presence.test.ts+++ b/src/renderer/state/presence.test.ts@@ -611,16 +611,25 @@ describe('selectDino (the spectator picks THE authority broadcasting for a node)})describe('session.dino (casts the live snapshot on the api)', () => {- it('forwards the payload (and the clearing null) straight to api.presence.dino', async () => {+ it('publishes a snapshot only when a peer is watching, but ALWAYS sends the clearing null', async () => {vi.stubGlobal('localStorage', memStorage(STORED_ME))const api = fakePresenceApi()- const { defaultPresence } = await import('./presence')-+ const { defaultPresence, usePresence } = await import('./presence')const payload = { nodeId: 'dino-a', snap: snap({ score: 42 }) }++ // Alone: a solo player's ~20 Hz snapshot casts are FREE — skipped (like reportFocus). But the+ // stop (null) still lands (an edge; and it costs nothing) so a spectator can never be stranded.+ usePresence.setState({ myId: 7, peers: { 7: peer(7) } }) // just medefaultPresence.dino(payload)defaultPresence.dino(null)+ expect(api.calls.filter((c) => c[0] === 'dino')).toEqual([['dino', null]])+ // A peer shows up: the snapshot publishes, and its clearing null with it.+ usePresence.setState({ peers: { 7: peer(7), 8: peer(8) } })+ defaultPresence.dino(payload)+ defaultPresence.dino(null)expect(api.calls.filter((c) => c[0] === 'dino')).toEqual([+ ['dino', null],['dino', payload],['dino', null]])diff --git a/src/renderer/state/presence.ts b/src/renderer/state/presence.tsindex 6d39fb84e..5d0ae1e96 100644--- a/src/renderer/state/presence.ts+++ b/src/renderer/state/presence.ts@@ -588,8 +588,11 @@ function buildPresenceSession(api: NodeTerminalApi): PresenceSession {/** Broadcast the live dino game we are the authority for (null = stopped/idle). Unlike focus/* project this is NOT deduped: the DinoNode throttles the snapshot rate itself, each frame is- * distinct, and the clearing null must always reach the hub so spectators stop drawing. */+ * distinct. Presence is FREE when you are alone (like reportFocus): a solo player's ~20 Hz+ * snapshot casts are skipped when there is no peer to watch — but a clearing `null` ALWAYS lands+ * (a stop is an edge; and it costs nothing) so a spectator can never be left drawing a ghost. */function dino(payload: { nodeId: string; snap: DinoSnapshot } | null): void {+ if (payload !== null && !hasPeers()) returnapi.presence.dino(payload)}