Repository navigation
Conversation
|
Important Review skippedWe couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting You can disable this status message by setting the Use the checkbox below for a quick retry:
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:
Walkthrough
🚥 Pre-merge checks | ✅ 4 | ❌ 1
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6250c252-ecd5-407b-b64b-dfc2cbf49fe2
📒 Files selected for processing (3)
src/main/runtime/orca-runtime.tssrc/shared/terminal-input.test.tssrc/shared/terminal-input.ts
Maintainer review: I could not reproduce the premise on real Windows, and the pacing introduces a new failure modeI picked this up to land it and ran the change against a real Windows 11 box (win32 x64, Node v24.18.0, ConPTY via the repo's own 1. 16 KiB +
|
| Payload | main | this PR |
|---|---|---|
| 4 KiB | 1 write, 0 ms | 4 writes, 48 ms |
| 64 KiB | 4 writes, 0 ms | 64 writes, 1.0 s [1829 ms] |
| 256 KiB | 16 writes, 0 ms | 256 writes, 4.1 s [7330 ms] |
| 100 KB | 7 writes, 0 ms | 98 writes, 1.6 s |
| 2 MiB | 128 writes, 0 ms | 2048 writes, 32.7 s [57 785 ms] — past the 30 s wall |
| 16 MiB (cap) | 1024 writes, 0 ms | 16 384 writes, 262 s |
4. Concurrent sends to one PTY interleave — pre-existing, but this widens the window 16x
There is no per-PTY write queue on the runtime path (the renderer has one in pty-input-write-queue.ts; the runtime/RPC path does not). Two overlapping sendTerminal calls to one PTY interleave chunk-by-chunk — I confirmed with a temporary test that logged write order ababab. This is pre-existing on main (which also awaits setTimeout(0) between chunks and therefore also yields), so the PR does not introduce it. But it stretches the interleavable window on Windows from ~0 ms to ~1 s per 64 KiB, making a latent race materially more likely to bite.
What is good here
- Pacing is correctly scoped to
win32;getTerminalInputChunkGapMs()returns 0 elsewhere. - Commit 9f090cb (skip the timer when gap is 0) is a genuine improvement over
mainfor macOS/Linux —mainawaitssetTimeout(0)between chunks unconditionally; this skips it. That part is worth keeping regardless of what happens to the rest. - No per-keystroke impact. Interactive typing goes through
pty:writeIPC →writePtyProviderInput(src/main/ipc/pty.ts:4812), which never calls the runtime helper and keeps the 16 KiB default. And any payload under one chunk emits a single chunk, so the gap loop never runs.
Suggested path
- Reproduce Long PTY injections into TUI agent panes are silently truncated; dispatch reports 'dispatched' anyway #10416 against the daemon write path (NDJSON frame handling), not ConPTY — that is where the reporter's bytes actually flow.
- If pacing is still wanted, bound total paced duration or make
terminal.senda keepalive/long-poll request first, otherwise the 30 s wall turns into a new bug. - Consider the issue's own asks 2 and 3 (file-based delivery, delivery ack before marking
dispatched) — an ack would have surfaced this class of failure instead of silently reporting success.
Verification run: src/shared/terminal-input.test.ts 14 passed; orca-runtime.test.ts -t chunk 24 passed; tsc --noEmit -p config/tsconfig.node.json exit 0; oxlint on all three changed files clean. Windows probes executed on real hardware as shown. Not pushing changes — the diff is unchanged from the author's.
Original patch by @innocarpe — the win32 scoping and the zero-gap fast path are sound; it is the underlying premise I could not confirm.
Could not reproduce the truncation this paces around — recommend holdingI ran a self-contained node-pty probe on a real Windows host (win32, Node v24.18.0, Also tested an idle reader at 64 KB, a stalled reader at 256 KB, and a child still in cooked mode with raw mode not yet armed (the freshly-launched-agent regime). All three strategies delivered 100% in all of them. I could not get ConPTY to drop bytes at all. The cost is severe and measured. The gap is per-chunk, so wall-clock ≈ bytes/1024 × 16 ms: 64 KB → ~1.7 s, 100 KB → ~1.6 s, 1 MiB → 28.9 s. That's a large regression on paste to fix a truncation I can't demonstrate, and 1 KiB/16 ms don't correspond to any ConPTY buffer behavior I could measure — they read as tuned constants. What the PR gets right: it's correctly Windows-gated (non-win32 returns gap 0 and the Two real defects if pacing is kept:
I've left |
Re-reviewed after the rewrite — three of my findings are fixed; the linkage regressedI verified the new revision ( Fixed, and I confirmed each:
The RPC keepalive addition is a good catch too — it addresses the 30-second socket idle timeout I measured earlier, which would otherwise have killed large paced sends outright. One thing to put back: this revision restored That isn't bookkeeping pedantry. The PR's own body states the Windows probe did not reproduce the truncation — my independent probe didn't either (zero loss at 1 MiB unchunked into a stalled reader). Merging with Where that leaves it. The concurrency, lifetime, remote-host, and timeout fixes are solid, well-tested work that stands on its own merits. The pacing remains unjustified by any reproduction — two independent probes on real Windows/ConPTY failed to lose a byte, and 1 KiB/16 ms still costs ~1.55 s per 100 KB and ~262 s at 16 MiB. Reasonable people could ship this as defensive hardening; I'd rather see the pacing gated or dropped until someone reproduces #10416, with the queue/lifetime/keepalive fixes landing regardless. That call is the maintainers', and the body is now honest about the evidence either way. |
|
@nwparker Thanks for the thorough real-Windows probes and for re-checking the rewrite — the measurements and the split between “justified infrastructure” vs “unjustified pacing” are very clear. I agree: we still don’t have a reproduction of the silent truncation this PR originally targeted, so I don’t want to ship 1 KiB / 16 ms pacing as a fix for #10416. The per-PTY write queue, host-platform-aware chunking inputs, teardown cancellation, and RPC keepalive are the parts that stand on their own (and the queue regression is real). Plan from here: drop (or fully disable by default) the Windows inter-chunk gap / small-chunk pacing, keep the serialization + lifetime + keepalive work, and leave the issue as Refs #10416 until someone can reproduce the original drop. Happy to adjust if you’d rather gate pacing behind an env flag instead of removing it outright. |
|
@nwparker Follow-up on the plan above — pushed to this branch:
Happy to tweak further if you'd rather have pacing behind an env flag instead of removing it outright. |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/main/runtime/runtime-rpc.test.ts (1)
4441-4443: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winSynchronize on overflow responses instead of a fixed sleep.
activeLongPolls >= 2only proves that two asks were admitted; the other two requests may not yet have reached admission when the latershedassertion runs. Wait until two ask sessions contain terminal responses withruntime_busyrather than relying onsleep(100).src/main/runtime/runtime-rpc.ts (1)
501-502: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winPreserve reserved headroom when
longPollCapis 1.With
longPollCap: 1, this computesaskLongPollCapas1, allowing anorchestration.askto consume the only slot and starveterminal.wait/check --wait. Clamp the ask cap to at mostlongPollCap - 1(or reject configurations below two slots); the existing tests already uselongPollCap: 1.Suggested boundary fix
- this.askLongPollCap = Math.max(1, Math.floor(longPollCap * ASK_LONG_POLL_SHARE)) + this.askLongPollCap = Math.max( + 0, + Math.min(longPollCap - 1, Math.floor(longPollCap * ASK_LONG_POLL_SHARE)) + )
🧹 Nitpick comments (2)
src/main/runtime/runtime-rpc.ts (1)
1057-1059: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCorrect the admission-fence comment.
Short RPCs bypass
admitLongPoll(), so the total cap bounds concurrent long-polls; it does not protect short RPCs.src/main/runtime/orca-runtime.ts (1)
14200-14232: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winReintroduce a periodic macrotask yield for multi-chunk terminal sends.
TERMINAL_INPUT_CHUNK_GAP_MSis now0for all platforms, so large texts are chunked into up to 64 chunks per MiB with no unconditionalsetTimeout/delay between chunks. Add a lightweight macrotask yield periodically inwriteTerminalInputChunkswhen the remaining payload can exceed one chunk, instead of avoiding yielding every chunk.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a83cb870-5a29-4a2a-9207-e241ba002b4c
📥 Commits
Reviewing files that changed from the base of the PR and between 9f090cb and 5c84225919fd951729eb8106e36cfb518ee9f56b.
📒 Files selected for processing (4)
src/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/runtime-rpc.test.tssrc/main/runtime/runtime-rpc.ts
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3559d326-efe9-492c-a8cc-0d9f84ef3026
📥 Commits
Reviewing files that changed from the base of the PR and between 5c84225919fd951729eb8106e36cfb518ee9f56b and 3e23a88e2769c716a21ed80d8ecef344c4122387.
📒 Files selected for processing (2)
src/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/runtime/orca-runtime.ts
|
@coderabbitai Tightened the large-chunk test so it only flushes microtasks (no timer advance) before asserting both 16 KiB writes — reintroducing an inter-chunk gap should fail that assertion now. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
ast-grep outline src/main/runtime/orca-runtime.test.ts --items all --type function --match 'sendTerminal|chunk|terminal' || true
rg -n -i -C 8 '16\s*\*\s*1024|16384|microtask|advanceTimers|sendTerminal|chunk' src/main/runtime/orca-runtime.test.ts
rg -n -C 6 'writeTerminalInputChunks|waitForTerminalInputGap|getTerminalInputChunkGapMs|iterateTerminalInputChunks' src/main/runtime/orca-runtime.ts src/shared/terminal-input.tsLength of output: 83391
If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! |
8d78eea to
f7fcdf8
Compare
Sync update (
|
f7fcdf8 to
7632f29
Compare
[High impact] Adds serialization and keepalive logic to terminal input handling. The PR is not yet safe to merge because opted-in agent prompts can still be overtaken by later terminal input. Findings
SummaryThe PR adds per-PTY-generation input serialization, lifecycle checks, prompt reply windows, and RPC keepalives for queued terminal sends. The default prompt, raw-send, preview, and protocol-reply paths are coordinated, but opted-in prompt submissions still bypass the shared queue.
|
7632f29 to
6612d06
Compare
6612d06 to
e5a2775
Compare
e5a2775 to
f9f1b46
Compare
|
Updated this follow-up at Greptile has completed successfully. PR Checks, Mobile Checks, PR test LoC, and Bun profile persistence currently require maintainer approval; please approve those workflow runs when reviewing this update. |
f9f1b46 to
b3fbc81
Compare
| const delivery = await this.serializeAgentPromptSubmission(ptyId, generation, async () => { | ||
| await assertTerminalInputWithinLimitWithYield(payload) |
There was a problem hiding this comment.
Opted-in prompts bypass input queue
When an agent prompt uses onPermission: 'wait' or expectedBinding, this path serializes it only through serializeAgentPromptSubmission instead of the shared per-PTY input queue. If later raw or preview input arrives while the prompt is waiting for permission or yielding during validation, that later input writes first, reversing the invocation order.
b3fbc81 to
52a7c29
Compare
ELI5
A large terminal send can yield while checking its size. A shorter send arriving then could overtake it. This change reserves the terminal’s input turn first, so the larger send stays ahead and queued input stops when that terminal exits.
What Changed
Why
Ordering and teardown protection address independently reproducible problems. Current chunk yields already keep the event loop responsive; unproven Windows-only pacing would slow every paste.
Linked Issue
Refs #10416
Visual Proof
N/A — terminal byte ordering and RPC lifetime changes; the before/after evidence is the deterministic runtime regressions.
Testing
AI Disclosure
Implementation and verification assisted by OpenAI Codex.
Review
Addressed the Greptile ordering, queued-prompt, and protocol-reply findings with regressions. Current runtime modules and existing platform/remote behavior are retained.
Agent skill upstream boundary
Checklist