macOS: keep the menu-bar icon from vanishing when the window opens#229
Open
kevin-nous wants to merge 1 commit into
Open
macOS: keep the menu-bar icon from vanishing when the window opens#229kevin-nous wants to merge 1 commit into
kevin-nous wants to merge 1 commit into
Conversation
Clicking the status-item promotes the app .accessory -> .regular (for a Dock tile + Cmd-Tab), and that activation-policy flip detaches our custom NSStatusItem from the menu bar -- the object survives, but its menu-bar slot is dropped, so the icon disappears until the app is relaunched. Re-create the status item right after the flip, mirroring the existing _schedule_macos_dock_icon_refresh 0ms+250ms double-fire so it works whether AppKit detaches synchronously or a tick later. Installing now drops any prior item first, so a re-install never leaves a duplicate. Preserves the intended Dock-tile-on-window-open behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Problem
On macOS, opening the window (e.g. clicking the menu-bar icon) makes the menu-bar
icon disappear until the app is relaunched. Opening the window promotes the app
.accessory->.regularto give the window a Dock tile + Cmd-Tab entry, and thatactivation-policy flip detaches our custom
NSStatusItemfrom the menu bar: the objectsurvives (it's strongly referenced), but its menu-bar slot is dropped. On a
multi-monitor setup it's especially confusing — the window opens on one display while
the icon vanishes on another, so it reads as the app having quit.
Fix
Re-create the status item right after the
.regularflip, mirroring the existing_schedule_macos_dock_icon_refresh0ms + 250ms double-fire so it works whether AppKitdetaches the item synchronously or a tick later. A re-install drops any prior item
first, so it never leaves a duplicate. The intended Dock-tile-on-window-open behavior
is preserved.
Known limitation (being upfront)
This turns "icon vanishes until relaunch" into "icon blinks briefly and returns" — but
a one-frame blink remains, because the activation-policy toggle inherently tears the
status item off the menu bar before we can re-add it. I tried a synchronous re-install
to close the gap; it still blinks, so the detach isn't cleanly synchronous. Fully
eliminating the blink would mean not toggling activation policy (i.e. dropping the
Dock tile / Cmd-Tab entry for the window) — a deliberate design call I've left to you
rather than change unilaterally. Happy to follow up either way.
Testing
Verified on a real MX Anywhere 2S / macOS, including the multi-monitor case that
surfaced it: before, the icon vanished permanently; after, it returns immediately.
Menu (right/control/option-click) and Dock-tile behavior are unchanged.