Preserve menu bar icon position when hiding (FB9052637)#71
Open
stavfx wants to merge 1 commit into
Open
Conversation
The "Hide icon if monitored app isn't running" and "Hide icons when there are no new notifications" options toggled statusItem.isVisible. On macOS 12+, macOS discards a status item's saved position when it's hidden (FB9052637), so the icon jumped to the leftmost slot whenever the app restarted — repeatedly pushing icons into the hidden section of menu-bar managers like Hidden Bar. Snapshot the OS-managed position before hiding (in memory and in a namespaced default), then write it back before the item reappears — in showStatusBar() for the normal hide/show cycle, and in monitorApp() to re-seed it across a Doll restart / reboot while the app was closed. feedback-assistant/reports#200
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
With a menu-bar manager like Hidden Bar, Doll's icons keep getting pushed back into the hidden section. Whenever a monitored app restarts (or Doll restarts), the icon jumps to the leftmost slot, undoing the user's arrangement.
Root cause
The "Hide icon if monitored app isn't running" and "Hide icons when there are no new notifications" options hide an icon with
statusItem.isVisible = false. On macOS 12+, macOS discards a status item's saved menu-bar position when it's hidden - a long-standing AppKit bug, FB9052637. So when the icon is shown again it reappears at the default leftmost slot, which is exactly the hidden zone of menu-bar managers.Verified on macOS 26: the
NSStatusItem Preferred Position <autosaveName>default is nulled out whenever the item is hidden, even with a stableautosaveName.Approaches that don't work (on current macOS)
isVisible = false/true- loses the position (the bug above).removeStatusItem+ recreate - purges the position key entirely.length = 0to keep the item alive - preserves position but leaves an empty gap in the menu bar.Fix
Keep using
isVisible(so hiding stays gapless), but manage the position ourselves:Doll_SavedPosition_<bundleId>default.showStatusBar()for the normal hide/show cycle, and inmonitorApp()to re-seed it across a Doll restart / reboot when the app was closed.Result: gapless hide and a stable position, including across reboots.
Testing
Manual, on macOS 26 with Hidden Bar: pin icons via ⌘-drag, quit/relaunch monitored apps repeatedly, and restart Doll with apps closed - icons return to their pinned slots every time, and the saved-position defaults stop churning.