feat(composer): mouse + keyboard text selection with copy/cut#1726
feat(composer): mouse + keyboard text selection with copy/cut#1726imkingjh999 wants to merge 7 commits into
Conversation
Mouse: click to position cursor, drag to select text. Ctrl+C copies composer selection. Ctrl+X cuts when selection exists, toggles Plan/Agent mode otherwise.
Add keyboard selection with Shift+arrow keys. Plain arrows clear selection, Ctrl/Alt arrows move by word without affecting selection. Also gitignore docs/superpowers/ and .serena/.
There was a problem hiding this comment.
Code Review
This pull request implements keyboard and mouse text selection for the composer input box. Key changes include the addition of a selection anchor to the state, updating editing methods to handle selected ranges, and implementing mouse click-and-drag selection logic. The reviewer identified a logic error in how character ranges are aligned when the composer is scrolled and pointed out significant layout logic duplication that should be refactored. Additionally, feedback was provided to source selection colors from the active theme and to ensure the composer selection is automatically copied to the clipboard on mouse release for consistency with the rest of the application.
- Remove needless borrows flagged by clippy - Auto-copy selection on mouse release (consistent with transcript) - Use theme selection_bg instead of hardcoded color
Covered by .gitignore, should not be in the PR.
|
@gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces text selection and mouse interaction support for the composer input field, including coordinate mapping for wrapped/scrolled text and support for standard selection shortcuts like Shift+Arrows, Copy, and Cut. Feedback focuses on improving performance and usability: the reviewer recommends removing the automatic 'copy-on-release' behavior to prevent premature clearing of selections, and suggests optimizations to reduce redundant text wrapping and unnecessary memory allocations during the render pass, particularly for large inputs.
- Revert auto-copy on mouse release (preserves selection for cut/delete) - Use actual scroll_offset in visible_line_char_ranges instead of inferring - Use &str slices in line_spans_with_selection to avoid String allocations
|
@gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements text selection within the TUI composer, enabling users to select, copy, cut, and delete text using both mouse interactions and keyboard shortcuts (Shift+Arrow). Key changes include adding selection state to the composer, implementing mouse-to-character coordinate mapping that accounts for text wrapping and scrolling, and updating input handlers to respect active selections. Reviewers identified several opportunities to improve efficiency and maintainability by reducing redundant layout calculations and refactoring duplicated wrapping logic across the rendering and event-handling paths.
|
This PR was opened before the v0.8.41 rebrand and is now stale. Feel free to rebase onto current |
Summary
selection_bgcolorPlatform differences
Test plan