Skip to content

fix(terminal): right-click pastes once into Codex - #29647

Merged
AmoabaKelvin merged 1 commit into
stablyai:mainfrom
AmoabaKelvin:terminal-right-click-paste-owns-press
Oct 16, 2026
Merged

AmoabaKelvin merged 1 commit into
stablyai:mainfrom
AmoabaKelvin:terminal-right-click-paste-owns-press

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​96 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​94
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​99 $\color{#cf222e}{\Huge{\mathbf{−}}}$​20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​79

ELI5

Right-clicking in a Codex terminal on Windows pasted the clipboard twice. Orca pasted it, and Codex pasted it too, because Codex now has its own right-click paste and the click reached it. Orca now keeps the right button to itself when "Right-click to paste" is on, so only Orca pastes.

What Changed

Before: with "Right-click to paste" on (the Windows default), one right-click in a Codex pane inserted the clipboard twice. Claude Code was fine because it has no right-click paste of its own.

After: one right-click inserts it once. Ctrl+right-click still opens Orca's menu and still reaches the app as a mouse report.

Mechanism: a right-click fires a mousedown and then a contextmenu event. Orca pasted on contextmenu, but xterm had already turned the mousedown into a mouse report for the app, because Codex runs with mouse tracking on. Codex pastes the clipboard on that report (openai/codex#48118, on by default on Windows and Linux). The terminal pane and the dashboard terminal preview now claim the right mousedown in the capture phase, so xterm never sees it. The shared check lives in terminal-right-click-paste-gesture.ts.

Why

The setting says right-click is a paste gesture, so Orca should be the only thing acting on it. Letting the app own the click instead, as the middle-click fix in #21834 does, would turn off right-click paste for Claude Code and every other mouse-tracking app that does not paste on its own. Turning off Codex's feature from Orca is not an option either, since it is Codex config.

On macOS the contextmenu event fires on press rather than release, so Orca's paste usually lands while Codex is still reading the clipboard and Codex drops its own. That is why the bug looked Windows-only and intermittent.

Linked Issue

Fixes #25192

Likely the same cause as #24643 (pi), not verified.

Visual Proof

What a mouse-tracking program receives from one right-click, logged from its stdin. No screenshot, the change is in bytes written to the pty.

pty input from one right-click
Before ESC[<2;38;80M ESC[<2;38;80m ESC[200~TEXT ESC[201~ (press, release, paste)
After ESC[200~TEXT ESC[201~

Testing

  • macOS, hidden dev build: real Codex 0.162.1 with tui.right_click_paste = "on" and Orca's setting on. Three right-clicks each pasted once. A fake TUI that logs its stdin produced the table above. Ctrl+right-click still opened the menu and still reached the TUI as a ctrl-modified report.

  • New e2e case in terminal-paste-ownership.spec.ts: a mouse-tracking child plus the pty write spy. On main it fails with the button-2 report in the writes; here it passes. New unit cases for the dashboard preview, one of which fails on main.

  • Not tested on Windows or Linux.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

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

Cross-platform: the same code path runs on all three desktops; Windows is only where both defaults are on. SSH: unaffected, the change happens in the renderer before any pty write. Mobile: untouched.

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)

Codex pastes the clipboard on the right-button mouse report itself, so one
right-click pasted twice on Windows where both defaults are on.

Fixes stablyai#25192
@coderabbitai

coderabbitai Bot commented Oct 16, 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: e10c19de-bf9c-4631-ad5e-8455bd68a21f
📥 Commits

Reviewing files that changed from the base of the PR and between e522986 and 3238568.

📒 Files selected for processing: 7
  • src/renderer/src/components/dashboard-popout/preview-terminal-right-click-paste.test.ts
  • src/renderer/src/components/dashboard-popout/preview-terminal-right-click-paste.ts
  • src/renderer/src/components/terminal-pane/TerminalPaneSurface.tsx
  • src/renderer/src/components/terminal-pane/terminal-right-click-paste-gesture.ts
  • src/renderer/src/components/terminal-pane/use-terminal-context-menu-trigger.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-context-menu.ts
  • tests/e2e/terminal-paste-ownership.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The change adds capture-phase handling for right-click-to-paste gestures in terminal panes and dashboard preview terminals. Eligible gestures prevent the mouse-down event from reaching terminal mouse tracking and focus the terminal. Unit and end-to-end tests cover eligible and ineligible presses, and verify that a paste occurs once without a right-button mouse report.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 32385

The reported search-focus issue does not affect this change. No actionable merge-blocking issue remains 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 37.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Issue [#25192] requires one right-click paste to insert copied text exactly once in Codex. The terminal pane and dashboard preview now claim an unmodified right-button mousedown during capture when ri…
Out of Scope Changes check Passed The changes stay within the linked issue scope. The shared gesture helper, terminal-pane wiring, dashboard preview wiring, and their tests all support consistent right-click paste ownership. The chang…
Title check Passed The title clearly identifies the primary fix: preventing duplicate right-click pastes in Codex terminals.
Description check Passed The description is complete and relevant. It explains the user impact, mechanism, rationale, linked issue, behavioral proof, testing, scope, and checklist status.
Full details: Linked Issues check

Explanation

Issue [#25192] requires one right-click paste to insert copied text exactly once in Codex. The terminal pane and dashboard preview now claim an unmodified right-button mousedown during capture when right-click paste is enabled. This prevents xterm from sending the right-button report to a mouse-tracking app, while the existing context-menu path performs the paste. Ctrl+right-click remains unclaimed. The added dashboard unit tests and terminal end-to-end test cover ownership, focus, single clipboard delivery, and absence of the right-button report.

Full details: Out of Scope Changes check

Explanation

The changes stay within the linked issue scope. The shared gesture helper, terminal-pane wiring, dashboard preview wiring, and their tests all support consistent right-click paste ownership. The changes do not add unrelated product behavior or modify mobile, SSH, or other workflows.

  • 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.

@AmoabaKelvin
AmoabaKelvin merged commit 942ffe2 into stablyai:main Oct 16, 2026
42 checks passed
@AmoabaKelvin
AmoabaKelvin deleted the terminal-right-click-paste-owns-press branch October 16, 2026 12:11
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]: Right-click paste inserts selected text twice in Codex

1 participant