Repository navigation
fix(terminal): size the pre-Enter wait to what the host actually ingests (#15925) - #16586
Conversation
The Windows agent-prompt submit delay was a flat 1_500 ms frozen from the client's process.platform at import. Measured on two real Win11 hosts, ConPTY ingests a bracketed paste linearly at ~0.009-0.010 ms/byte, so the constant was both far too long for a 2-8 KB prompt (14-89 ms of real cost) and too short past ~145 KB — at 160 KB one host took 1_499 ms, meaning Enter landed mid-paste, exactly the corruption the delay exists to prevent, up to the 16 MB input ceiling. Replace it with getTerminalPasteIngestMs(platform, byteLength) and derive every pre-Enter wait from it: - open-loop fallback = 500 ms settle + ingest bound, uncapped - claude/codex render gate cannot start its quiet window before the ingest bound elapses (an agent that repaints mid-ingest could otherwise satisfy marker-then-quiet while ConPTY was still feeding the paste), and its 8 s hard cap now sits on top of the ingest bound instead of standing in for it - the plain terminal.send suffix path, which had an undocumented flat 500 ms The rate follows the host that owns the pty transport, not the client: a WSL pane is spawned as wsl.exe behind the Windows pseudoconsole so it still pays ConPTY, while an SSH pane follows the relay's reported remotePlatform. Also swap the inter-chunk setTimeout(0) for setImmediate. It cost a full ~15 ms Windows timer tick per 16 KiB chunk (~0.95 s/MB) while pacing ~1.07 MB/s — 11x above ConPTY's drain rate — so it never provided backpressure; the event-loop yield it did provide is preserved.
The render gate's hard cap is armed twice -- once at arm() and again when the show-cursor marker arrives -- but it re-added the whole ingest window each time while the ingest clock itself runs once from gate construction. A marker seen mid-ingest pushed the cap out by a second full ingest term (~34 s instead of ~24 s for a 1 MB prompt on ConPTY). Capture the ingest deadline absolutely and arm with what is left of it. Also thread the request AbortSignal through terminal.send so the now payload-scaled suffix wait can be cancelled: at 16 MB it runs ~262 s, well past the CLI's 60 s request budget, and previously nothing stopped the eventual Enter. Cleanups: a pty record's connectionId is only ever an SSH target id, so the wsl: relay-id guard in getPtyWriteHostPlatform was dead; and hoisting action.text removes both non-null assertions in writeTerminalAction.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
🚧 Files skipped from review as they are similar to previous changes (8)
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughTerminal submission delays now scale with UTF-8 payload size and PTY host platform. Terminal sends resolve remote host platforms, yield between chunks with Merge Risk: ⚪ Minimal · up to This change adjusts terminal prompt submission timing and cancellation handling; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description is complete and directly matches the template. It explains the change and rationale, links issue Full details: Docstring CoverageExplanation Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 6 files. (2 skipped: 2 too large.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
…sts (stablyai#15925) (stablyai#16586) * fix(terminal): size the pre-Enter wait to what the host actually ingests The Windows agent-prompt submit delay was a flat 1_500 ms frozen from the client's process.platform at import. Measured on two real Win11 hosts, ConPTY ingests a bracketed paste linearly at ~0.009-0.010 ms/byte, so the constant was both far too long for a 2-8 KB prompt (14-89 ms of real cost) and too short past ~145 KB — at 160 KB one host took 1_499 ms, meaning Enter landed mid-paste, exactly the corruption the delay exists to prevent, up to the 16 MB input ceiling. Replace it with getTerminalPasteIngestMs(platform, byteLength) and derive every pre-Enter wait from it: - open-loop fallback = 500 ms settle + ingest bound, uncapped - claude/codex render gate cannot start its quiet window before the ingest bound elapses (an agent that repaints mid-ingest could otherwise satisfy marker-then-quiet while ConPTY was still feeding the paste), and its 8 s hard cap now sits on top of the ingest bound instead of standing in for it - the plain terminal.send suffix path, which had an undocumented flat 500 ms The rate follows the host that owns the pty transport, not the client: a WSL pane is spawned as wsl.exe behind the Windows pseudoconsole so it still pays ConPTY, while an SSH pane follows the relay's reported remotePlatform. Also swap the inter-chunk setTimeout(0) for setImmediate. It cost a full ~15 ms Windows timer tick per 16 KiB chunk (~0.95 s/MB) while pacing ~1.07 MB/s — 11x above ConPTY's drain rate — so it never provided backpressure; the event-loop yield it did provide is preserved. * fix(terminal): stop double-charging paste ingest in the render gate The render gate's hard cap is armed twice -- once at arm() and again when the show-cursor marker arrives -- but it re-added the whole ingest window each time while the ingest clock itself runs once from gate construction. A marker seen mid-ingest pushed the cap out by a second full ingest term (~34 s instead of ~24 s for a 1 MB prompt on ConPTY). Capture the ingest deadline absolutely and arm with what is left of it. Also thread the request AbortSignal through terminal.send so the now payload-scaled suffix wait can be cancelled: at 16 MB it runs ~262 s, well past the CLI's 60 s request budget, and previously nothing stopped the eventual Enter. Cleanups: a pty record's connectionId is only ever an SSH target id, so the wsl: relay-id guard in getPtyWriteHostPlatform was dead; and hoisting action.text removes both non-null assertions in writeTerminalAction.
…sts (stablyai#15925) (stablyai#16586) * fix(terminal): size the pre-Enter wait to what the host actually ingests The Windows agent-prompt submit delay was a flat 1_500 ms frozen from the client's process.platform at import. Measured on two real Win11 hosts, ConPTY ingests a bracketed paste linearly at ~0.009-0.010 ms/byte, so the constant was both far too long for a 2-8 KB prompt (14-89 ms of real cost) and too short past ~145 KB — at 160 KB one host took 1_499 ms, meaning Enter landed mid-paste, exactly the corruption the delay exists to prevent, up to the 16 MB input ceiling. Replace it with getTerminalPasteIngestMs(platform, byteLength) and derive every pre-Enter wait from it: - open-loop fallback = 500 ms settle + ingest bound, uncapped - claude/codex render gate cannot start its quiet window before the ingest bound elapses (an agent that repaints mid-ingest could otherwise satisfy marker-then-quiet while ConPTY was still feeding the paste), and its 8 s hard cap now sits on top of the ingest bound instead of standing in for it - the plain terminal.send suffix path, which had an undocumented flat 500 ms The rate follows the host that owns the pty transport, not the client: a WSL pane is spawned as wsl.exe behind the Windows pseudoconsole so it still pays ConPTY, while an SSH pane follows the relay's reported remotePlatform. Also swap the inter-chunk setTimeout(0) for setImmediate. It cost a full ~15 ms Windows timer tick per 16 KiB chunk (~0.95 s/MB) while pacing ~1.07 MB/s — 11x above ConPTY's drain rate — so it never provided backpressure; the event-loop yield it did provide is preserved. * fix(terminal): stop double-charging paste ingest in the render gate The render gate's hard cap is armed twice -- once at arm() and again when the show-cursor marker arrives -- but it re-added the whole ingest window each time while the ingest clock itself runs once from gate construction. A marker seen mid-ingest pushed the cap out by a second full ingest term (~34 s instead of ~24 s for a 1 MB prompt on ConPTY). Capture the ingest deadline absolutely and arm with what is left of it. Also thread the request AbortSignal through terminal.send so the now payload-scaled suffix wait can be cancelled: at 16 MB it runs ~262 s, well past the CLI's 60 s request budget, and previously nothing stopped the eventual Enter. Cleanups: a pty record's connectionId is only ever an SSH target id, so the wsl: relay-id guard in getPtyWriteHostPlatform was dead; and hoisting action.text removes both non-null assertions in writeTerminalAction.
Keep the pending-draft check ahead of the paste-ingest sizing (stablyai#16586) that now feeds createAgentPromptRenderGate. Co-Authored-By: Claude Fable 5 <[email protected]>
…sts (stablyai#15925) (stablyai#16586) * fix(terminal): size the pre-Enter wait to what the host actually ingests The Windows agent-prompt submit delay was a flat 1_500 ms frozen from the client's process.platform at import. Measured on two real Win11 hosts, ConPTY ingests a bracketed paste linearly at ~0.009-0.010 ms/byte, so the constant was both far too long for a 2-8 KB prompt (14-89 ms of real cost) and too short past ~145 KB — at 160 KB one host took 1_499 ms, meaning Enter landed mid-paste, exactly the corruption the delay exists to prevent, up to the 16 MB input ceiling. Replace it with getTerminalPasteIngestMs(platform, byteLength) and derive every pre-Enter wait from it: - open-loop fallback = 500 ms settle + ingest bound, uncapped - claude/codex render gate cannot start its quiet window before the ingest bound elapses (an agent that repaints mid-ingest could otherwise satisfy marker-then-quiet while ConPTY was still feeding the paste), and its 8 s hard cap now sits on top of the ingest bound instead of standing in for it - the plain terminal.send suffix path, which had an undocumented flat 500 ms The rate follows the host that owns the pty transport, not the client: a WSL pane is spawned as wsl.exe behind the Windows pseudoconsole so it still pays ConPTY, while an SSH pane follows the relay's reported remotePlatform. Also swap the inter-chunk setTimeout(0) for setImmediate. It cost a full ~15 ms Windows timer tick per 16 KiB chunk (~0.95 s/MB) while pacing ~1.07 MB/s — 11x above ConPTY's drain rate — so it never provided backpressure; the event-loop yield it did provide is preserved. * fix(terminal): stop double-charging paste ingest in the render gate The render gate's hard cap is armed twice -- once at arm() and again when the show-cursor marker arrives -- but it re-added the whole ingest window each time while the ingest clock itself runs once from gate construction. A marker seen mid-ingest pushed the cap out by a second full ingest term (~34 s instead of ~24 s for a 1 MB prompt on ConPTY). Capture the ingest deadline absolutely and arm with what is left of it. Also thread the request AbortSignal through terminal.send so the now payload-scaled suffix wait can be cancelled: at 16 MB it runs ~262 s, well past the CLI's 60 s request budget, and previously nothing stopped the eventual Enter. Cleanups: a pty record's connectionId is only ever an SSH target id, so the wsl: relay-id guard in getPtyWriteHostPlatform was dead; and hoisting action.text removes both non-null assertions in writeTerminalAction. (cherry picked from commit 08a447d)
…sts (stablyai#15925) (stablyai#16586) * fix(terminal): size the pre-Enter wait to what the host actually ingests The Windows agent-prompt submit delay was a flat 1_500 ms frozen from the client's process.platform at import. Measured on two real Win11 hosts, ConPTY ingests a bracketed paste linearly at ~0.009-0.010 ms/byte, so the constant was both far too long for a 2-8 KB prompt (14-89 ms of real cost) and too short past ~145 KB — at 160 KB one host took 1_499 ms, meaning Enter landed mid-paste, exactly the corruption the delay exists to prevent, up to the 16 MB input ceiling. Replace it with getTerminalPasteIngestMs(platform, byteLength) and derive every pre-Enter wait from it: - open-loop fallback = 500 ms settle + ingest bound, uncapped - claude/codex render gate cannot start its quiet window before the ingest bound elapses (an agent that repaints mid-ingest could otherwise satisfy marker-then-quiet while ConPTY was still feeding the paste), and its 8 s hard cap now sits on top of the ingest bound instead of standing in for it - the plain terminal.send suffix path, which had an undocumented flat 500 ms The rate follows the host that owns the pty transport, not the client: a WSL pane is spawned as wsl.exe behind the Windows pseudoconsole so it still pays ConPTY, while an SSH pane follows the relay's reported remotePlatform. Also swap the inter-chunk setTimeout(0) for setImmediate. It cost a full ~15 ms Windows timer tick per 16 KiB chunk (~0.95 s/MB) while pacing ~1.07 MB/s — 11x above ConPTY's drain rate — so it never provided backpressure; the event-loop yield it did provide is preserved. * fix(terminal): stop double-charging paste ingest in the render gate The render gate's hard cap is armed twice -- once at arm() and again when the show-cursor marker arrives -- but it re-added the whole ingest window each time while the ingest clock itself runs once from gate construction. A marker seen mid-ingest pushed the cap out by a second full ingest term (~34 s instead of ~24 s for a 1 MB prompt on ConPTY). Capture the ingest deadline absolutely and arm with what is left of it. Also thread the request AbortSignal through terminal.send so the now payload-scaled suffix wait can be cancelled: at 16 MB it runs ~262 s, well past the CLI's 60 s request budget, and previously nothing stopped the eventual Enter. Cleanups: a pty record's connectionId is only ever an SSH target id, so the wsl: relay-id guard in getPtyWriteHostPlatform was dead; and hoisting action.text removes both non-null assertions in writeTerminalAction.
ELI5
When Orca pastes a long prompt into a terminal on Windows, the text takes time to actually arrive — the longer the prompt, the longer it takes. Orca used to wait a fixed 1.5 seconds and then press Enter, which was far too long for a short prompt and, on a big one, meant Enter reached the agent while the paste was still being delivered. The text is never lost or scrambled — the terminal writes bytes strictly in order — but the agent gets Enter with no breathing room, so it can submit an empty box and then watch your prompt appear underneath, unsent. Now Orca works out how long that particular paste needs based on its size and the machine it is going to, and waits for that instead. Short prompts submit roughly three times faster; long ones keep the same quiet gap before Enter that macOS and Linux have always had.
What Changed
src/shared/agent-prompt-injection.tsAGENT_PROMPT_SUBMIT_DELAY_MSconstant (500 ms / 1500 ms on Windows, frozen from the importing process'sprocess.platform) withgetTerminalPasteIngestMs(platform, byteLength)— a size-proportional lower bound on when a paste can have reached the child — andgetAgentPromptSubmitDelayMs(platform, byteLength)= 500 ms settle + that bound, uncapped.WINDOWS_CONPTY_INGEST_BYTES_PER_MS = 64(1.5x the slower of two measured host slopes); non-Windows keeps a 3x-margin 4096 B/ms rate that costs 0 ms at real prompt sizes.src/main/runtime/orca-runtime.tsgetPtyWriteHostPlatform), not the client and not the command's OS. A WSL pane on Windows still pays ConPTY, becauselocal-pty-provider.ts:625spawnswsl.exebehind the Windows pseudoconsole; an SSH pane follows the relay's reportedremotePlatform.terminal.sendsuffix path, which previously had an undocumented flat 500 ms with no platform check at all.setTimeout(0)→setImmediatein the terminal input chunk loop.Fix round (commit
9b7edafac28), on top of the original commit:armHardTimer()runs twice — atarm()and again when the show-cursor marker arrives — and each arming re-added the fullpasteIngestMs, while the ingest clock runs once from gate construction. Now the deadline is captured absolutely (ingestDeadlineAt = Date.now() + pasteIngestMs) and both call sites arm withAGENT_PROMPT_RENDER_TIMEOUT_MS + Math.max(0, ingestDeadlineAt - Date.now()). Worst case for a 1 MB prompt on a never-quiet pane drops from ~34 s back to the intended ~24 s.signalis threadedterminal-send-method.ts→sendTerminal→writeTerminalAction→waitForAgentPromptDelay, matching whatsendTerminalAgentPromptalready did. A 16 MB payload's wait is ~262 s, far past the CLI's 60 s request budget; before this an abandoned request still wrote\rat the end.isWslHookRelayConnectionId(connectionId)clause fromgetPtyWriteHostPlatform(a pty record'sconnectionIdis only ever an SSH target id;wsl:ids are stamped on hook envelopes only), and removed twoaction.text!non-null assertions by hoisting a narrowedtext.No new commits landed in this review round; the branch head is still
9b7edafac28. What changed is the analysis below.Why
AGENT_PROMPT_SUBMIT_DELAY_MSwas a constant modelling a size-proportional cost, so it was wrong in both directions. It was also computed from the importing process'sprocess.platformat module load, so a macOS client driving a Windows host got the macOS value.ConPTY paste ingest re-measured on a second real Windows 11 host (Node 24.18.0, the repo's patched node-pty,
useConptyDll: true, 16 KiB chunks, raw-mode child; metric = first pasted byte written → child observesESC[201~; 6 iterations per size, first discarded, p50):Linear on both, slopes 0.0104 and 0.0092 ms/byte (96.2 and 108.5 B/ms) — ~40% host-to-host spread, in both directions, which is why 64 B/ms is deliberately 1.5x the slower slope rather than a tight fit.
\ris always appended afterESC[201~, so no byte is ever lost, dropped, or reordered. What the flat 1500 ms actually destroyed is the settle gap. Host B took 1,499 ms of ingest at 160 KB against a 1,500 ms constant, so the\rsat behind still-queued paste bytes and reached the child ~1 ms after paste-end — and is provably early beyond that, up to the 16 MBTERMINAL_INPUT_MAX_BYTESceiling. An agent that attaches the pasted block asynchronously then processes Enter against pre-paste composer state: it submits an empty or previous-turn prompt, and the pasted text lands afterwards, sitting unsent in the box. Silent, and recoverable by pressing Enter again — but an automated caller has no one to press it and getsagent_prompt_stalled.Resulting Windows waits: 2 KB 532 ms (was 1500) · 8 KB 626 ms (was 1500) · 160 KB 3000 ms (was 1500, measured 1499–1662) · 320 KB 5500 ms (measured 2969–3342).
The
setTimeout(0)→setImmediateswap is separate: it cost a full ~15 ms Windows timer tick per 16 KiB chunk (~0.95 s/MB). It was not flow control — at 16 KiB/~15 ms it paces ~1.07 MB/s, 11x above ConPTY's ~96 KB/s drain, so the in-flight buffer grew regardless andTERMINAL_INPUT_MAX_BYTESbounds it identically either way. The event-loop yield it did provide (abort/permission/data callbacks between chunks) is preserved.AGENT_PROMPT_RENDER_QUIET_MSis deliberately unchanged at 1500: nothing measured here describes post-paste redraw cadence, and shortening it risks submitting mid-redraw.Risk & Trade-offs
Merge risk: Low-medium. The change touches every agent-prompt paste on every platform, and its central number (64 B/ms) is still fitted to two Windows hosts — but this round replaced the hand-wave with arithmetic, and the arithmetic says the failure mode is a silent, self-recoverable empty submit that needs an order-of-magnitude slowdown to reach ordinary prompts.
The grade was revisited, not carried over, and it did not move — for two offsetting reasons. It went down because the break condition is now derived rather than guessed, and because the derivation shows the ≥64 B/ms case is behaviourally identical to what macOS and Linux already ship (see below). It went up because the failure the PR actually prevents turned out to be a silent wrong-state submit rather than the visible corruption the old body claimed, and because the primary UI flow is still on the old flat delay (now #16680).
What the break condition actually is
The 500 ms settle term is not margin — it cancels. The gap the child sees between paste-end and
\ris(500 + N/64) − N/R, so keeping the same flat 500 ms gap that non-Windows has always shipped requiresR ≥ 64 B/msindependent of payload size. Host A measured 96.2 B/ms, so the entire budget is96.2/64 = 1.503x. That is the whole safety story; there is no size at which the 500 ms buys extra room.Two regimes follow:
The only plausible source of a 2–3x factor is CPU contention (a busy build, a thermally throttled laptop). Two candidates were checked and ruled out: RDP is irrelevant because the ConPTY here is headless with no attached console window, and AV hooks file I/O, not named-pipe reads.
The strongest argument for the number
At
R ≥ 64 B/msthe formula reduces the Windows large-paste case to exactly the macOS/Linux case: a flat 500 ms gap between paste-end and Enter. That configuration ships to the entire non-Windows fleet today and has produced no reports of this failure. That is empirical validation on a large population — a much better warrant than "1.5x of two hosts", which is how the previous version of this section justified it.What could go wrong
A slow Windows host still gets Enter pressed too early, truncating or splitting a long prompt.Measured and re-characterised. Nothing truncates or splits — writes are ordered. The real risk is the settle gap reaching zero, which requiresR < 64 B/ms: a 1.503x slowdown from host A, reachable only above ~100 KB, and needing ~10x at ordinary prompt sizes. Consequence if it happens: the agent submits an empty or previous-turn composer and the prompt lands unsent below it. Silent for a human (fixed by pressing Enter),agent_prompt_stalledfor an automated caller. Still no telemetry to observe the field distribution; the tests pin the floor against regression only.agent-paste-draft.ts:214andactive-agent-note-send.ts:217write Enter a flatPOST_PASTE_SUBMIT_DELAY_MS = 50after the paste, and because that Enter is a text-lessterminal.sendit picks up no ingest bound at all. The caller is the startup draft prompt — the way most prompts actually reach an agent — so this PR does not mean "large prompts are fixed". Pre-existing, deliberately out of scope, now filed as Renderer paste-then-Enter still uses a flat 50ms delay, so the startup draft prompt can submit empty on Windows #16680.getPtyWriteHostPlatformfalls back toprocess.platformwhen the pty record is missing. A macOS client driving a Windows host in that window would compute the non-Windows rate and effectively wait 0 ms of ingest. No case was constructed where a writable leaf has no record, so this is unhardened rather than known-broken; if it happened it would look identical to the pre-PR bug on that one send.setTimeout(0)->setImmediateswap changes chunk pacing. It removes ~15 ms of Windows timer sleep per 16 KiB chunk. It was never flow control (it paced 11x above ConPTY's drain rate, andTERMINAL_INPUT_MAX_BYTESbounds the buffer identically either way), and it makes real ingest faster than the numbers the bound was fitted to, so the safety margin grows. Self-correcting in the direction that matters.What a user gets in exchange
Ordinary prompts submit about 3x faster on Windows: a 2 KB prompt waits 532 ms instead of 1500 ms, an 8 KB prompt 626 ms instead of 1500 ms. Large prompts get back the 500 ms settle gap they had lost — host B measured 1,499 ms of ingest at 160 KB against the old 1,500 ms constant, i.e. Enter was reaching the child ~1 ms after paste-end and provably before it above that, up to the 16 MB input ceiling, which is how an agent ends up submitting an empty composer with the prompt sitting under it. Two paths the linked issue never mentioned (the claude/codex render gate and the plain
terminal.sendsuffix, which had an undocumented flat 500 ms with no platform check) are now covered too, and the rate is resolved from the host that actually owns the pty — so a macOS client driving a Windows or WSL pane no longer gets the macOS value.Alternatives considered and rejected
AGENT_PROMPT_RENDER_MARKERisESC[?25h(show cursor), an artifact of how claude and codex repaint, not a paste acknowledgement. For an agent that never hides the cursor,canSettlenever flips and the gate falls through to its 8 s timeout — turning today's 626 ms wait into a flat 8 s. A genuine closed loop needs a ConPTY drain signal, which node-pty does not expose on Windows.Trade-offs accepted
agent-paste-draft.ts:214andactive-agent-note-send.ts:217.AGENT_PROMPT_RENDER_QUIET_MSstays at 1500 ms, unmeasured. Nothing here describes post-paste redraw cadence, and shortening it on a guess risks submitting mid-redraw — so the 1500 ms is still being paid on top of the ingest bound.yieldBetweenTerminalInputChunks()wrapper stays instead of the repo'snode:timers/promisessetImmediateidiom, because the promises binding cannot be patched byvi.useFakeTimers()and four tests fail with the swap. A comment records why; the small inconsistency withorchestration.tsand friends is accepted.How to back it out
Clean revert. No persisted state, no schema or wire fields, no stream opcodes, no migration — the change is timing constants and call-site arithmetic, so reverting restores the previous flat delays immediately with no cleanup.
Linked Issue
Fixes #15925.
This closes the root cause the issue names, and additionally covers two paths the issue did not (the claude/codex render gate and the plain
terminal.sendsuffix). It does not cover the two renderer-side flat delays described under Review below — those are tracked separately as #16680, and because their caller is the startup draft prompt, merging this PR should not be read as "large prompts are fixed".Visual Proof
N/A — this is a main-process timing change with no rendered output; the only user-visible difference is how long Orca waits before pressing Enter, which produces no UI a screenshot can distinguish.
Testing
From the fix round (real output, clean worktree on the branch head
9b7edafac28):Non-vacuity checks (fixes reverted, new tests kept):
Independently re-run by the reviewer on a clean checkout of the branch before the fix round (454 files / 5371 tests green at that point);
check:max-lines-ratchetOK. The three tests above were added after that run.Hardware measurement (this round, no code change): ConPTY ingest re-run on a second real Windows 11 host — host B in the table above, 6 iterations per size at 2 KB / 8 KB / 40 KB / 80 KB / 160 KB / 320 KB, first discarded, p50 reported. Linear fit on both hosts; slopes 96.2 B/ms (A) and 108.5 B/ms (B). From those, the break condition was derived rather than asserted: the settle gap is
(500 + N/64) − N/R, which is size-independent and requiresR ≥ 64 B/ms, giving a 1.503x budget against host A. The empty-submit failure mode was confirmed by inspection of node-pty's ordered write queue (\ralways appended afterESC[201~), which is what disproved the earlier truncation claim.Coverage added by the branch:
\ris not written before 3,342 ms at 320 KB; a mid-ingest render marker cannot settle the gate early; a never-quiet pane is capped at exactly one ingest window past the render timeout; an abortedsendTerminalwrites no Enter; a WSL pane on Windows still pays ConPTY; both SSH directions. Shared-module table tests are pinned to the slower of the two measured hosts at each size, so a future slope reduction cannot silently reopen the bug.Not covered by any test: the settle-gap failure itself (it needs a real slow ConPTY, not fake timers), and the renderer two-phase path, which is out of scope and tracked in #16680.
Preserved unchanged: abort/
request_aborted,terminal_handle_stalegeneration checks,agent_prompt_blockedescalation, the bracketed-paste-end recovery write, andserializeAgentPromptSubmission.Review
Credit
No community PR credit is owed on this one, and that is a checked result rather than an omission:
gh pr list --repo stablyai/orca --search "15925 in:body" --state allreturns exactly one PR — this one. No other contributor filed an overlapping or adjacent fix, so nothing here was inherited from anyone else's work.Corrected claims from earlier versions of this body
"The ingest bound backs every pre-Enter wait." False, removed earlier, and still false. Two renderer-side waits are untouched:
src/renderer/src/lib/agent-paste-draft.ts:214waits a flatPOST_PASTE_SUBMIT_DELAY_MS = 50(defined at:36) between the bracketed paste and a separate Enter-only write.src/renderer/src/lib/active-agent-note-send.ts:217does the same in the guarded two-phase send.Neither picks up the new runtime bound, because the Enter arrives as a text-less
terminal.send:hasTextis false atorca-runtime.ts:19706, sowriteTerminalActioninserts no delay at all.AGENT_DRAFT_PASTE_MAX_BYTESis 16 MB (agent-draft-paste-content.ts:20). The caller is the startup draft prompt, i.e. the primary UI flow. Pre-existing, out of scope here, filed as Renderer paste-then-Enter still uses a flat 50ms delay, so the startup draft prompt can submit empty on Windows #16680."Enter lands mid-paste, so the prompt is truncated or split across two turns." False — corrected in place above. node-pty's write queue is ordered and
\ris appended afterESC[201~, so nothing is truncated, dropped, or reordered. The real defect is that the settle gap collapses to zero: the\rsits behind queued bytes and reaches the child immediately at paste-end, so an agent that attaches the paste asynchronously evaluates Enter against pre-paste state and submits an empty or previous-turn composer, with the pasted text landing afterwards, unsent. Silent and human-recoverable;agent_prompt_stalledfor automated callers."The 500 ms settle plus 1.5x of two hosts is the margin." Misleading. The 500 ms cancels out of the gap equation and buys nothing; the entire budget is the 1.503x in the rate constant. The real warrant for 64 B/ms is that at
R ≥ 64the Windows case becomes byte-for-byte the macOS/Linux case, which the whole non-Windows fleet already runs without reports.Declined during the fix round
The reviewer proposed replacing the local
yieldBetweenTerminalInputChunks()wrapper with the repo's establishedimport { setImmediate as yieldToEventLoop } from 'node:timers/promises'idiom (-5 lines, matchesorchestration.ts:3and others). Declined, with an experiment.vi.useFakeTimers()intercepts the globalsetImmediatebut cannot patch the binding insidenode:timers/promises; a throwaway probe confirmed the global resolves underadvanceTimersByTimeAsyncwhile thetimers/promisesone waits on the real event loop. With the swap applied, four of this PR's tests failed — a 320 KB paste needs ~20 sequential chunk yields, and a chain of pure-microtask awaits never reaches the libuv check phase, so the paste never completed on the fake clock. The existing importers of that idiom are not exercised under fake timers, so the precedent does not transfer. The wrapper stays, with one added comment line recording why the global is required here.Residual risk
R ≥ 64 B/msis required at every size, so a host 1.503x slower than host A loses the settle gap — but only above ~100 KB (a 2x-slower host regresses at ~97 KB), and ordinary prompts need ~10x. CPU contention is the only plausible route there; RDP does not apply (headless ConPTY) and AV hooks file I/O, not named-pipe reads. The tests pin the floor so a regression is caught; a slower real-world host is not covered.agent_prompt_stalled.getPtyWriteHostPlatformfalls back toprocess.platformwhenptysByIdhas no record for the ptyId.parseAppSshPtyId(ptyId)would recover an SSH pane in that window, but no case was constructed where a writable leaf has no record — this is hardening not done, not a known defect.setImmediateswap removes ~15 ms/chunk of Windows timer sleep that was inside the measured baseline, so real ingest is now faster than the numbers the bound was fitted to. Margin grows, not shrinks.AGENT_PROMPT_SUBMIT_DELAY_MSfrom asrc/sharedmodule is a small improvement for non-Node bundles; grep acrosssrc/,mobile/anddocs/confirms the only remaining importers of the changed exports areorca-runtime.tsand tests.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
Security: no new surface. Cross-platform: the whole point — rate follows the pty transport host (win32/WSL-behind-ConPTY/SSH
remotePlatform), non-Windows keeps a 3x-margin rate that is 0 ms at real prompt sizes. Remote SSH: covered in both directions by tests. Mobile: untouched. Backwards compatibility: no persisted or wire state. Performance: 2–8 KB Windows prompts submit ~3x faster; large prompts intentionally wait longer because they have to.Checklist
N/Awith reasonpnpm tc,pnpm test src/main/runtime src/shared/agent-prompt-injection.test.ts, andoxlintpass locally; fullpnpm buildleft to CI