Repository navigation
Use a native template icon in the macOS menu bar - #10196
Conversation
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. 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". |
|
@wasimysaid When you have a moment, could you take a look? This is a small macOS-only tray icon change, and the local Tauri checks and all 453 Rust tests pass. |
Superseded by unslothai#10880, which already ships a macOS template tray icon.
10f6da4 to
bb625ca
Compare
|
Thank you for the PR and for testing it so carefully, @guus6457! We will not be taking the code change here because #10880, merged on 2026-09-14, already does the same thing: on macOS the tray now uses a monochrome icon registered with So that your contribution is still recorded and you are listed as a contributor, I reduced this PR to a single empty commit under your authorship and am merging that. Thanks again, and we would be glad to see more PRs from you. |
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 `.setup` then switches the app to `ActivationPolicy::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 existing `RunEvent::Reopen` → `show_main_window` path. "Run Unsloth at login" is left exactly as the user set it. ## Changes **`studio/src-tauri/src/main.rs`** - New `tray-icon-visible-v1` preference beside `close-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. - The tray is built with `TrayIconBuilder::with_id("main")`, and on macOS the stored visibility is applied right after it is built. - `get_tray_icon_visible` returns `None` off macOS, so the row only renders on macOS. `set_tray_icon_visible` applies `TrayIcon::set_visible` first, 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. - The Accessory policy is applied only when `launched_hidden` **and** the icon is visible. - Two unit tests: the default is visible and round-trips; an invalid file reads as visible. **`studio/frontend`** - `api/tray-icon.ts` invoke wrappers, and a Startup row in `general-tab.tsx` built on the existing `useDesktopBooleanSetting` hook, mirroring the close-to-tray row. - The row is indexed for Settings search only on the macOS desktop (`createSettingsSearchIndex({ …, menuBarIcon })`), with a test extended in `tests/settings-search.test.ts`. - `menuBarIcon`, `menuBarIconDescription` and `menuBarIconSaveError` added to `en.ts` and translated in all 11 other locales, since `i18n:check:strict` requires them. ## Not in this PR The issue comment also asked for a monochrome icon. That already shipped in #10880 (`macos_tray.rs` picks 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 clippy` report only findings that already exist on `main` (120 fmt diffs on `main` itself); none are in the lines this PR touches. - `npm run typecheck`, `npm test` (8776 passed), `npm run i18n:check:strict`, `npm run build` all pass. `npm run lint` reports only existing findings in files this PR does not touch. - Ran the debug desktop build and read the menu bar and Dock state through System Events: - normal launch → menu bar icon shown, Dock icon shown; - `--hidden`, icon visible → menu bar icon shown, no Dock icon (unchanged behaviour); - `--hidden`, icon hidden → no menu bar icon, Dock icon kept. - Toggled the switch in the running debug build: off → the menu bar item disappears and `tray-icon-visible-v1` holds `false`; on → it returns and the file holds `true`. 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-26` runner: 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-v1` held `false`, then `true`. --------- Co-authored-by: Nilay Yadav <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel Han <[email protected]>
The macOS tray currently reuses the full-color app icon, which leaves a green square in the menu bar. This adds a small transparent version of the existing sloth mark and registers it as a template image so macOS can match light and dark appearances automatically.
Windows and Linux keep the existing tray icon.
Tested with:
cargo check --manifest-path studio/src-tauri/Cargo.toml --all-targetscargo test --manifest-path studio/src-tauri/Cargo.toml --all-targets(453 passed)