Repository navigation
Menu bar: a Hidden style that takes the item off the menu bar - #297
Merged
Merged
Conversation
Settings > General > Menu bar gets a fourth choice next to icon and numbers / icon only / numbers only. It takes effect at once: the NSStatusItem is removed with removeStatusItem and a new one is created, with the same menu, when another style is picked. setVisible(false) is not used because AppKit persists it under the autosave name, so the item would start hidden on the next launch and stay hidden in an older version that does not know this style. While hidden, the menu bar loop asks core for nothing until the style changes. With the item hidden and the window closed the app stays an accessory app (no Dock icon): opening it again from Finder, Spotlight or `open` reaches the running instance as RunEvent::Reopen, which already shows the main window. Choosing Hidden swaps the row's note for how to get back to the window, the launch-at-login note and the first-autostart notice say it runs in the background. macOS only, like the other styles: elsewhere the stored value still draws the tray icon. Co-Authored-By: Claude Opus 5.5 <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.
What
Settings › General › Menu bar gets a fourth choice, Hidden (不显示), next to Icon and numbers / Icon only / Numbers only. It removes ThinkWatch Lite's item from the menu bar, at once and without a restart; picking another style brings it back with the same menu.
How
menubar::model::Style::Hidden(serde"hidden", atomic3);MenubarStyleinsrc/settings/api.tsgains"hidden".menubar/macos.rs): theNSStatusItemis now created lazily byapplyand removed withNSStatusBar.removeStatusItembyhide; theNSMenuand its delegate stay, and are attached to the new item when it comes back. Started with Hidden, no item is created at all.setVisible(false): AppKit persists it under the autosave name (NSStatusItem VisibleCC ThinkWatchLite = 0, checked with a probe), so the next launch would start hidden and an older version, which never sets it back, would keep the item hidden for good.removeStatusItempersists nothing./summary,/quota, ChatGPT reset credits);menubar_now, already notified byset_menubar_style, wakes it when the style changes.Getting back to the app with the item hidden
Nothing changes in the window/activation code: closing the main window still turns the app into an accessory app (no Dock icon). Opening ThinkWatch Lite again from Finder, Spotlight or
openreaches the running instance asapplicationShouldHandleReopen→RunEvent::Reopen, which already callsshow_main_window(which makes the app Regular again). I checked that an Accessory-policy app does receive the reopen event (probe app bundle, opened twice), and ran the real app isolated (below). Notifications (clicks open the window), auto-update (its own window), ⌘Q from the main window and deep links are untouched.The row's note becomes "To show the main window, open ThinkWatch Lite again from Finder or Spotlight." while Hidden is selected (instead of a one-time pop-up, it stays where someone would look for it). The launch-at-login note and the first-autostart notice say the app runs in the background instead of "only the icon appears in the menu bar".
Windows / Linux
Unchanged and still macOS-only, like the other styles: the row is only shown on macOS and
drawn_style()keeps drawing the tray icon there whatever is stored. Hiding the tray icon would leave relaunching as the only way in, and on Linux that depends on the desktop (activation tokens, AppIndicator); Windows already lets users hide notification-area icons itself.Verification
pnpm typecheck,pnpm test(932),pnpm build,cargo fmt --check,cargo clippy --all-targets -D warnings,cargo test(901, incl. control_plane against twcore v0.65.0)."hidden".style/set_style/drawn_style+ the hidden branch of the loop) extracted into a throwaway crate: clippy--all-targets -D warningsclean for x86_64/aarch64-pc-windows-msvc and x86_64-unknown-linux-gnu.set_menubar_styleIPC): started Hidden → no status item; window closed → Accessory policy, no window;openthe bundle again → window shown, Regular; Icon and numbers → item back with its menu attached, and a click opens the menu; Hidden again → gone; Icon only → back. Prefs file follows each change, and noNSStatusItem Visible…key was written.🤖 Generated with Claude Code