Repository navigation
fix(terminal): settle CLI prompts for Claude and Codex - #14608
Conversation
|
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 (9)
🚧 Files skipped from review as they are similar to previous changes (7)
📝 WalkthroughWalkthroughThe CLI now marks text-plus-Enter sends as agent prompts. The terminal RPC routes eligible sends for running agents through 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (6)
src/cli/handlers/terminal.test.ts (1)
97-137: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the interrupt exclusion. Neither test exercises text plus Enter plus interrupt. This branch must remain direct terminal input.
src/cli/handlers/terminal.test.ts#L97-L137: Add a--textplus--enterplus--interruptcase. Assert that the payload omitsagentPrompt.src/main/runtime/rpc/terminal-agent-prompt-send.test.ts#L53-L86: Add anagentPrompt: truerequest withinterrupt: true. Assert that it callssendTerminaland does not callsendTerminalAgentPrompt.The PR objective requires interrupts to retain direct terminal input.
tests/e2e/terminal-send-agent-prompt-submit.spec.ts (1)
14-14: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReuse
fixtureScriptinstead of recomputing the script path.Line 14 already resolves the repro script path. Line 55 rebuilds the same path from
repoRoot. Two sources for one path can drift.♻️ Proposed refactor
- path.join(repoRoot, 'tests', 'tools', 'repro-terminal-send-submit.mjs'), + fixtureScript,Also applies to: 52-67
tests/tools/repro-terminal-send-submit.mjs (2)
270-270: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winWrite a report when the fake agent times out.
The timeout handler exits with code 8 and writes nothing. The parent then throws
fake agent did not write a report, and the recordedprematureEntersand paste-framing data are lost. That data identifies the failure mode this tool exists to diagnose.♻️ Proposed refactor
- const timeout = setTimeout(() => process.exit(8), timeoutMs) + const timeout = setTimeout(() => { + void writeFile( + reportPath, + JSON.stringify( + { + contractOk: false, + submitted: false, + timedOut: true, + prematureEnters, + pasteFramingRequired, + hasBracketedPasteFrame: input.includes(BEGIN) && input.includes(END), + markerReceived: input.includes(marker), + receivedBytes: Buffer.byteLength(input, 'utf8') + }, + null, + 2 + ) + ).finally(() => process.exit(8)) + }, timeoutMs)
42-74: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winBound
runCommandwith a manual timeout.
callOrcapasses no timeout, so a hungorcaprocess can block direct runs. UsesetTimeoutto kill the child and reject the promise. Clear the timer when the child exits.src/main/runtime/orca-runtime.test.ts (1)
16730-16738: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCheck carriage returns across complete writes.
The 1,500 ms
AGENT_PROMPT_RENDER_QUIET_MSwindow makes the current timer sequence valid. Assert overwrites.join(''), or count carriage returns across all writes, so an embedded'\r'cannot bypass the test.config/reliability-gates.jsonc (1)
8656-8659: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd the CLI build step to the Windows command.
build:cliexists and installs the development CLI. The Windows command should prepare the source-built CLI before running Playwright, as the macOS command does.Proposed change
- "pnpm.cmd exec playwright test tests/e2e/terminal-send-agent-prompt-submit.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1", + "pnpm.cmd run build:cli && pnpm.cmd exec playwright test tests/e2e/terminal-send-agent-prompt-submit.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1",
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6d70d886-4610-4cd0-8fdc-6eef07e3b955
📒 Files selected for processing (9)
config/reliability-gates.jsoncsrc/cli/handlers/terminal.test.tssrc/cli/handlers/terminal.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/terminal.tssrc/main/runtime/rpc/terminal-agent-prompt-send.test.tstests/e2e/terminal-send-agent-prompt-submit.spec.tstests/tools/repro-terminal-send-submit.mjs
fd5332e to
11e42fa
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.ts (1)
17610-17619: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valueRepresent the prompt render-marker policy in configuration.
claudeuses--prefillandcodexusescodex-composer-prompt, so these checks are intentional but separate fromdraftPasteReadySignal; an explicit field would prevent future drift.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ea6d5838-6073-43e5-8338-f4c757780b50
📒 Files selected for processing (5)
config/reliability-gates.jsoncsrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/terminal.tssrc/main/runtime/rpc/terminal-agent-prompt-send.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/runtime/rpc/terminal-agent-prompt-send.test.ts
- src/main/runtime/rpc/methods/terminal.ts
| "https://github.com/stablyai/orca/issues/14525" | ||
| ], | ||
| "invariant": "A public CLI send containing non-empty text plus Enter and no interrupt identifies agent-prompt intent. The owning runtime uses bracketed-paste and settled submit only when the exact target is a running recognized agent on a desktop call; shells, text-only input, bare Enter, interrupts, mobile input, query replies, and older clients keep the direct terminal contract.", | ||
| "oracle": "Launch a bare fake Codex through the real Electron PTY and delay its composer render for 1,200 ms, beyond the legacy generic 500 ms gap. Send a 557-byte prompt with the public CLI and require the marker, zero premature Enter, no rescue Enter, and one submission. POSIX child stdin must retain one bracketed-paste frame; Windows ConPTY consumes that control frame, so runtime tests require the frame at the PTY write boundary while the Windows child requires the exact prompt. The same harness against the installed pre-fix runtime must record one premature Enter and require one bare rescue Enter. Focused units require CLI intent only for text plus Enter, settled routing after recognized-agent confirmation, every configured TUI agent to wait for output quiescence, unidentified fresh prompts to wait 1.5 seconds, wrapper foregrounds to avoid speculative polling, and byte-for-byte direct fallback for a non-agent target.", |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Reconcile the prompt byte counts.
Line 8871 states a "557-byte prompt". Line 8928 states "all 567 prompt bytes". Both describe the same fake-Codex payload. Correct the wrong value, or state why the counts differ (for example, framing bytes).
Also applies to: 8928-8928
11e42fa to
9a25596
Compare
|
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. |
Summary
terminal send --text ... --entercalls as optional agent-prompt intentFixes #14347
Fixes #14525
Tracks STA-4328
Root cause
The generic CLI path pastes text, waits a fixed 500 ms on POSIX (1.5 s on Windows), then sends Enter. Slow or busy composers can still be processing the paste, so Enter is consumed before submission is ready and the completed prompt remains in the composer.
The generic writer is byte-identical across the inspected 1.4.170–1.4.183 release range, so no recent Orca source first-bad boundary was found. This is a latent timing race that became more visible with long handoff prompts and TUI/runtime timing changes.
Narrow fix
For freshly identified Claude and Codex terminals only, the owning runtime:
Unknown, wrapper-only, stale, and non-target identities fail open to the pre-existing direct behavior. OpenCode was deliberately removed from this PR after review because its existing startup-ready cursor signal is not proof of a post-paste render marker.
Validation
origin/main(931cb037c5)pnpm typecheck:nodepnpm typecheck:cliRisk and tradeoffs