Skip to content

fix(orchestration): hold mailbox pointers while the agent shows an open dialog (#21745) - #33366

Merged
nwparker merged 7 commits into
mainfrom
nwparker/agint-mailbox-pointer-into-open-dialog
Oct 25, 2026
Merged

nwparker merged 7 commits into
mainfrom
nwparker/agint-mailbox-pointer-into-open-dialog

Conversation

@nwparker

@nwparker nwparker commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​232 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​232
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​108 $\color{#cf222e}{\Huge{\mathbf{−}}}$​20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​88

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 typed You 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

  • Claude keeps its rest title while AskUserQuestion, a permission prompt, or plan approval is open. In a real claude 2.1.310 under tmux, the pane title read ✳ Color preference question with the dialog on screen.
  • Claude posts PreToolUse and PermissionRequest for AskUserQuestion when the dialog opens. It posts PostToolUse and then Stop once 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 a waiting row (src/shared/agent-hook-listener/providers/claude-events.ts).
  • The mailbox gate (isAgentSettledForDelivery) ranks evidence through evaluateTuiIdle, and for Claude the hook lane only votes on task wake-ups (evaluateHookTurn in tui-idle-hook-lane.ts). So the ✳ title won: the verdict was ready-strong while the hook turn read permission/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"}}
  • Claude ≥ 2.1.295 also reports the dialog over OSC 7501 (src/main/agent-hooks/README.md), and current main turns that into a permission leaf 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.
  • Codex's request_user_input is not affected. Checked in ~/projects/codex origin/main: the overlay sets [ ! ] Action Required | <dir> (tui/src/bottom_pane/request_user_input/mod.rs terminal_title_requires_action, chatwidget/status_surfaces.rs) and replaces the composer, so no idle edge fires and the gate refuses. A runtime probe test on main with the real overlay screen and title confirmed it, both with a hooked working row 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 in claude-open-dialog-hold.ts and is Claude only: Claude is the agent whose rest title hides its dialogs. Codex's overlays retitle the pane to [ ! ] Action Required and replace the composer, and agents that send OSC 7501 report the block themselves.
    • Readable screen: hold only while Claude's dialog chrome is in the bottom 14 non-blank rows. That chrome is either the Enter to select / Esc to cancel footer (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.
    • Unreadable screen: hold on the row alone.
    • Hard cap: no row holds for more than 10 minutes. Esc posts no hook, so on an unreadable screen a dismissed dialog's row would otherwise never retire. After the cap, behavior is the same as main.
  • isAgentSettledForDelivery refuses 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.
  • The delayed Enter (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.
  • My follow-up adds the abstract declaration on the construction base and moves the hook-row join into 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 send as a worker heartbeat):

Build Claude Result
main 2.1.294 (no OSC 7501) Reproduced. Heartbeat sent with the dialog open. It was delivered 1 s later and the dialog closed with → Mars (the first option); the user never answered.
this PR 2.1.294 Held 25 s with the dialog open (delivered_at NULL). User answered Venus. The pointer was delivered 1 s after the turn ended and Claude ran orchestration check.
this PR 2.1.310 Same: held 25 s, user's answer kept, pointer delivered 2 s after the turn ended.

Tests:

  • orchestration-open-dialog-delivery-hold.test.ts drives OrcaRuntimeService with a ✳ title, the real AskUserQuestion screen and a waiting row, and checks three outcomes:
    • answered: the pointer and Enter are delivered;
    • Esc-dismissed with the row left behind: delivered;
    • only navigated: nothing is written.
  • claude-open-dialog-hold.test.ts covers the predicate:
    • holds on permission and plan-approval screens;
    • releases on an empty composer, a numbered composer draft, and a dialog in scrollback;
    • holds on an unreadable screen until the cap;
    • the cap also ends a hold while the dialog is visible.
  • mailbox-pointer-submit.test.ts covers the deferred Enter.
  • pnpm tc:node and check:code-quality:changed pass. 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

  • A Claude dialog left open for more than 10 minutes can again be answered by mail, as on main. The cap is deliberate: it bounds a row that nothing else retires.
  • The dismissed-dialog release is tested only through the runtime harness. A real-app Esc check was blocked by the host-wide terminal cap: other Orca instances on this machine held every slot.
  • A future Claude dialog without either kind of chrome would not be held while the screen is readable. That is no worse than main.
  • A restored-unconfirmed row (after an Orca restart) is ignored, as with every live-row reader.
  • No wire or protocol change. Hook rows from SSH/WSL panes join the same way, so mixed versions are unaffected. Nothing mobile-specific: delivery runs on the host.

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

yasyf and others added 4 commits October 24, 2026 19:57
…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>
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The runtime detects Claude dialogs awaiting user input from hook status and terminal screen content. It defers orchestration pointer submission while the target PTY awaits input and delays delivery settlement with periodic rechecks. Tests cover dialog detection, deferred submission, and answered, dismissed, and navigation-only dialog outcomes. The test harness can set the first pane’s launch agent.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 21b9c

Mailbox delivery now waits while a Claude dialog is open and is released after a bounded 10-minute window, as the PR states. No concrete, unbounded failure remains at the current head. Hold coverage for other hook-capable agents is a scope question for the author, not a defect in this change.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning [#21745] Partly met for Claude. Head src/main/runtime/claude-open-dialog-hold.ts holds a pane while the newest fresh hook row is waiting or blocked. isAgentSettledForDelivery refuses while the… (1) Extend the hold to waiting/blocked rows of other hook-capable agents, or guard their pointer write and Enter in the same way. In isClaudeDialogHoldingPane and its caller isPtyAwaitingUserInput, remove or narrow the `agentType !=…
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 14 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: holding orchestration mailbox pointers while an agent dialog is open.
Description check Passed The description is detailed and covers the user impact, root cause, implementation, linked issue, testing, risks, and platform considerations. It does not include the template's explicit Visual Proof …
Out of Scope Changes check Passed Each changed file connects to the #21745 objective. The isPtyAwaitingUserInput declarations (runtime-construction-services.ts, runtime-service-state.ts, mailbox-pointer-delivery-contract.ts) p…
Full details: Description check

Explanation

The description is detailed and covers the user impact, root cause, implementation, linked issue, testing, risks, and platform considerations. It does not include the template's explicit Visual Proof section or completed checklist items, but the required information is otherwise substantially present.

Full details: Out of Scope Changes check

Explanation

Each changed file connects to the #21745 objective. The isPtyAwaitingUserInput declarations (runtime-construction-services.ts, runtime-service-state.ts, mailbox-pointer-delivery-contract.ts) pass the hold into the pointer pipeline. claude-open-dialog-hold.ts implements the predicate. terminal-wait-permission.ts implements the hook-row join and the runtime check. mailbox-pointer-submit.ts and mailbox-pointer-stage.ts apply the deferred Enter. terminal-wait-settlements.ts applies the refusal and the 2 s recheck while a dialog holds the pane. The test harness launchAgent option and the new test files support the Claude-pane and dialog cases. No change in the summaries affects unrelated behavior. The Claude-only scope and the 10-minute cap are requirement gaps. They are assessed under the linked-issue check, not here.

Full details: Linked Issues check

Explanation

[#21745] Partly met for Claude. Head src/main/runtime/claude-open-dialog-hold.ts holds a pane while the newest fresh hook row is waiting or blocked. isAgentSettledForDelivery refuses while the hold applies, and the deferred Enter in submitOrchestrationMailboxPointer rechecks the same signal. Tests cover Claude permission and plan-approval screens, the Esc-dismissed case, and the deferred Enter.

Unmet item 1: the issue requires that pointer delivery and Enter not run while the hook store reports waiting/blocked with an interactive prompt, 'for any hook-capable agent'. isClaudeDialogHoldingPane returns false at its first check, row?.agentType !== 'claude'. A waiting or blocked row from another hook-capable agent under an idle title still lets the pointer and Enter through. The PR gives Codex evidence only: Codex retitles its pane and replaces the composer. It gives no evidence for other hook-capable agents. The PR states the Claude-only scope as a design choice. The issue text is unchanged and still names any hook-capable agent.

Unmet item 2: the issue requires that mail 'stays queued until the question is answered by a person'. At head, the hold check order is: agent type, state, respawn time, then now - row.receivedAt &gt; CLAUDE_DIALOG_HOLD_CAP_MS, and only after that the screen read. A Claude waiting or blocked row older than 10 minutes therefore releases the hold even when the dialog is still readable and visible. The PR states this trade-off. A long open question can still receive mail and an Enter.

The Claude-only restriction and the time cap are both present at the reviewed head. The previous FAIL is kept for both items. Codex evidence is not a basis for the other agents.

Resolution

(1) Extend the hold to waiting/blocked rows of other hook-capable agents, or guard their pointer write and Enter in the same way. In isClaudeDialogHoldingPane and its caller isPtyAwaitingUserInput, remove or narrow the agentType !== 'claude' gate. Give each added agent a release path that does not depend on Claude selector chrome. Add tests for each added agent. Alternatively, the #21745 author or a maintainer can amend Expected item 1 of the issue to name Claude only. The amendment must be recorded on the issue before this check can pass. (2) Do not release a waiting/blocked row on the time cap while its dialog is still readable and visible. Apply the cap only when the screen cannot be read, or remove the cap for that case. Add a test that holds a readable, visible open dialog beyond 10 minutes. Alternatively, record in the issue that the 'stays queued until answered' requirement is relaxed for the cap case.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

nwparker and others added 2 commits October 24, 2026 20:10
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>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Commits

Reviewing files that changed from the base of the PR and between dbfd1a1 and 8d3b14b.

Files selected for processing: 4
  • src/main/runtime/claude-open-dialog-hold.ts
  • src/main/runtime/orchestration-open-dialog-delivery-hold.test.ts
  • src/main/runtime/terminal/wait/terminal-wait-permission.ts
  • src/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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Functional Correctness · Quick win

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>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Commits

Reviewing files that changed from the base of the PR and between 8d3b14b and b49e926.

Files selected for processing: 4
  • src/main/runtime/claude-open-dialog-hold.test.ts
  • src/main/runtime/claude-open-dialog-hold.ts
  • src/main/runtime/orchestration-open-dialog-delivery-hold.test.ts
  • src/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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Functional Correctness · Quick win

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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major · Functional Correctness · Heavy lift

🔎 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔇 Additional comments: 2
src/main/runtime/claude-open-dialog-hold.ts: 1

22-22: Use evidence time for lifecycle checks.

The predicate uses row.receivedAt for both lifecycle comparisons. A relay replay can refresh receivedAt without changing evidenceObservedAt. An old waiting row can then survive a respawn or receive another ten-minute hold when the screen is unreadable. Compare row.evidenceObservedAt ?? row.receivedAt for these checks. Keep receivedAt for 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.

isClaudeDialogHoldingPane returns false for every non-Claude row before it checks waiting or blocked. 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
Commits

Reviewing files that changed from the base of the PR and between b49e926 and 21b9cc4.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: orchestration mail pointer answers a Claude AskUserQuestion — the delayed Enter selects the highlighted option while the pane reads as idle

2 participants