M1.10: light theme, live theme switching, editor tokens

- theme::LIGHT next to DARK with the 10 new tokens (editor selection,
  active line, cursor, gutter, match, font size, tab active/modified,
  notice); light fg-muted, accent and error darkened for WCAG AA
- theme.list, theme.systemPreference, themeChanged event when the
  resolved theme changes (settings.set/reset appearance.theme, or the
  OS preference in system mode)
- desktop init script and window background from the stored setting;
  system mode uses a prefers-color-scheme media query for the first frame
- ui/src/theme.ts applies tokens to :root and color-scheme live; editor,
  tabs and notice drop their var() fallbacks
- Vitest WCAG AA contrast check against a Rust-maintained snapshot,
  DOM tests, headless control-channel test
- docs: architecture Themes, parity rows, ui-parity, gaps, roadmaps

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-10-16 15:49:23 +02:00
parent 1ab448de4d
commit cde6e119c6
29 changed files with 1192 additions and 72 deletions

View file

@ -10,6 +10,8 @@
//! Serialised as `{"kind": "<camelCase variant>", ...fields in camelCase}`.
//! Paths are project-relative with `/` separators, the root is `""`.
use std::collections::BTreeMap;
use serde::Serialize;
use serde_json::{Map, Value};
@ -83,6 +85,17 @@ pub enum Event {
/// The changed keys.
keys: Vec<String>,
},
/// The resolved theme changed, through `appearance.theme` or, in
/// "system" mode, the OS preference. The frontend writes the tokens onto
/// `:root` and sets `color-scheme`.
ThemeChanged {
/// Theme id, e.g. `lutra-light`.
id: String,
/// Whether the theme is dark.
dark: bool,
/// Every token as `--lt-<name>` → CSS value.
tokens: BTreeMap<String, String>,
},
/// A message for the user, shown as a toast.
Notification {
/// Unique id of this notification, for dismissing it.
@ -166,4 +179,17 @@ mod tests {
json!({"kind": "settingsChanged", "keys": ["editor.fontSize"]})
);
}
#[test]
fn theme_changed_shape() {
let e = Event::ThemeChanged {
id: "lutra-light".into(),
dark: false,
tokens: [("--lt-bg".to_string(), "#f4f1ec".to_string())].into(),
};
assert_eq!(
serde_json::to_value(e).unwrap(),
json!({"kind": "themeChanged", "id": "lutra-light", "dark": false, "tokens": {"--lt-bg": "#f4f1ec"}})
);
}
}