Repository navigation
Conversation
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. 📝 WalkthroughWalkthroughThe runtime now combines TUI-idle checks with live agent status data before delivering orchestration mail. Interactive prompts, ask-user tools, Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to An unanswered prompt can still receive a mailbox pointer and Enter after status expiry, while mail withheld at submission can be discarded rather than delivered after the prompt clears. These prompt-safety and delivery-loss paths should be fixed before merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 689b84af-0dca-4d14-8ce3-73bf09098dd1
📥 Commits
Reviewing files that changed from the base of the PR and between e476193 and b171989ce1c7fc8879d3efcbca4667e47cc923a4.
📒 Files selected for processing (6)
src/main/runtime/orca-runtime-resolve-exit-waiters.tssrc/main/runtime/orchestration/mailbox-pointer-stage.tssrc/main/runtime/orchestration/mailbox-pointer-submit.test.tssrc/main/runtime/orchestration/mailbox-pointer-submit.tssrc/main/runtime/tui-idle-delivery-and-quiescence.test.tssrc/main/runtime/tui-idle-wait-test-harness.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.
| this.getAgentProviderSessionRowsForPaneFn?.(paneKey) ?? | ||
| this.getAgentStatusSnapshotFn?.().filter((s) => s.paneKey === paneKey) ?? | ||
| [] | ||
| const hookRow = selectRuntimeHookAgentRowForPane(rows) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the freshness rule that determines whether prompt state remains visible.
ast-grep outline src/main/runtime/runtime-mobile-agent-status-projection.ts \
--match selectRuntimeHookAgentRowForPane --view expanded
rg -n -C 5 'AGENT_STATUS_STALE_AFTER_MS|freshAfter|interactivePrompt|waiting|blocked' \
src/main/runtime/runtime-mobile-agent-status-projection.ts src/main
# Inspect delivery tests for a prompt that remains active beyond the stale-status window.
rg -n -C 6 'interactivePrompt|AskUserQuestion|waiting|blocked|stale|deliveryRecheck' \
src/main/runtime/tui-idle-delivery-and-quiescence.test.ts \
src/main/runtime/tui-idle-wait-test-harness.tsRepository: stablyai/orca
Length of output: 45532
🏁 Script executed:
set -euo pipefail
printf '%s\n' '--- selector and freshness definitions ---'
rg -n -C 12 'selectRuntimeHookAgentRowForPane|AGENT_STATUS_STALE_AFTER_MS|freshAfter' \
src/main/runtime/runtime-mobile-agent-status-projection.ts \
src/main/runtime/orca-runtime-resolve-exit-waiters.ts \
src/shared/agent-status-types.ts \
src/main/agent-hooks
printf '%s\n' '--- delivery method ---'
sed -n '150,235p' src/main/runtime/orca-runtime-resolve-exit-waiters.ts
printf '%s\n' '--- focused delivery tests ---'
sed -n '175,230p' src/main/runtime/tui-idle-delivery-and-quiescence.test.ts
printf '%s\n' '--- prompt status refresh / stale tests ---'
rg -n -C 8 'stale|heartbeat|refresh|AskUserQuestion|interactivePrompt' \
src/main/runtime/*test.ts src/main/agent-hooks/*test.tsRepository: stablyai/orca
Length of output: 45541
🏁 Script executed:
set -euo pipefail
printf '%s\n' '--- exact selector locations ---'
rg -n 'selectRuntimeHookAgentRowForPane|AGENT_STATUS_STALE_AFTER_MS|freshAfter' src/main src/shared -g '*.ts' | head -80Repository: stablyai/orca
Length of output: 10188
🏁 Script executed:
set -euo pipefail
rg -n -C 12 'selectRuntimeHookAgentRowForPane|AGENT_STATUS_STALE_AFTER_MS|freshAfter' \
src/main/runtime/runtime-mobile-agent-status-projection.ts \
src/main/runtime/orca-runtime-resolve-exit-waiters.ts \
src/shared/agent-status-types.ts
sed -n '150,235p' src/main/runtime/orca-runtime-resolve-exit-waiters.ts
sed -n '175,230p' src/main/runtime/tui-idle-delivery-and-quiescence.test.tsRepository: stablyai/orca
Length of output: 24856
🏁 Script executed:
set -euo pipefail
printf '%s\n' '--- heartbeat implementation and callers ---'
cat -n src/main/runtime/mobile-session-tabs-agent-status-heartbeat.ts
rg -n -C 10 'SESSION_TABS_AGENT_STATUS_HEARTBEAT_INTERVAL_MS|agent.status|status heartbeat|heartbeat' \
src/main/runtime src/main/agent-hooks src/shared -g '*.ts'
printf '%s\n' '--- hook status update timestamps and prompt lifecycle ---'
rg -n -C 12 'receivedAt|evidenceObservedAt|stateStartedAt|interactivePrompt|AskUserQuestion|same-state|refresh' \
src/main/agent-hooks/server.ts \
src/main/agent-hooks/server-*.ts \
src/main/agent-hooks/server/server-*.ts \
src/main/agent-hooks -g '*.ts' | head -500
printf '%s\n' '--- delivery call path ---'
rg -n -C 12 'checkDeliverySettledAndArmRecheck|deliverPendingMessagesForLeaf|send.*Enter|pointer|write.*\\r' \
src/main/runtime/orca-runtime-resolve-exit-waiters.ts \
src/main/runtime/orca-runtime*.ts \
src/main/runtime -g '*.ts' | head -500Repository: stablyai/orca
Length of output: 45540
🏁 Script executed:
set -euo pipefail
cat -n src/main/runtime/mobile-session-tabs-agent-status-heartbeat.ts
rg -n -C 10 'SESSION_TABS_AGENT_STATUS_HEARTBEAT_INTERVAL_MS|heartbeat' src/main/runtime src/main/agent-hooks src/shared -g '*.ts'
rg -n -C 12 'receivedAt|evidenceObservedAt|interactivePrompt|AskUserQuestion|same-state' src/main/agent-hooks -g '*.ts' | head -500Repository: stablyai/orca
Length of output: 45541
🏁 Script executed:
set -euo pipefail
printf '%s\n' '--- heartbeat file ---'
cat -n src/main/runtime/mobile-session-tabs-agent-status-heartbeat.ts
printf '%s\n' '--- production references ---'
rg -n -C 8 'SESSION_TABS_AGENT_STATUS_HEARTBEAT_INTERVAL_MS|mobile-session-tabs-agent-status-heartbeat' \
src/main/runtime src/main -g '*.ts' | grep -v '\.test\.ts' | head -200
printf '%s\n' '--- hook server update implementation ---'
rg -n 'receivedAt|evidenceObservedAt|ingestRemote|setTimeout|setInterval' \
src/main/agent-hooks/server.ts src/main/agent-hooks/server -g '*.ts' | head -200Repository: stablyai/orca
Length of output: 28309
🏁 Script executed:
set -euo pipefail
cat -n src/main/runtime/mobile-session-tabs-agent-status-heartbeat.ts
rg -n -C 8 'SESSION_TABS_AGENT_STATUS_HEARTBEAT_INTERVAL_MS|mobile-session-tabs-agent-status-heartbeat' src/main/runtime src/main -g '*.ts' | grep -v '\.test\.ts' | head -200
rg -n 'receivedAt|evidenceObservedAt|ingestRemote|setTimeout|setInterval' src/main/agent-hooks/server.ts src/main/agent-hooks/server -g '*.ts' | head -200Repository: stablyai/orca
Length of output: 28214
🏁 Script executed:
set -euo pipefail
rg -n -C 10 'agentStatusHeartbeat|scheduleDecorativeHeartbeat|scheduleWorktreeHeartbeat|observeWorktreeRefresh|createMobileSessionTabsAgentStatusHeartbeat' \
src/main/runtime/orca-runtime-runtime-id.ts \
src/main/runtime -g '*.ts' | head -400Repository: stablyai/orca
Length of output: 43013
🏁 Script executed:
set -euo pipefail
rg -n -C 10 'agentStatusHeartbeat|scheduleDecorativeHeartbeat|scheduleWorktreeHeartbeat|observeWorktreeRefresh|createMobileSessionTabsAgentStatusHeartbeat' src/main/runtime/orca-runtime-runtime-id.ts src/main/runtime -g '*.ts' | head -400Repository: stablyai/orca
Length of output: 43013
Preserve the prompt block after hook status becomes stale.
When no newer hook event arrives, selectRuntimeHookAgentRowForPane drops the live row after AGENT_STATUS_STALE_AFTER_MS. isPaneWaitingOnInteractivePrompt then returns false. The one-second retry can pass the delivery gate once the TUI is idle and write the pointer plus Enter into the still-open prompt. Keep the prompt blocked until a newer non-interactive hook status explicitly clears it.
| @@ -85,7 +86,8 @@ export function submitOrchestrationMailboxPointer<TWaiter extends OrchestrationM | |||
| const queueSafe = | |||
| exactTarget?.leaf.lastAgentStatusObservedLive === true && | |||
| (exactTarget.leaf.lastAgentStatus === 'idle' || | |||
| exactTarget.leaf.lastAgentStatus === 'working') | |||
| exactTarget.leaf.lastAgentStatus === 'working') && | |||
| (deps.isAgentSettledForDelivery ? deps.isAgentSettledForDelivery(exactTarget.leaf) : true) | |||
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,180p' src/main/runtime/orchestration/mailbox-pointer-submit.ts
rg -n -C 4 'settleMailboxPointerEnter|MAILBOX_POINTER_WRITE_ATTEMPTED|markMailboxPointerWriteAttempted|stageMailboxPointerEnter|submitOrchestrationMailboxPointer' src/main/runtime
sed -n '1,220p' src/main/runtime/orchestration/db/messages/mailbox-pointer-enter-state.tsRepository: stablyai/orca
Length of output: 42237
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- direct callers and related symbols ---'
rg -n -C 6 'submitOrchestrationMailboxPointer|redrive\(|redrive:|isAgentSettledForDelivery|deferFlightUntilIdle|deliverPendingMessagesForHandle' src/main/runtime/orchestration src/main/runtime --glob '*.ts' | head -n 1200
printf '%s\n' '--- candidate files ---'
fd -t f . src/main/runtime/orchestration | rg 'mailbox-pointer|orchestration.*delivery|mailbox.*deliver'
printf '%s\n' '--- focused test region ---'
sed -n '500,590p' src/main/runtime/orchestration/mailbox-pointer-submit.test.tsRepository: stablyai/orca
Length of output: 41941
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- delivery entry and redrive implementation ---'
sed -n '1,285p' src/main/runtime/orchestration/mailbox-pointer-delivery.ts
printf '%s\n' '--- pointer state implementation ---'
sed -n '1,180p' src/main/runtime/orchestration/mailbox-pointer-state.ts
printf '%s\n' '--- staging and submit transition ranges ---'
sed -n '45,185p' src/main/runtime/orchestration/mailbox-pointer-stage.ts
sed -n '80,180p' src/main/runtime/orchestration/mailbox-pointer-submit.tsRepository: stablyai/orca
Length of output: 24079
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- pending-pointer resume path ---'
sed -n '1,260p' src/main/runtime/orchestration/mailbox-pointer-resume.ts
printf '%s\n' '--- direct redrive calls in pointer delivery files ---'
rg -n -C 3 'redrive\(' src/main/runtime/orchestration/mailbox-pointer-{delivery,stage,submit,resume,state}.tsRepository: stablyai/orca
Length of output: 10297
Park delivery when isAgentSettledForDelivery returns false. This callback can become false after the reservation reaches MAILBOX_POINTER_WRITE_ATTEMPTED. The current branch marks the unread message as delivered, clears its reservation, and suppresses redrive. The message is therefore unavailable when delivery becomes safe. Release the reservation and route the mailbox through the existing park and delayed-redrive path instead of settling it.
Update src/main/runtime/orchestration/mailbox-pointer-submit.test.ts#L569-L573 to assert that the message remains unread and that delayed redrive is scheduled.
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline, plus two nits.
Reviewed changes
- Prompt-aware delivery gate —
isAgentSettledForDeliverynow also refuses while the pane's hook row reports an interactive prompt:interactivePrompt != null, an ask-user tool name, orstate: 'waiting' | 'blocked'. It reads per-pane hook rows first (getAgentProviderSessionRowsForPaneFn) and falls back to the pane-filtered status snapshot. - Submit-time Enter guard —
submitOrchestrationMailboxPointerfolds the same check intoqueueSafe, so the 500ms-delayed Enter is suppressed if a prompt opens between the pointer write and the submit. - Recheck backoff — a pane waiting on a prompt re-arms the delivery recheck at 1000ms (unref'd) instead of the quiescence-derived delay, and keeps re-arming until the prompt clears.
- Tests — a runtime-level test parks delivery while
waitingand delivers afterdone; a submit-level test suppresses Enter whenisAgentSettledForDeliveryreturns false.
I verified both changed test files pass and mutation-checked them: removing the prompt gate fails the tui-idle test, and removing the queueSafe clause fails the submit test. The blocked state is only emitted for human-decider prompts, so gating on it is sound.
ℹ️ Nitpicks
tui-idle-wait-test-harness.tsadds agetAgentProviderSessionRowsForPaneoption, but no test wires it. Production resolves the per-pane rows first and only falls back to the snapshot, so the new runtime test exercises the fallback path rather than the source production reads. Wiring it in (or dropping the unused option) would close that gap.isAgentSettledForDeliveryis optional inPointerSubmitDependenciesand defaults totruewhen absent, so a future caller that forgets to pass it silently disables the gate. The delivery contract already declares it required, so making it required here too would keep the two in sync.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| @@ -503,4 +503,73 @@ describe('orchestration mailbox pointer submit', () => { | |||
| expect(releaseMailboxPointerEnter).not.toHaveBeenCalled() | |||
| expect(writePty).not.toHaveBeenCalled() | |||
| }) | |||
|
|
|||
| it('abandons staged Enter and redrives when isAgentSettledForDelivery returns false', async () => { | |||
There was a problem hiding this comment.
The test name says "and redrives", but a false isAgentSettledForDelivery drives the releaseWithoutRedrive path: settleMailboxPointerEnter runs (pointer text was already written) and redrive is never called — the test doesn't assert redrive at all. Either add expect(redrive).not.toHaveBeenCalled() to document that semantics, or rename so it doesn't promise a redrive the code doesn't do.
| it('abandons staged Enter and redrives when isAgentSettledForDelivery returns false', async () => { | |
| it('abandons staged Enter without redriving when isAgentSettledForDelivery returns false', async () => { |
b171989 to
75cd510
Compare
|
Rebased onto current Rebase. Review findings
Tests run: focused suites plus the orchestration mailbox and tui-idle suites, 20 files and 256 tests passing. Also ran |
…en dialog (#21745) (#33366) Orchestration mailbox pointers (typing and the delayed Enter) are held while a Claude pane shows an open dialog (AskUserQuestion / permission / plan approval chrome on screen, or a fresh waiting row when the screen can't be read), capped at 10 minutes, so mail no longer answers the dialog. Recheck backs off to 2s while held. Fixes #21745. Supersedes #26928, #21880. Co-authored-by: yasyf <709645+yasyf@users.noreply.github.com>
|
Thanks for working on this! The mailbox-into-dialog fix landed via #33366, which holds both the pointer text and Enter while Claude's dialog is open (marking mail read without Enter would leave the pointer text sitting unsent at the prompt). Closing as superseded. |

ELI5
When Claude Code asks the user an interactive question in the terminal (like picking an option with arrow keys), Orca's background mailbox delivery could mistake the terminal as idle and press Enter to deliver a queued message. This accidentally selected the first choice of the question. Now, Orca checks if the agent is waiting on an interactive question before typing or pressing Enter, and holds back the delivery until the user has finished answering.
What Changed
AskUserQuestion/state: 'waiting'/state: 'blocked'), the terminal title could repaint to the agent name orready. Mailbox delivery considered this an idle settled state and typed the pointer message plus Enter into the terminal. This auto-submitted the question with whatever option was highlighted.isAgentSettledForDeliverykeeps main's tui-idle ranking and additionally refuses whileisPaneWaitingOnInteractivePromptis true.isPaneWaitingOnInteractivePrompttakes the pane's newest hook row, joined on any pane key or terminal handle the PTY is known under, and blocks oninteractivePrompt, an ask-user tool, or statewaiting/blocked. It applies no 30-minute staleness cutoff, because an unanswered question posts no further hooks. Rows from before a PTY respawn, restored-unconfirmed rows, and identity-only rows are ignored.isAwaitingInteractivePromptdependency rather than the full idle gate, because a working agent is queue-safe there and the pointer's own echo would fail a quiet-stream check. A prompt that opened between the write and the Enter settles the pointer without Enter, the same as main's handling of a target that turned to permission.Why
This directly resolves issue #21745 where orchestration mail pointer pushes corrupted user input by inadvertently answering open Claude Code
AskUserQuestionprompts.Alternatives considered:
interactivePrompt,toolName,state: 'waiting'), making hook inspection accurate and deterministic across supported agents.Linked Issue
Fixes #21745
Visual Proof
N/A - Non-visual runtime terminal delivery gating.
Testing
Added automated tests in
src/main/runtime/tui-idle-delivery-and-quiescence.test.tsverifying delivery is parked whileAskUserQuestionis open and delivered once answered.Added unit tests in
src/main/runtime/orchestration/mailbox-pointer-submit.test.tsverifyingsubmitOrchestrationMailboxPointersuppresses Enter whenisAgentSettledForDeliveryreturns false.Verified all quality gates and typechecks (
check-changed-code-quality.mjs,check-max-lines-ratchet.mjs,tc:cli,tc:node,tc:web).I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
No breaking wire or API changes. Minimal changes strictly scoped to mailbox delivery gating.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)