Fix tab drag never starting on second-click presses
Problem
Regression from the native tab drag rewrite (6bee68f, after cmux 0.64.22): dragging a pane tab sporadically does nothing — no drag image, no session (manaflow-ai/cmux#10033).
Root cause: trackTabMouseDown only armed a drag when event.clickCount == 1. AppKit increments clickCount for any press that lands near the same point inside the double-click interval, so the extremely common flow click a tab to select it, then press again and drag it arrives with clickCount == 2 and the drag was silently never armed. Waiting ~500ms before dragging made it work again, which is why it felt sporadic and why clicking first "fixed" it. The 0.64.22 SwiftUI .onDrag path armed on any press.
Fix
Accept any clickCount when arming a pending tab drag (control-click still excluded for context menus). A stationary double-click is unaffected: the native session only begins after the pointer crosses the 4pt movement threshold.
Tests
Commit 1 adds secondClickOfDoubleClickStillArmsTabDrag (fails on main), commit 2 fixes it. Also carries the prior session's static-title-control coverage. Full suite: 22 tests green.
🤖 Generated with Claude Code
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Fixes a regression where dragging a tab after a quick second click wouldn’t start (fixes cmux #10033). Drags now arm on any click count and control hit-testing is tuned so labels don’t block drags while actionable controls keep ownership.
- Bug Fixes
- Arm tab drags regardless of click count (control-click still excluded); stationary double-clicks remain unaffected by the movement threshold.
- Recompute the dragging frame and image at threshold to reflect any UI changes before the drag starts.
- Tighten native-control detection: static labels allow drags; editable/enabled controls keep presses. Begin callback now receives the threshold drag event; tests cover second-click drag, static label, and button ownership.
Summary by CodeRabbit
-
Bug Fixes
- Improved tab dragging for click-then-drag interactions, including double-click-initiated drags.
- Preserved standard double-click behavior when the tab remains stationary.
- Improved handling of buttons, text fields, and other interactive controls during tab dragging.
- Refreshed tab visuals before starting a drag for more accurate drag previews.
-
Tests
- Added coverage for double-click dragging, static title controls, actionable buttons, and forwarded drag events.