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(agents): deliver permission tickets during held questions
reviewa2bb70d95406
diff --git a/CLAUDE.md b/CLAUDE.mdindex 492519758..c8e5bb4e4 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -4872,3 +4872,7 @@ Claude child `PreToolUse`/`PostToolUse`/`PostToolUseFailure` hooks must not drivChild `PermissionRequest` and attention `Notification` hooks still reach needs-you and phoneapprovals, including the raw approval summary and deterministic reply ticket. Keep raw summaryrecording before the child transcript-association guard in both shells.++A held parent question can overlap child permissions: retain its question card and waiting+state while publishing each approval ticket separately. Approval replies resolve only their+own ticket; the picker stays pending until its correlated answer or explicit reset.diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 45e9d3afb..d01c820bb 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -785,3 +785,7 @@ Claude child `PreToolUse`/`PostToolUse`/`PostToolUseFailure` hooks must not drivChild `PermissionRequest` and attention `Notification` hooks still reach needs-you and phoneapprovals, including the raw approval summary and deterministic reply ticket. Keep raw summaryrecording before the child transcript-association guard in both shells.++A held parent question can overlap child permissions: retain its question card and waiting+state while publishing each approval ticket separately. Approval replies resolve only their+own ticket; the picker stays pending until its correlated answer or explicit reset.diff --git a/src/core/agent-status-mirror.ts b/src/core/agent-status-mirror.tsindex b2e468925..def5466e8 100644--- a/src/core/agent-status-mirror.ts+++ b/src/core/agent-status-mirror.ts@@ -1425,6 +1425,21 @@ export function recordAgentEvent(rawEvent: NormalizedAgentEvent): NormalizedAgenlet out = evif (next.pendingQuestion && prev?.pendingQuestion && next.state) {if (ev.kind !== 'state' && ev.kind !== 'session') return ev+ // A concurrent permission is independent of the held picker. Publish its ticket/card,+ // but keep the parent's waiting badge and question correlation until its own answer.+ if (ev.pendingId && ev.state === 'blocked' && ev.askKind === 'approval') {+ produceInboxFromState(nodeId, ev, prevState, 'blocked', now, true)+ scheduleWrite()+ return { ...ev, state: next.state, sessionId: next.sessionId }+ }+ if (ev.pendingId && ev.state === 'working') {+ for (const card of inboxEvents) {+ if (card.nodeId === nodeId && card.kind === 'approval' && card.pendingId === ev.pendingId) {+ card.resolved = true+ }+ }+ scheduleWrite()+ }// Broadcast the same held state to Desktop, Server, canvas/board and the phone.return { ...ev, kind: 'state', state: next.state, sessionId: next.sessionId,verified: ev.verified, newTurn: undefined, interrupted: undefined,@@ -1452,7 +1467,8 @@ function produceInboxFromState(ev: NormalizedAgentEvent,prevState: AgentState | undefined,nextState: AgentState | undefined,- now: number+ now: number,+ concurrentApproval = false): NeedsYouClassification | undefined {// Clear any stashed question options on a new turn or session boundary — a stale option set must// never attach to a later, unrelated question. (State-leave clearing is handled below.)@@ -1499,7 +1515,7 @@ function produceInboxFromState(const stash = freshStash(nodeId, now)// Only a real AskUserQuestion picker (options present) forces the QUESTION classification — an// approval-only stash (a PermissionRequest summary) must stay an approval.- const options = stash?.options+ const options = concurrentApproval ? undefined : stash?.options// multiSelect rides only a real question (options present) — an approval-only stash never sets it.const multiSelect = options ? stash?.multiSelect : undefinedconst hasQuestion = !!options@@ -1539,7 +1555,9 @@ function produceInboxFromState(// stops muzzling — and the new ask fires. A different-title unresolved event never suppresses:// that is a genuinely NEW ask. Always return the classification below so the broadcast// enrichment stays consistent across the re-assert.- const dup = newestUnresolved(inboxEvents, nodeId)+ const dup = concurrentApproval+ ? inboxEvents.find(e => e.nodeId === nodeId && e.kind === 'approval' && !e.resolved && e.pendingId === ev.pendingId)+ : newestUnresolved(inboxEvents, nodeId)const sameTitle = !!dup && dup.title === titleconst freshDup = sameTitle && dup ? now - dup.ts < QUESTION_DEDUP_WINDOW_MS : falseconst newAsk = !freshDup@@ -1566,7 +1584,7 @@ function produceInboxFromState(// asking something else unless the previous one was answered. Without this the Inbox kept a// card per ask and the user had to dismiss answered questions by hand — the state never// leaves `blocked` between them, so the transition-based resolve never ran.- resolveUnresolvedFor(nodeId)+ if (!concurrentApproval) resolveUnresolvedFor(nodeId)pushInboxEvent({...baseEvent,kind,diff --git a/src/core/pending-question.test.ts b/src/core/pending-question.test.tsindex e558ccdd3..0c3723de9 100644--- a/src/core/pending-question.test.ts+++ b/src/core/pending-question.test.ts@@ -91,6 +91,44 @@ describe('subagent attention forwarding (W2)', () => {expect(_inboxSnapshot().events[0].resolved).toBe(true)})+ it.each(['allow', 'deny'])('keeps the parent picker while concurrent child approvals receive %s replies', decision => {+ ask()+ const question = _inboxSnapshot().events[0]+ const approval = { agent_id: 'child', session_id: 'child-session', tool_name: 'Bash',+ tool_input: { command: 'echo child' }, nodeterm_pending_id: 'ticket-1' }+ const request = (ticket: string) => hook('PermissionRequest', { ...approval, nodeterm_pending_id: ticket })+ expect(request('ticket-1')).toMatchObject({ state: 'waiting', sessionId: 'parent',+ pendingId: 'ticket-1', askKind: 'approval' })+ request('ticket-1') // A reassertion must not duplicate the card.+ request('ticket-2') // Identical commands may be waiting on distinct tickets.+ const cards = _inboxSnapshot().events+ expect(cards).toHaveLength(3)+ expect(cards.filter(e => !e.resolved)).toHaveLength(3)+ for (const pendingId of ['ticket-1', 'ticket-2']) {+ expect(cards.find(e => e.pendingId === pendingId)).toMatchObject({ kind: 'approval' })+ expect(JSON.stringify(cards.find(e => e.pendingId === pendingId))).toContain('echo child')+ expect(cards.find(e => e.pendingId === pendingId)?.options).toBeUndefined()+ }+ expect(hook('PermissionRequest', { ...approval, nodeterm_answered: decision })).toMatchObject({+ state: 'waiting', sessionId: 'parent', askKind: 'question' })+ expect(_inboxSnapshot().events.find(e => e.pendingId === 'ticket-1')?.resolved).toBe(true)+ expect(_inboxSnapshot().events.find(e => e.pendingId === 'ticket-2')?.resolved).not.toBe(true)+ expect(_inboxSnapshot().events.find(e => e.id === question.id)?.resolved).not.toBe(true)+ expect(_snapshot().node.pendingQuestion).toEqual({ sessionId: 'parent', toolUseId: 'ask-1' })+ hook('PermissionRequest', { ...approval, nodeterm_pending_id: 'ticket-2', nodeterm_answered: decision })+ expect(_inboxSnapshot().events.filter(e => !e.resolved).map(e => e.id)).toEqual([question.id])+ expect(recordQuestionResult('node', 'parent', 'ask-1')?.state).toBe('working')+ expect(_inboxSnapshot().events.every(e => e.resolved)).toBe(true)+ })++ it('does not turn the held picker own permission into an approval', () => {+ ask()+ expect(hook('PermissionRequest', { tool_name: 'AskUserQuestion', nodeterm_pending_id: 'picker' }))+ .toMatchObject({ state: 'waiting', askKind: 'question' })+ expect(_inboxSnapshot().events).toHaveLength(1)+ expect(_inboxSnapshot().events[0].pendingId).toBeUndefined()+ })+it('forwards child permission notifications and ignores informational notifications', () => {expect(hook('Notification', { agent_id: 'child', notification_type: 'permission_prompt' })?.state).toBe('blocked')expect(hook('Notification', { agent_id: 'child', notification_type: 'auth_success' })).toBeNull()diff --git a/src/shared/agents/normalize.ts b/src/shared/agents/normalize.tsindex 10c0ba06f..5f7123270 100644--- a/src/shared/agents/normalize.ts+++ b/src/shared/agents/normalize.ts@@ -65,8 +65,8 @@ export interface NormalizedAgentEvent {// stash-priority reclassification (see agent-status-mirror.recordAgentEvent). 'question' = an// AskUserQuestion picker (its `pendingId` is stripped — approve/deny on a question is wrong UX);// 'approval' = a genuine permission request (its `pendingId`, if any, is kept). Absent on every- // non-needs-you event. This is the ENRICHED field the shells broadcast — it is not produced by- // the normalizers themselves. Present for future UI; the canvas already keys the approve/deny+ // non-needs-you event. Claude also identifies non-picker PermissionRequest hooks here so a+ // concurrent parent picker cannot hide their approval tickets. The canvas keys the approve/deny// buttons off `pendingId`, which is now absent on a question. */askKind?: 'question' | 'approval'// session@@ -313,6 +313,7 @@ export function normalizeClaude(env: RawHookEnvelope): NormalizedAgentEvent | nu...base,kind: 'state',state: 'blocked',+ ...(tool && tool !== 'AskUserQuestion' ? { askKind: 'approval' as const } : {}),lastMessage: p.last_assistant_message,// Deterministic-approval ticket (present only when the wait-branch of the managed hook ran)....(p.nodeterm_pending_id ? { pendingId: p.nodeterm_pending_id } : {})