Follow the OS native theme on macOS, Windows and Linux

This commit is contained in:
2026-10-21 13:57:01 +07:00
parent f7865780d9
commit 6122474f9e
8 changed files with 797 additions and 513 deletions
+28 -23
View File
@@ -58,7 +58,8 @@ Verified against crates.io and the upstream repo on 2026-10-21:
| --- | --- |
| Latest connector | `native-theme-gpui` 0.6.1 (2026-10-09); upstream `main` is the same |
| Connector requires | `gpui-component ^0.7.1`, `gpui-base ^0.7.1`, `gpui-pre ^0.3.8`, Rust ≥ 1.95 |
| `gpui-component` 0.7.x pins | `gpui-pre =0.3.8` |
| `gpui-component`/`gpui-base` 0.7.1 pin | `gpui-pre =0.3.8` |
| `gpui-component`/`gpui-base` 0.7.3 pin | `gpui-pre =0.3.9` |
| `gpui-component` 0.8.0 pins | `gpui-pre =0.3.9` (0.8.0 published 2026-10-19) |
| This branch | moved 0.7.1 / 0.3.8 → 0.8 / 0.3.9 in `eb4fbb0` ("chore: update deps") |
@@ -79,23 +80,25 @@ gpui = { package = "gpui-pre", version = "0.3.8" }
gpui_platform = { package = "gpui-pre-platform", version = "0.3.8", features = ["font-kit", "x11", "wayland"] }
reqwest_client = { package = "gpui-pre-reqwest-client", version = "0.3.8" }
gpui-component = { version = "0.7.1", features = ["tree-sitter-languages"] }
gpui-base = "0.7.1"
gpui-component = { version = "=0.7.1", features = ["tree-sitter-languages"] }
gpui-base = "=0.7.1"
native-theme = "0.6.1"
native-theme-gpui = "0.6.1"
native-theme-gpui = { version = "0.6.1", default-features = false, features = ["system-fonts"] }
```
- This is exactly the state of `master` before `eb4fbb0`, which is also the
version set the connector was verified against (2026-10-08 stamp) and that
its nightly dependency canary exercises. `"0.7.1"` is a caret requirement;
it resolves the newest 0.7.x (currently 0.7.3). Pin `=0.7.1` instead if
strict reproducibility is preferred.
- The three `gpui-pre-*` family crates are published in lockstep; all three
move back to 0.3.8 together.
- This is the state of `master` before `eb4fbb0`, the version set the
connector was verified against (2026-10-08 stamp). The exact `=0.7.1`
pins are required, not a style choice: a caret `"0.7.1"` resolves 0.7.3,
whose `gpui-pre =0.3.9` pin drags the graph onto 0.3.9, outside the
closure the connector is verified against. The three `gpui-pre-*` family
crates are published in lockstep; all three move back to 0.3.8 together.
- The connector re-exports the `native-theme` types that appear in its
public signatures (`SystemTheme`, `AccessibilityPreferences`, …), so the
app does **not** need `native-theme` as a direct dependency.
- The cost of the revert is the two one-line tweaks `eb4fbb0` made for 0.8
(the `Deref` removal in `crates/dock/src/dock_area.rs`; verify it compiles
either way). The nostr changes in that commit are unrelated and stay.
(the `Deref` removal in `crates/dock/src/dock_area.rs` is restored; the
0.7.1 `ResizeHandle::on_drag` hands the closure an `Rc<T>` and requires
`E: Render`). The nostr changes in that commit are unrelated and stay.
- When `native-theme-gpui` releases gpui-component 0.8 support (upstream has
bumped within days of each gpui-component release so far), bump both sides
together in one commit.
@@ -128,8 +131,8 @@ Order is load-bearing:
4. Apply the native theme:
```rust
let prefs = native_theme_gpui::AccessibilityPreferences::from_system();
match native_theme::SystemTheme::from_system() {
// native_theme_gpui re-exports SystemTheme from native-theme.
match native_theme_gpui::SystemTheme::from_system() {
Ok(system) => native_theme_gpui::apply_system_theme(&system, cx),
Err(error) => {
tracing::warn!("native theme unavailable ({error}); using bundled themes");
@@ -182,9 +185,11 @@ Remove (the native theme now owns all of these):
size. Keeping manual overrides would require re-applying them after every
upstream rebuild, a permanent fight with the connector.
`apply_theme()` shrinks to the fallback-only body (registry lookups + global
field setup), called only when native detection failed at startup and by the
Appearance handler's fallback branch.
`apply_theme()` and `theme_options()` are deleted outright: with the pickers
and number fields gone they have no remaining callers. The fallback logic
lives only in `main.rs`'s `Err` branch; the Appearance handler keeps working
through `apply_appearance()` alone (`Theme::change` picks up whatever configs
are installed, bundled or native).
`ThemeSettings` keeps its fields and serde shape — the fallback branch still
reads them, existing settings files keep parsing, and the tests in
@@ -224,8 +229,8 @@ Adopting any of them is a separate, deliberate follow-up.
| File | Change |
| --- | --- |
| `Cargo.toml` | Revert gpui-side pins to 0.3.8 / 0.7.1 (Gate 0); add `native-theme` and `native-theme-gpui` workspace deps |
| `desktop/Cargo.toml` | Add `native-theme`, `native-theme-gpui` |
| `Cargo.toml` | Revert gpui-side pins to 0.3.8 / `=0.7.1` (Gate 0); add the `native-theme-gpui` workspace dep |
| `desktop/Cargo.toml` | Add `native-theme-gpui` |
| `desktop/src/main.rs` | Native apply with bundled fallback (§4.2); move the settings-field setup into the fallback branch |
| `crates/workspace/src/views/sidebar/settings_dialog.rs` | Remove theme picker + font/radius/focus/shadow rows; shrink `apply_theme` to fallback-only (§4.4) |
| `CHANGELOG.md` | Added: native OS theme via `native-theme`; Removed: manual theme/font/radius settings |
@@ -240,8 +245,8 @@ Unchanged:
## 6. Validation
1. `cargo check`, `cargo test`, `cargo clippy` across the workspace (toolchain
1.96 satisfies the connector's 1.95 MSRV).
1. `cargo check`, `cargo test --workspace`, `cargo clippy` across the workspace
(toolchain 1.96 satisfies the connector's 1.95 MSRV).
2. Manual matrix, per platform available (macOS first; KDE and GNOME Linux;
Windows):
- cold start matches the OS theme and accent; radius, fonts and controls