Repository navigation
Studio: adapt macOS tray artwork to the menu bar appearance - #10880
Conversation
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ae705968d3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| // macOS renders tray images at 18 points. Embed the 36 px scale for crisp Retina output; | ||
| // template mode lets AppKit choose the correct monochrome color for the current menu bar. | ||
| #[cfg(target_os = "macos")] | ||
| let tray_icon = tauri::include_image!("./icons/[email protected]"); |
There was a problem hiding this comment.
Point the embedded icon at its source-relative path
On macOS, this cfg branch expands include_image!, whose path is resolved relative to the invoking Rust source file. Since main.rs is under src/, this searches for studio/src-tauri/src/icons/[email protected], but the asset was added under studio/src-tauri/icons; consequently every macOS build fails while Linux tests skip the branch. Use ../icons/[email protected] here.
Useful? React with 👍 / 👎.
|
Superseded by #10890, which uses the separate light/dark artwork and switches the tray icon when macOS appearance changes. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d1428028e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
Real macOS tray E2E evidenceTested exact PR head: The GitHub-hosted Apple Silicon macOS job built and launched the actual Tauri GitHub Actions run 34824594349 · evidence source PR · artifact Labelled light/dark comparisonFull-screen light and dark capturesLight menu bar — black filled tray artwork Dark menu bar — white outlined tray artwork, same live PID Measured from the real screenshots:
Result: PASS — the tray artwork stays visible and switches to the correct contrasting variant when macOS appearance changes. |
Superseded by #10880. Null contribution. Co-authored-by: Guus <[email protected]>
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]>



Summary
NSStatusBarButton.effectiveAppearance, rather than the app/window theme, so wallpaper-, display-, and fullscreen-specific menu-bar changes are handledWhy
On modern macOS, the menu bar's effective appearance can differ from the system or application theme and can change with the wallpaper or display.
WindowEvent::ThemeChangedtherefore cannot reliably select a contrasting status-item image. AppKit exposes the authoritative appearance on the status bar button itself.Verification
cargo test --manifest-path studio/src-tauri/Cargo.toml --no-fail-fast(539 passed locally)cargo check --manifest-path studio/src-tauri/Cargo.tomlrustfmt --edition 2021 --check studio/src-tauri/src/macos_tray.rsgit diff --checkA Linux-hosted Apple-target check reaches native Apple dependencies but cannot complete without the macOS SDK (
Cocoa/Cocoa.handTargetConditionals.h). The repository's macOS Rust CI job provides native compile/test coverage.References
NSStatusBarButtoneffectiveAppearancebestMatch(from:)TrayIcon::with_inner_tray_icon