Repository navigation
fix(terminal): keep Windows Codex multiline Ctrl+V and Edit > Paste as one draft - #33339
Conversation
…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]>
|
Warning Review limit reachedYou'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. View limit details
Finishing Touches
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 |
…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.
|
Review note: reproduced deterministically on real Windows with |
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
resolveProtectedMultilinePasteOptionsForPaneand 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 asESC 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 genericforceBracketedMultilineTextPasteflag, which wraps the paste inESC[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 andPASTE_BURST_*constants) says that on Windows, pastes usually arrive as a fast stream ofKeyCode::Char/KeyCode::Enterevents, not as aPasteevent. 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-paneresolvePaneProtectedMultilinePasteOptions(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 theforceBracketedMultilineTextPastefallback frompasteTerminalClipboard. No caller needs it any more, and keeping it would let a new caller skip the agent-aware encoding again.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
codexin an Orca terminal, putalpha line\nbeta line\ngamma lineon the clipboard, then triggered the paste. Orca identified Codex as the foreground agent (paneForegroundAgentByPaneKey:codex,process-read).ESC[200~alpha line\rbeta line\rgamma line ESC[201~ESC[200~alpha line\rbeta line\rgamma line ESC[201~alpha line ESC\r beta line ESC\r gamma linealpha line ESC\r beta line ESC\r gamma lineThese 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), andcheck:code-quality:changedall 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]