Fix sidebar hover drag-handle event dispatch
Fixes #750
Summary
- Add regression coverage for stale titlebar drag-handle event dispatch before the source fix.
- Follow-up commit will make drag-handle view hit-testing depend on active NSWindow event dispatch, not stale NSApp.currentEvent.
Test plan
- Not run locally per repository policy.
- CI should fail on the first test-only commit, then pass after the fix commit.
Reproduction
- Existing issue report reproduces on cmux 0.61.0 / macOS 14.5 by hovering the sidebar top button group.
- PR #736 already documents reproduction on v0.61.0 and fixed-after verification for the direct hover path; this PR closes the remaining stale-currentEvent class around that same drag-handle route.
[!NOTE]
Low Risk
Localized AppKit event/hit-test plumbing for the titlebar drag handle with tests; no auth, data, or broad behavior changes beyond fixing stale-event drags.
Overview
Fixes unintended titlebar/window drags when sidebar hover or layout hit-testing sees a stale leftMouseDown on NSApp.currentEvent (#750).
Window event dispatch is now bracketed in sendEvent with beginWindowDragHandleEventDispatch / endWindowDragHandleEventDispatch, maintaining a main-thread stack of active window + event type. WindowDragHandleView only participates in hitTest when that stack says a matching leftMouseDown is being delivered—not on passive events like mouseMoved.
Regression tests cover stale vs active dispatch and that hover stays transparent during dispatch.
Reviewed by Cursor Bugbot for commit 6ec7079a3121a58ee22f94c04506fabd16fe7cf4. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Fixes unintended titlebar drags by scoping the drag-handle hit-test to active window event dispatch; fixes #750. Wraps NSWindow.sendEvent with begin/end tokens backed by a main-thread-asserted dispatch stack so only an in-flight leftMouseDown can capture; stale NSApp.currentEvent reads and hover/passive events are ignored, with tests for stale, active, and hover cases.
Need help on this PR? Tag @codesmith with what you need. Autofix is disabled.
Summary by CodeRabbit
- Bug Fixes
- Improved window drag handle hit-testing so stale or unrelated mouse events no longer trigger unintended drags.
- Tests
- Added coverage verifying drag-handle hit-testing rejects stale and passive events unless part of an active drag dispatch.