fix(mac): restore right-click status-item menu on macOS 27#472
Conversation
macOS 27 no longer routes right-mouse events to the status-item button's target/action, so the right-click context menu (Settings / Refresh Now / Check for Updates / Quit) never appears. Left-click / popover is unaffected. Worked on macOS 26. Verified with an instrumented build: with the sendAction mask widened to all mouse types, only .leftMouseDown/.leftMouseUp are ever delivered to the button action; right-mouse-down and right-mouse-up are consumed by the system's status-item host, so the event.type == .rightMouseUp branch is dead code on 27. Restore the menu via a global rightMouseDown monitor, hit-tested against the status-item window, presented with NSMenu.popUp instead of the statusItem.menu + performClick trick (which relies on the click->action path 27 changed). The legacy action path is retained for macOS <= 26, guarded by a 0.3s debounce so a single right-click never double-presents. Verified on macOS 27.0 (build 26A5353q).
|
A couple of process notes I want to own up front:
Glad to adjust the approach based on what you'd like to see. |
Summary
NSStatusItembutton'starget/action. With thesendAction(on:)mask widened to every mouse type on an instrumented build, only.leftMouseDown/.leftMouseUpare ever delivered — right-mouse-down and right-mouse-up are consumed by the system's status-item host (NSMenuBarNavigationSceneExtension). So theevent.type == .rightMouseUpbranch inhandleButtonClickis dead code on 27.addGlobalMonitorForEvents(matching: .rightMouseDown)hit-tested against the status-item window, usingNSMenu.popUp(positioning:at:in:)instead of thestatusItem.menu = menu; button.performClicktrick (which depends on the click→action path 27 changed). The legacy action path is retained for macOS ≤ 26, guarded by a 0.3 s debounce so a single right-click never double-presents.Testing
This change is confined to
mac/Sources/CodeBurnMenubar/CodeBurnApp.swift(the Swift menubar) — it does not touch the TS CLI, so thenpmchecks below are N/A to this diff.swift build -c releasesucceeds (Swift 6.2.3)Verification method: instrumented build with
NSLogprobes in the button action and menu path..leftMouseDown(rawValue 1) delivered; no right-mouse events.rightMouseDown, hit-test matches the status-item window,NSMenu.popUppresents the menu. One right-click → menu appears. Confirmed by a maintainer-style manual test on the affected machine.Note: no AI co-author trailer is present on the commit (per CONTRIBUTING /
block-claude-coauthor).