Repository navigation
fix(terminal): right-click pastes once into Codex - #29647
AmoabaKelvin merged 1 commit into
Conversation
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
|
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
|
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.
ESC[<2;38;80MESC[<2;38;80mESC[200~TEXT ESC[201~(press, release, paste)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
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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)