From 633ab58e9ba19b0c3abd95c00f7b5d336a4f6c26 Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 13 Nov 2026 13:57:14 +0800 Subject: [PATCH] gui: every page says it draws a dark theme, so browsers don't repaint it (xjp on X) Chrome's Auto Dark Theme and Safari's Adaptive Dark Mode (Safari 27.3 beta) repaint pages that don't declare dark support. magpie's GUI draws both themes itself but never said so, so a browser's light magpie was repainted. WebKit's post (webkit.org/blog/18541) and Chrome's (developer.chrome.com/blog/auto-dark-theme) say: `color-scheme: light dark` (CSS on :root or the meta) is skipped; `light only` opts an element out (Safari 27.3 beta 1 doesn't honour `only` yet). - index.html: . - app.css: :root takes `light dark` always (the signal browsers read); body takes the theme shown: Settings' Light is `light only`, Dark is `dark`, System follows the root. Native controls, scrollbars and a plugin's frame follow the theme shown. - pagebridge.js: a plugin page's light frame is `light only`. - The other pages magpie serves (magpie web's sign-in, a sign-in's end page, an MCP sign-in's end page, a plugin service's "starting" page) declare `light dark`; the MCP page drops its fixed #222 text so it reads on a dark canvas. keypage.html and the extension popup already did; site/ pages already do. Tests: color-scheme.test.cjs (chromium + webkit; system/light/dark on a dark OS: meta, root and body schemes), TestPagesDeclareBothColorSchemes, TestSignInPageDeclaresBothColorSchemes, TestPageDeclaresBothColorSchemes. Run (mote, before the rebase on origin/main 6bcdc6468): the new GUI file 6/6 in chromium + webkit; checkbox-look 8/8, plugin-page, plugin-panels and plugin-page-idle 14/14; go test of the new tests and -run "PluginPage|Page|Bridge|SignIn" in internal/gui, internal/provider, internal/mcpauth ok; go vet darwin, linux (nogui), windows ok; gofmt clean. api-key-theme is red 6/6 here and on origin/main 2f2a0afa5 alone (#6444, a #lanList selector matches nothing). At the pushed head (after the rebase): color-scheme.test.cjs 6/6 and -run "ColorScheme|Budget" in the three packages ok. Broken by hand: the four new tests on origin/main's code (2f2a0afa5) are all red (GUI 0/6, three Go tests FAIL). Not tried: Safari 27.3 beta's Adaptive Dark Mode and Chrome's Auto Dark Theme themselves (no beta device here); the real app's windows (Wails WebKit, WebView2, WebKitGTK) with the root's new color-scheme; the full GUI suite. --- internal/gui/assets/app.css | 9 ++++ internal/gui/assets/index.html | 4 ++ internal/gui/color_scheme_test.go | 34 +++++++++++++++ internal/gui/pagebridge.js | 6 ++- internal/gui/pageservice.go | 2 +- internal/gui/tests/color-scheme.test.cjs | 41 +++++++++++++++++++ internal/gui/web.go | 2 +- internal/mcpauth/mcpauth.go | 2 +- internal/mcpauth/page_color_scheme_test.go | 21 ++++++++++ internal/provider/signin.go | 3 +- internal/provider/signin_color_scheme_test.go | 17 ++++++++ 11 files changed, 135 insertions(+), 6 deletions(-) create mode 100644 internal/gui/color_scheme_test.go create mode 100644 internal/gui/tests/color-scheme.test.cjs create mode 100644 internal/mcpauth/page_color_scheme_test.go create mode 100644 internal/provider/signin_color_scheme_test.go diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.css index 23e716f1e..506dbb391 100644 --- a/internal/gui/assets/app.css +++ b/internal/gui/assets/app.css @@ -94,6 +94,15 @@ --tk-s: #98d8a4; --tk-k: #c4b5fd; --tk-f: #93c5fd; --tk-n: #f2b544; --tk-v: #67e8f9; --tk-o: #f0abfc; --tk-c: #8b8b94; --c1: #a5b4fc; --c2: #7dd3fc; --c3: #6ee7b7; --c4: #fcd34d; --c5: #f9a8d4; --c6: #c4b5fd; --c7: #94a3b8; } +/* magpie draws both themes itself. The root says so, as index.html's meta + does, so a browser that repaints light pages dark (Chrome's Auto Dark + Theme, Safari's Adaptive Dark Mode) leaves the page alone (xjp on X). + The page under it takes the theme shown, so native controls, scrollbars + and a plugin's frame match it, and a theme chosen in Settings is the + only one: Light stays light on a dark system. */ +:root { color-scheme: light dark; } +:root[data-theme="light"] body { color-scheme: light only; } +:root[data-theme="dark"] body { color-scheme: dark; } /* Okabe–Ito qualitative series (#2073): adjacent series stay apart in hue and lightness in both light and dark themes */ :root[data-colorblind="1"] { diff --git a/internal/gui/assets/index.html b/internal/gui/assets/index.html index eb4e767ad..6cf0ad59e 100644 --- a/internal/gui/assets/index.html +++ b/internal/gui/assets/index.html @@ -3,6 +3,10 @@ + + magpie