Skip to content

fix(terminal): keep Windows Codex multiline Ctrl+V and Edit > Paste as one draft - #33339

Merged
nwparker merged 5 commits into
mainfrom
nwparker/agint-30470
Oct 25, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/agint-30470

Conversation

@nwparker

@nwparker nwparker commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​83 $\color{#cf222e}{\Huge{\mathbf{−}}}$​21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​62
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​36 $\color{#cf222e}{\Huge{\mathbf{−}}}$​18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​18

ELI5

On Windows, pasting several lines into Codex with Ctrl+V (or Shift+Insert, or Edit > Paste) could send each line as its own prompt. Right-click paste never did that. Now all of these paste the same way right-click does: each newline is sent as Alt+Enter, so the lines stay in Codex's composer until you press Enter.

Root cause

#14456 (e12b22c) added resolveProtectedMultilinePasteOptionsForPane and wired it into all four paste entry points. For Codex on a Windows host it returns { windowsInputRecordNewline: 'alt-enter' } (src/shared/tui-agent-config.ts, codex.windowsInputRecordPasteNewline), so each newline is sent as ESC CR. Codex binds Alt+Enter to insert a newline in the composer.

The renderer split in 286c210 ("refactor(renderer): split oversized UI surfaces") moved paste out of TerminalPane.tsx. The keyboard/paste-event path (terminal-pane-paste-execution.ts) and the Edit > Paste path (terminal-pane-paste-listeners.ts) both stopped calling the resolver. They fell back to the generic forceBracketedMultilineTextPaste flag, which wraps the paste in ESC[200~ … ESC[201~ with bare CRs. Only right-click (terminal-pane-menu-paste.ts) kept the agent-aware encoding.

Upstream Codex (codex-rs/tui/src/bottom_pane/paste_burst.rs, header doc and PASTE_BURST_* constants) says that on Windows, pastes usually arrive as a fast stream of KeyCode::Char/KeyCode::Enter events, not as a Paste event. Whether an Enter inside that stream becomes a newline or a submit depends on a timing heuristic: a burst of at least 3 chars with gaps of 8 ms or less, plus a 120 ms window after the burst where Enter inserts a newline. So the bracketed fallback only works when the keys arrive quickly enough. Alt+Enter is a real newline keystroke, so it doesn't depend on timing.

What changed

  • terminal-pane-paste-execution.ts: one per-pane resolvePaneProtectedMultilinePasteOptions(pane). It restores what the pre-split code did and is used by Ctrl+V/Shift+Insert, the paste event, and Edit > Paste. (STiFLeR7's commit fixed the keyboard path; the follow-up commit also fixes Edit > Paste, which had the same regression.)
  • terminal-clipboard-paste.ts: removed the forceBracketedMultilineTextPaste fallback from pasteTerminalClipboard. No caller needs it any more, and keeping it would let a new caller skip the agent-aware encoding again.
  • One regression test: Ctrl+V on a Windows Codex pane resolves to windowsInputRecordNewline: 'alt-enter'. It fails on main.

Nothing changes for macOS, Linux, or SSH hosts that aren't Windows. For a non-Windows client on an agent pane, keyboard paste goes back to the #14456 behaviour (forced bracketing), which right-click already used. Folder workspaces and mobile aren't affected; mobile already uses its own paste path.

Verification

All runs were on a real Windows 11 host (awin, build 26200) with Codex 0.164.0, using a temporary Playwright e2e spec that wasn't committed. Each run launched Orca built from this branch's base and from the branch, started real codex in an Orca terminal, put alpha line\nbeta line\ngamma line on the clipboard, then triggered the paste. Orca identified Codex as the foreground agent (paneForegroundAgentByPaneKey: codex, process-read).

Build Trigger Bytes written to the PTY Codex composer
main 6017bc9 Ctrl+V ESC[200~alpha line\rbeta line\rgamma line ESC[201~ 3-line draft
main 6017bc9 Edit > Paste ESC[200~alpha line\rbeta line\rgamma line ESC[201~ 3-line draft
this branch Ctrl+V alpha line ESC\r beta line ESC\r gamma line 3-line draft
this branch Edit > Paste alpha line ESC\r beta line ESC\r gamma line 3-line draft

These runs confirm the regression: on main, Ctrl+V and Edit > Paste send bracketed bytes, while right-click sends Alt+Enter. On this branch, all three send Alt+Enter, and Codex keeps the draft.

I couldn't reproduce the reported submit on this fast host. I also ran ConPTY-level checks: node-pty with both the system ConPTY and the bundled OpenConsole, Codex 0.162.1 (the reporter's version) and 0.164.0, short (ok/go/hi) and 12-line payloads, and with the CPU saturated. In all of them Codex kept the bracketed paste as one draft, because the bytes arrive in a single fast burst. That matches upstream's description of the Windows path as a timing heuristic (paste_burst.rs), so the reporter's failure probably depends on their machine's timing. Alt+Enter doesn't depend on timing.

Locally: pnpm tc:web, targeted vitest (the new test fails on main and passes here), and check:code-quality:changed all pass.

Risk

Low. The change only affects how multiline paste text is encoded, and only through a resolver that right-click paste has used since #14456. If Orca wrongly thinks Codex is in the foreground, the only effect is that the newlines in that one paste are encoded differently.

Fixes #30470

Co-authored-by: STiFLeR7 [email protected]

STiFLeR7 and others added 2 commits October 24, 2026 18:24
…l+V, not just right-click

Ctrl+V/Shift+Insert paste (pasteFromClipboard in terminal-pane-paste-execution.ts)
only passed forceBracketedMultilineTextPaste, which falls back to the generic
forceBracketedPasteForMultiline option. Right-click paste (terminal-pane-menu-paste.ts)
already resolves the pane's agent-aware protectedMultilineTextPasteOptions, which on
Windows with a TUI agent such as Codex returns windowsInputRecordNewline: 'alt-enter'
instead of relying on bracketed paste mode, which ConPTY/Codex does not see.

Wire the same resolveProtectedMultilinePasteOptionsForPane call into the keyboard
paste path so Ctrl+V (and Shift+Insert, which shares this path) gets the same
encoding right-click already gets, instead of submitting each pasted line as a
separate Enter press.

Fixes #30470
…e flag

The renderer split in 286c210 dropped the per-pane multiline paste
resolver from three entry points, not just Ctrl+V: Edit > Paste (app menu)
also fell back to the generic bracketed flag, so Windows Codex still got
submitted line by line from the menu. Resolve options once per pane in the
paste execution and use it for keyboard, paste-event and app-menu paste.

Remove pasteTerminalClipboard's forceBracketedMultilineTextPaste fallback;
no caller needs it now, and keeping it let a caller silently skip the
agent-aware Windows encoding.

Co-authored-by: STiFLeR7 <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

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: da636d6f-c9e2-4e91-a663-d8738540bcc4
Commits

Reviewing files that changed from the base of the PR and between d058e8f and 08c7a52.

Files selected for processing: 6
  • src/renderer/src/components/native-chat/native-chat-paste-routing.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-clipboard-paste.test.ts
  • src/renderer/src/components/terminal-pane/terminal-clipboard-paste.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-paste-execution.test.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-paste-execution.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-paste-listeners.ts
Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…anes

Only add the Windows input-record newline contract to keyboard and Edit > Paste;
a macOS/Linux client pasting into a local agent pane keeps its previous bytes.
@nwparker

Copy link
Copy Markdown
Contributor Author

Review note: reproduced deterministically on real Windows with tui.disable_paste_burst = true in the Codex config — main's Ctrl+V then submits each line; this PR keeps one draft. With default config both behave the same (Codex on Windows reads key events either way, and Enter inside a paste burst is absorbed regardless of Alt). Known, pre-existing for disable_paste_burst users: a pasted tab still triggers Codex's Tab (queue) key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Windows: Ctrl+V multiline paste into Codex submits each line (right-click paste works)

2 participants