Repository navigation
Conversation
…raft Orca typed "You have N orchestration message(s)..." and Enter into a coordinator pane even when the user had unsent text in the agent's input box, so the Enter sent their half-written message with the nudge on the end. The run-facts register already sees every byte written to a PTY. It now also tracks whether text was typed or pasted since the last Enter or Ctrl+C. Delivery checks that before typing a new pointer and leaves the mail unread for the next idle edge or message. Orca's own pointer bytes stay out of that state. Fixes stablyai#26992
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:
ea262129-f9b4-4c4d-86af-0f4210457d83
📒 Files selected for processing (8)
src/main/runtime/orca-runtime-stop-requested-pty-ids.tssrc/main/runtime/orca-runtime-write-orchestration-pointer-pty.tssrc/main/runtime/orchestration/mailbox-pointer-delivery-contract.tssrc/main/runtime/orchestration/mailbox-pointer-delivery.tssrc/main/runtime/orchestration/mailbox-pointer-stage.test.tssrc/main/runtime/terminal-run-facts-input.test.tssrc/main/runtime/terminal-run-facts.test.tssrc/main/runtime/terminal-run-facts.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Retry pending delivery after the draft is cleared. · mailbox-pointer-delivery.ts:121-124
src/main/runtime/orchestration/mailbox-pointer-delivery.ts:121-124
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winRetry pending delivery after the draft is cleared.
When
OrchestrationMailboxPointerDelivery.deliverreturns atmailbox-pointer-delivery.ts:121-124, it leaves the message unread. Enter and Ctrl+C clear the tracked draft, but the input paths only record the input and write it to the PTY. They do not request mailbox delivery.The settlement timer does not cover this case. It is armed only when the settlement check rejects delivery, while the draft gate returns before that check. An already-idle coordinator can therefore keep the message unread until another delivery event occurs.
Add a retry after an accepted user input that clears the draft. Keep the draft check in
OrchestrationMailboxPointerDelivery.deliver, so the retry cannot write into an active draft.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
fccb642e-1ea6-4879-b3f6-f19c73f46668
📒 Files selected for processing (2)
src/main/runtime/terminal-run-facts.test.tssrc/main/runtime/terminal-run-facts.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/runtime/terminal-run-facts.test.ts
- src/main/runtime/terminal-run-facts.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
…udge-waits-for-draft # Conflicts: # src/main/runtime/terminal-run-facts.ts
…n unsent draft (#33429) Hold the orchestration mailbox pointer (and coordinator nudges) while the agent's composer has an unsent draft, so Orca never submits over what the user is typing. Fixes #26992 Supersedes #27195 Co-authored-by: Hotragn <[email protected]>
ELI5
When a coordinator agent gets orchestration mail, Orca types "You have N orchestration message(s)…" into its terminal and presses Enter. If you were halfway through typing your own message in that same box, Orca typed on top of it and the Enter sent your unfinished message, with the nudge glued to the end. Now Orca waits: while you have unsent text in the box, it doesn't type the nudge. Once you send your message (or clear it with Ctrl+C), the nudge comes at the next chance, and no mail is lost.
What Changed
TerminalRunFactsRegister.recordInput, which both write paths already call for every byte going to a PTY, now also tracks per PTY whether text was typed or pasted since the last Enter.\r, kitty'sESC[13uEnter, or Ctrl+C ends it;ESC CR/ESC[13;2u), arrows, Esc, Alt+key, Tab, Backspace, focus reports and terminal replies leave it as it was;OrchestrationMailboxPointerDelivery.deliverchecks this right before it would type a new pointer. If there is a draft, it types nothing. The mail stays unread in the DB, so the idle edge after you send, or the next message, offers it again.orca orchestration checkstill returns it at any time.writeOrchestrationPointerPtysaves the draft state before its write and restores it right after. Input is recorded synchronously inside that write, so the restore can't undo a keystroke.Why
The issue lists three options: skip the nudge while the box has text, a setting to turn the nudge off (#26767), or deliver it outside the input line. I went with the first. It fixes the actual damage (your message sent half-written) without making anyone change settings, and it keeps the nudge for people who rely on it.
I track input bytes instead of reading the screen. Orca already sees every byte going into the PTY, and screen rules differ for every agent and break when an agent changes its prompt.
Each rule above is there to avoid a specific mistake:
Known limit: if you type and then delete everything with Backspace, Orca can't prove the box is empty, so the nudge waits until your next Enter or the next message. Waiting a little longer is the safe side here.
The 500 ms gap between the pointer text and its Enter is a separate race: you start typing exactly then. #26928 is already changing that Enter path (
mailbox-pointer-submit.ts), so I left it alone to stay out of that PR's way. This change only touches one wiring line next to it.Linked Issue
Fixes #26992
Visual Proof
N/A. No UI changes: the difference is that Orca no longer types into the terminal while a draft is there. The tests below cover it.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
terminal-run-facts.test.ts:deletedrops it.mailbox-pointer-stage.test.ts: with a draft,deliverwrites nothing and reserves nothing. Once the draft is sent, the same mail is pointed. I checked that this test fails with the gate removed.terminal-run-facts-input.test.ts: through the real runtime write funnel, Orca's own pointer write leaves no draft and keeps a user's draft. I checked that this test fails without the save/restore.pnpm tc:node,oxlint,oxfmtandpnpm run check:code-quality:changedpass. I also ran every suite undersrc/main/runtimeandsrc/main/ipc/pty(1,248 files, 12,725 tests): all pass on macOS.I did not run a live Claude Code coordinator for this; the tests drive the delivery and write funnel directly.
AI Disclosure
I used Claude Code (Claude Opus 5.5) to trace the delivery path and the input write funnel, and to draft the change and tests. I chose where the gate goes, reworked the rules after spotting the Esc and Cursor cases, and reviewed every line.
Review
My review of the change, with the agent's help:
ESC CR,ESC[13;2u) count as newlines, not sends.Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)