Skip to content

fix: open SwiftUI menu bar panels from the bar on macOS 27 - #904

Merged
M4n0x merged 1 commit into
mainfrom
fix/798-window-menu-bar-extras
Nov 22, 2026
Merged

M4n0x merged 1 commit into
mainfrom
fix/798-window-menu-bar-extras

Conversation

@M4n0x

@M4n0x M4n0x commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Problem

On macOS 27, clicking a menu bar item on the bar, or in the Menu bar items row, pressed it through Accessibility. SwiftUI menu bar extras that open a window (.menuBarExtraStyle(.window)) ignore that press, so their panels never opened from StableBar. Spectra's menu bar panel is one of them.

Fixes #798

Changes

No configuration change. The guide already says these items open their own panel or menu, so the docs stay as they are.

Testing

  • New tests in BarContextMenuTests:

    • a left click on an item on the bar goes to MenuBarAgent's window for the item's display, at the item's middle, as a left click, without waiting for a button;
    • a hidden menu bar is revealed transparent for that click and hidden again;
    • the events carry the button, the window number, the location and the click state, for both buttons.

    Three of them fail with the old press. The existing right-click tests now check the button.

  • BarContextMenuTests, ArchitectureRulesTests, NativePresentationTests and the AppMenu tests pass locally, and so does scripts/check.sh --quick. CI runs the full suite.

  • In a macOS 27.2 tart VM (cirruslabs' Golden Gate image), with the menu bar hiding automatically, a test app with one SwiftUI .window extra and one .menu extra, and Spectra 0.9.21 Free:

    Clicked from the bar main This branch
    Window-style panel nothing opens opens and stays
    Pull-down menu opens opens
    Spectra Free's menu opens opens
    Control Center and Clock, from the row open open

    Control Center and Clock were checked with an earlier build that sends the same click.

    main: click on the panel's item This branch This branch: Spectra Free
  • In that VM, synthetic clicks never fire the SwiftUI gesture the bar's items use to act on mouse-down, so the left-click checks used a build whose gesture also triggers on perform, which fires at mouse-down too. Right-clicks ran the unchanged code.

  • Not checked:

    • a real Mac;
    • Spectra's paid panel, which needs a licence;
    • choosing an item in an open menu, or closing it by clicking outside: in that VM, open status-item menus ignore every click, even when opened natively;
    • macOS 26, whose fallback anItemGetsAPressWhereAClickCanNotBeSentToTheMenuBar covers.
  • Separate and not fixed: holding the button down 700 ms or more makes Spectra Free's menu close on release, on main too.

Merging

One commit; any merge method keeps it.

Claude Opus 5.5 via Claude Code

A menu bar item whose menu the bar doesn't draw got a press through
Accessibility. SwiftUI menu bar extras that open a window ignore that
press, so their panels, such as Spectra's, never opened from the bar.

Left clicks now go to MenuBarAgent's menu bar window as a real click,
the way the experimental right-click already does. Where no such window
is found, the item still gets the press. Right-clicking stays opt-in.

Fixes #798
@M4n0x
M4n0x requested a review from Seb-GRAF as a code owner November 22, 2026 13:24

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Re-trigger cubic

@M4n0x M4n0x added the deep-review CodeRabbit reviews this pull request: big or risky changes label Nov 22, 2026
@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Menu bar item activation now uses a shared click path for left and right buttons. When the item frame or MenuBarAgent window is unavailable, the path uses an Accessibility press. Tests cover button-specific events, window handling, and fallback behavior.

Changes: Menu bar item activation

Layer / File(s) Summary
Button-specific click events
Sources/StableBar/MenuBar/AppMenu.swift, Tests/StableBarTests/BarContextMenuTests.swift
MenuBarMouse accepts a mouse button and posts the matching click events. Test fakes record the button.
Shared activation path
Sources/StableBar/MenuBar/AppMenu.swift, Tests/StableBarTests/BarContextMenuTests.swift, DECISIONS.md
pressInMenuBar routes both buttons through clickInMenuBar. Tests cover window selection, hidden menu bar handling, right-click configuration, and the Accessibility press fallback. The decision entry documents the macOS 27 behavior and adds issue references.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 50fae

Clicking a menu bar item now opens SwiftUI window-style panels on macOS 27, and items without a MenuBarAgent window still use the existing press. No actionable merge-blocking risk was found.

Security architecture risk: Minimal · up to 50fae

The change reuses existing click delivery for user-initiated menu-bar actions. The inspected changes do not establish a material weakening of permissions, target isolation, or state restoration.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The supported exposure increase is default use of an existing synthetic-click channel for menu-bar activation in the local desktop session. Inspected callers are UI activation paths; no new externally callable activation surface was identified in that scope.

Trust Boundaries and Controls

  • observed — Window selection requires the selected MenuBarAgent PID, menu-bar window layer, display-aligned bounds, and a height limit. Generated events carry that window number and are posted to its process. These unchanged controls constrain process and window targeting, but do not prove item identity remains stable until delivery.

Resilience and Maintainability Implications

  • observed — A missing frame or compatible window results in an awaited Accessibility press before the hidden-menu path proceeds to restoration. Restoration ownership still uses the existing press counters; the PR does not add a separate cleanup or recovery mechanism.
Pre-merge checks: Passed 3

Check name Status Explanation
Description check Passed The description follows the repository template. It has Problem, Changes, Testing, and Merging sections, and it ends with the model and harness line. The Problem section states the bug and links the i…
Linked Issues check Passed Directly linked issue #798 reports that clicking the Spectra menu bar item on macOS 27.2.1 does not open Spectra's menu, for left and right clicks. The diff in Sources/StableBar/MenuBar/AppMenu.swift …
Out of Scope Changes check Passed All changed hunks support the objective in #798 and the documented behavior. AppMenu.swift changes the click path (pressInMenuBar, clickInMenuBar, MenuBarMouse.click, menuBarClick) and keeps the Acces…
Full details: Description check

Explanation

The description follows the repository template. It has Problem, Changes, Testing, and Merging sections, and it ends with the model and harness line. The Problem section states the bug and links the issue with "Fixes #798". The Changes section lists the click path, the mouse API rename, the fallback, the unchanged right-click behavior, and the DECISIONS.md entry, with reasons. The Testing section lists new and updated tests, local check runs, a macOS 27.2 VM comparison table with screenshots, and what was not checked. The Merging section says one commit and that any merge method keeps it, so it states which merge method applies. The final line names the model and harness. The description is detailed and specific. Minor gaps: the Merging section does not say whether a squash message needs review, and the template asks for that. The Problem section also uses "clicking a menu bar item on the bar", which is slightly loose but still clear.

Full details: Linked Issues check

Explanation

Directly linked issue #798 reports that clicking the Spectra menu bar item on macOS 27.2.1 does not open Spectra's menu, for left and right clicks. The diff in Sources/StableBar/MenuBar/AppMenu.swift changes pressInMenuBar so both paths call clickInMenuBar with the button. On a found MenuBarAgent window, this posts a left click (or the right click when opted in) through menuBarClick(at:in:button:). The author reports that the SwiftUI .window-style panel opened from the bar on macOS 27.2 in a VM, and that the BarContextMenuTests cases for left-click routing, reveal/restore, and event fields exist. Right-click with the setting off now sends a click, so it also reaches the item. The reviewed diff supports the code path. The author did not check a real Mac or Spectra's paid panel, so the result rests on VM evidence and the diff. I did not read the test file, so the test claims rest on the PR description.

Full details: Out of Scope Changes check

Explanation

All changed hunks support the objective in #798 and the documented behavior. AppMenu.swift changes the click path (pressInMenuBar, clickInMenuBar, MenuBarMouse.click, menuBarClick) and keeps the Accessibility press as fallback when no MenuBarAgent window or frame is found. The rename from rightClick to click and the new button parameter are needed for the left-click path. The DECISIONS.md entry records the change to the opt-in decision from #767. The BarContextMenuTests changes cover the new behavior, including the button and fallback paths. No unrelated code change appears in the reviewed diff.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7133cdb and 50fae9e.

Files selected for processing: 3

  • DECISIONS.md
  • Sources/StableBar/MenuBar/AppMenu.swift
  • Tests/StableBarTests/BarContextMenuTests.swift

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Before and after

main at 7133cdb → this pull request at 50fae9e · 265 screens drawn · 0 changed

265 unchanged screens

docs/essentials-clock-settings-dark, docs/essentials-clock-settings-light, docs/essentials-dark, docs/essentials-light, docs/essentials-settings-dark, docs/essentials-settings-light, docs/hero-dark, docs/hero-light, docs/popups-dark, docs/popups-light, docs/settings-dark, docs/settings-light, docs/themes-dark, docs/themes-light, scenes/accessibility-guide-dark, scenes/accessibility-guide-light, scenes/app-menu-popup-dark, scenes/app-menu-popup-light, scenes/apple-menu-settings-dark, scenes/apple-menu-settings-light, scenes/apple-menu-symbol-bar-dark, scenes/apple-menu-symbol-bar-light, scenes/apple-menu-symbol-settings-dark, scenes/apple-menu-symbol-settings-light, scenes/bottom-bar-popup-dark, scenes/bottom-bar-popup-light, scenes/chat-popup-dark, scenes/chat-popup-light, scenes/crowded-edit-bar-dark, scenes/crowded-edit-bar-light, scenes/disk-meter-bar-dark, scenes/disk-meter-bar-light, scenes/dock-badges-bar-dark, scenes/dock-badges-bar-light, scenes/edit-bar-wide-group-dark, scenes/edit-bar-wide-group-light, scenes/essentials-clock-popup-dark, scenes/essentials-clock-popup-light, scenes/essentials-disk-popup-dark, scenes/essentials-disk-popup-light, scenes/filled-slider-popup-dark, scenes/filled-slider-popup-light, scenes/group-members-bar-dark, scenes/group-members-bar-light, scenes/gruvbox-bar-dark, scenes/gruvbox-bar-light, scenes/horizontal-list-popup-dark, scenes/horizontal-list-popup-light, scenes/increase-contrast-bar-dark, scenes/increase-contrast-bar-light, scenes/increase-contrast-popup-dark, scenes/increase-contrast-popup-light, scenes/input-source-popup-dark, scenes/input-source-popup-light, scenes/labeled-metric-built-in-dark, scenes/labeled-metric-built-in-light, scenes/labeled-metric-catppuccin-dark, scenes/labeled-metric-catppuccin-light, scenes/meeting-live-popup-dark, scenes/meeting-live-popup-light, scenes/meeting-soon-bar-dark, scenes/meeting-soon-bar-light, scenes/menu-bar-items-widget-settings-dark, scenes/menu-bar-items-widget-settings-light, scenes/merged-status-bar-dark, scenes/merged-status-bar-light, scenes/notch-flare-bar-dark, scenes/notch-flare-bar-light, scenes/output-device-popup-dark, scenes/output-device-popup-light, scenes/popup-gap-bar-dark, scenes/popup-gap-bar-light, scenes/popup-spacing-bar-dark, scenes/popup-spacing-bar-light, scenes/popup-view-dark, scenes/popup-view-light, scenes/privacy-both-bar-dark, scenes/privacy-both-bar-light, scenes/privacy-hide-when-idle-bar-dark, scenes/privacy-hide-when-idle-bar-light, scenes/privacy-idle-bar-dark, scenes/privacy-idle-bar-light, scenes/privacy-microphone-bar-dark, scenes/privacy-microphone-bar-light, scenes/privacy-settings-dark, scenes/privacy-settings-light, scenes/reduce-transparency-bar-dark, scenes/reduce-transparency-bar-light, scenes/reduce-transparency-glass-bar-dark, scenes/reduce-transparency-glass-bar-light, scenes/ring-bar-dark, scenes/ring-bar-light, scenes/settings-bar-dark, scenes/settings-bar-light, scenes/settings-bar-link-dark, scenes/settings-bar-link-light, scenes/settings-bar-link-review-dark, scenes/settings-bar-link-review-light, scenes/settings-bar-look-dark, scenes/settings-bar-look-light, scenes/settings-bar-placement-bottom-dark, scenes/settings-bar-placement-bottom-light, scenes/settings-bar-placement-dark, scenes/settings-bar-placement-light, scenes/settings-calendar-picker-dark, scenes/settings-calendar-picker-light, scenes/settings-calendar-widget-dark, scenes/settings-calendar-widget-light, scenes/settings-crashes-dark, scenes/settings-crashes-light, scenes/settings-disk-widget-dark, scenes/settings-disk-widget-light, scenes/settings-feedback-dark, scenes/settings-feedback-light, scenes/settings-general-dark, scenes/settings-general-light, scenes/settings-general-macos15-dark, scenes/settings-general-macos15-light, scenes/settings-general-macos27-dark, scenes/settings-general-macos27-light, scenes/settings-general-manager-not-found-dark, scenes/settings-general-manager-not-found-light, scenes/settings-general-move-dark, scenes/settings-general-move-failed-dark, scenes/settings-general-move-failed-light, scenes/settings-general-move-light, scenes/settings-general-move-moving-dark, scenes/settings-general-move-moving-light, scenes/settings-general-move-replace-dark, scenes/settings-general-move-replace-light, scenes/settings-general-setup-open-dark, scenes/settings-general-setup-open-light, scenes/settings-general-spaces-dark, scenes/settings-general-spaces-light, scenes/settings-general-yabai-gap-dark, scenes/settings-general-yabai-gap-light, scenes/settings-group-dark, scenes/settings-group-defaults-dark, scenes/settings-group-defaults-light, scenes/settings-group-light, scenes/settings-group-theme-color-dark, scenes/settings-group-theme-color-light, scenes/settings-help-dark, scenes/settings-help-light, scenes/settings-help-starred-dark, scenes/settings-help-starred-light, scenes/settings-labeled-metric-dark, scenes/settings-labeled-metric-light, scenes/settings-narrow-dark, scenes/settings-narrow-light, scenes/settings-package-dark, scenes/settings-package-light, scenes/settings-package-widget-dark, scenes/settings-package-widget-light, scenes/settings-profiles-conditions-dark, scenes/settings-profiles-conditions-light, scenes/settings-profiles-dark, scenes/settings-profiles-groups-dark, scenes/settings-profiles-groups-light, scenes/settings-profiles-light, scenes/settings-profiles-theme-dark, scenes/settings-profiles-theme-light, scenes/settings-store-dark, scenes/settings-store-light, scenes/settings-theme-dark, scenes/settings-theme-edits-dark, scenes/settings-theme-edits-light, scenes/settings-theme-groups-dark, scenes/settings-theme-groups-light, scenes/settings-theme-light, scenes/settings-theme-link-dark, scenes/settings-theme-link-light, scenes/settings-theme-origins-dark, scenes/settings-theme-origins-light, scenes/settings-theme-versions-dark, scenes/settings-theme-versions-light, scenes/settings-tiled-dark, scenes/settings-tiled-light, scenes/settings-tiled-narrowest-dark, scenes/settings-tiled-narrowest-light, scenes/settings-uninstall-dark, scenes/settings-uninstall-failed-dark, scenes/settings-uninstall-failed-light, scenes/settings-uninstall-light, scenes/settings-widget-backgrounds-dark, scenes/settings-widget-backgrounds-light, scenes/settings-widget-colors-dark, scenes/settings-widget-colors-light, scenes/settings-widget-style-theme-edits-dark, scenes/settings-widget-style-theme-edits-light, scenes/settings-workspace-hidden-dark, scenes/settings-workspace-hidden-light, scenes/setup-look-below-menu-bar-dark, scenes/setup-look-dark, scenes/setup-look-no-notch-dark, scenes/setup-look-suggestions-dark, scenes/setup-move-existing-dark, scenes/setup-move-failed-dark, scenes/setup-move-ready-dark, scenes/setup-move-replace-dark, and 65 more

Visual review: 265 screens, none changed.

@M4n0x
M4n0x added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit d88aa6b Nov 22, 2026
24 checks passed
@M4n0x
M4n0x deleted the fix/798-window-menu-bar-extras branch November 22, 2026 14:42
@stablebar-releases

Copy link
Copy Markdown

🎉 This PR is included in version 0.19.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deep-review CodeRabbit reviews this pull request: big or risky changes released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Menu bar icon does not show the app's menu

1 participant