Skip to content

fix(ui): keep titlebar presses from starting a text selection - #191

Merged
Tryanks merged 1 commit into
mainfrom
fix/titlebar-drag-selection
Jul 31, 2026
Merged

fix(ui): keep titlebar presses from starting a text selection#191
Tryanks merged 1 commit into
mainfrom
fix/titlebar-drag-selection

Conversation

@Tryanks

@Tryanks Tryanks commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Problem

Holding the titlebar kept selecting chat content and scrolling the list upward (按住标题栏会不断选中正文内容并向上滚动).

A press on a window_drag_area strip propagated to the window-level Markdown selection controller, which proxy-anchored a selection to the nearest message view. On the first mouse move the controller saw the pointer above the list's top edge and started its 16ms auto-scroll task; meanwhile start_window_move() entered the native macOS window drag, which swallows the mouse-up — so end_selection never ran and the scroll/select loop continued for as long as the titlebar was held.

Fix

Call window.prevent_default() in the drag area's left mouse-down handler (crates/ui/src/shell.rs). The selection controller already skips default-prevented presses that land outside Markdown hitboxes (window_selection.rs), and drag strips contain no Markdown — matching native titlebar behavior. Covers all four drag surfaces: chat header, sidebar top strip, settings header, diff tab strip.

Testing

  • New regression test press_on_titlebar_drag_area_does_not_start_selection, with a sentinel assertion that a blank-space press still arms selection (guards against a vacuous pass). Verified it fails with the fix reverted.
  • cargo test -p tcode-ui --lib: 230 passed. Clippy and fmt clean.

🤖 Generated with Claude Code

A press on a window drag strip propagated to the window-level Markdown
selection controller, which proxy-anchored a selection to the nearest
message. Once start_window_move swallowed the mouse-up on macOS, the
selection's auto-scroll loop kept scrolling the chat up and extending
the selection for as long as the titlebar was held.

Prevent the default on the drag area's left mouse-down: the controller
already skips default-prevented presses outside Markdown hitboxes, and
drag strips contain no Markdown. Covers the chat header, sidebar top
strip, settings header and diff tab strip alike.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Tryanks
Tryanks enabled auto-merge July 30, 2026 13:22
@Tryanks
Tryanks merged commit c112b29 into main Jul 31, 2026
5 of 6 checks passed
@Tryanks
Tryanks deleted the fix/titlebar-drag-selection branch July 31, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant