Repository navigation
fix(terminal): preserve multiline Windows Codex host prompts - #35902
Tomauskasz wants to merge 3 commits into
Conversation
Context: Host dispatch frames launch and driving prompts with bracketed paste. Native Windows Codex reads input records, where raw newlines can submit separate turns. Changes: - Move the existing Windows input-record newline encoder and type into shared paste code while preserving renderer exports. - Select the foreground consumer before launch identity and retain Linux semantics for WSL transported through Windows ConPTY. - Add host-method regressions for launch/driving newlines, Unicode/ESC handling, byte accounting, foreground identity and platform controls. Impact: Native Windows Codex host prompts use the same newline protocol as terminal paste. Existing payload admission and serialized submission remain in their owning path. Validation: - Nine host regressions and eighteen renderer paste tests passed. - Changed-file formatting, oxlint and LSP error diagnostics passed. - All four full typecheck projects passed under the documented Bun compiler. - Main/preload/renderer, WSL, CLI and projected web bundles built and verified. - Exact installed 1.4.244 backport passed archive integrity/rollback and actual Codex fake-provider ninety-line single-turn validation. Notes: Full unit/lint/build validation continues independently; no claim of a fully green source suite yet. Actual SSH/WSL sessions were not run. The encoder body is moved unchanged.
[Medium impact] The reviewed changes appear safe to merge. SummaryThe PR shares the existing Windows newline encoder between renderer pastes and host prompts. Native Windows Codex receives modified Enter sequences instead of raw newlines.
No actionable new issues were found in the changes since the previous review. No previous review threads were supplied. This review checked source and tests; it did not run them.
|
|
No actionable comments were generated in the recent review.
|
Context: Four runtime prompt tests simulate composer output only after bracketed-paste framing. Native Windows Codex now uses input-record newline encoding. Changes: - Set the mocked PTY write host to Linux in the four frame-specific scenarios. - Preserve the focused native Windows dispatch regression coverage. Impact: The generic framed-paste scenarios exercise the protocol their write mocks implement on every test host. Validation: - Focused dispatch and renderer tests: 27 passed. - Affected runtime plus focused suites: 1499 passed, 28 failed, 2 skipped; all 28 failure names and the selector_not_found unhandled rejection also occur on pristine f8cf317. - Changed test formatting, oxlint and language diagnostics passed. Notes: Production behavior is unchanged by this commit. Full repository unit and lint checks remain active.
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 · Select the foreground agent for held-submit timing. · terminal-input-dispatch.ts:210-231
src/main/runtime/terminal/input/terminal-input-dispatch.ts:210-231
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winSelect the foreground agent for held-submit timing.
When
launchAgentis Claude andforegroundAgentis Codex on Windows,payloadForencodes the prompt as Codex input records. The writer then callsgetAgentPromptHeldSubmitBudgetMswith the launch-first agent, Claude. Claude has no Windows input-record newline or retry delay, so the budget is zero and no held-submit retry runs. A large Codex input-record paste can still be consuming the first Enter, leaving the prompt in the composer instead of starting a turn.This behavior is introduced by the new Windows encoding branch. Make
getPtyAgentuse the foreground agent first so payload encoding and held-submit handling use the same consumer.Suggested fix
protected getPtyAgent(ptyId: string): TerminalAgent | null { const pty = this.ptysById.get(ptyId) - return pty?.launchAgent ?? pty?.foregroundAgent ?? null + return pty?.foregroundAgent ?? pty?.launchAgent ?? null }

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:
31542a6e-a74f-4988-b6c4-3ad8acc17f33
Files selected for processing: 2-
src/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-07.spec.tssrc/main/runtime/orca-runtime-tests/terminal-creation-and-readiness-part-08.spec.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.
-
Context: Windows prompt encoding selects the foreground agent while submit scheduling previously selected the launch agent first. A foreground Codex launched from Claude received no Codex held-submit retry; the inverse used Codex retries for Claude. Changes: - Select foregroundAgent before launchAgent in the input-timing resolver. - Add five real-runtime consumer and launch-fallback scenarios that swallow the first Enter and assert encoded bytes plus retry counts. - Pin the generic framed worker-start contract harness to a Linux write host. Impact: Payload encoding, submit delay, held-submit budget, retry delay and effect timeout use the consuming agent with launch identity as a startup fallback. Validation: - Two mismatched-agent retry scenarios failed before this change; the aligned Codex control passed. - Five consumer controls, six existing held-retry tests, twelve worker-start contract tests and twenty-seven focused tests: 50 passed. - Runtime/writer/RPC suites: 1497 passed, 27 failed, 2 skipped; all failure names occur in the pristine 28-failure baseline, with the same unhandled selector_not_found rejection. - Final pnpm build exited 0; rebuilt-host native Codex fixture and offline two-completed-turn proof passed. - Changed-file formatting, lint and language diagnostics passed. Notes: Mixed or partial composer displays remain a separate retry limitation. No matcher relaxation is included. The original broad unit run remains active.
|
Addressed the submit-timing consumer mismatch in a11df45c. The foreground Codex/launch Claude case missed its retry before the change; the inverse used an inappropriate Codex retry. Both directions and launch-only controls now pass, within 50/50 targeted tests. Final The description separately records unresolved mixed/partial composer retry behavior and broad-suite limitations. No ownership-matcher relaxation is included. |
ELI5
Windows Codex should receive a worker brief as one message, with all its lines intact.
What Changed
Host launch and driving prompts reuse the existing Windows input-record newline encoder. The foreground process determines the consumer; WSL keeps Linux semantics even when its transport is Windows ConPTY. Renderer exports are preserved. Encoding and submit timing select the same foreground consumer, with launch identity as startup fallback. Frame-specific tests explicitly select Linux; native Windows behavior has separate coverage.
Why
Raw newlines in the host bracketed-paste path can submit preamble fragments as separate Codex turns. Sharing the existing encoder fixes that host entry point in source so releases can carry the correction.
Linked Issue
Fixes #35898.
Related renderer work: #22703 / #22705. Held-Enter timing in #33295 / #35558 is a separate mechanism.
Visual Proof
Programmatic behavior evidence:
Native bootstrap adds a separate environment-context item. The rebuilt-host fixture made three HTTP requests because Codex separately generated a title; its native rollout contains exactly two completed fixture turns. The successful installed-host and rebuilt-host fixtures used a loopback fake provider. No rebuilt-app video is attached; the production screenshot contains private workspace context.
Testing
pnpm buildexited 0 after the selector change: four typecheck projects, Electron main/preload/renderer, WSL guest, CLI, web projection, mobile assets and Windows native executables. An independent native build and static-CRT check passed.terminal.sendoperations into idle Codex preserved each full multiline message and rendered both fake replies. Independent native rollout proof: one exact item per fixture prompt, two matching started/completed turn IDs, zero tools. Isolated apps and children were cleaned up.selector_not_foundrejection. Every failed name and that rejection also occur in the untouched base's 28-failure runtime set; writer/RPC files pass. One baseline concurrency failure did not recur, with no causal improvement claimed.origin/maincaused whole-tree fallback. The failed gate passes withORCA_CODE_QUALITY_BASE=f8cf31797e15cb82fc2559e6f0c244700cdaea3d; a pristine all-files scan reproduces exactly the same five findings. Original full-command exit 1 is retained.not-delivered. Actual fresh/reused workers can retain an intact mixed/partial composer draft that the ownership guard refuses to retry. This remaining submit limitation is unresolved; no screen-matcher relaxation is included. No actual SSH/WSL remote sessions or rebuilt-app before/after video were tested.Review
Reviewed the encoder move, execution-platform guard, foreground precedence for encoding and timing, payload bounds and existing serialized submit path. Audited timing-selector callers and reproduced both mismatched-agent retry cases. The renderer encoder body is moved unchanged; embedded ESC sanitization stays intact.
Agent skill upstream boundary
Notes
Medium merge risk: terminal protocol selection is execution-context sensitive. Reverting restores prior framing; no persisted data schema changes. Official update durability depends on merging and releasing this source correction; local archive edits alone are replaced by updates.
Checklist