fix(menubar): make provider strip reachable and mouse-wheel scrollable#334
Merged
iamtoruk merged 1 commit intoMay 16, 2026
Merged
Conversation
Two related bugs in the macOS menubar `AgentTabStrip`: 1. With more detected providers than fit at the default 360pt popover width (~7+), the off-screen provider chips were unreachable. SwiftUI's horizontal `ScrollView` does not scroll from click-drag, and there was no other affordance to reveal the hidden tabs. 2. Independent mouse wheels could not scroll the horizontal strip. Standard wheels emit only vertical `deltaY` with `hasPreciseScrollingDeltas == false`, and a horizontal SwiftUI `ScrollView` ignores vertical-only deltas. Trackpads (which emit horizontal deltas natively) already worked. Fix: - Wrap the strip in `ScrollViewReader` and add overflow-aware left/right chevron buttons that programmatically scroll to the next/previous visible provider via `proxy.scrollTo(_, anchor: .center)`. Buttons only appear when `stripContentWidth > stripViewportWidth - 30` and disable at the ends. - Install an `NSEvent.addLocalMonitorForEvents(matching: .scrollWheel)` in `.onAppear` (removed in `.onDisappear`). When the cursor is over the strip and the event is non-precise (`!hasPreciseScrollingDeltas`) with `deltaX≈0` and `deltaY≠0`, copy the `CGEvent` and transpose `scrollWheelEventDeltaAxis1` / `PointDeltaAxis1` / `FixedPtDeltaAxis1` onto axis 2 so the underlying NSScrollView receives a real horizontal delta. - Track strip hover via a `@MainActor` singleton `AgentTabStripScrollState` so the local-monitor closure can read the latest hover status without capturing stale SwiftUI state. Trackpad events are passed through untouched, so vertical scrolling elsewhere in the popover is unaffected. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AgentTabStripso off-screen providers are reachable when chips don't all fit in the popover.Why
The strip already lays out provider chips inside a horizontal
ScrollView, which on macOS:NSEvents. Standard mouse wheels emithasPreciseScrollingDeltas == falsewith a non-zerodeltaYand zerodeltaX, so a horizontalScrollViewsilently drops the event. Trackpads, which produce precise deltas with native horizontal components, already worked.Either bug alone is annoying; together they make some providers unselectable on a mouse-only setup.
Implementation notes
ScrollViewReader. Add left/right chevron buttons that programmatically scroll to the next/previous visible provider viaproxy.scrollTo(target.id, anchor: .center)and switch the selected provider via the existingstore.switchTo(provider:). Buttons are only rendered whenstripContentWidth > stripViewportWidth - 30, and they disable at the strip's ends.NSEvent.addLocalMonitorForEvents(matching: .scrollWheel)in.onAppear(removed in.onDisappear). Track strip hover via.onHoverinto a@MainActorsingletonAgentTabStripScrollStateso the monitor closure can read the latest hover state without capturing stale SwiftUI@State.!event.hasPreciseScrollingDeltas(mouse wheel, not trackpad)|deltaX| < 0.001and|deltaY| > 0(vertical-only delta)When all hold, copy the
CGEventand transposescrollWheelEventDeltaAxis1/PointDeltaAxis1/FixedPtDeltaAxis1onto axis 2, then return the rewritten event so the underlying NSScrollView receives a real horizontal delta. All other events (trackpad, vertical scroll outside the strip, etc.) are passed through untouched, so vertical scrolling of the main popover content is unaffected.Test plan
Fixes #333. Related to #332.
Made with Cursor