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
feat(push): needsYou live-updates carry kind, question options and pendingId
enes8074cd38c4d8
diff --git a/src/core/agent-status-mirror.test.ts b/src/core/agent-status-mirror.test.tsindex 8c6c796e9..9a5ab3543 100644--- a/src/core/agent-status-mirror.test.ts+++ b/src/core/agent-status-mirror.test.ts@@ -600,6 +600,61 @@ describe('onNodeStateChange seam', () => {recordAgentEvent(ev({ state: 'working' }))expect(seen.filter((c) => c.event === 'start')).toHaveLength(0)})++ it('the needsYou edge into blocked carries kind:approval + the pendingId (from the approval event)', () => {+ const seen: NodeStateChange[] = []+ onNodeStateChange((c) => seen.push(c))+ recordAgentEvent(ev({ state: 'blocked', lastMessage: 'Approve write', pendingId: 'n1-123-9' }))+ const ny = seen.find((c) => c.state === 'needsYou')!+ expect(ny.kind).toBe('approval')+ expect(ny.pendingId).toBe('n1-123-9')+ expect('options' in ny).toBe(false)+ })++ it('an approval edge whose hook did not arm a wait omits pendingId (still kind:approval)', () => {+ const seen: NodeStateChange[] = []+ onNodeStateChange((c) => seen.push(c))+ recordAgentEvent(ev({ state: 'blocked', lastMessage: 'Approve write' }))+ const ny = seen.find((c) => c.state === 'needsYou')!+ expect(ny.kind).toBe('approval')+ expect('pendingId' in ny).toBe(false)+ })++ it('the needsYou edge into waiting carries kind:question + the stashed AskUserQuestion options', () => {+ const seen: NodeStateChange[] = []+ onNodeStateChange((c) => seen.push(c))+ recordRawToolEvent('n1', {+ hook_event_name: 'PreToolUse',+ tool_name: 'AskUserQuestion',+ tool_input: { questions: [{ options: [{ label: 'Dark' }, { label: 'Light' }, { label: 'System' }] }] }+ })+ recordAgentEvent(ev({ state: 'waiting', lastMessage: 'Pick a theme' }))+ const ny = seen.find((c) => c.state === 'needsYou')!+ expect(ny.kind).toBe('question')+ expect(ny.options).toEqual(['Dark', 'Light', 'System'])+ expect('pendingId' in ny).toBe(false)+ })++ it('a plain waiting edge (no AskUserQuestion stash) is kind:question with no options', () => {+ const seen: NodeStateChange[] = []+ onNodeStateChange((c) => seen.push(c))+ recordAgentEvent(ev({ state: 'waiting', lastMessage: 'Which one?' }))+ const ny = seen.find((c) => c.state === 'needsYou')!+ expect(ny.kind).toBe('question')+ expect('options' in ny).toBe(false)+ })++ it('working and done edges carry no kind/options/pendingId', () => {+ const seen: NodeStateChange[] = []+ onNodeStateChange((c) => seen.push(c))+ recordAgentEvent(ev({ state: 'working', newTurn: true }))+ recordAgentEvent(ev({ state: 'done', lastMessage: 'Wrapped up.' }))+ for (const c of seen) {+ expect('kind' in c).toBe(false)+ expect('options' in c).toBe(false)+ expect('pendingId' in c).toBe(false)+ }+ })})describe('onNodeNowChange seam', () => {diff --git a/src/core/agent-status-mirror.ts b/src/core/agent-status-mirror.tsindex 5e871f71e..a6ac56791 100644--- a/src/core/agent-status-mirror.ts+++ b/src/core/agent-status-mirror.ts@@ -462,6 +462,15 @@ export interface NodeStateChange {state: 'working' | 'needsYou' | 'done'/** needs-you / done headline, ≤120 chars. Absent for a plain 'start'. */message?: string+ /** needsYou only (spec: interactive-push-live-activities addendum): 'approval' on the edge into+ * blocked, 'question' on the edge into waiting. Absent on working/done edges. */+ kind?: 'approval' | 'question'+ /** question needsYou only: the AskUserQuestion choices from the stash (≤4 × ≤60), so the phone+ * can render option buttons straight from the Live Activity. Absent otherwise. */+ options?: string[]+ /** approval needsYou only: the deterministic hook-reply ticket from the just-produced approval+ * event, letting an intent answer the held hook. Absent otherwise. */+ pendingId?: stringts: number}@@ -681,8 +690,18 @@ function produceInboxFromState(if (nextState === 'blocked') {const title = firstLine(ev.lastMessage, INBOX_TITLE_MAX) || 'Needs approval'// needsYou live-update on the EDGE into blocked (a re-assert keeps the same activity live).+ // Carries kind:'approval' + the deterministic-approval ticket (from the same `ev.pendingId`+ // the approval InboxEvent below stashes) so an intent can answer the held hook straight from+ // the Live Activity (spec: interactive-push-live-activities addendum).if (prevState !== 'blocked') {- fireNodeStateChange({ ...stateBase, event: 'update', state: 'needsYou', message: clip(title, LIVE_MESSAGE_MAX) })+ fireNodeStateChange({+ ...stateBase,+ event: 'update',+ state: 'needsYou',+ kind: 'approval',+ message: clip(title, LIVE_MESSAGE_MAX),+ ...(ev.pendingId ? { pendingId: ev.pendingId } : {})+ })}if (newestUnresolved(inboxEvents, nodeId)?.title === title) return// Carry the deterministic-approval ticket (present only when the wait-branch of the managed@@ -690,10 +709,19 @@ function produceInboxFromState(pushInboxEvent({ ...baseEvent, kind: 'approval', title, ...(ev.pendingId ? { pendingId: ev.pendingId } : {}) })} else if (nextState === 'waiting') {const title = firstLine(ev.lastMessage, INBOX_TITLE_MAX) || 'Waiting for input'+ const options = pendingOptions.get(nodeId)+ // needsYou live-update on the EDGE into waiting, carrying kind:'question' + the AskUserQuestion+ // choices from the stash so the Live Activity can render numbered option buttons.if (prevState !== 'waiting') {- fireNodeStateChange({ ...stateBase, event: 'update', state: 'needsYou', message: clip(title, LIVE_MESSAGE_MAX) })+ fireNodeStateChange({+ ...stateBase,+ event: 'update',+ state: 'needsYou',+ kind: 'question',+ message: clip(title, LIVE_MESSAGE_MAX),+ ...(options ? { options } : {})+ })}- const options = pendingOptions.get(nodeId)if (newestUnresolved(inboxEvents, nodeId)?.title === title) returnpushInboxEvent({ ...baseEvent, kind: 'question', title, ...(options ? { options } : {}) })} else if (nextState === 'done' && prevState !== 'done') {diff --git a/src/core/push-notify.test.ts b/src/core/push-notify.test.tsindex 8f018492c..dcd078f07 100644--- a/src/core/push-notify.test.ts+++ b/src/core/push-notify.test.ts@@ -640,6 +640,71 @@ describe('createLiveUpdatePush', () => {})})+ describe('needsYou kind/options/pendingId pass-through (interactive Dynamic Island)', () => {+ it('passes kind + pendingId on an approval needsYou edge', async () => {+ const { h, st } = wire()+ st.emit({+ nodeId: 'a',+ event: 'update',+ state: 'needsYou',+ kind: 'approval',+ message: 'Approve write',+ pendingId: 'a-123-9',+ ts: 1+ })+ await vi.advanceTimersByTimeAsync(1000)+ const u = liveBodyOf().updates[0]+ expect(u.kind).toBe('approval')+ expect(u.pendingId).toBe('a-123-9')+ expect(u).not.toHaveProperty('options')+ h.stop()+ })++ it('passes kind + options on a question needsYou edge', async () => {+ const { h, st } = wire()+ st.emit({+ nodeId: 'a',+ event: 'update',+ state: 'needsYou',+ kind: 'question',+ message: 'Pick a theme',+ options: ['Dark', 'Light', 'System'],+ ts: 1+ })+ await vi.advanceTimersByTimeAsync(1000)+ const u = liveBodyOf().updates[0]+ expect(u.kind).toBe('question')+ expect(u.options).toEqual(['Dark', 'Light', 'System'])+ expect(u).not.toHaveProperty('pendingId')+ h.stop()+ })++ it('omits kind/options/pendingId on working and done edges', async () => {+ const { h, st } = wire()+ st.emit({ nodeId: 'a', event: 'start', state: 'working', ts: 1 })+ st.emit({ nodeId: 'b', event: 'end', state: 'done', message: 'Finished', ts: 2 })+ await vi.advanceTimersByTimeAsync(1000)+ for (const u of liveBodyOf().updates) {+ expect(u).not.toHaveProperty('kind')+ expect(u).not.toHaveProperty('options')+ expect(u).not.toHaveProperty('pendingId')+ }+ h.stop()+ })++ it('now-update (activity/context) ticks never carry kind/options/pendingId', async () => {+ const { h, nw } = wire()+ clock = 0+ nw.emit({ nodeId: 'a', activity: 'Editing a.ts', contextPercent: 10, ts: 0 })+ await vi.advanceTimersByTimeAsync(1000)+ const u = liveBodyOf().updates[0]+ expect(u).not.toHaveProperty('kind')+ expect(u).not.toHaveProperty('options')+ expect(u).not.toHaveProperty('pendingId')+ h.stop()+ })+ })+it('stop() unsubscribes both seams so later events are ignored', async () => {const { h, st, nw } = wire()h.stop()diff --git a/src/core/push-notify.ts b/src/core/push-notify.tsindex fa8dede0e..3b5e7efcb 100644--- a/src/core/push-notify.ts+++ b/src/core/push-notify.ts@@ -256,6 +256,13 @@ export interface LiveUpdateItem {activity?: stringcontextPercent?: numbermessage?: string+ /** needsYou only (spec: interactive-push-live-activities addendum): 'approval' | 'question'.+ * Omitted otherwise — the backend also forces null on non-needsYou content-state. */+ kind?: 'approval' | 'question'+ /** question needsYou only: the AskUserQuestion choices (≤4 × ≤60), for Live Activity buttons. */+ options?: string[]+ /** approval needsYou only: the deterministic hook-reply ticket, letting an intent answer. */+ pendingId?: stringts: number}@@ -343,6 +350,10 @@ export function createLiveUpdatePush(deps: LiveUpdateDeps): LiveUpdateHandle {function onStateChange(c: NodeStateChange): void {if (!liveIdentity()) returnconst title = nodeTitleOf(c.nodeId)+ // kind/options/pendingId ride only a needsYou edge (spec: interactive-push-live-activities+ // addendum) — belt-and-braces gate on state so a working/done edge never carries them (the+ // backend also nulls them on non-needsYou content-state).+ const needsYou = c.state === 'needsYou'buffer.push({nodeId: c.nodeId,...(title ? { nodeTitle: title } : {}),@@ -350,6 +361,9 @@ export function createLiveUpdatePush(deps: LiveUpdateDeps): LiveUpdateHandle {event: c.event,state: c.state,...(c.message ? { message: c.message.slice(0, LIVE_MESSAGE_MAX) } : {}),+ ...(needsYou && c.kind ? { kind: c.kind } : {}),+ ...(needsYou && c.options && c.options.length > 0 ? { options: c.options } : {}),+ ...(needsYou && c.pendingId ? { pendingId: c.pendingId } : {}),ts: c.ts})scheduleFlush()