Repository navigation
fix(orchestration): hold the mailbox pointer while the composer has an unsent draft - #33429
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review.
|
7085c8b to
0f3c09e
Compare
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:
5d7a6af5-baf6-4076-b70f-4c885c747c3a
Commits-
Reviewing files that changed from the base of the PR and between 7085c8b198d2ca7ac9dd29ccc49383d21f8ab40c and ea88febea31762253aca9368b021bc21513c1090.
Files selected for processing: 17-
src/main/daemon/terminal-cursor-line-context.test.tssrc/main/ipc/pty/runtime/operations.tssrc/main/runtime/__fixtures__/codex-0-137-0-rotating-placeholder.meta.jsonsrc/main/runtime/__fixtures__/codex-0-137-0-rotating-placeholder.txtsrc/main/runtime/claude-agent-teams-tmux-dispatcher.tssrc/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/orchestration/mailbox-pointer-pty-write.tssrc/main/runtime/orchestration/preamble.tssrc/main/runtime/orchestration/send-agent-turn.tssrc/main/runtime/terminal-run-facts-input.test.tssrc/main/runtime/terminal-run-facts.tssrc/main/runtime/terminal/layout/terminal-input-floor.tssrc/main/runtime/terminal/wait/terminal-wait-settlements.tssrc/shared/terminal-composer-draft.tssrc/shared/terminal-input-kind.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.
-
| @@ -89,6 +90,7 @@ export class TerminalRunFactsRegister { | |||
| origin === 'reattach' && (incarnationId === null || !previous?.incarnationId) | |||
| if (!sameProcess) { | |||
| this.lastInputAtByPtyId.delete(commit.id) | |||
| this.lastDrivingInputAtByPtyId.delete(commit.id) | |||
There was a problem hiding this comment.
Preserve literal-driving input recorded before the spawn commit.
If a user types after reserveSpawnCommit but before recordSpawnCommit, recordInput records the draft timestamp and pending first-input evidence. This deletion discards the draft timestamp while the pending first-input evidence survives. isPtyHoldingDelivery then cannot hold a visible unsent draft, so a mailbox pointer can submit it. Track the pending literal-driving timestamp by incarnation and carry it into the new process record.
| text === 'Ask Codex to do anything' || | ||
| text === 'Ask a follow-up question' | ||
| ) | ||
| return /^Try\s+["\u201C]/.test(text) || STOCK_PLACEHOLDERS.has(text) |
There was a problem hiding this comment.
🔎 Supported by static analysis
-
Script executed:
# Read the full target module with line numbers; confirm the snippet's lines and the set contents. test -f src/shared/terminal-composer-draft.ts && cat -n src/shared/terminal-composer-draft.ts # Locate other definitions or references of the relevant helpers across the source tree. rg -n -F -e 'STOCK_PLACEHOLDERS' -e 'isStockPlaceholder' -e 'getCursorLineContext' -e 'detectTerminalComposerDraft' -- src/ || test "$?" -eq 1
Repository: stablyai/orca
Length of output: 13709
Stop treating typed text as a stock placeholder.
isStockPlaceholder matches the cursor suffix against the stock set without checking whether that text is dim or typed. If a user types Explain this codebase and moves the cursor to the start of the phrase, the suffix equals that exact stock string. The check then clears the suffix. With nothing before the cursor, the composer text is empty, and detectTerminalComposerDraft returns null. Callers that treat null as "no draft" can then deliver into a pane that holds unsent user text.
The trigger is narrow. It needs the cursor before the phrase and an exact match of the full suffix. The /^Try\s+["\u201C]/ branch has the same gap.
Apply the placeholder rule only to dim suffix text, and keep undimmed suffix text as draft content. Add a regression case with the cursor at the start of a typed stock phrase.
ea88feb to
6cb0e65
Compare
…n unsent draft (#26992) The coordinator nudge plus its Enter was typed onto the user's half-written prompt and submitted it. Delivery now also holds while the pane's composer shows a draft (read with the existing terminal-composer-draft reader), on the same settled-for-delivery gate and 2s recheck as the open-dialog hold. The hold lapses 10 minutes after the last input so an abandoned or misread draft cannot strand mail. Co-authored-by: Hotragn Pettugani <103170876+Hotragn@users.noreply.github.com>
…otating placeholders - Hold clock reads driving input only, so Orca's own launch writes and prefilled drafts never hold its own mail. - Codex < 0.152 rotating placeholders (codex-rs/tui/src/chatwidget.rs PLACEHOLDERS / SIDE_PLACEHOLDERS) are stock placeholders, not drafts; covered by a real codex 0.137.0 frame. - Rename the shared cap to USER_INPUT_HOLD_CAP_MS. Co-authored-by: Hotragn Pettugani <103170876+Hotragn@users.noreply.github.com>
…he draft-hold clock Mailbox pointers, dispatch preambles, external-message turns and the Claude agent-teams tmux dispatcher now write with inputKind 'orchestration', which is treated as driving input everywhere (run facts, terminal-use listeners, Claude input evidence, remote-desktop floor) except the user-input hold clock. Co-authored-by: Hotragn Pettugani <103170876+Hotragn@users.noreply.github.com>
…ration input Co-authored-by: Hotragn Pettugani <103170876+Hotragn@users.noreply.github.com>
…mposer Co-authored-by: Hotragn Pettugani <103170876+Hotragn@users.noreply.github.com>
6cb0e65 to
c0f953a
Compare
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 prompt there, Orca typed on top of it and the Enter sent your half-written prompt with the nudge glued on. Now Orca waits while the agent's input box shows unsent text. Once you send or clear it, the nudge arrives on the next check. The wait has a limit: it ends 10 minutes after your last keystroke, so a draft you walked away from (or a misread screen) can't hold mail forever.
Root cause
isAgentSettledForDelivery(the single gate in front ofOrchestrationMailboxPointerDelivery.deliver) only checked agent idleness and, since #33366, an open Claude dialog. Nothing checked the composer, so an idle Claude/Codex pane with a typed draft passed the gate and gotpointer + \r.What changed (reuse, no new subsystem)
terminal-wait-settlements.ts: the existing hold predicate that fix(orchestration): hold mailbox pointers while the agent shows an open dialog (#21745) #33366 added (open dialog → refuse and recheck at 2s instead of 20 Hz) now also holds while the live screen model shows a composer draft. It reads the draft with the existingdetectTerminalComposerDraft(src/shared/terminal-composer-draft.ts, the same reader the terminal projection uses). It only holds when the last driving (user/client) input is withinUSER_INPUT_HOLD_CAP_MS(10 min, renamed fromCLAUDE_DIALOG_HOLD_CAP_MSsince both holds share it), so the hold is bounded.TerminalRunFactsRegistergainedreadLastDrivingInputAt, so Orca's ownlaunchwrites (prefilled startup drafts, launch follow-ups) never hold its own mail.mailbox-pointer-pty-write.ts, dispatch preamblepreamble.ts, external-message turnssend-agent-turn.ts, Claude agent-teams tmux dispatcher) now use a newTerminalInputKind'orchestration'. Every former=== 'driving'consumer in main (run facts, terminal-use listeners, Claude input evidence, remote-desktop floor) treats it as driving viaisDrivingInputKind. Only the hold clock ignores it. The value never leaves the main process: renderer, IPC and RPC inputs keep their existing kinds.terminal-composer-draft.ts: Codex before 0.152 shows a rotating dim placeholder (codex-rs/tui/src/chatwidget.rsPLACEHOLDERS/SIDE_PLACEHOLDERS, removed in Use consistent TUI input placeholders openai/codex#37360). The reader'srawAfterCursorfallback read these as drafts. They're now stock placeholders. A real codex 0.137.0 frame (__fixtures__/codex-0-137-0-rotating-placeholder.txt) previously read{text:"Explain this codebase"}and now readsnull.mailbox-pointer-submit.ts) still usesisPtyAwaitingUserInputalone, so Orca's own pointer text sitting in the composer never blocks its own Enter.Compared with #27195 (input-byte draft tracking in
TerminalRunFactsRegister, +242): this change reads the draft from the screen model with the existing reader and plugs into the existing #33366 hold. That makes it about 20 non-test lines, with no new state machine for keystrokes, Shift+Enter, kitty Enter, or bracketed paste. Backspacing to empty is handled exactly, because the screen shows an empty composer.Agent evidence (upstream)
Captured real PTY bytes from Claude Code 2.1.310 and codex (installed CLIs, 120x40 and 80x24) at an empty composer and after typing
please refactor the auth mod. Fed throughHeadlessEmulator+detectTerminalComposerDraft:null(theTry "…"placeholder is excluded); Claude draft →{text:"please refactor the auth mod", promptGlyph:"❯"}null(Ask Codex to do anythingis excluded); Codex draft →{text:"please refactor the auth mod", promptGlyph:"›"}Verification
orchestration-mailbox-notification-test-harness, not checked in): with the Claude 2.1.310 draft screen, main writes["\nYou have 1 orchestration message. Runorca-dev orchestration check --run ….\n", "\r"], which submits the draft. With this branch it writes[]. With the empty-composer capture, both deliver normally.orchestration-open-dialog-delivery-hold.test.ts. A draft holds the pointer, and it delivers after the draft is sent, or after the cap when the draft is abandoned. It fails on main.pnpm tc:node;pnpm testoversrc/main/runtime/orchestration*,terminal/,claude-*,tui-idle*: 2211 passed. The only failures are 3 inorchestration-cli-subprocess.test.ts(built-CLI subprocess timeouts), which fail identically on main in this worktree.check:code-quality:changedis clean.Risk
→) aren't held, which is the same as today.Fixes #26992. Supersedes #27195 (credit: @Hotragn, co-author).