fix(tui): make selection copy reliable and improve copy affordances#3535
Merged
Conversation
Selection copy: - Route mouse motion and release to the chat while a text-selection drag is active, so a drag that ends over the editor or status bar still extends and finalizes the selection instead of dropping it. - Treat triple-click like double-click: anchor the line, let the drag extend it, and copy on release or via the debounce, instead of copying the line immediately on press and ignoring the drag. - Fall back to a plain drag selection when a double or triple click lands on a blank line instead of leaving a dead drag. - Reset multi-click tracking after a completed drag and cycle the click count after a triple-click, so quick selection retries are not misdetected as word or line selections. - Preserve code indentation (dedent to the common prefix), trim the right-hand width padding, and drop UI affordance lines (copy, edit, retry labels, expand and collapse indicators) and boundary blank lines from copied text. - Fix findClosestRuneIndex dropping the last character when the selection extends past the end of an unpadded line. Copy affordances: - Widen the copy labels from "⎘" to "⎘ copy" on assistant messages and code blocks for a larger click target. - Flash a same-width "copied" confirmation in place of the clicked label for 1.5s. Adds a tuitest Drag helper and an e2e test that releases the drag over the editor region, which fails without the routing fix.
dgageot
approved these changes
Jul 8, 2026
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.
Summary
Copying from the chat via cursor selection was unreliable (random one-word or one-line copies, trailing padding, UI glyphs in the clipboard), and the message copy button was a 1-cell target with no click feedback. This PR makes the selection copy path deterministic and improves the copy affordances.
Selection copy fixes
IsSelecting()plumbed messages -> chat page -> app)⎘ copy,✎,[+] expand ...labels and padding linesfindClosestRuneIndexwalked backwards past end-of-lineDrag lifecycle after the routing fix:
Copy affordances
⎘becomes⎘ copyon assistant messages and code blocks (7-cell click target instead of 1)copiedconfirmation for 1.5s; view-time overlay, render caches untouchedTests
Draghelper and e2eTestChat_DragSelectionCopiesAcrossRegions: drags from the response text and releases over the editor region; verified to fail without the routing fixpkg/tuiande2e/tuisuites and linters pass