fix(7606): sync theme-color meta with client-side dark-mode switch#7690
fix(7606): sync theme-color meta with client-side dark-mode switch#7690JohnMcLear merged 2 commits intodevelopfrom
Conversation
PR #7636 emits <meta name="theme-color"> server-side from settings.skinVariants. That covers operators who hard-code a dark toolbar in settings.json, but not the runtime path: pad.ts auto-flips the toolbar to super-dark when enableDarkMode is on, the browser reports prefers-color-scheme: dark, and no localStorage white-mode override is set, plus the user can flip it via #options-darkmode. Both paths run skinVariants.updateSkinVariantsClasses(), which until now never touched the meta — so dark-mode users kept the light #ffffff baseline and saw a white address bar above a dark toolbar (stffen on #7606 after 2.7.3). Push the toolbar-color lookup into updateSkinVariantsClasses so the meta tracks every class change: the auto-switch on init, the user toggle, and the skinVariants builder. Mirrors the CSS-source-order table from src/node/utils/SkinColors.ts (last matching *-toolbar token wins). When no meta is present (non-colibris skin, server omits it) the helper is a no-op. Adds Playwright coverage for both paths under colorScheme: 'light' (manual toggle) and 'dark' (auto-switch on dark-OS clients — the case stffen reported). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one. |
Review Summary by QodoSync theme-color meta with client-side dark-mode toolbar changes
WalkthroughsDescription• Sync <meta name="theme-color"> with client-side dark-mode toolbar changes • Add updateThemeColorMeta() function to track toolbar color class updates • Mirror CSS source-order logic from SkinColors.ts for consistent color resolution • Add Playwright tests covering manual toggle and auto-switch scenarios Diagramflowchart LR
A["Dark-mode toggle<br/>or auto-switch"] -->|calls| B["updateSkinVariantsClasses()"]
B -->|now calls| C["updateThemeColorMeta()"]
C -->|updates| D["meta[name=theme-color]"]
D -->|reflects| E["Toolbar color<br/>in address bar"]
File Changes1. src/static/js/skin_variants.ts
|
Code Review by Qodo
1.
|
(1) Bug — duplicated toolbar→color table: extract the CSS-source-order mapping and the default-color constant into src/static/js/skin_toolbar_colors, re-imported by both src/node/utils/SkinColors.ts (server, EJS template helper) and src/static/js/skin_variants.ts (client, runtime updates). Lives under static/js so the browser bundle can resolve it; server-side imports of static/js modules already exist (Changeset, AttributeMap, ImportHtml, hooks). One source of truth means a future palette change can no longer silently desync the server-rendered baseline meta from the client updates, which was the exact regression that brought us here. (2) Rule violation — 4-space continuation indentation in the new Playwright spec: re-indent the themeColor helper and the multiline test(...) call to the repo's 2-space rule (.editorconfig). Existing backend coverage (configuredToolbarColor unit tests + the specialpages server-render checks for both pad and timeslider) still passes against the refactored helper, so it's regression-locked end to end. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Actioned Qodo's two findings in
|
Summary
settings.skinVariants, but the toolbar can be flipped tosuper-dark-toolbarclient-side in three places —pad.ts:712auto-switch (enableDarkMode+prefers-color-scheme: dark+ no localStorage white-mode override), the#options-darkmodetoggle inpad_editor.ts, and the#skinvariantsbuilderadmin tool. All three callskinVariants.updateSkinVariantsClasses(), which until now never touched the meta.updateSkinVariantsClassesso the meta tracks every class change. Mirrors the CSS-source-order table fromsrc/node/utils/SkinColors.tsso the same "last matching*-toolbartoken wins" rule the server uses also applies on the client. No-op when the server didn't emit a meta (non-colibris skins).Test plan
tests/frontend-new/specs/theme_color_dark_mode.spec.tscovers both paths:colorScheme: 'light'— manual toggle via#options-darkmodeflips meta#ffffff→#485365→#ffffff.colorScheme: 'dark'— auto-switch on dark-OS clients lands on#485365after init (the case stffen reported).🤖 Generated with Claude Code