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(dino): use the gated presence.dino wrapper + emit the yield-null (whole-branch review)
enesfc2827993802
diff --git a/src/renderer/nodes/DinoNode.tsx b/src/renderer/nodes/DinoNode.tsxindex 13803c41d..dfb6daab7 100644--- a/src/renderer/nodes/DinoNode.tsx+++ b/src/renderer/nodes/DinoNode.tsx@@ -3,7 +3,7 @@ import { NodeResizer, useReactFlow, type NodeProps } from '@xyflow/react'import { useShallow } from 'zustand/react/shallow'import { type CanvasNode } from '../state/workspace'import { useProjects } from '../state/projects'-import { useSession, useActiveSessionPresence } from '../session/session'+import { useActiveSessionPresence } from '../session/session'import { createDinoGame } from './dino/dino-game'import { shouldSpectate } from './dino/dino-authority'@@ -16,10 +16,10 @@ import { shouldSpectate } from './dino/dino-authority'* while this node is focused and stays silent when you're on another node.** Live/shared play (docs/superpowers/specs/2026-07-14-dino-live-design.md): while WE author a run- * the engine broadcasts each frame over presence (`api.presence.dino`); while a peer authors this+ * the engine broadcasts each frame over presence (`presence.dino`); while a peer authors this* node we SPECTATE their snapshots (`game.setRemote`). A lowest-clientId tiebreak (shouldSpectate)* settles a brief take-over race so every client converges on one authority. Solo (no peers) →- * `selectDino` is null → we never spectate and the broadcast casts are hub no-ops, so play is+ * `selectDino` is null → we never spectate and `presence.dino` skips the cast, so play is* byte-identical to before.*/export function DinoNode({ id, data, selected }: NodeProps<CanvasNode>) {@@ -27,10 +27,9 @@ export function DinoNode({ id, data, selected }: NodeProps<CanvasNode>) {const hostRef = useRef<HTMLDivElement>(null)const gameRef = useRef<ReturnType<typeof createDinoGame> | null>(null)- // The active session's api + presence. DinoNode renders under Canvas's active-session provider,- // which is KEYED on `session.id` (Canvas.tsx), so this node REMOUNTS on a session swap — the- // mount-time `api` capture below is therefore always the current session's, no ref needed.- const { api } = useSession()+ // The active session's presence. DinoNode renders under Canvas's active-session provider, which is+ // KEYED on `session.id` (Canvas.tsx), so this node REMOUNTS on a session swap — the mount-time+ // `presence` capture below is therefore always the current session's, no ref needed.const presence = useActiveSessionPresence()// The peer (if any) broadcasting a live dino for THIS node, and our own id for the tiebreak.// selectDino excludes self and already applies the lowest-clientId rule, so `peer` is the one@@ -51,9 +50,11 @@ export function DinoNode({ id, data, selected }: NodeProps<CanvasNode>) {const s = useProjects.getState()s.setDinoHighScore(s.activeProjectId, score)},- // Authority broadcast: each throttled frame while we play, one null on stop/idle. Solo → a- // hub no-op (no peers). `api` is captured once at mount (safe — see the remount note above).- onSnapshot: (snap) => api.presence.dino(snap ? { nodeId: id, snap } : null)+ // Authority broadcast: each throttled frame while we play, one null on stop/idle. Cast through+ // the SESSION wrapper `presence.dino` (not raw `api.presence.dino`), so a solo player's ~20 Hz+ // snapshots are SKIPPED with no peer to watch (the `null` stop always lands). `presence` is+ // captured once at mount (safe — DinoNode remounts on session change; see the note above).+ onSnapshot: (snap) => presence.dino(snap ? { nodeId: id, snap } : null)})gameRef.current = gamereturn () => {@@ -61,7 +62,7 @@ export function DinoNode({ id, data, selected }: NodeProps<CanvasNode>) {// broadcast was mid-run (destroy() already emits null via onSnapshot when mid-broadcast; a// repeat null is an idempotent hub no-op).game.destroy()- api.presence.dino(null)+ presence.dino(null)gameRef.current = null}// Mount once; never re-run (would respawn the game). data.highScore is readdiff --git a/src/renderer/nodes/dino/dino-game.ts b/src/renderer/nodes/dino/dino-game.tsindex 5cb24f4ab..a82b49f2f 100644--- a/src/renderer/nodes/dino/dino-game.ts+++ b/src/renderer/nodes/dino/dino-game.ts@@ -393,7 +393,7 @@ export function createDinoGame(// when unfocused; leaving returns the own sim to its pre-start idle frame.function setRemote(snap: DinoSnapshot | null) {if (snap) {- sync.setRemote(snap)+ emit(sync.setRemote(snap)) // may emit one null on the authority→spectator (yield) edgeapplyRemote(snap)start()draw()diff --git a/src/renderer/nodes/dino/dino-sync.test.ts b/src/renderer/nodes/dino/dino-sync.test.tsindex e8660646b..c26995de4 100644--- a/src/renderer/nodes/dino/dino-sync.test.ts+++ b/src/renderer/nodes/dino/dino-sync.test.ts@@ -81,11 +81,27 @@ describe('DinoSync', () => {it('setRemote(null) returns to local authority', () => {const s = new DinoSync()s.setRemote(snap())- s.setRemote(null)+ expect(s.setRemote(null)).toBe('none')expect(s.isAuthority()).toBe(true)expect(s.remoteSnap).toBe(null)})+ it('yielding authority (broadcasting → remote) owes ONE null so the hub does not keep a stale game', () => {+ const s = new DinoSync()+ s.tick(0, true) // start authoring → broadcasting = true+ // We lose the tiebreak and go spectate a peer: the transition owes a clearing null.+ expect(s.setRemote(snap())).toBe('null')+ expect(s.isRemote()).toBe(true)+ // And no further null is owed (broadcasting was cleared): a later stop emits nothing.+ expect(s.setRemote(null)).toBe('none')+ expect(s.endBroadcast()).toBe('none')+ })++ it('an idle spectator entering remote owes nothing (was never broadcasting)', () => {+ const s = new DinoSync()+ expect(s.setRemote(snap())).toBe('none')+ })+it('takeOver() flips remote→local and returns the seed snapshot', () => {const s = new DinoSync()const view = snap({ score: 999 })diff --git a/src/renderer/nodes/dino/dino-sync.ts b/src/renderer/nodes/dino/dino-sync.tsindex 67505e49a..a00e52a1c 100644--- a/src/renderer/nodes/dino/dino-sync.ts+++ b/src/renderer/nodes/dino/dino-sync.ts@@ -66,15 +66,24 @@ export class DinoSync {return 'none'}- /** Enter remote spectator mode with `snap`, or return to local authority with null. */- setRemote(snap: DinoSnapshot | null): void {+ /**+ * Enter remote spectator mode with `snap`, or return to local authority with null.+ * Returns the emit owed by the transition: entering remote WHILE we were the authority+ * (e.g. we lost the lowest-clientId tiebreak) owes ONE `null` so our last snapshot stops+ * lingering on the hub — otherwise a third peer that later loses ITS authority could be+ * left watching our frozen frame forever. Any other transition owes nothing.+ */+ setRemote(snap: DinoSnapshot | null): DinoSyncEmit {if (snap) {+ const owed: DinoSyncEmit = this.broadcasting ? 'null' : 'none'this._mode = 'remote'this._remote = snap- } else {- this._mode = 'local'- this._remote = null+ this.broadcasting = false // we stopped authoring; the owed null (if any) clears the hub+ return owed}+ this._mode = 'local'+ this._remote = null+ return 'none'}/**