Repository navigation
fix(terminal): send agent-aware Windows paste newline encoding on Ctrl+V, not just right-click - #30550
fix(terminal): send agent-aware Windows paste newline encoding on Ctrl+V, not just right-click#30550STiFLeR7 wants to merge 1 commit into
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 stablyai#30470
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to
|
…s one draft (#33339) Windows + Codex: Ctrl+V, Shift+Insert and Edit > Paste send multi-line pastes with Alt+Enter newlines like right-click already does (restoring #14456 wiring lost in a refactor), so pasted lines no longer submit one by one when Codex's paste-burst heuristic doesn't catch them (e.g. disable_paste_burst = true). macOS/Linux clients unchanged. Fixes #30470. Supersedes #30550. Co-authored-by: STiFLeR7 <[email protected]>
ELI5
Pasting several lines of text into a Codex terminal with Ctrl+V on Windows used to submit each line as its own prompt, as if you pressed Enter after every line. Right-click paste never had this problem. Now Ctrl+V (and Shift+Insert, which shares the same code path) behaves the same as right-click: the whole block lands as one paste, and you press Enter yourself when you're ready.
What Changed
pasteFromClipboardinterminal-pane-paste-execution.ts(the Ctrl+V / Shift+Insert path) only passedforceBracketedMultilineTextPaste, which falls back to the genericforceBracketedPasteForMultilineoption. That option relies on the terminal being in bracketed-paste mode, which Windows ConPTY does not surface to Codex, so each newline in the pasted text is read as a real Enter keypress.The right-click path (
terminal-pane-menu-paste.ts) already avoids this by callingresolveProtectedMultilinePasteOptionsForPane, which — for a TUI agent on Windows — returnswindowsInputRecordNewline: 'alt-enter'instead, so newlines are sent as Alt+Enter rather than relying on bracketed paste at all.This PR wires the same
resolveProtectedMultilinePasteOptionsForPanecall into the keyboard paste path, so both paste sources resolve the pane's paste options identically.Why
The two paste paths diverged in how they compute paste options, and only one of them accounted for the agent/Windows-specific encoding. Rather than adding a Windows-only special case at the keyboard-handler level, this reuses the exact resolver the right-click path already relies on and already has test coverage for — so the fix is "make the two paths agree," not "teach a new code path about ConPTY."
Linked Issue
Fixes #30470
Visual Proof
N/A — this is a terminal input-encoding fix with no UI/visual change. Behavior change: pasting multi-line text via Ctrl+V now stays as one prompt until Enter is pressed, same as right-click paste already does.
Testing
Added
terminal-pane-paste-execution.test.tscoveringpasteFromClipboard: asserts it now passesprotectedMultilineTextPasteOptions(not just the generic bracketed-paste fallback) topasteTerminalClipboard, including the exact Windows+Codex case from the issue (windowsInputRecordNewline: 'alt-enter') and the plain-shell fallback case. The underlying resolver (resolveProtectedMultilinePasteOptionsForPane) already has its own dedicated test suite covering the win32/agent decision logic in detail; this test covers the wiring bug specifically (the keyboard path not calling it at all).I could not do a live manual repro with a real Codex session on this box — native module builds (
node-pty,@orca/windows-registry,@orca/windows-security) fail to compile here due to an MSBuild/node-gyp path-with-spaces issue unrelated to this change (C:\Program Files (x86)\...gets split at the space), which also blocks the full native-backed test/build pipeline. Typecheck (pnpm run typecheck:web), lint (oxlint), and format (oxfmt --check) all pass clean on the touched files. Traced both paste call sites and the shared resolver/options-merge logic directly interminal-clipboard-paste.tsto confirm the mechanism before and after.Platforms tested: unit test only (no native build available on this box for a live Windows ConPTY repro). The change is guarded by the same
hostPlatform === 'win32'check the already-working right-click path uses, so macOS/Linux behavior (and the non-TUI-agent/non-Windows case) is unchanged — confirmed in the test's second case.AI Disclosure
This change was implemented by an autonomous coding agent (Claude, via Claude Code) on behalf of @STiFLeR7, who reviewed and is submitting the PR. Root-cause tracing, the fix, and the added test were agent-authored; the issue's own detailed diagnosis (exact file/line pointers to both paste paths) made the root cause straightforward to verify directly against the current code.
Review
Agent skill upstream boundary
Notes
Security: none, pure input-encoding selection logic, no new inputs trusted differently.
Cross-platform: guarded by existing
hostPlatform/agent checks already used by the right-click path; macOS/Linux/non-agent behavior unchanged (covered by the test's fallback case).Remote SSH:
resolveTerminalInputHostPlatform(already used by the fixed path) is what resolves the host's platform for SSH/remote sessions, not the client's — this fix doesn't change that resolution, just makes the keyboard path call it at all.Mobile: not applicable, this is the desktop terminal-pane paste path.
Backwards compatibility: no public contract change; purely internal paste-option resolution.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred) — lint/typecheck pass locally; fullpnpm test/pnpm buildcould not run locally due to an unrelated native-build environment issue (see Testing section); deferring to CI for those.