Repository navigation
Menu bar: own the status item and rebuild the panel on every open - #62
Merged
Merged
Conversation
MenuBarExtra(.window) builds its panel once and reuses it for the process's life. After ~10 hours one went deaf: AppKit tracked clicks and sent actions, but no SwiftUI action ran and nothing redrew, until eWiz was relaunched. MenuBarController now owns an NSStatusItem hosting MenuBarLabel, and builds a borderless NSPanel + NSHostingView on each open, torn down on close (resign key, Esc, outside click, icon click). The window sizes from the content's own constraints in the same layout pass, and setFrame pins the top edge and clamps to the screen, which fixes the mode-switch flicker and the off-screen right edge. Follow-ons of rebuilding the panel each open: - a hidden MenuBarExtra(isInserted: false) keeps SwiftUI from opening Settings at launch, and the no-Cmd-Q command moves to the Settings scene - the panel's helper-install error lives in ChargeLimitStore, not view state - the panel seeds its height from the last measurement instead of growing in
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
After eWiz had been running for hours (~10h here), the menu-bar panel opened looking normal but nothing in it responded. Logs showed AppKit tracking each click and sending the action, yet the SwiftUI action never ran (
rest.snoozeUntilunchanged after Later) and the panel never redrew. Relaunching eWiz fixed it.MenuBarExtra(.window)builds one panel window at launch and reuses it forever, and that window had come loose from its view graph.Change
MenuBarController(new) owns anNSStatusItemthat hostsMenuBarLabel, and builds a borderlessNSPanel+NSHostingViewon every open, discarded on close (resign key, Esc, outside click, icon click). There is no long-lived panel left to go stale.setFramepins the top edge and clamps to the screen. This fixes the flicker on mode switches and the panel running off the right edge.MenuBarExtra(isInserted: false)stops SwiftUI opening Settings at launch. The no-⌘Q command moves to the Settings scene.ChargeLimitStoreso it survives the admin prompt closing the panel. The panel seeds its height from the last measurement.Verified
swift build, and all 262 tests passopenWindowworks from the hosted label (History opened)