Skip to content

Fix tab drag never starting on second-click presses - #217

Merged
austinywang merged 3 commits into
mainfrom
issue-10033-second-click-drag
Aug 12, 2026
Merged

austinywang merged 3 commits into
mainfrom
issue-10033-second-click-drag

Conversation

@austinywang

@austinywang austinywang commented Aug 12, 2026 •

Copy link
Copy Markdown

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


View with [code]smith Autofix with [code]smith
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.

Written for commit 7679865. Summary will update on new commits.

Review in cubic

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.

austinywang and others added 3 commits August 12, 2026 02:38
Selecting a tab and immediately dragging it delivers the press with
clickCount == 2 (AppKit keeps counting presses near the same point inside
the double-click interval), and trackTabMouseDown refused to arm the drag,
so the drag silently never started. Regression from the native tab drag
rewrite; SwiftUI .onDrag in 0.64.22 armed on any press.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
AppKit increments clickCount for any press that lands near the same point
inside the double-click interval, so the common click-to-select-then-drag
flow arrives as clickCount 2 and the drag was silently never armed. Accept
any press; a stationary double-click is unaffected because the native
session only begins after the pointer crosses the movement threshold.

Fixes manaflow-ai/cmux#10033

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a91c708e-a771-4011-b9c8-1bc51c9c55ca

📥 Commits

Reviewing files that changed from the base of the PR and between 5b61b18 and 7679865.

📒 Files selected for processing (2)
  • Sources/Bonsplit/Internal/Views/TabBarView.swift
  • Tests/BonsplitTests/TabBarDragEventRoutingTests.swift

📝 Walkthrough

Walkthrough

Tab dragging now accepts double-click-counted presses, forwards the threshold-crossing event, refreshes the tab frame before drag creation, and filters native interactions by enabled, editable, or actionable controls. Tests cover event forwarding, click counts, static title controls, and buttons.

Changes

Tab drag routing

Layer / File(s) Summary
Drag lifecycle and event forwarding
Sources/Bonsplit/Internal/Views/TabBarView.swift, Tests/BonsplitTests/TabBarDragEventRoutingTests.swift
Drag tracking accepts non-control clicks with any click count. Pending state no longer stores the mouse-down event. Threshold crossing refreshes the tab frame and forwards the current event. Tests verify event forwarding and configurable click counts.
Native interaction filtering
Sources/Bonsplit/Internal/Views/TabBarView.swift, Tests/BonsplitTests/TabBarDragEventRoutingTests.swift
Native interaction detection handles enabled buttons, editable text inputs, and enabled controls with targets and actions. Tests cover static title controls and actionable buttons.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: lawrencecchen, azooz2003-bit

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main fix: tab dragging now starts when the second click is used to initiate a drag.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-10033-second-click-drag

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@austinywang
austinywang merged commit 3389bdf into main Aug 12, 2026
6 checks passed
@austinywang
austinywang deleted the issue-10033-second-click-drag branch August 12, 2026 09:46
pull Bot pushed a commit to jasonkneen/cmux that referenced this pull request Aug 12, 2026
Tab drags silently never started when the press arrived with
clickCount >= 2 — the common click-to-select-then-immediately-drag flow.
Bonsplit PR: manaflow-ai/bonsplit#217

Fixes manaflow-ai#10033

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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