Skip to content

fix(mac): keep right-click status-item menu open and stable#803

Open
hyknerf wants to merge 2 commits into
getagentseal:mainfrom
hyknerf:fix/802-menubar-right-click-menu
Open

fix(mac): keep right-click status-item menu open and stable#803
hyknerf wants to merge 2 commits into
getagentseal:mainfrom
hyknerf:fix/802-menubar-right-click-menu

Conversation

@hyknerf

@hyknerf hyknerf commented Jul 24, 2026

Copy link
Copy Markdown

Summary

  • Fixes the menubar right-click context menu on macOS 27 (and keeps ≤26 working): menu no longer flashes closed, and no longer jumps/scrolls the top "Today · …" row under a chevron on mouse move.
  • Flash: global monitor presented on rightMouseDown; matching rightMouseUp dismissed the menu. Monitor is now rightMouseUp.
  • Jump: manual NSMenu.popUp(at:in:) tracked poorly while the cursor sat on the status item. Open via statusItem.menu + performClick instead; clear the menu in menuDidClose so left-click still opens the popover.
  • Closes macOS menubar: right-click context menu flashes and/or scrolls away on mouse move #802.

Context

#472 restored right-click on macOS 27 with a global monitor + popUp, but presentation on mouse-down caused the flash. #509 tried height + 6 anchoring to avoid scroll; NSStatusBarButton is flipped and manual popUp still engaged scroll mode on mouse move.

#472 avoided statusItem.menu + performClick because the right-mouse action never runs on 27. We still open from the global monitor (or legacy action on ≤26); once statusItem.menu is set, performClick only means "open the attached menu" and works on 27.

Test plan

  • ./mac/Scripts/package-app.sh dev succeeds (Xcode 26.6 / Swift 6.3)
  • Built binary has global-monitor mask 0x10 (rightMouseUp) and references performClick
  • Installed dev build on macOS 27 beta; right-click opens menu (flash path fixed in earlier binary probe)
  • Please verify on macOS 27: right-click stays open; mouse move does not show ^ / scroll away Today row; Settings / Quit work
  • Please verify on macOS 27: after dismissing the menu, left-click still opens the popover
  • Smoke on macOS ≤26 if available: right-click presents exactly once (0.3s debounce); no flash; no jump

Notes

hyknerf added 2 commits July 24, 2026 19:22
Present the context menu on rightMouseUp (not down) so the matching
mouse-up no longer dismisses it, and open via statusItem.menu +
performClick so AppKit tracks the menu under the status item instead of
manual popUp (which scrolled the Today row away on mouse move).

Clears statusItem.menu in menuDidClose so left-click still opens the
popover. Debounce + legacy rightMouseUp path retained for macOS <= 26.

Closes getagentseal#802
Extract StatusItemContextMenuPolicy (event mask, debounce, presentation
mode) and unit-test it so rightMouseUp + statusItemMenu cannot regress
to the flash/scroll-jump paths without a failing test.
@hyknerf

hyknerf commented Jul 24, 2026

Copy link
Copy Markdown
Author

Added unit tests for the extractable policy behind this fix:

  • StatusItemContextMenuPolicy — event mask (rightMouseUp), presentation (.statusItemMenu not .manualPopUp), debounce gate
  • StatusItemContextMenuPolicyTests — 7 cases, all green via swift test --filter StatusItemContextMenuPolicyTests

AppKit open/track/dismiss still needs a manual smoke (no good headless seam for NSStatusItem + real menu tracking). The tests lock the decisions that caused the regressions so they can’t silently flip back.

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.

macOS menubar: right-click context menu flashes and/or scrolls away on mouse move

1 participant