Repository navigation
feat(studio): add a setting to hide the macOS menu bar icon - #11937
Conversation
7b7731e to
cfcd9fc
Compare
Add a macOS-only Settings > General > Startup "Show in menu bar" switch. The choice persists in a new tray-icon-visible-v1 preference beside close-to-tray-v1; a missing or unreadable file means shown, so hiding stays opt-in. The tray is built with a stable id so the new set_tray_icon_visible command can reach it; the command applies TrayIcon::set_visible first and restores the previous visibility if persisting fails. get_tray_icon_visible returns None off macOS, so the row renders only there. A login start (--hidden) drops the Dock icon via ActivationPolicy::Accessory. With the menu bar icon also hidden that would leave no way back to the app, so Accessory is now applied only when the menu bar icon is visible; otherwise the hidden start keeps its Dock icon. Closes unslothai#10157
82a91d4 to
dbee215
Compare
|
Review record for #11937, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#235. Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found. Round 1: reviewed mirror
|
|
@codex review |
|
@codex security review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
## Summary Main is over the startup bundle budget again, by 189 B raw, so `Frontend build + bundle sanity` fails on every PR based on it: ``` over the startup budget: raw 6682.2 KB > 6682.0 KB (main at 6ccf0e4) ``` #14258 set both limits to the measured build plus a 160 B raw / 189 B transfer margin. #11937 (a setting to hide the macOS menu bar icon) then added 349 B raw / 78 B transfer to the startup chunks, and merged without raising them. ## Cause #11937 adds strings to `i18n/locales/en.ts`, which ships in the startup chunks, and entries to the settings search index (`settings-search.ts`, `dialog-search-index.ts`). That is small real growth. I measured each commit since #14258 on its own: | tree | raw B | transfer B | |---|---|---| | `46e4f50bea` (#14258) | 6,842,183 | 2,060,321 | | `2b20770c91` (+ #11937) | 6,842,532 | 2,060,399 | | `f5e91f1ca5` (+ #14223) | 6,842,532 | 2,060,421 | | main `6ccf0e4e74` (+ #14232) | 6,842,532 | 2,060,400 | #14223 and #14232 add no raw bytes. #14021 and #14263 change no frontend code. ## Change - **`check-bundle-budget.ts`:** a BUDGET comment entry for #11937, and both limits moved to the measured build at main plus the same margin: - `rawBytes`: 6,842,343 -> 6,842,692. - `transferBytes`: 2,060,510 -> 2,060,589. ## Testing One machine and build, Node 24, exact byte totals from the budget script, 96 chunks. - **Main against the old limits:** `over the startup budget: raw 6682.2 KB > 6682.0 KB`. - **With this change:** `within budget (0.2 KB transfer, 0.2 KB raw to spare)`.
Closes #10157
What
Adds a macOS-only Settings → General → Startup → Show in menu bar switch. Turning it off hides the Unsloth menu bar icon immediately and keeps it hidden on later launches; turning it on brings it back.
Why this shape
A login start runs with
--hidden, and.setupthen switches the app toActivationPolicy::Accessory(no Dock icon). With the menu bar icon also gone, a hidden start would leave a running app with no way back to it. So a hidden start keeps its Dock icon whenever the menu bar icon is hidden: the window still stays hidden, and clicking the Dock icon opens it through the existingRunEvent::Reopen→show_main_windowpath. "Run Unsloth at login" is left exactly as the user set it.Changes
studio/src-tauri/src/main.rstray-icon-visible-v1preference besideclose-to-tray-v1, with the same read/write helpers. A missing, unreadable or invalid file reads as visible: hiding is opt-in, and a corrupt file can never strand the app.TrayIconBuilder::with_id("main"), and on macOS the stored visibility is applied right after it is built.get_tray_icon_visiblereturnsNoneoff macOS, so the row only renders on macOS.set_tray_icon_visibleappliesTrayIcon::set_visiblefirst, then persists; if persisting fails it restores the previous visibility and returns the error, so the switch never disagrees with what the next launch will do.launched_hiddenand the icon is visible.studio/frontendapi/tray-icon.tsinvoke wrappers, and a Startup row ingeneral-tab.tsxbuilt on the existinguseDesktopBooleanSettinghook, mirroring the close-to-tray row.createSettingsSearchIndex({ …, menuBarIcon })), with a test extended intests/settings-search.test.ts.menuBarIcon,menuBarIconDescriptionandmenuBarIconSaveErroradded toen.tsand translated in all 11 other locales, sincei18n:check:strictrequires them.Not in this PR
The issue comment also asked for a monochrome icon. That already shipped in #10880 (
macos_tray.rspicks light or dark artwork from the menu bar's effective appearance), and #10196 is marked superseded.Verification (macOS 26, Apple M1 Pro)
cargo test --no-fail-fast: 580 passed, including the two new tests.cargo fmt --check/cargo clippyreport only findings that already exist onmain(120 fmt diffs onmainitself); none are in the lines this PR touches.npm run typecheck,npm test(8776 passed),npm run i18n:check:strict,npm run buildall pass.npm run lintreports only existing findings in files this PR does not touch.--hidden, icon visible → menu bar icon shown, no Dock icon (unchanged behaviour);--hidden, icon hidden → no menu bar icon, Dock icon kept.tray-icon-visible-v1holdsfalse; on → it returns and the file holdstrue. After switching it off, quitting and relaunching, the icon stays hidden at startup and the switch reads off.macOS Desktop before/after
Captured on a GitHub
macos-26runner: the Desktop app built from the merge base (31436b1) and from this PR (2a07993), both attached to the same installed Studio backend and driven through the Accessibility API.Settings > General > Startup. The new "Show in menu bar" row appears only on the PR build:
Flipping the switch on the PR build removes the Unsloth menu bar item, and flipping it back restores it:
Read from the running app at each step: the app's menu bar extras count went 1 -> 0 -> 1, the switch value 1 -> 0 -> 1, and
tray-icon-visible-v1heldfalse, thentrue.