Repository navigation
fix(terminal): let Shift+middle-click paste in mouse-tracking panes - #21858
Merged
Merged
Conversation
Follow-up to #21834 (issue #21762). That fix arms the native-paste suppression window for every terminal middle-click, then returns early when the pane is in mouse-tracking mode so the TUI performs the paste from the forwarded mouse report. xterm's SelectionService.shouldForceSelection deliberately withholds that report for a shifted click (Option-click on Mac), so the TUI never pastes. With the native follow-up paste now suppressed as well, Shift+middle-click in Claude Code, Codex, and other tracking TUIs pasted nothing at all. Previously Chromium's native paste was the one paste. Mirror xterm's platform rule: when the click's modifier forces selection, fall through to Orca's own paste-to-PTY path (stop propagation, focus, paste) exactly as in a non-tracking pane. The auxclick handler gates stopPropagation the same way.
Contributor
|
This run was cancelled 🛑 The workflow was cancelled before completion. Please check the link below for details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

ELI5
Holding Shift while middle-clicking is the long-standing terminal trick for "ignore the app running in here, just do the normal terminal thing". A fix I merged yesterday (#21834) accidentally made that gesture paste nothing at all in terminals running a full-screen app like Claude Code. This restores it.
What Changed
Before: Shift+middle-click in a pane running a mouse-tracking TUI pasted nothing.
After: it pastes the primary selection once, as it did before #21834 — and now via Orca's own paste path, which is more reliable than depending on the browser's native paste.
The mechanism. xterm deliberately withholds the mouse report for a shifted click, so the TUI never learns the click happened and never pastes. Concretely,
MouseService._handleMouseDownreturns early whenSelectionService.shouldForceSelection(ev)is true, and that method ends inreturn event.shiftKeyon non-Mac.#21834 taught the middle-click handler to always arm the native-paste suppression window (that was the whole point — it stops Chromium's native paste from duplicating the TUI's own paste). But it also kept returning early for every click in a tracking pane. For a shifted click that combination is fatal: Orca swallows the native paste, and the TUI never gets a report to paste from, so both candidates are gone.
The fix narrows that early return. It now applies only when the click will actually reach the TUI — i.e. tracking mode and the modifier is not one that makes xterm withhold the report. A shifted click falls through to Orca's normal paste-to-PTY branch instead.
The new
terminalForcesSelectionForClickhelper mirrors xterm's own rule rather than hardcoding Shift, so Orca and xterm always agree on who owns the click: Shift on Linux/Windows, Option on Mac (Orca setsmacOptionClickForcesSelection: trueinpane-terminal-options.ts, and xterm's Mac branch isaltKey && macOptionClickForcesSelection). Without the Mac branch, a Mac user with this setting enabled would get a double paste on Shift+middle-click — Orca's own plus the TUI's — since Mac does forward shifted clicks to the TUI. (Not #21762's exact mechanism, whose native-paste half is Linux-only, but the same visible symptom.)Why
The alternative — special-casing Shift only on Linux — would silently break Mac, where Shift is forwarded and Option is the withholding modifier. Mirroring
shouldForceSelectionkeeps one source of truth for the question "will xterm forward this click?", so the two components cannot drift apart.This also composes correctly with the terminal link feature from #21438: its
isTerminalMiddleClickActivationalready requires!shiftKey, so a shifted click was never a link gesture and nothing is taken away from it.Linked Issue
Follow-up to #21834 / #21762 — fixes a regression introduced there, found during post-merge review.
Refs #21762
Visual Proof
N/A — input-handling fix with no rendered UI change. The observable difference is "Shift+middle-click pastes once" vs. "pastes nothing" in a terminal running a mouse-tracking TUI.
Testing
Extended
issue-21762-tracking-mode-middle-click-double-paste.repro.test.tswith five cases: Shift in a tracking pane takes the paste path; unshifted in a tracking pane is unchanged (proves #21762 is not regressed); Alt+middle-click off Mac stays on the TUI-owned path (guards against collapsing the check toshiftKey || altKey); the auxclick handler matches; and on a Mac user agent Shift does not take the paste path while Option does.Verified the tests actually catch the bug rather than merely passing: with the source change reverted and the new tests kept, the three fix-dependent tests fail on
propagationStopped; with the fix restored, all six pass.usePrimarySelectionPaste*,primary-selection*, and allterminal-link-*suites.pnpm tc:webclean;pnpm run check:code-quality:changedpasses all seven gates.AI Disclosure
Authored by Claude (Anthropic) in Claude Code, following post-merge review of #21834.
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)