Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

@ feat(ui): give the app a real light theme, not a switch that goes nowhere

rubenluetke10-beep14662009c59f
diff --git a/jarvis/core/config.py b/jarvis/core/config.py
index 30fa979a0d..fbee1c2531 100644
--- a/jarvis/core/config.py
+++ b/jarvis/core/config.py
@@ -1523,6 +1523,16 @@ class UIConfig(BaseModel):
# switches live (a ConfigReloaded / UiLanguageChanged event reaches the
# frontend over /ws). Distinct from brain.reply_language (what Jarvis SPEAKS).
language: Literal["en", "de", "es"] = "en"
+ # Colour theme of the whole desktop app: "dark" (the product default —
+ # matte black + signal yellow), "light" (warm paper + dark gold), or
+ # "system" (follow the OS appearance, re-evaluated live when the OS flips).
+ # Persisted here rather than only in the browser so the CHOICE survives a
+ # cleared web store, so the native window frame can be painted in the right
+ # colour before the web view has loaded anything (jarvis/ui/shell/window.py),
+ # and so `jarvis api settings put-appearance` can drive it like every other
+ # user-facing action. The frontend caches it in localStorage purely to paint
+ # the boot splash without waiting for HTTP.
+ theme: Literal["dark", "light", "system"] = "dark"
# Dev mode: the frontend is not mounted from frontend/dist/ but loaded from
# a running Vite dev server (HMR). Activated via ENV JARVIS_DEV=1 or CLI
# --dev; the fields here simply hold the parameters.
diff --git a/jarvis/core/config_writer.py b/jarvis/core/config_writer.py
index 2295665189..c04c1aaa72 100644
--- a/jarvis/core/config_writer.py
+++ b/jarvis/core/config_writer.py
@@ -982,6 +982,17 @@ def set_ui_language(name: str, *, path: Path = DEFAULT_CONFIG_FILE) -> None:
_patch_table(path, "ui", "language", name)
+def set_ui_theme(theme: str, *, path: Path = DEFAULT_CONFIG_FILE) -> None:
+ """Persist the app's colour theme in ``[ui] theme``.
+
+ ``theme`` is one of ``dark`` | ``light`` | ``system`` (validated by the
+ caller). Read at boot by the native window so the frame is painted in the
+ matching colour before the web view loads, and by the frontend so the
+ choice survives a cleared browser store.
+ """
+ _patch_table(path, "ui", "theme", theme)
+
+
def set_preferred_opener(opener: str, *, path: Path = DEFAULT_CONFIG_FILE) -> None:
"""Persist the remembered "open with" choice in ``[ui] preferred_opener``.
diff --git a/jarvis/core/events.py b/jarvis/core/events.py
index 8be9d0e6cd..26e3235b40 100644
--- a/jarvis/core/events.py
+++ b/jarvis/core/events.py
@@ -389,6 +389,19 @@ class UiLanguageChanged(Event):
language: str = "" # "en" | "de" | "es"
+@dataclass(frozen=True, slots=True)
+class UiThemeChanged(Event):
+ """Fired when the app's colour theme changes.
+
+ The frontend listens for this over ``/ws`` (wildcard-forwarded) and repaints
+ live — no reload. Emitted by the settings endpoint and (indirectly, via
+ ``ConfigReloaded``) by the Control API, so ``jarvis api settings
+ put-appearance`` reaches an already-open window instead of waiting for a
+ restart.
+ """
+ theme: str = "" # "dark" | "light" | "system"
+
+
# ----------------------------------------------------------------------
# Action-Lifecycle
# ----------------------------------------------------------------------
diff --git a/jarvis/ui/desktop_app.py b/jarvis/ui/desktop_app.py
index d59a50760c..f2177ebea3 100644
--- a/jarvis/ui/desktop_app.py
+++ b/jarvis/ui/desktop_app.py
@@ -3860,6 +3860,13 @@ class DesktopApp:
sys.stderr.write("Backend did not start within 45s — aborting.\n")
return self.shutdown() or 2
+ # The frame is painted before the web view has loaded a single byte, so
+ # it must already know the user's theme — otherwise a light app spends
+ # its entire boot inside a black window.
+ from jarvis.ui.theme import configured_theme, window_background
+
+ window_bg = window_background(configured_theme(getattr(self, "cfg", None)))
+
try:
self._window = webview.create_window(
WINDOW_TITLE,
@@ -3869,7 +3876,7 @@ class DesktopApp:
min_size=(900, 600),
resizable=True,
confirm_close=False,
- background_color="#0a0e14",
+ background_color=window_bg,
)
except webview.WebViewException as exc:
# No native desktop-window backend is available. This is the Linux
diff --git a/jarvis/ui/shell/window.py b/jarvis/ui/shell/window.py
index 2df432d977..6b36e0868f 100644
--- a/jarvis/ui/shell/window.py
+++ b/jarvis/ui/shell/window.py
@@ -19,6 +19,9 @@ class WindowConfig:
min_width: int = 760
min_height: int = 560
start_hidden: bool = False
+ # Default ground only. A caller that knows the user's [ui] theme should pass
+ # ``jarvis.ui.theme.window_background(...)`` instead, so the frame matches
+ # the app it is about to contain.
background_color: str = "#0a0e14" # Jarvis dark theme
# Frameless is supported by pywebview, but we keep the standard frame
# for the first version — window controls come from the OS.
diff --git a/jarvis/ui/theme.py b/jarvis/ui/theme.py
new file mode 100644
index 0000000000..63f19a9086
--- /dev/null
+++ b/jarvis/ui/theme.py
@@ -0,0 +1,181 @@
+"""The app's colour theme, as the NATIVE layer needs it.
+
+The web UI resolves its own theme from CSS custom properties
+(``frontend/src/index.css``). This module exists for the surfaces that are
+painted before — or entirely outside — that stylesheet:
+
+* the pywebview window background, drawn while the web view is still empty
+ (``jarvis/ui/shell/window.py``, ``jarvis/ui/desktop_app.py``);
+* the "backend is still starting" holding page served by the web server
+ (``jarvis/ui/web/server.py``), which has no bundle to fall back on.
+
+Both used to hardcode ``#0a0e14``, which meant a user on the light theme spent
+the whole boot looking at a black frame around a paper-white app. The two
+grounds here are kept in lockstep with the boot splash in ``frontend/index.html``
+and with ``--background`` in ``index.css``.
+
+``system`` is resolved per OS behind a capability probe. Every probe is allowed
+to fail: an unreadable registry, a missing ``defaults`` binary, a headless box
+with no desktop session at all — all of them degrade to the product default
+(dark) rather than raising, because a colour is never worth failing a boot over.
+"""
+from __future__ import annotations
+
+import logging
+import subprocess
+import sys
+from typing import Literal
+
+log = logging.getLogger(__name__)
+
+Theme = Literal["dark", "light"]
+
+#: What the user may choose. ``system`` is an intent, not a colour — it is
+#: resolved to one of the two concrete themes by :func:`resolve_theme`.
+THEME_CHOICES: tuple[str, ...] = ("dark", "light", "system")
+
+#: Window/holding-page ground per theme. Dark is the deep slate the app shell
+#: sits on; light is the warm paper of ``--background``.
+WINDOW_BACKGROUND: dict[str, str] = {
+ "dark": "#0a0e14",
+ "light": "#fcfbf8",
+}
+
+#: Text colours for the holding page, so it is legible on either ground.
+HOLDING_PAGE_FOREGROUND: dict[str, str] = {
+ "dark": "#e6e6e6",
+ "light": "#2b2b33",
+}
+
+HOLDING_PAGE_MUTED: dict[str, str] = {
+ "dark": "#9aa3ad",
+ "light": "#6b6b76",
+}
+
+_DEFAULT_THEME: Theme = "dark"
+
+
+def detect_os_theme() -> Theme | None:
+ """The desktop's own light/dark preference, or ``None`` if unknowable.
+
+ ``None`` is a real answer, not an error: a headless Linux server, a Wayland
+ session with no portal, and a locked-down Windows profile genuinely have no
+ appearance preference to read, and the caller should fall back rather than
+ guess.
+ """
+ try:
+ if sys.platform == "win32":
+ return _detect_windows()
+ if sys.platform == "darwin":
+ return _detect_macos()
+ return _detect_linux()
+ except Exception as exc: # noqa: BLE001 — a colour probe never breaks a boot
+ log.debug("OS theme probe failed (%s); caller falls back", exc)
+ return None
+
+
+def _detect_windows() -> Theme | None:
+ """Windows 10/11: ``AppsUseLightTheme`` under the Personalize key."""
+ try:
+ import winreg # type: ignore[import-not-found]
+ except ImportError:
+ return None
+ try:
+ with winreg.OpenKey(
+ winreg.HKEY_CURRENT_USER,
+ r"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize",
+ ) as key:
+ value, _ = winreg.QueryValueEx(key, "AppsUseLightTheme")
+ except OSError as exc:
+ # Key absent on older/stripped builds — no preference to read.
+ log.debug("Windows theme key unreadable: %s", exc)
+ return None
+ return "light" if int(value) == 1 else "dark"
+
+
+def _detect_macos() -> Theme | None:
+ """macOS: ``AppleInterfaceStyle`` is set to "Dark" ONLY in dark mode.
+
+ In light mode the key does not exist and ``defaults`` exits non-zero — that
+ absence is the light answer, not a failure.
+ """
+ out = _run(["defaults", "read", "-g", "AppleInterfaceStyle"])
+ if out is None:
+ return None
+ return "dark" if "dark" in out.strip().lower() else "light"
+
+
+def _detect_linux() -> Theme | None:
+ """Linux: the freedesktop ``color-scheme`` hint, GNOME's key, then theme name.
+
+ Tried in order of how much they actually mean. A server with no session has
+ none of them and returns ``None``.
+ """
+ scheme = _run(["gsettings", "get", "org.gnome.desktop.interface", "color-scheme"])
+ if scheme:
+ low = scheme.strip().strip("'\"").lower()
+ if "dark" in low:
+ return "dark"
+ if "light" in low:
+ return "light"
+ # 'default' means "no preference expressed" — keep looking.
+
+ name = _run(["gsettings", "get", "org.gnome.desktop.interface", "gtk-theme"])
+ if name:
+ return "dark" if "dark" in name.strip().strip("'\"").lower() else "light"
+ return None
+
+
+def _run(cmd: list[str]) -> str | None:
+ """Run a probe command, or ``None`` if it is missing / fails / hangs.
+
+ ``NO_WINDOW_CREATIONFLAGS`` keeps this from flashing a console window under
+ ``pythonw.exe`` (AP-1); the timeout keeps a wedged desktop service from
+ holding up startup.
+ """
+ try:
+ from jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGS
+ except Exception: # noqa: BLE001 — probe must work even standalone
+ NO_WINDOW_CREATIONFLAGS = 0 # noqa: N806
+ try:
+ proc = subprocess.run( # noqa: S603 — fixed argv, no shell
+ cmd,
+ capture_output=True,
+ text=True,
+ timeout=2.0,
+ creationflags=NO_WINDOW_CREATIONFLAGS,
+ )
+ except (OSError, subprocess.SubprocessError) as exc:
+ log.debug("theme probe %s unavailable: %s", cmd[0], exc)
+ return None
+ if proc.returncode != 0:
+ return None
+ return proc.stdout
+
+
+def resolve_theme(configured: str | None) -> Theme:
+ """Turn a configured value (``dark`` | ``light`` | ``system``) into a colour.
+
+ Anything unrecognised — including ``None`` and a value from a newer config
+ written by a future build — resolves to the product default.
+ """
+ value = (configured or "").strip().lower()
+ if value in ("dark", "light"):
+ return value # type: ignore[return-value]
+ if value == "system":
+ return detect_os_theme() or _DEFAULT_THEME
+ return _DEFAULT_THEME
+
+
+def window_background(configured: str | None) -> str:
+ """The native window ground for a configured theme value."""
+ return WINDOW_BACKGROUND[resolve_theme(configured)]
+
+
+def configured_theme(cfg: object | None) -> str:
+ """Read ``[ui] theme`` off a config object without assuming it is present.
+
+ Tolerates an older config model and a ``None`` config, both of which happen
+ on the degraded boot paths that call this.
+ """
+ return str(getattr(getattr(cfg, "ui", None), "theme", "dark") or "dark")
diff --git a/jarvis/ui/web/frontend/index.html b/jarvis/ui/web/frontend/index.html
index 5755c8a314..611b6ecf72 100644
--- a/jarvis/ui/web/frontend/index.html
+++ b/jarvis/ui/web/frontend/index.html
@@ -1,5 +1,9 @@
<!doctype html>
-<html lang="en">
+<!-- `class="dark"` is the STATIC default so the product's default theme needs
+ no script at all to paint correctly. The boot script in <head> strips it
+ when the user has chosen light. Both run before the first paint, so
+ neither theme ever flashes the other one. -->
+<html lang="en" class="dark">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
@@ -10,32 +14,81 @@
cache) the instant the window opens, so a trademarked placeholder is
never shown. -->
<title>Assistant</title>
+ <script>
+ // Resolve the theme SYNCHRONOUSLY, before a single pixel is painted.
+ //
+ // This has to happen here rather than in React: the bundle is large, and
+ // a document that paints its default ground first and switches when the
+ // app mounts is the classic theme flash — a white window blinking black a
+ // second later (or the reverse), every single launch.
+ //
+ // Reads the same key ThemeProvider writes (src/hooks/useTheme.tsx — keep
+ // the key and the resolution order in lockstep). "system" follows the OS.
+ // The backend value in [ui] theme is authoritative, but it arrives over
+ // HTTP; ThemeProvider reconciles it once it does, and mirrors it back
+ // here so the NEXT launch is instant.
+ (function () {
+ var mode = "dark";
+ try {
+ var stored = (localStorage.getItem("jarvis.theme") || "").trim();
+ if (stored === "light" || stored === "dark") {
+ mode = stored;
+ } else if (stored === "system") {
+ mode = window.matchMedia("(prefers-color-scheme: light)").matches
+ ? "light"
+ : "dark";
+ }
+ } catch (e) {
+ /* storage blocked (private mode) — keep the dark default */
+ }
+ var root = document.documentElement;
+ root.classList.toggle("dark", mode === "dark");
+ root.style.colorScheme = mode;
+ })();
+ </script>
<style>
/* Boot splash — painted from index.html the instant the window opens, so
- there is NO black screen while the (large) JS bundle loads + React
+ there is NO blank screen while the (large) JS bundle loads + React
mounts. React's createRoot clears #root on its first render, so this is
- replaced by the real UI automatically. Background matches the pywebview
- window color (#0a0e14) so there is never a flash. */
- html, body { margin: 0; height: 100%; background: #0a0e14; }
+ replaced by the real UI automatically.
+
+ The two grounds match the pywebview window colour for their theme
+ (jarvis/ui/shell/window.py), so the window frame and its contents are
+ one surface from the first frame. Keep the pairs in lockstep. */
+ :root {
+ --jbs-bg: #fcfbf8;
+ --jbs-accent: #a86b00;
+ --jbs-ring: rgba(168, 107, 0, 0.22);
+ --jbs-name: #2b2b33;
+ --jbs-sub: #6b6b76;
+ }
+ :root.dark {
+ --jbs-bg: #0a0e14;
+ --jbs-accent: #e7c46e;
+ --jbs-ring: rgba(231, 196, 110, 0.2);
+ --jbs-name: #e6e6e6;
+ --jbs-sub: #9aa3ad;
+ }
+ html, body { margin: 0; height: 100%; background: var(--jbs-bg); }
#jarvis-boot-splash {
position: fixed; inset: 0; display: flex; flex-direction: column;
align-items: center; justify-content: center; gap: 18px;
- background: #0a0e14;
+ background: var(--jbs-bg);
font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
- color: #e7c46e;
+ color: var(--jbs-accent);
}
#jarvis-boot-splash .ring {
width: 38px; height: 38px; border-radius: 50%;
- border: 3px solid rgba(231, 196, 110, 0.2);
- border-top-color: #e7c46e;
+ border: 3px solid var(--jbs-ring);
+ border-top-color: var(--jbs-accent);
animation: jbs-spin 0.8s linear infinite;
}
#jarvis-boot-splash .name {
font-size: 15px; font-weight: 600; letter-spacing: 0.04em;
- color: #e6e6e6;
+ color: var(--jbs-name);
}
#jarvis-boot-splash .sub {
- font-size: 12px; color: #9aa3ad; letter-spacing: 0.06em;
+ font-size: 12px; color: var(--jbs-sub); letter-spacing: 0.06em;
text-transform: uppercase;
}
@keyframes jbs-spin { to { transform: rotate(360deg); } }
diff --git a/jarvis/ui/web/frontend/src/hooks/useTheme.tsx b/jarvis/ui/web/frontend/src/hooks/useTheme.tsx
index 859abec59d..f7c6039b15 100644
--- a/jarvis/ui/web/frontend/src/hooks/useTheme.tsx
+++ b/jarvis/ui/web/frontend/src/hooks/useTheme.tsx
@@ -1,39 +1,189 @@
-import { createContext, useContext, useEffect, useMemo, useState, type ReactNode } from "react";
+import {
+ createContext,
+ useCallback,
+ useContext,
+ useEffect,
+ useMemo,
+ useState,
+ type ReactNode,
+} from "react";
-type Theme = "dark" | "light";
+/** What the user picks. `system` is an intent that follows the OS live. */
+export type ThemePreference = "dark" | "light" | "system";
+/** What actually gets painted. */
+export type Theme = "dark" | "light";
interface ThemeCtx {
+ /** The resolved colour currently on screen. */
theme: Theme;
- setTheme: (t: Theme) => void;
+ /** The user's choice, which may be `system`. */
+ preference: ThemePreference;
+ /** Persist a choice (backend + local cache) and repaint. */
+ setPreference: (p: ThemePreference) => void;
+ /** Flip between the two concrete themes. Resolves `system` first. */
toggle: () => void;
}
const Ctx = createContext<ThemeCtx | undefined>(undefined);
+
+/**
+ * Cache key. Shared verbatim with the inline boot script in `index.html`,
+ * which reads it before the first paint — keep the key AND the resolution
+ * order in lockstep with that script, or the app will flash on launch.
+ */
const STORAGE_KEY = "jarvis.theme";
+const ENDPOINT = "/api/settings/appearance";
+const DEFAULT_PREFERENCE: ThemePreference = "dark";
+
+function isPreference(v: unknown): v is ThemePreference {
+ return v === "dark" || v === "light" || v === "system";
+}
-function readInitial(): Theme {
- if (typeof window === "undefined") return "dark";
- const stored = window.localStorage.getItem(STORAGE_KEY);
- if (stored === "dark" || stored === "light") return stored;
- return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
+/** The OS preference, or the product default where it cannot be read. */
+function systemTheme(): Theme {
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
+ return DEFAULT_PREFERENCE === "dark" ? "dark" : "light";
+ }
+ return window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
+}
+
+export function resolveTheme(preference: ThemePreference): Theme {
+ return preference === "system" ? systemTheme() : preference;
+}
+
+/**
+ * The cached preference, read synchronously.
+ *
+ * The authoritative value lives in `[ui] theme` on the backend, but it arrives
+ * over HTTP — too late to paint the first frame with. So the cache is what the
+ * app starts from, and `hydrate()` reconciles it a moment later. In the normal
+ * case the two already agree and nothing visibly changes.
+ */
+function readCachedPreference(): ThemePreference {
+ if (typeof window === "undefined") return DEFAULT_PREFERENCE;
+ try {
+ const stored = window.localStorage.getItem(STORAGE_KEY);
+ if (isPreference(stored)) return stored;
+ } catch {
+ /* storage blocked (private mode) — fall through to the default */
+ }
+ return DEFAULT_PREFERENCE;
+}
+
+function applyToDocument(theme: Theme) {
+ const root = document.documentElement;
+ root.classList.toggle("dark", theme === "dark");
+ // Native widgets — dropdowns, the caret, scrollbar internals CSS cannot
+ // reach — follow this rather than the class.
+ root.style.colorScheme = theme;
+}
+
+/**
+ * Re-read the theme from the backend and repaint.
+ *
+ * Called when a `ConfigReloaded` names `ui.theme` — i.e. something wrote
+ * jarvis.toml directly (a voice command, the self-mod pipeline, an edit on
+ * another machine) without going through the appearance endpoint, so no
+ * `UiThemeChanged` was ever published. Routed through the same custom event as
+ * the broadcast, so ThemeProvider stays the only writer.
+ */
+export async function hydrateUiTheme(): Promise<void> {
+ try {
+ const res = await fetch(ENDPOINT, { credentials: "same-origin" });
+ if (!res.ok) return;
+ const data: unknown = await res.json();
+ const theme = (data as { theme?: unknown }).theme;
+ if (isPreference(theme)) {
+ window.dispatchEvent(new CustomEvent("jarvis:theme-changed", { detail: { theme } }));
+ }
+ } catch (err) {
+ if (import.meta.env?.DEV) console.debug("appearance re-hydrate skipped", err);
+ }
}
export function ThemeProvider({ children }: { children: ReactNode }) {
- const [theme, setThemeState] = useState<Theme>(readInitial);
+ const [preference, setPreferenceState] = useState<ThemePreference>(readCachedPreference);
+ const [systemValue, setSystemValue] = useState<Theme>(systemTheme);
+ const theme: Theme = preference === "system" ? systemValue : preference;
+
+ // Follow the OS while the preference is `system`. Registered unconditionally
+ // so switching TO `system` picks up the current OS value without a reload.
useEffect(() => {
- const root = document.documentElement;
- root.classList.toggle("dark", theme === "dark");
- window.localStorage.setItem(STORAGE_KEY, theme);
- }, [theme]);
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
+ const mq = window.matchMedia("(prefers-color-scheme: light)");
+ const onChange = () => setSystemValue(mq.matches ? "light" : "dark");
+ onChange();
+ mq.addEventListener("change", onChange);
+ return () => mq.removeEventListener("change", onChange);
+ }, []);
+
+ // Paint, and mirror the choice into the cache the boot script reads.
+ useEffect(() => {
+ applyToDocument(theme);
+ try {
+ window.localStorage.setItem(STORAGE_KEY, preference);
+ } catch {
+ /* storage blocked — the backend value still survives a restart */
+ }
+ }, [theme, preference]);
+
+ // Reconcile with the backend once, on mount. A value written by the Control
+ // API (`jarvis api settings put-appearance`) or carried over from another
+ // machine's config wins over a stale local cache.
+ useEffect(() => {
+ let cancelled = false;
+ void (async () => {
+ try {
+ const res = await fetch(ENDPOINT, { credentials: "same-origin" });
+ if (!res.ok) return;
+ const data: unknown = await res.json();
+ const remote = (data as { theme?: unknown }).theme;
+ if (!cancelled && isPreference(remote)) setPreferenceState(remote);
+ } catch (err) {
+ // Offline or the route is not mounted yet — the cached preference is a
+ // perfectly good answer, so this is a non-event rather than a failure.
+ if (import.meta.env?.DEV) console.debug("appearance hydrate skipped", err);
+ }
+ })();
+ return () => {
+ cancelled = true;
+ };
+ }, []);
+
+ // Another client / the Control API changed it: repaint without a reload.
+ useEffect(() => {
+ const onRemote = (e: Event) => {
+ const next = (e as CustomEvent<{ theme?: unknown }>).detail?.theme;
+ if (isPreference(next)) setPreferenceState(next);
+ };
+ window.addEventListener("jarvis:theme-changed", onRemote);
+ return () => window.removeEventListener("jarvis:theme-changed", onRemote);
+ }, []);
+
+ const setPreference = useCallback((next: ThemePreference) => {
+ setPreferenceState(next);
+ void fetch(ENDPOINT, {
+ method: "PUT",
+ credentials: "same-origin",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ theme: next, persist: true }),
+ }).catch((err) => {
+ // The visible switch already happened and the local cache holds it, so a
+ // failed PUT costs the user nothing this session — it only means the
+ // choice may not survive a config reload elsewhere.
+ if (import.meta.env?.DEV) console.debug("appearance persist failed", err);
+ });
+ }, []);
const value = useMemo<ThemeCtx>(
() => ({
theme,
- setTheme: setThemeState,
- toggle: () => setThemeState((t) => (t === "dark" ? "light" : "dark")),
+ preference,
+ setPreference,
+ toggle: () => setPreference(theme === "dark" ? "light" : "dark"),
}),
- [theme],
+ [theme, preference, setPreference],
);
return <Ctx.Provider value={value}>{children}</Ctx.Provider>;
@@ -52,10 +202,28 @@ export function useTheme(): ThemeCtx {
* switches the theme — that is a wiring bug worth failing loudly on. But a
* component that only tints itself to fit should not take the view down when it
* is rendered outside the provider (a unit test, a storybook, an isolated
- * mount). Those get the stored/system value instead, which is what the provider
- * would have resolved anyway.
+ * mount). Those read the document instead, which is where the answer actually
+ * is: the class on <html> is set before React mounts and stays authoritative.
*/
export function useThemeValue(): Theme {
const ctx = useContext(Ctx);
- return ctx?.theme ?? readInitial();
+ const [fallback, setFallback] = useState<Theme>(() =>
+ typeof document !== "undefined" && document.documentElement.classList.contains("dark")
+ ? "dark"
+ : resolveTheme(readCachedPreference()),
+ );
+
+ // Outside a provider, follow the class on <html> so an isolated component
+ // still repaints when the theme changes around it.
+ useEffect(() => {
+ if (ctx || typeof document === "undefined") return;
+ const root = document.documentElement;
+ const sync = () => setFallback(root.classList.contains("dark") ? "dark" : "light");
+ sync();
+ const observer = new MutationObserver(sync);
+ observer.observe(root, { attributes: true, attributeFilter: ["class"] });
+ return () => observer.disconnect();
+ }, [ctx]);
+
+ return ctx?.theme ?? fallback;
}
diff --git a/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts b/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts
index c96579d274..8d8a03a65e 100644
--- a/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts
+++ b/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts
@@ -18,6 +18,7 @@ import {
import { useSubAgentStore, SUB_AGENT_EVENT_NAMES } from "@/store/jarvisAgents";
import { WSAudioLevel, WSEventEnvelope, WSWelcome } from "@/schema/ws";
import { useI18nStore, hydrateUiLanguage, hydrateReplyLanguage, translate } from "@/i18n";
+import { hydrateUiTheme } from "@/hooks/useTheme";
let singleton: WSClient | null = null;
@@ -396,6 +397,18 @@ export function useWebSocket(): void {
}
}
+ // Live theme switch (Control API / another client). ThemeProvider owns
+ // the repaint; this only relays the value, so the provider stays the one
+ // place that writes the class on <html>.
+ if (env.event_name === "UiThemeChanged") {
+ const p = env.payload as { theme?: string };
+ if (p.theme === "dark" || p.theme === "light" || p.theme === "system") {
+ window.dispatchEvent(
+ new CustomEvent("jarvis:theme-changed", { detail: { theme: p.theme } }),
+ );
+ }
+ }
+
// A voice command / the Control API writes config via the atomic writer,
// which fires ConfigReloaded (not UiLanguageChanged). Re-hydrate the
// affected language setting so the UI reflects it live.
@@ -404,6 +417,7 @@ export function useWebSocket(): void {
const keys = Array.isArray(p.changed_keys) ? (p.changed_keys as string[]) : [];
if (keys.includes("ui.language")) void hydrateUiLanguage();
if (keys.includes("brain.reply_language")) void hydrateReplyLanguage();
+ if (keys.includes("ui.theme")) void hydrateUiTheme();
}
if (env.event_name === "ToastNotification") {
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 73e3f104c7..816c09b7cd 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -1631,7 +1631,16 @@
"codex_title": "OpenAI Codex CLI",
"codex_description": "Manueller Pfad für Windows-PATH-Probleme. Leer lassen nutzt 'codex' aus PATH.",
"safety_title": "Safety-Whitelist",
- "safety_description": "Patterns die ohne Nachfrage ausgeführt werden, auch bei Risk-Tier 'ask'. Vermeidet Confirmation-Fatigue."
+ "safety_description": "Patterns die ohne Nachfrage ausgeführt werden, auch bei Risk-Tier 'ask'. Vermeidet Confirmation-Fatigue.",
+ "appearance": {
+ "title": "Erscheinungsbild",
+ "description": "Das Farbschema der gesamten App. Dunkel ist die Voreinstellung; Hell ist ein warmer Papier-Look. Wechselt sofort.",
+ "dark": "Dunkel",
+ "light": "Hell",
+ "system": "System",
+ "system_now_dark": "Folgt Ihrem System, das derzeit dunkel ist.",
+ "system_now_light": "Folgt Ihrem System, das derzeit hell ist."
+ }
},
"telephony_view": {
"title": "Telefonie (experimentell)",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index f79f9d7de5..e94e051239 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -1632,7 +1632,16 @@
"codex_title": "OpenAI Codex CLI",
"codex_description": "Manual path for Windows PATH issues. Empty uses 'codex' from PATH.",
"safety_title": "Safety Whitelist",
- "safety_description": "Patterns executed without confirmation, even at risk-tier 'ask'. Avoids confirmation fatigue."
+ "safety_description": "Patterns executed without confirmation, even at risk-tier 'ask'. Avoids confirmation fatigue.",
+ "appearance": {
+ "title": "Appearance",
+ "description": "The colour theme of the whole app. Dark is the default; light is a warm paper look. Switches instantly.",
+ "dark": "Dark",
+ "light": "Light",
+ "system": "System",
+ "system_now_dark": "Following your system, which is currently dark.",
+ "system_now_light": "Following your system, which is currently light."
+ }
},
"telephony_view": {
"title": "Telephony (experimental)",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index a64c269759..5d1af8bc84 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -1631,7 +1631,16 @@
"codex_title": "OpenAI Codex CLI",
"codex_description": "Ruta manual para problemas de PATH en Windows. Vacío usa 'codex' del PATH.",
"safety_title": "Lista blanca de seguridad",
- "safety_description": "Patrones ejecutados sin confirmación, incluso en nivel de riesgo 'preguntar'. Evita la fatiga de confirmaciones."
+ "safety_description": "Patrones ejecutados sin confirmación, incluso en nivel de riesgo 'preguntar'. Evita la fatiga de confirmaciones.",
+ "appearance": {
+ "title": "Apariencia",
+ "description": "El tema de color de toda la aplicación. Oscuro es el predeterminado; claro es un aspecto de papel cálido. Cambia al instante.",
+ "dark": "Oscuro",
+ "light": "Claro",
+ "system": "Sistema",
+ "system_now_dark": "Sigue a su sistema, que actualmente está en modo oscuro.",
+ "system_now_light": "Sigue a su sistema, que actualmente está en modo claro."
+ }
},
"telephony_view": {
"title": "Telefonía",
diff --git a/jarvis/ui/web/frontend/src/index.css b/jarvis/ui/web/frontend/src/index.css
index 47996d2136..5d87007fd3 100644
--- a/jarvis/ui/web/frontend/src/index.css
+++ b/jarvis/ui/web/frontend/src/index.css
@@ -244,8 +244,90 @@
}
@layer base {
+ /*
+ * ===========================================================================
+ * Theme tokens — light lives on :root, dark on .dark
+ * ===========================================================================
+ *
+ * The class is put on <html> by two places that must agree: the inline boot
+ * script in index.html (synchronously, before the first paint, so neither
+ * theme flashes the other one) and ThemeProvider (hooks/useTheme.tsx) once
+ * React owns the document. Dark remains the product's default.
+ *
+ * THE RULE FOR EVERY SURFACE IN THIS APP: never write a literal colour.
+ * A component that hardcodes `bg-zinc-900`, `#0a0a0a`, or `rgba(0,0,0,.6)`
+ * looks correct in exactly one theme and is a bug in the other — and because
+ * the app defaults to dark, that bug ships invisible to whoever wrote it.
+ *
+ * The shadcn set below covers flat surfaces and text. Effects — glows, grid
+ * lines, scrims, glass, hatching — cannot use it, because they need colour
+ * CHANNELS to build an rgba() from. That is what the four `*-rgb` triples
+ * exist for; each is a bare `R G B` list meant for `rgb(var(--x) / <alpha>)`.
+ */
:root {
- /* Jarvis — Schwarz/Gelb Theme (matte, signal-yellow) */
+ /* --- Light: warm paper, dark gold ------------------------------------ */
+ --background: 45 40% 98%; /* #FCFBF8 warm paper */
+ --foreground: 240 9% 18%; /* #2B2B33 warm near-black */
+ --card: 0 0% 100%; /* #FFFFFF — cards lift OFF the paper */
+ --card-foreground: 240 9% 18%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 240 9% 18%;
+ /* #A86B00. The signal-yellow of the dark theme is 1.4:1 on paper — a
+ button nobody can read. This is the same gold the light terminal theme
+ already uses for its cursor, at 5.1:1 against --background. */
+ --primary: 38 100% 33%;
+ --primary-foreground: 0 0% 100%; /* white on gold */
+ --secondary: 45 27% 94%; /* #F4F2EC recessed surface */
+ --secondary-foreground: 240 9% 18%;
+ --muted: 45 27% 94%;
+ --muted-foreground: 240 5% 44%; /* #6B6B76 — 4.9:1, still body-text legal */
+ --accent: 38 100% 33%;
+ --accent-foreground: 0 0% 100%;
+ --destructive: 6 63% 46%; /* #C0392B — the light terminal's red */
+ --destructive-foreground: 0 0% 100%;
+ --border: 44 18% 88%; /* #E6E3DB */
+ --input: 45 30% 96%;
+ --ring: 38 100% 33%;
+ --radius: 0.75rem;
+
+ /* --- Effect channels (see the note above) ---------------------------- */
+ /* The accent as raw channels, for glows / grid lines / halos. */
+ --accent-rgb: 168 107 0;
+ /* What a translucent overlay DARKENS with (backdrops, vignettes, shadows).
+ Warm near-black rather than pure black, so a scrim over paper does not
+ turn grey-blue. */
+ --scrim-rgb: 43 40 32;
+ /* What a translucent overlay LIGHTENS with (hatching, glass rims, sheen).
+ In light mode "highlight" means going darker, so this is the ink colour —
+ the two swap roles between themes, which is exactly the point. */
+ --sheen-rgb: 43 43 51;
+ /* The ground colour of the app shell as channels, for glass pills that
+ must read as "the app, blurred" rather than a grey rectangle. */
+ --shell-rgb: 252 251 248;
+
+ /* --- Stages ----------------------------------------------------------
+ The full-bleed canvases behind the knowledge maps. They are not chrome:
+ a force graph needs its own depth cue, so it gets its own ground, its
+ own centre-of-gravity glow, and its own dot field. Light mode keeps the
+ depth and inverts the material — pale sky with ink-dark stars. */
+ --stage-bg: 45 40% 97%;
+ --stage-dot-rgb: 43 43 51;
+ --stage-dot-strong: 0.28;
+ --stage-dot-soft: 0.16;
+ --stage-wash-rgb: 120 148 200;
+ --stage-wash-strength: 0.16;
+ --stage-vignette-rgb: 43 40 32;
+ --stage-vignette-strength: 0.1;
+
+ /* Legacy aliases. Kept because they are referenced from a handful of
+ places that predate the token set; both now follow the theme. */
+ --jarvis-yellow: 168 107 0;
+ --jarvis-yellow-dim: 138 90 8;
+ --jarvis-grid: 44 18% 88%;
+ }
+
+ .dark {
+ /* --- Dark: matte black, signal yellow — the product default ---------- */
--background: 0 0% 4%; /* #0A0A0A matte-black */
--foreground: 0 0% 96%; /* #F4F4F5 */
--card: 0 0% 6%; /* #0F0F0F */
@@ -253,7 +335,7 @@
--popover: 0 0% 6%;
--popover-foreground: 0 0% 96%;
--primary: 50 100% 52%; /* #FFD60A signal-yellow */
- --primary-foreground: 0 0% 4%; /* schwarz auf gelb */
+ --primary-foreground: 0 0% 4%; /* black on yellow */
--secondary: 0 0% 10%; /* #1A1A1A */
--secondary-foreground: 0 0% 96%;
--muted: 0 0% 10%;
@@ -265,20 +347,25 @@
--border: 0 0% 14%; /* #242424 */
--input: 0 0% 10%;
--ring: 50 100% 52%;
- --radius: 0.75rem;
- /* Jarvis-specific custom tokens */
- --jarvis-yellow: 255 214 10; /* #FFD60A for rgba() */
- --jarvis-yellow-dim: 230 190 40; /* dimmed yellow */
+ --accent-rgb: 255 214 10;
+ --scrim-rgb: 0 0 0;
+ --sheen-rgb: 255 255 255;
+ --shell-rgb: 10 10 10;
+
+ --stage-bg: 0 0% 4%;
+ --stage-dot-rgb: 255 255 255;
+ --stage-dot-strong: 0.5;
+ --stage-dot-soft: 0.35;
+ --stage-wash-rgb: 40 78 140;
+ --stage-wash-strength: 0.22;
+ --stage-vignette-rgb: 0 0 0;
+ --stage-vignette-strength: 0.62;
+
+ --jarvis-yellow: 255 214 10;
+ --jarvis-yellow-dim: 230 190 40;
--jarvis-grid: 0 0% 12%;
}
-
- .dark {
- /* Dark is default — this class is only for explicit dark switches.
- We keep the same scheme, dark = default = Jarvis. */
- --background: 0 0% 4%;
- --foreground: 0 0% 96%;
- }
}
@layer base {
@@ -289,6 +376,14 @@
html {
@apply bg-background;
scroll-behavior: smooth;
+ /* Tells the engine which theme its OWN widgets belong to — form controls,
+ the caret, focus rings, and (on WebView2) the parts of a scrollbar that
+ CSS cannot reach. Without it a light app keeps dark native dropdowns. */
+ color-scheme: light;
+ }
+
+ .dark {
+ color-scheme: dark;
}
body {
@@ -316,32 +411,51 @@
}
@layer components {
- /* Subtle grid pattern in the background — gives a dashboard feel without distracting */
+ /* Subtle grid pattern in the background — gives a dashboard feel without
+ distracting. Drawn in the accent so it reads as the app's own texture;
+ slightly stronger on paper, where a 4 % line simply disappears. */
.jarvis-grid {
background-image:
- linear-gradient(rgba(255, 214, 10, 0.04) 1px, transparent 1px),
- linear-gradient(90deg, rgba(255, 214, 10, 0.04) 1px, transparent 1px);
+ linear-gradient(rgb(var(--accent-rgb) / 0.04) 1px, transparent 1px),
+ linear-gradient(90deg, rgb(var(--accent-rgb) / 0.04) 1px, transparent 1px);
background-size: 64px 64px;
mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
}
- /* Yellow spot glow — used as an absolute-positioned element */
+ :root:not(.dark) .jarvis-grid {
+ background-image:
+ linear-gradient(rgb(var(--accent-rgb) / 0.09) 1px, transparent 1px),
+ linear-gradient(90deg, rgb(var(--accent-rgb) / 0.09) 1px, transparent 1px);
+ }
+
+ /* Accent spot glow — used as an absolute-positioned element. A blurred glow
+ is additive light: it works by being BRIGHTER than its ground, which paper
+ already is. On light the same shape becomes a soft gold wash instead. */
.jarvis-glow {
background: radial-gradient(
circle at center,
- rgba(255, 214, 10, 0.22) 0%,
- rgba(255, 214, 10, 0.08) 30%,
+ rgb(var(--accent-rgb) / 0.22) 0%,
+ rgb(var(--accent-rgb) / 0.08) 30%,
transparent 70%
);
filter: blur(60px);
}
+ :root:not(.dark) .jarvis-glow {
+ background: radial-gradient(
+ circle at center,
+ rgb(var(--accent-rgb) / 0.14) 0%,
+ rgb(var(--accent-rgb) / 0.05) 30%,
+ transparent 70%
+ );
+ }
+
/* Button base — for CTAs */
.btn-primary {
@apply inline-flex items-center justify-center gap-2 rounded-full px-6 py-3 font-medium
bg-primary text-primary-foreground
transition-all duration-200
- hover:bg-primary/90 hover:shadow-[0_0_32px_rgba(255,214,10,0.35)]
+ hover:bg-primary/90 hover:shadow-[0_0_32px_rgb(var(--accent-rgb)/0.35)]
active:scale-[0.98] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring;
}
@@ -397,11 +511,11 @@
0%,
100% {
opacity: 1;
- box-shadow: 0 0 0 0 rgba(255, 214, 10, 0.4);
+ box-shadow: 0 0 0 0 rgb(var(--accent-rgb) / 0.4);
}
50% {
opacity: 0.85;
- box-shadow: 0 0 0 8px rgba(255, 214, 10, 0);
+ box-shadow: 0 0 0 8px rgb(var(--accent-rgb) / 0);
}
}
.animate-jarvis-pulse {
@@ -422,11 +536,14 @@
}
}
.thinking-shimmer {
+ /* The travelling band is the ACCENT, not a fixed pale yellow: on paper a
+ #ffe552 highlight passing over grey text is lighter than the text it is
+ meant to light up, so the sweep reads as a gap rather than a shine. */
background: linear-gradient(
90deg,
hsl(var(--muted-foreground)) 0%,
hsl(var(--muted-foreground)) 38%,
- #ffe552 50%,
+ hsl(var(--primary)) 50%,
hsl(var(--muted-foreground)) 62%,
hsl(var(--muted-foreground)) 100%
);
@@ -450,7 +567,7 @@
animation: thinking-ring 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}
.thinking-core {
- box-shadow: 0 0 12px 2px rgba(255, 214, 10, 0.45);
+ box-shadow: 0 0 12px 2px rgb(var(--accent-rgb) / 0.45);
}
@keyframes thinking-breathe {
0%,
@@ -503,9 +620,17 @@
animation: jarvis-spin-slow 40s linear infinite;
}
- /* Text gradient for the hero */
+ /* Text gradient for the hero. Both stops are derived from the accent so the
+ headline stays readable on either ground — on paper the ramp runs from the
+ gold DOWN into a deeper bronze, because a gradient that brightens toward
+ white is an invisible headline. */
.text-gradient-yellow {
- background: linear-gradient(135deg, #ffe552 0%, #ffd60a 50%, #b8960a 100%);
+ background: linear-gradient(
+ 135deg,
+ hsl(var(--primary) / 0.82) 0%,
+ hsl(var(--primary)) 50%,
+ color-mix(in srgb, hsl(var(--primary)) 72%, hsl(var(--foreground))) 100%
+ );
-webkit-background-clip: text;
background-clip: text;
color: transparent;
@@ -891,10 +1016,10 @@
padding: 6px 11px;
border-radius: 10px;
background: hsl(var(--card));
- border: 1px solid rgba(255, 214, 10, 0.45);
+ border: 1px solid rgb(var(--accent-rgb) / 0.45);
box-shadow:
- 0 0 18px rgba(255, 214, 10, 0.18),
- 0 4px 14px rgba(0, 0, 0, 0.45);
+ 0 0 18px rgb(var(--accent-rgb) / 0.18),
+ 0 4px 14px rgb(var(--scrim-rgb) / 0.45);
font-size: 11.5px;
line-height: 1.35;
color: hsl(var(--foreground));
@@ -912,7 +1037,7 @@
right: 100%;
transform: translateY(-50%);
border: 6px solid transparent;
- border-right-color: rgba(255, 214, 10, 0.45);
+ border-right-color: rgb(var(--accent-rgb) / 0.45);
}
.gigi-bubble::after {
content: "";
@@ -936,10 +1061,10 @@
padding: 8px 12px;
display: flex;
align-items: flex-end;
- border-color: rgba(255, 214, 10, 0.72);
+ border-color: rgb(var(--accent-rgb) / 0.72);
box-shadow:
- 0 0 24px rgba(255, 214, 10, 0.22),
- 0 8px 22px rgba(0, 0, 0, 0.55);
+ 0 0 24px rgb(var(--accent-rgb) / 0.22),
+ 0 8px 22px rgb(var(--scrim-rgb) / 0.55);
font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
font-size: 13px;
line-height: 1.35;
@@ -951,7 +1076,7 @@
right: auto;
left: 100%;
border-right-color: transparent;
- border-left-color: rgba(255, 214, 10, 0.72);
+ border-left-color: rgb(var(--accent-rgb) / 0.72);
}
.gigi-bubble-listening::after {
right: auto;
@@ -1001,8 +1126,8 @@
cursor: copy;
background: radial-gradient(
460px circle at calc(100% - 3rem) calc(100% - 3rem),
- rgba(255, 214, 10, 0.1),
- rgba(255, 214, 10, 0.03) 42%,
+ rgb(var(--accent-rgb) / 0.1),
+ rgb(var(--accent-rgb) / 0.03) 42%,
transparent 72%
);
animation: dock-catch-in 180ms ease-out;
@@ -1033,10 +1158,10 @@
@keyframes dock-breathe {
0%,
100% {
- box-shadow: 0 0 26px rgba(255, 214, 10, 0.22);
+ box-shadow: 0 0 26px rgb(var(--accent-rgb) / 0.22);
}
50% {
- box-shadow: 0 0 42px rgba(255, 214, 10, 0.45);
+ box-shadow: 0 0 42px rgb(var(--accent-rgb) / 0.45);
}
}
@@ -1072,8 +1197,8 @@
.uw-hatch {
background-image: repeating-linear-gradient(
-45deg,
- rgba(255, 255, 255, 0.14) 0px,
- rgba(255, 255, 255, 0.14) 2px,
+ rgb(var(--sheen-rgb) / 0.14) 0px,
+ rgb(var(--sheen-rgb) / 0.14) 2px,
transparent 2px,
transparent 6px
);
@@ -1096,18 +1221,24 @@
* marks the centre of gravity, the vignette pulls the eye off the edges.
*/
.uw-stage {
- background-color: hsl(var(--background));
+ background-color: hsl(var(--stage-bg));
background-image:
- linear-gradient(rgba(255, 214, 10, 0.028) 1px, transparent 1px),
- linear-gradient(90deg, rgba(255, 214, 10, 0.028) 1px, transparent 1px);
+ linear-gradient(rgb(var(--accent-rgb) / 0.028) 1px, transparent 1px),
+ linear-gradient(90deg, rgb(var(--accent-rgb) / 0.028) 1px, transparent 1px);
background-size: 48px 48px;
}
+ :root:not(.dark) .uw-stage {
+ background-image:
+ linear-gradient(rgb(var(--accent-rgb) / 0.07) 1px, transparent 1px),
+ linear-gradient(90deg, rgb(var(--accent-rgb) / 0.07) 1px, transparent 1px);
+ }
+
.uw-stage-glow {
background: radial-gradient(
circle at 50% 46%,
- rgba(255, 214, 10, 0.13) 0%,
- rgba(255, 214, 10, 0.04) 34%,
+ rgb(var(--accent-rgb) / 0.13) 0%,
+ rgb(var(--accent-rgb) / 0.04) 34%,
transparent 66%
);
filter: blur(46px);
@@ -1117,7 +1248,7 @@
background: radial-gradient(
ellipse at 50% 50%,
transparent 42%,
- rgba(0, 0, 0, 0.5) 100%
+ rgb(var(--stage-vignette-rgb) / var(--stage-vignette-strength)) 100%
);
}
@@ -1128,25 +1259,38 @@
* plain CSS: no textures to download, no extra draw calls, nothing for the
* GPU to carry. Three layers, and each one earns its place —
*
- * - a deep blue-black wash off centre, so the frame is a volume rather
- * than a flat black rectangle;
+ * - a deep wash off centre, so the frame is a volume rather than a flat
+ * rectangle;
* - two very faint dot fields at different sizes, which is what gives the
* orbiting network something to move AGAINST. Without them a slow
* rotation is nearly invisible: the nodes shift, but with no fixed
* reference the eye reads it as drift rather than depth.
* - a vignette that pulls the attention back to the middle.
+ *
+ * Light mode keeps all three and swaps the material: pale sky instead of
+ * deep space, ink-dark specks instead of white ones. The alternative —
+ * leaving the space black on a paper-white app — punches a hole in the
+ * window, which is the same mistake as a #000 terminal in a #12141a shell.
*/
.wiki-space {
- background-color: #05070c;
+ background-color: hsl(var(--stage-bg));
background-image:
radial-gradient(
ellipse 120% 90% at 50% 42%,
- rgba(40, 78, 140, 0.22) 0%,
- rgba(14, 24, 44, 0.5) 45%,
+ rgb(var(--stage-wash-rgb) / var(--stage-wash-strength)) 0%,
+ rgb(var(--stage-wash-rgb) / calc(var(--stage-wash-strength) * 0.55)) 45%,
transparent 78%
),
- radial-gradient(circle at 18% 24%, rgba(255, 255, 255, 0.5) 0.6px, transparent 0.7px),
- radial-gradient(circle at 72% 68%, rgba(255, 255, 255, 0.35) 0.5px, transparent 0.6px);
+ radial-gradient(
+ circle at 18% 24%,
+ rgb(var(--stage-dot-rgb) / var(--stage-dot-strong)) 0.6px,
+ transparent 0.7px
+ ),
+ radial-gradient(
+ circle at 72% 68%,
+ rgb(var(--stage-dot-rgb) / var(--stage-dot-soft)) 0.5px,
+ transparent 0.6px
+ );
background-size: 100% 100%, 190px 190px, 97px 97px;
}
@@ -1154,7 +1298,7 @@
background: radial-gradient(
ellipse at 50% 50%,
transparent 38%,
- rgba(0, 0, 0, 0.62) 100%
+ rgb(var(--stage-vignette-rgb) / var(--stage-vignette-strength)) 100%
);
}
@@ -1162,7 +1306,7 @@
Glass rather than a solid card: the map has to stay visible underneath,
or the controls become a second letterbox. */
.uw-stage-pill {
- background: rgba(10, 10, 10, 0.66);
+ background: rgb(var(--shell-rgb) / 0.66);
border: 1px solid hsl(var(--border));
backdrop-filter: blur(10px);
}
diff --git a/jarvis/ui/web/frontend/src/views/settings/AppSettingsGroup.tsx b/jarvis/ui/web/frontend/src/views/settings/AppSettingsGroup.tsx
index 7c29ad16d8..1ad925bc45 100644
--- a/jarvis/ui/web/frontend/src/views/settings/AppSettingsGroup.tsx
+++ b/jarvis/ui/web/frontend/src/views/settings/AppSettingsGroup.tsx
@@ -1,7 +1,8 @@
import { useState } from "react";
-import { Power, Zap } from "lucide-react";
+import { Monitor, Moon, Power, Sun, Zap } from "lucide-react";
import { Switch } from "@/components/ui/switch";
import { useAutostart } from "@/hooks/useAutostart";
+import { useTheme, type ThemePreference } from "@/hooks/useTheme";
import { useEventStore } from "@/store/events";
import { useT } from "@/i18n";
@@ -26,11 +27,92 @@ export function AppSettingsGroup() {
<h3 className="font-display text-xs font-semibold uppercase tracking-wide text-muted-foreground">
{t("settings_view.app_settings_group_title")}
</h3>
+ <AppearanceRow />
<AutostartRow />
</div>
);
}
+const THEME_OPTIONS: ReadonlyArray<{
+ value: ThemePreference;
+ icon: typeof Sun;
+ labelKey: string;
+}> = [
+ { value: "dark", icon: Moon, labelKey: "settings_view.appearance.dark" },
+ { value: "light", icon: Sun, labelKey: "settings_view.appearance.light" },
+ { value: "system", icon: Monitor, labelKey: "settings_view.appearance.system" },
+];
+
+/**
+ * Colour theme picker — three exclusive choices rather than a dark/light switch,
+ * because "follow the system" is a third state a toggle cannot express.
+ *
+ * The repaint is instant and local (ThemeProvider writes the class on <html>);
+ * the PUT that persists it to ``[ui] theme`` runs in the background. So the
+ * control never feels like it is waiting on the network, and a failed write
+ * costs the user only the persistence, not the switch.
+ */
+function AppearanceRow() {
+ const t = useT();
+ const { preference, theme, setPreference } = useTheme();
+
+ return (
+ <div className="rounded-lg border border-border bg-card/60 p-4">
+ <div className="flex items-start gap-3">
+ {theme === "dark" ? (
+ <Moon className="mt-0.5 h-4 w-4 shrink-0 text-primary" />
+ ) : (
+ <Sun className="mt-0.5 h-4 w-4 shrink-0 text-primary" />
+ )}
+ <div className="min-w-0 flex-1">
+ <div className="flex flex-wrap items-center justify-between gap-3">
+ <h4 className="font-medium">{t("settings_view.appearance.title")}</h4>
+ <div
+ role="radiogroup"
+ aria-label={t("settings_view.appearance.title")}
+ className="inline-flex rounded-lg border border-border bg-background/60 p-0.5"
+ >
+ {THEME_OPTIONS.map(({ value, icon: Icon, labelKey }) => {
+ const active = preference === value;
+ return (
+ <button
+ key={value}
+ type="button"
+ role="radio"
+ aria-checked={active}
+ onClick={() => setPreference(value)}
+ className={
+ "inline-flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors " +
+ (active
+ ? "bg-primary text-primary-foreground"
+ : "text-muted-foreground hover:bg-secondary hover:text-foreground")
+ }
+ >
+ <Icon className="h-3.5 w-3.5" />
+ {t(labelKey)}
+ </button>
+ );
+ })}
+ </div>
+ </div>
+ <p className="mt-0.5 text-xs text-muted-foreground">
+ {t("settings_view.appearance.description")}
+ </p>
+ {preference === "system" && (
+ <p className="mt-2 text-xs text-muted-foreground">
+ {t(
+ theme === "dark"
+ ? "settings_view.appearance.system_now_dark"
+ : "settings_view.appearance.system_now_light",
+ )}
+ </p>
+ )}
+ </div>
+ </div>
+ </div>
+ );
+}
+
/**
* Label + description on the left, a toggle on the right (grouped-card layout). The
* switch reflects the backend's authoritative ``enabled`` once GET resolves and
diff --git a/jarvis/ui/web/server.py b/jarvis/ui/web/server.py
index 903672470e..6346c0c75e 100644
--- a/jarvis/ui/web/server.py
+++ b/jarvis/ui/web/server.py
@@ -1961,17 +1961,40 @@ class WebServer:
@staticmethod
def _spa_placeholder_response() -> HTMLResponse:
+ # This page has no bundle behind it, so it carries its own theme. It is
+ # served INSIDE the native window, whose ground was already painted from
+ # [ui] theme — a hardcoded dark page here would be a black rectangle in
+ # a paper-white frame for the whole rebuild.
+ from jarvis.ui.theme import (
+ HOLDING_PAGE_FOREGROUND,
+ HOLDING_PAGE_MUTED,
+ WINDOW_BACKGROUND,
+ configured_theme,
+ resolve_theme,
+ )
+
+ try:
+ from jarvis.core.config import load_config
+
+ theme = resolve_theme(configured_theme(load_config()))
+ except Exception: # noqa: BLE001 — a holding page never fails on config
+ theme = "dark"
+
+ bg = WINDOW_BACKGROUND[theme]
+ fg = HOLDING_PAGE_FOREGROUND[theme]
+ muted = HOLDING_PAGE_MUTED[theme]
body = (
"<!doctype html><html lang=\"en\"><head>"
"<meta charset=\"utf-8\">"
"<title>Jarvis</title>"
"<meta http-equiv=\"refresh\" content=\"2\">"
- "<style>html,body{margin:0;height:100%;background:#0a0e14;"
- "color:#e6e6e6;font-family:ui-sans-serif,system-ui,sans-serif;"
+ f"<meta name=\"color-scheme\" content=\"{theme}\">"
+ f"<style>html,body{{margin:0;height:100%;background:{bg};"
+ f"color:{fg};font-family:ui-sans-serif,system-ui,sans-serif;"
"display:flex;align-items:center;justify-content:center}"
"main{text-align:center;max-width:480px;padding:24px}"
"h1{font-weight:500;font-size:18px;margin:0 0 12px}"
- "p{margin:0;color:#9aa3ad;font-size:14px;line-height:1.5}</style>"
+ f"p{{margin:0;color:{muted};font-size:14px;line-height:1.5}}</style>"
"</head><body><main>"
"<h1>Jarvis is starting…</h1>"
"<p>The frontend is currently being built or reloaded. "
diff --git a/jarvis/ui/web/settings_routes.py b/jarvis/ui/web/settings_routes.py
index 530ceffe24..eabcf288f8 100644
--- a/jarvis/ui/web/settings_routes.py
+++ b/jarvis/ui/web/settings_routes.py
@@ -545,6 +545,90 @@ async def put_ui_language(body: UiLanguageBody, request: Request) -> dict[str, o
return {"ok": True, "language": lang, "persisted": persisted}
+# ----------------------------------------------------------------------
+# Appearance — the app's colour theme.
+#
+# Lives in the backend rather than only in the browser store for three reasons,
+# all of which the desktop app hits in practice: the native window frame is
+# painted from config BEFORE the web view loads anything (a light app inside a
+# black frame is visible for the whole boot), the choice must survive a cleared
+# web store, and every user-facing action in this project ships as a REST route
+# so it becomes a `jarvis api settings ...` command (CLAUDE.md §5, CLI-first).
+#
+# "system" is stored as intent, not as a resolved value: the frontend re-reads
+# the OS preference live, so flipping the OS theme flips the app with it.
+# ----------------------------------------------------------------------
+
+_UI_THEMES: tuple[str, ...] = ("dark", "light", "system")
+
+
+class AppearanceBody(BaseModel):
+ theme: str = Field(..., min_length=1, description="dark | light | system")
+ persist: bool = Field(default=True, description="Persist as boot default in jarvis.toml")
+
+
+def _current_ui_theme(request: Request) -> str:
+ # Read fresh from disk so a value just written by the Control API is
+ # reflected; fall back to the boot config, then the "dark" default.
+ try:
+ from jarvis.core.config import load_config
+
+ return str(getattr(load_config().ui, "theme", "dark"))
+ except Exception as exc: # noqa: BLE001 — never 500 a settings read
+ log.debug("appearance fresh read failed, using boot config: %s", exc)
+ cfg = getattr(request.app.state, "config", None)
+ return str(getattr(getattr(cfg, "ui", None), "theme", "dark"))
+
+
[email protected]("/appearance")
+async def get_appearance(request: Request) -> dict[str, object]:
+ """The app's colour theme, plus the values this build accepts."""
+ return {"theme": _current_ui_theme(request), "options": list(_UI_THEMES)}
+
+
[email protected]("/appearance")
+async def put_appearance(body: AppearanceBody, request: Request) -> dict[str, object]:
+ """Switch the app's colour theme and persist it as the boot default."""
+ theme = (body.theme or "").strip().lower()
+ if theme not in _UI_THEMES:
+ raise HTTPException(
+ status_code=400,
+ detail=f"Unknown theme {body.theme!r} (allowed: {list(_UI_THEMES)})",
+ )
+
+ persisted = False
+ if body.persist:
+ try:
+ from jarvis.core import config_writer
+ from jarvis.core.config import resolve_config_path
+
+ # Honour JARVIS_CONFIG (cloud-first) so the write lands in the same
+ # file load_config reads — no desktop/VPS split-brain.
+ config_writer.set_ui_theme(theme, path=resolve_config_path())
+ persisted = True
+ except Exception as exc: # noqa: BLE001 — persist is best-effort
+ log.warning("appearance persist failed: %s", exc)
+
+ cfg = getattr(request.app.state, "config", None)
+ if cfg is not None and getattr(cfg, "ui", None) is not None:
+ try:
+ cfg.ui.theme = theme # type: ignore[attr-defined]
+ except Exception as exc: # noqa: BLE001 — frozen model is not an error
+ log.debug("in-memory cfg.ui.theme update skipped: %s", exc)
+
+ # Broadcast so EVERY open frontend repaints live.
+ bus = getattr(request.app.state, "bus", None)
+ if bus is not None:
+ try:
+ from jarvis.core.events import UiThemeChanged
+
+ await bus.publish(UiThemeChanged(theme=theme))
+ except Exception as exc: # noqa: BLE001 — a bus hiccup must not fail the write
+ log.warning("UiThemeChanged publish failed: %s", exc)
+
+ return {"ok": True, "theme": theme, "persisted": persisted}
+
+
# ----------------------------------------------------------------------
# STT recognition language — the language Whisper TRANSCRIBES the user's voice
# into. Distinct from BOTH the UI language (what the user sees) and the reply