fix: suppress right-click paste after failed drag-select with mouse reporting#90
Merged
InbarR merged 1 commit intoMay 4, 2026
Conversation
…eporting When a TUI app enables mouse reporting, xterm forwards drag events to the pty as SGR mouse sequences instead of creating a DOM selection. The user thinks they selected text, but hasSelection() returns false causing the right-click handler to paste clipboard content into the terminal. Fix: track left-button drag attempts. When a drag occurred with mouse tracking active and no xterm selection resulted, set a short-lived flag (recentDragWithoutSelection) that suppresses the paste on the subsequent right-click. This is narrower than blocking all paste when mouse reporting is on (which breaks PSReadLine's click-to-position since it enables ?1003h). The flag auto-expires after 3s so intentional TUI mouse interactions don't permanently disable paste. Users can always Ctrl+V to paste explicitly. Applied to both TerminalPanel and DetachedApp. Added e2e tests verifying both the fix and no-regression. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Owner
|
Merged in b3485c1 - confirmed working in dev tmax against Copilot CLI (drag in the TUI, right-click after, clipboard text no longer leaks into the prompt). Thanks @eladavraham! |
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.
Problem
When a TUI app (Claude Code, Copilot CLI, vim, etc.) enables mouse reporting, drag-selecting text is consumed by the pty xterm never creates a DOM selection. Right-clicking then triggers paste instead of copy, because \hasSelection()\ returns false.
Fix
Track left-button drag attempts. When a drag occurred with mouse tracking active and no xterm selection resulted, suppress the auto-paste on the subsequent right-click. The flag auto-expires after 3s.
This is narrower than blocking all paste when mouse reporting is on (which would break PSReadLine's click-to-position since it enables ?1003h).
Test
Added
ightclick-paste-mouse-reporting-text.spec.ts\ with two cases: