Repository navigation
Fix sidebar hover drag-handle event dispatch - #4818
austinywang wants to merge 5 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR adds a dispatch-token stack for window-drag event dispatch, instruments NSWindow.cmux_sendEvent(_) to push/pop tokens during dispatch, updates WindowDragHandleView.hitTest to consult the dispatch state, and adds tests plus an NSEvent factory to validate gating behavior. ChangesWindow-drag dispatch + tests
Sequence Diagram(s)sequenceDiagram
participant NSWindow_cmux_sendEvent
participant DispatchAPI as beginWindowDragHandleEventDispatch/endWindowDragHandleEventDispatch
participant WindowDragHandleView_hitTest
NSWindow_cmux_sendEvent->>DispatchAPI: beginWindowDragHandleEventDispatch(window,event)
NSWindow_cmux_sendEvent->>WindowDragHandleView_hitTest: dispatch event / hitTest calls
WindowDragHandleView_hitTest->>DispatchAPI: windowDragHandleViewHitTestingAllowsCurrentEvent(currentEvent)?
DispatchAPI-->>WindowDragHandleView_hitTest: allowed / rejected
NSWindow_cmux_sendEvent->>DispatchAPI: endWindowDragHandleEventDispatch(token) (deferred)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error, 1 warning, 1 inconclusive)
✅ Passed checks (14 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Greptile SummaryThis PR fixes unintended titlebar drags (#750) by replacing the naive
Confidence Score: 5/5Safe to merge — the change is tightly scoped to AppKit hit-test plumbing with no auth, data, or broad behavioral impact, and the defer-based cleanup ensures the dispatch stack stays consistent even on early returns. The production logic change is small and well-guarded: Sources/WindowDragHandleView.swift — the new dispatch-state enum uses Important Files Changed
Sequence DiagramsequenceDiagram
participant AppKit
participant NSWindow_sendEvent as NSWindow.sendEvent
participant DispatchState as WindowDragHandleEventDispatchState
participant hitTest as WindowDragHandleView.hitTest
AppKit->>NSWindow_sendEvent: leftMouseDown event
NSWindow_sendEvent->>DispatchState: begin(window, event) → token
NSWindow_sendEvent->>AppKit: super.sendEvent(event)
AppKit->>hitTest: hitTest(point)
hitTest->>DispatchState: containsActiveDispatch(event)?
DispatchState-->>hitTest: true (frame present)
hitTest-->>AppKit: self (drag handle captures hit)
NSWindow_sendEvent->>DispatchState: defer: end(token)
Note over AppKit,hitTest: Stale / passive event (no active frame)
AppKit->>hitTest: hitTest(point) [mouseMoved or stale leftMouseDown]
hitTest->>DispatchState: containsActiveDispatch(event)?
DispatchState-->>hitTest: false (no matching frame)
hitTest-->>AppKit: nil (transparent, no drag)
Reviews (4): Last reviewed commit: "fix: return drag dispatch token after pr..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Sources/WindowDragHandleView.swift`:
- Around line 199-215: The three public functions
beginWindowDragHandleEventDispatch(window:event:),
endWindowDragHandleEventDispatch(_:), and
windowDragHandleViewHitTestingAllowsCurrentEvent(_:) call into the
main-thread-only WindowDragHandleEventDispatchState but lack runtime
enforcement; add a main-thread precondition (e.g.
dispatchPrecondition(condition: .onQueue(.main)) or equivalent) at the start of
each of these functions to assert they run on the main thread (matching the
pattern used in minimalModeTrafficLightFrameInContentCoordinates) so misuse is
caught early.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: ae08c139-a145-4bad-baf2-14e493ca38bd
📒 Files selected for processing (2)
Sources/AppDelegate.swiftSources/WindowDragHandleView.swift
CodeRabbit confirmed the requested main-thread precondition change is addressed, the inline thread is resolved, and the latest CodeRabbit status check passes.
Fixes #750
Summary
Test plan
Reproduction
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
leftMouseDownonNSApp.currentEvent(#750).Window event dispatch is now bracketed in
sendEventwithbeginWindowDragHandleEventDispatch/endWindowDragHandleEventDispatch, maintaining a main-thread stack of active window + event type.WindowDragHandleViewonly participates inhitTestwhen that stack says a matchingleftMouseDownis being delivered—not on passive events likemouseMoved.Regression tests cover stale vs active dispatch and that hover stays transparent during dispatch.
Reviewed by Cursor Bugbot for commit 6ec7079. 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.sendEventwith begin/end tokens backed by a main-thread-asserted dispatch stack so only an in-flightleftMouseDowncan capture; staleNSApp.currentEventreads and hover/passive events are ignored, with tests for stale, active, and hover cases.Written for commit 68f1924. Summary will update on new commits. Review in cubic
Need help on this PR? Tag
@codesmithwith what you need. Autofix is disabled.Summary by CodeRabbit