Repository navigation
fix(orchestration): hold mailbox pointers while the agent shows an open dialog (#21745) - #33366
Conversation
…en dialog Claude keeps its rest title (`✳ ...`) while an AskUserQuestion, permission, or plan-approval dialog is open, so the mailbox delivery gate read the pane as idle and typed the pointer plus a delayed Enter into the dialog. The Enter picked the dialog's first option. Delivery now reads the pane's hook row: while the agent's hooks report a wait (`waiting`/`blocked`), the pre-write gate refuses and re-arms its recheck, and the delayed Enter is deferred until the next idle edge, where it rechecks.
An unanswered question posts no further hooks, so the 30-minute freshness bound on the hook turn reader would have let mail answer a question left open longer than that. The hold now reads the pane's newest live hook row with no age bound, retired only by a newer row or a respawn.
…ruction base Co-authored-by: Yasyf Mohamedali <yasyf@poetic.com>
Co-authored-by: Yasyf Mohamedali <yasyf@poetic.com>
Walkthrough
Priority: Severity of issue fixed: Medium Merge Risk:
|
Esc dismisses a Claude dialog without posting a hook, so the waiting row could hold mail forever. Once input follows the row, only a selector still on screen keeps the hold. The hold is scoped to Claude, whose rest title hides its dialogs, and a held leaf rechecks every 2 s instead of 20 Hz. Co-authored-by: Yasyf Mohamedali <yasyf@poetic.com>
…d at 10 min A readable screen now holds only while Claude's dialog chrome (its select footer, or a cursored option beside another option) is in the bottom rows, so a dismissed dialog or a numbered composer draft releases the hold. An unreadable screen holds on the row alone, and no row holds past 10 minutes, so the hold is never worse than main for long. The hook row reverts to the fresh-row selector, which the cap makes sufficient. Co-authored-by: Yasyf Mohamedali <yasyf@poetic.com>
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
d8e997ac-119d-4560-92eb-200f71c54908
Files selected for processing: 4-
src/main/runtime/claude-open-dialog-hold.tssrc/main/runtime/orchestration-open-dialog-delivery-hold.test.tssrc/main/runtime/terminal/wait/terminal-wait-permission.tssrc/main/runtime/terminal/wait/terminal-wait-settlements.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
-
| if ( | ||
| row?.agentType !== 'claude' || | ||
| (row.state !== 'waiting' && row.state !== 'blocked') || | ||
| row.receivedAt < (args.respawnedAt ?? -1) |
There was a problem hiding this comment.
Compare input and respawn times with the evidence time.
If a relay replays a cached waiting row after the user dismisses a dialog with Esc, it can restamp receivedAt without changing evidenceObservedAt. The comparisons on Lines 21 and 25 then treat the old wait as newer than the input or respawn. In the Esc case, Line 25 skips the screen check, so queued mail can remain held until another input or hook arrives. Use row.evidenceObservedAt ?? row.receivedAt for these lifecycle comparisons; retain receivedAt for delivery ordering. (raw.githubusercontent.com)
Also applies to: 25-25
…ndle Co-authored-by: Yasyf Mohamedali <yasyf@poetic.com>
There was a problem hiding this comment.
Actionable comments posted: 2

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
a3025603-c930-4c10-9990-0f9e76190320
Files selected for processing: 4-
src/main/runtime/claude-open-dialog-hold.test.tssrc/main/runtime/claude-open-dialog-hold.tssrc/main/runtime/orchestration-open-dialog-delivery-hold.test.tssrc/main/runtime/terminal/wait/terminal-wait-permission.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
-
| row?.agentType !== 'claude' || | ||
| (row.state !== 'waiting' && row.state !== 'blocked') || | ||
| row.receivedAt < (args.respawnedAt ?? -1) || | ||
| (args.now ?? Date.now()) - row.receivedAt > CLAUDE_DIALOG_HOLD_CAP_MS |
There was a problem hiding this comment.
Keep a visible dialog held past the age cap.
If a Claude question remains open for more than ten minutes, this check returns false before reading the screen. Mailbox delivery can then type the pointer and Enter into the open dialog. Apply any age cap only to the unreadable-screen fallback. Keep holding while the screen confirms a dialog. Update the visible-dialog expectation in src/main/runtime/claude-open-dialog-hold.test.ts Line 67.
| protected isPtyAwaitingUserInput(ptyId: string): boolean { | ||
| const join = this.readHookRowJoinForPty(ptyId) | ||
| return isClaudeDialogHoldingPane({ | ||
| row: join ? selectFreshExplicitAgentStatusRow(join) : null, |
There was a problem hiding this comment.
🔎 Supported by static analysis
-
Script executed:
#!/bin/bash # Inspect the selector's threshold and its row-expiry condition. rg -n -C 5 'AGENT_STATUS_STALE_AFTER_MS|selectFreshExplicitAgentStatusRow' \ src/main/runtime/runtime-hook-agent-row-selection.ts
Repository: stablyai/orca
Length of output: 2038
Script executed:
#!/bin/bash set -e printf '%s\n' '--- stale threshold definitions ---' rg -n -F --glob '*.{ts,tsx}' -e 'AGENT_STATUS_STALE_AFTER_MS' src printf '%s\n' '--- dialog predicate and hold-cap references ---' rg -n -C 12 -F --glob '*.ts' -e 'isPtyAwaitingUserInput' -e 'dialog' -e 'hold cap' src/main/runtime/terminal/wait src/main/runtime | head -n 260 printf '%s\n' '--- target file ---' nl -ba src/main/runtime/terminal/wait/terminal-wait-permission.ts | sed -n '160,250p'
Repository: stablyai/orca
Length of output: 41999
Script executed:
#!/bin/bash set -e printf '%s\n' '--- Claude dialog helper ---' rg -n -C 30 -F --glob '*.ts' -e 'isClaudeDialogHoldingPane' src/main src/shared printf '%s\n' '--- dialog hold constants and cap references ---' rg -n -C 8 -F --glob '*.ts' -e 'DIALOG_HOLD_RECHECK_MS' -e 'CLAUDE_DIALOG' -e 'hold cap' -e 'HOLD_MAX' src/main src/shared
Repository: stablyai/orca
Length of output: 34317
Script executed:
#!/bin/bash set -e printf '%s\n' '--- payload fields and freshness semantics ---' rg -n -C 8 -F --glob '*.ts' -e 'evidenceObservedAt' -e 'receivedAt' src/shared/agent-status-types.ts src/main/agent-hooks src/shared/agent-hook-status-cache.ts printf '%s\n' '--- row construction and republish paths ---' rg -n -C 8 -F --glob '*.ts' -e 'AgentStatusIpcPayload' -e 'evidenceObservedAt:' src/main/agent-hooks src/shared/agent-hook-status-cache.ts | head -n 320
Repository: stablyai/orca
Length of output: 45665
Preserve the Claude dialog candidate before generic freshness filtering.
A replay can refresh receivedAt while preserving an old evidenceObservedAt. The selector can then return null after 30 minutes of evidence age, even though the row remains within the 10-minute dialog cap based on receivedAt. isClaudeDialogHoldingPane returns false for that null row before it reads the screen.
Use a dialog-specific candidate lookup that preserves Claude waiting or blocked rows for isClaudeDialogHoldingPane. Keep the existing CLAUDE_DIALOG_HOLD_CAP_MS and live-screen confirmation as the final bounds.
There was a problem hiding this comment.
🔇 Additional comments: 2
src/main/runtime/claude-open-dialog-hold.ts: 1
22-22: Use evidence time for lifecycle checks.The predicate uses
row.receivedAtfor both lifecycle comparisons. A relay replay can refreshreceivedAtwithout changingevidenceObservedAt. An oldwaitingrow can then survive a respawn or receive another ten-minute hold when the screen is unreadable. Comparerow.evidenceObservedAt ?? row.receivedAtfor these checks. KeepreceivedAtfor delivery ordering. (raw.githubusercontent.com)src/main/runtime/claude-open-dialog-hold.ts-22-22: 1
22-22:Major · Functional Correctness · Heavy lift
⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.Apply the hook-state hold to every supported hook-capable agent.
isClaudeDialogHoldingPanereturnsfalsefor every non-Claude row before it checkswaitingorblocked. The linked issue requires pointer and delayed-Enter delivery to remain queued for those states for any hook-capable agent. Keep Claude screen detection provider-specific, but add a provider-neutral hook-state gate or equivalent detectors for each supported provider. (github.com)

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
b9204d7a-68fd-4a18-b450-1c47f6ae51ae
Files selected for processing: 1-
src/main/runtime/claude-open-dialog-hold.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
-
ELI5
When Claude Code stops to ask the user a question, its terminal title still shows the "at rest"
✳. If orchestration mail arrived then, Orca typedYou have N orchestration messages…into the pane and pressed Enter, which picked the highlighted option for the user. Now Orca waits until the question is closed, then delivers the mail.This is #26928 by yasyf, rebased onto current
main(their two commits are kept with their authorship), plus a small follow-up to compile on the refactored runtime.Root cause
AskUserQuestion, a permission prompt, or plan approval is open. In a realclaude2.1.310 under tmux, the pane title read✳ Color preference questionwith the dialog on screen.PreToolUseandPermissionRequestforAskUserQuestionwhen the dialog opens. It postsPostToolUseand thenStoponce the dialog is answered, and nothing if the dialog is dismissed with Esc (logged with a hook recorder against 2.1.310). Orca maps the open dialog to awaitingrow (src/shared/agent-hook-listener/providers/claude-events.ts).isAgentSettledForDelivery) ranks evidence throughevaluateTuiIdle, and for Claude the hook lane only votes on task wake-ups (evaluateHookTurnintui-idle-hook-lane.ts). So the✳title won: the verdict wasready-strongwhile the hook turn readpermission/agent-interactive-prompt. I logged this from the live app:{"title":"✳ Planet preference question","status":"idle","hook":{"state":"permission","blockedReason":"agent-interactive-prompt"},"verdict":{"kind":"ready-strong"}}src/main/agent-hooks/README.md), and currentmainturns that into apermissionleaf status. That hides the bug for new Claude only. Older Claude (the Windows reporter ran 2.1.278), panes where the 7501 probe goes unanswered, and any other hook-reported wait under a rest title still get typed into.request_user_inputis not affected. Checked in~/projects/codexorigin/main: the overlay sets[ ! ] Action Required | <dir>(tui/src/bottom_pane/request_user_input/mod.rsterminal_title_requires_action,chatwidget/status_surfaces.rs) and replaces the composer, so no idle edge fires and the gate refuses. A runtime probe test onmainwith the real overlay screen and title confirmed it, both with a hookedworkingrow and hookless. I didn't add a test for it.What changed
isPtyAwaitingUserInput(ptyId)reads the pane's newest fresh hook row (joined on pane keys and terminal handles, ignoring rows from before a respawn). The decision is inclaude-open-dialog-hold.tsand is Claude only: Claude is the agent whose rest title hides its dialogs. Codex's overlays retitle the pane to[ ! ] Action Requiredand replace the composer, and agents that send OSC 7501 report the block themselves.Enter to select/Esc to cancelfooter (AskUserQuestion, permissions) or a cursored❯ N.option directly beside another numbered option (the plan approval has no footer). I captured each screen from real 2.1.310. An empty composer after Esc, a composer draft like❯ 1. fix X, or a dialog scrolled up into scrollback all release the hold.main.isAgentSettledForDeliveryrefuses while the hold applies. The existing delivery recheck keeps the mail queued, and while a dialog holds the pane it now polls every 2 s instead of re-arming at about 50 ms.submitOrchestrationMailboxPointer) rechecks the same signal. If a dialog opened between the pointer write and the Enter, the Enter is deferred to the next idle edge instead of answering the dialog.terminal/wait/terminal-wait-permission.ts. The 10-minute cap makes fix(orchestration): hold mailbox pointers while the agent shows an open dialog (#21745) #26928's unbounded row selector unnecessary, so I removed it.How verified
Real app, real
claude(dev Orca, background launch, isolated profile; a Run bound to the Claude pane;orca-dev orchestration sendas a worker heartbeat):main→ Mars(the first option); the user never answered.delivered_atNULL). User answeredVenus. The pointer was delivered 1 s after the turn ended and Claude ranorchestration check.Tests:
orchestration-open-dialog-delivery-hold.test.tsdrivesOrcaRuntimeServicewith a✳title, the real AskUserQuestion screen and awaitingrow, and checks three outcomes:claude-open-dialog-hold.test.tscovers the predicate:mailbox-pointer-submit.test.tscovers the deferred Enter.pnpm tc:nodeandcheck:code-quality:changedpass. In the orchestration, tui-idle and terminal-wait suites, the only failures are two built-CLI subprocess tests, which pass when run alone on a machine with load around 60.Risk
main. The cap is deliberate: it bounds a row that nothing else retires.main.Supersedes #26928 and #21880. #21880 settles the pointer as delivered without sending Enter when a dialog opens late, which leaves the text in the composer and marks the mail read.
Fixes #21745
Co-authored-by: Yasyf Mohamedali yasyf@poetic.com