Skip to content

fix(terminal): send agent-aware Windows paste newline encoding on Ctrl+V, not just right-click - #30550

Closed
STiFLeR7 wants to merge 1 commit into
stablyai:mainfrom
STiFLeR7:fix/ctrl-v-multiline-paste-windows-conpty
Closed

STiFLeR7 wants to merge 1 commit into
stablyai:mainfrom
STiFLeR7:fix/ctrl-v-multiline-paste-windows-conpty

Conversation

@STiFLeR7

Copy link
Copy Markdown
Contributor

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

pasteFromClipboard in terminal-pane-paste-execution.ts (the Ctrl+V / Shift+Insert path) only passed forceBracketedMultilineTextPaste, which falls back to the generic forceBracketedPasteForMultiline option. 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 calling resolveProtectedMultilinePasteOptionsForPane, which — for a TUI agent on Windows — returns windowsInputRecordNewline: 'alt-enter' instead, so newlines are sent as Alt+Enter rather than relying on bracketed paste at all.

This PR wires the same resolveProtectedMultilinePasteOptionsForPane call 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

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Added terminal-pane-paste-execution.test.ts covering pasteFromClipboard: asserts it now passes protectedMultilineTextPasteOptions (not just the generic bracketed-paste fallback) to pasteTerminalClipboard, 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 in terminal-clipboard-paste.ts to 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred) — lint/typecheck pass locally; full pnpm test/pnpm build could not run locally due to an unrelated native-build environment issue (see Testing section); deferring to CI for those.

…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
@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6541955a-3080-40f6-a123-a95de14cb18f
📥 Commits

Reviewing files that changed from the base of the PR and between 4d65c76 and 0900808.

📒 Files selected for processing: 2
  • src/renderer/src/components/terminal-pane/terminal-pane-paste-execution.test.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-paste-execution.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.

📝 Walkthrough

Keyboard clipboard paste now reads app state once and resolves protected multiline paste options from the runtime environment and pane state. It passes those options to pasteTerminalClipboard instead of the previous forceBracketedMultilineTextPaste argument. Tests cover Windows ConPTY agent and plain-shell paste options.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 09008

No actionable merge-blocking issue is established; the change is mergeable after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the terminal paste fix, the Windows-specific newline encoding, and the affected Ctrl+V path.
Description check Passed The description is complete and matches the repository template. It explains the user impact, implementation, rationale, linked issue, testing, platform considerations, AI disclosure, and checklist st…
Linked Issues check Passed Issue #30470 requires the Ctrl+V and Shift+Insert clipboard path to match right-click paste for multiline Codex input on Windows. terminal-pane-paste-execution.ts now calls `resolveProtectedMultilin…
Out of Scope Changes check Passed The changes stay within issue #30470. They update only keyboard clipboard-paste option resolution and add focused regression tests. No unrelated product behavior or public API changes are shown.
Full details: Description check

Explanation

The description is complete and matches the repository template. It explains the user impact, implementation, rationale, linked issue, testing, platform considerations, AI disclosure, and checklist status.

Full details: Linked Issues check

Explanation

Issue #30470 requires the Ctrl+V and Shift+Insert clipboard path to match right-click paste for multiline Codex input on Windows. terminal-pane-paste-execution.ts now calls resolveProtectedMultilinePasteOptionsForPane with the pane, store state, transport, and resolved host platform. The resolver returns windowsInputRecordNewline: 'alt-enter' for the Windows Codex case. The new test covers that case and the plain-shell fallback.

  • Fix all pre-merge checks with AI
  • 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.

@nwparker

Copy link
Copy Markdown
Contributor

Thanks @STiFLeR7! Your commit landed via #33339 (kept, plus Co-authored-by): it also covers Edit > Paste and keeps macOS/Linux unchanged. We reproduced the bug on real Windows with Codex's disable_paste_burst = true. Closing as superseded.

nwparker added a commit that referenced this pull request Oct 25, 2026
…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]>
@nwparker nwparker closed this Oct 25, 2026
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