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(team-access): send agent status, subagent activity and context updates to relay peers
reviewd9c09fd96767
diff --git a/src/main/agent-status-broadcast-wiring.test.ts b/src/main/agent-status-broadcast-wiring.test.tsnew file mode 100644index 000000000..03bdf1353--- /dev/null+++ b/src/main/agent-status-broadcast-wiring.test.ts@@ -0,0 +1,43 @@+// Source pins for the desktop Team Access host's agent-event fan-out. A desktop host's relay peers+// (a joined team tab) keep the host's agent status in their own store, but they can only do that if+// the host SENDS it to them: `sendToMain` / `win.webContents.send` reach the app's own window and+// nothing else. `corePlatform.broadcast` is the main window (via `sendToMain`, unchanged) plus+// every non-quiet relay peer, each in its own try/catch — the same channel presence and+// `canvas:mut` already ride. The delivery rules themselves are behaviour-tested in+// platform-electron.test.ts (main window once, quiet peer never, a throwing peer never stops the+// rest) and scoped-guest-policy.test.ts (a scoped guest only hears its own project's nodes).+import { describe, it, expect } from 'vitest'+import fs from 'fs'+import path from 'path'++const read = (rel: string): string => fs.readFileSync(path.join(__dirname, '..', rel), 'utf8').replace(/\r\n/g, '\n')+const count = (src: string, needle: string): number => src.split(needle).length - 1++describe('the desktop host broadcasts agent events to its relay peers', () => {+ const src = read('main/index.ts')++ it('agent events go through corePlatform.broadcast', () => {+ // Counted, not `not.toContain`: a failure then prints a number instead of the whole of index.ts.+ expect(count(src, 'sendToMain(IPC.agentStatus')).toBe(0)+ expect(count(src, 'webContents.send(IPC.agentSubagentActivity')).toBe(0)+ expect(count(src, 'webContents.send(IPC.contextUpdate')).toBe(0)+ expect(count(src, 'corePlatform.broadcast(IPC.agentStatus')).toBeGreaterThanOrEqual(4)+ expect(src).toContain('corePlatform.broadcast(IPC.agentSubagentActivity')+ expect(count(src, 'corePlatform.broadcast(IPC.contextUpdate')).toBe(2)+ })++ it('unread-clear stays a main-window event', () => {+ // Joiners never read it (decision 1): a read on the host's own window is the host's business.+ expect(src).toContain('sendToMain(IPC.agentUnreadClear')+ })++ it("broadcast's main-window leg is sendToMain, so the window's delivery is unchanged", () => {+ const platform = read('main/platform-electron.ts')+ const start = platform.indexOf('broadcast: (ch, ...args) => {')+ expect(start).toBeGreaterThan(-1)+ const body = platform.slice(start, platform.indexOf('\n },', start))+ // First statement, unconditional: the window hears every broadcast whether or not a peer exists.+ expect(body).toMatch(/^broadcast: \(ch, \.\.\.args\) => \{\n\s*sendToMain\(ch, \.\.\.args\)/)+ expect(count(body, 'sendToMain(')).toBe(1)+ })+})diff --git a/src/main/index.ts b/src/main/index.tsindex 404312bed..b19d71674 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -2961,7 +2961,7 @@ app.whenReady().then(async () => {// which need the raw transcript_path the NormalizedAgentEvent intentionally drops.const subagentTail = createSubagentTail(({ toolUseId, chunk }) => {subagentReplay.touch(toolUseId) // a streaming subagent is alive: keep it in the reload replay- if (!win.isDestroyed()) win.webContents.send(IPC.agentSubagentActivity, { toolUseId, chunk })+ corePlatform.broadcast(IPC.agentSubagentActivity, { toolUseId, chunk })})// Claude's two subagent signal paths merged into one card per child (native SubagentStart/Stop// win once a session sends them — core/claude-subagent-lifecycle.ts). Every normalized event@@ -2991,7 +2991,7 @@ app.whenReady().then(async () => {for (const [nid, sid] of nodeContextSession) if (sid === sessionId) nodeId = nidif (!nodeId) returnconst ev = recordQuestionResult(nodeId, sessionId, toolUseId)- if (ev) sendToMain(IPC.agentStatus, ev)+ if (ev) corePlatform.broadcast(IPC.agentStatus, ev)}/*** The transcript recorded an interrupt marker (Esc / Ctrl+C). Claude sends no hook for an@@ -3024,7 +3024,7 @@ app.whenReady().then(async () => {// Through the lifecycle like every other event: in a session that sends native hooks the card// is keyed by the child's agent_id, and this tool-keyed end is re-keyed onto it (idempotent).for (const out of claudeSubagents.apply(taskDoneEvent)) {- sendToMain(IPC.agentStatus, out)+ corePlatform.broadcast(IPC.agentStatus, out)recordAgentEvent(out)}subagentTail.finish(n.toolUseId)@@ -3035,14 +3035,15 @@ app.whenReady().then(async () => {const cursorSubagents = createCursorSubagentTracker({tail: subagentTail,emit: (ev) => {- sendToMain(IPC.agentStatus, ev)+ corePlatform.broadcast(IPC.agentStatus, ev)recordAgentEvent(ev)}})// Every context tail pushes through here, so an agent's meter reaches the renderer, the Notch HUD- // and the phone's context ring identically whichever CLI produced the numbers.+ // and the phone's context ring identically whichever CLI produced the numbers. `broadcast` is the+ // main window (sendToMain) plus every non-quiet relay peer, so a joined team tab's meter fills too.const pushContextUpdate = (payload: unknown): void => {- if (!win.isDestroyed()) win.webContents.send(IPC.contextUpdate, payload)+ corePlatform.broadcast(IPC.contextUpdate, payload)// Feed the macOS Notch HUD the model name (keyed by sessionId; no-op off/non-darwin).notchHudOnContextUpdate(payload as Parameters<typeof notchHudOnContextUpdate>[0])// Feed the mirror's per-node context ring (mobile-usage-inbox). The context tail keys by@@ -3130,7 +3131,7 @@ app.whenReady().then(async () => {onTrack: (nodeId, sessionId) => { nodeContextSession.set(nodeId, sessionId) },onClear: (nodeId, sessionId) => {notchHudOnContextUpdate({ nodeId, sessionId, cleared: true })- if (!win.isDestroyed()) win.webContents.send(IPC.contextUpdate, { nodeId, sessionId, cleared: true,+ corePlatform.broadcast(IPC.contextUpdate, { nodeId, sessionId, cleared: true,usedTokens: 0, windowTokens: 0, usedPercent: 0, model: null, updatedAt: Date.now() })}})@@ -3480,7 +3481,10 @@ app.whenReady().then(async () => {// A station that starts a DIFFERENT session drops the report its old one made — before the// renderer hears the event, so no `--after-success` can fire on it in between.stationOutcomes.onAgentEvent(enriched)- sendToMain(IPC.agentStatus, enriched)+ // The main window and every non-quiet relay peer: a joined team tab keeps the host's agent+ // status in its own session store (a scoped guest hears only its project's nodes —+ // filterScopedEvent).+ corePlatform.broadcast(IPC.agentStatus, enriched)// Feed the macOS Notch HUD its prompt (ev.task on newTurn) + subagent grouping (no-op off/non-darwin).notchHudOnAgentEvent(enriched)// Agent messaging taps the SAME stream: the sender's newTurn resets its fan-out budget, anddiff --git a/src/main/platform-electron.test.ts b/src/main/platform-electron.test.tsindex 992e7f6ca..f22debb8b 100644--- a/src/main/platform-electron.test.ts+++ b/src/main/platform-electron.test.ts@@ -255,6 +255,35 @@ describe('electronPlatform + relay peers', () => {expect(JSON.parse(quiet.text[0]!).channel).toBe('watch:meta')})+ it('the main window hears a broadcast exactly once, however many peers are registered', () => {+ // The desktop host's agent events (agent:status, agent:subagent-activity, context:update) ride+ // broadcast so a joined team tab hears them; the host's own window must not hear them twice.+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})+ const p = electronPlatform()+ h.clientIds = [1]+ const dead: UiSink = {+ sendText: () => {+ throw new Error('EPIPE')+ },+ sendBinary: () => {},+ bufferedAmount: () => 0+ }+ const a = peerSink()+ const b = peerSink()+ const quiet = peerSink()+ registerPeerSink(PEER, a.sink)+ registerPeerSink(PEER + 1, dead)+ registerPeerSink(PEER + 2, quiet.sink, { quiet: true, selfPaced: true })+ registerPeerSink(PEER + 3, b.sink)++ p.broadcast('agent:status', { nodeId: 'n1', kind: 'state', state: 'working' })+ expect(h.sent).toEqual([{ channel: 'agent:status', args: [{ nodeId: 'n1', kind: 'state', state: 'working' }] }])+ expect(a.text).toHaveLength(1)+ expect(b.text).toHaveLength(1)+ expect(quiet.text).toEqual([])+ warn.mockRestore()+ })+it('is BIT-IDENTICAL to the webContents-only path with no peer registered (merge gate)', () => {const p = electronPlatform()h.clientIds = [5]diff --git a/src/main/station-outcome-wiring.test.ts b/src/main/station-outcome-wiring.test.tsindex 9bcfc87b2..2066417cb 100644--- a/src/main/station-outcome-wiring.test.ts+++ b/src/main/station-outcome-wiring.test.ts@@ -70,7 +70,7 @@ describe('desktop main', () => {// A station's new session withdraws its report BEFORE the renderer hears the event.const withdraw = main.indexOf('stationOutcomes.onAgentEvent(enriched)')expect(withdraw).toBeGreaterThan(-1)- expect(withdraw).toBeLessThan(main.indexOf('sendToMain(IPC.agentStatus, enriched)'))+ expect(withdraw).toBeLessThan(main.indexOf('corePlatform.broadcast(IPC.agentStatus, enriched)'))expect(main).toContain('flushAllDurableFactsSync()')// The restore waits for the workspace index, or a restore-time expiry reaches no sender. The boot// read is shared with the live links' init (which must not judge a node gone before it either).