Skip to content

fix(tui): preserve multi-click text selection - #45292

Closed
kitlangton wants to merge 1 commit into
v2from
fix-click-selection
Closed

kitlangton wants to merge 1 commit into
v2from
fix-click-selection

Conversation

@kitlangton

@kitlangton kitlangton commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Why

The click-only selection guard introduced with #44971 clears selection on mouse release. OpenTUI also resets its multi-click counter when selection is cleared, so double- and triple-clicks never reach word or line selection when copy-on-select is enabled.

This caused the deterministic selection-test failures seen in #45157. That branch passed locally because it lacked the upstream guard, while CI tested the combined merge commit.

What Changes

Interaction Result
Bare terminal click Does not copy or reset click history
Double-click Selects and copies the word, preserving its highlight
Triple-click Selects and copies the line, preserving its highlight
Empty drag Does not copy or reset click history
Explicit copy of an invalid selection Still clears the invalid selection

Selection History

Stationary word and line selections can still report isStart = true. Only a start-only cell selection is treated as a bare click. Mouse-release copying ignores invalid selections instead of clearing them, preserving the renderer-owned click count without private-state manipulation.

Demo

Matched real OpenCode Drive recordings: base cbef698861 on the left and fix aa6297f7ae on the right. Both use the same fictional simulated response and native SGR mouse input through the real TUI. Before: double/triple clicks select nothing. After: word and line highlights remain visible and clipboard confirmation appears.

click-selection-before-after.mp4

Scope

Restores real double/triple-click behavior without weakening the existing dialog or selection tests. A bare embedded-terminal click retains its native single-cell highlight until another interaction clears or replaces it, but never auto-copies that cell. Explicit copy retains its existing invalid-selection cleanup.

Verification

# From packages/tui
bun run test test/cli/tui/dialog-select.test.tsx test/util/selection-copy-on-select.test.tsx test/util/selection.test.ts --rerun-each=20
bun run test
bun typecheck

# From repository root
bun run lint packages/tui/src/util/selection.ts packages/tui/test/util/selection.test.ts packages/tui/test/util/selection-copy-on-select.test.tsx
bunx prettier --check packages/tui/src/util/selection.ts packages/tui/test/util/selection.test.ts packages/tui/test/util/selection-copy-on-select.test.tsx

Focused tests: 560 passed across 20 repeats. Full TUI suite: 810 passed, 5 skipped, 0 failed. Typecheck, lint, formatting, and all 32 pre-push workspace typecheck tasks passed. Includes real embedded-terminal coverage for click suppression, nonempty drag copying/highlight preservation, and empty drags. Local validation was on macOS; Linux and Windows validation runs in CI.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant