Public: anyone can read this; the crew can change it.
Switching the theme no longer repaints the background until a refresh: the boot style paints from the OS, not the choice #1241
Changing the theme now repaints the page background straight away instead of after a refresh. The small inline style in the page head that paints the background before the stylesheet loads (bootCss) painted html and body with literal colors. Those came from the OS setting, or from the theme the server rendered with.
stopped closed without shipping deploy 9e44960
commented
Landed upstream as #32 (0.7.68, building) and live or building there; closing here so the lane is not spent on a copy. The fork takes it with the next update from parent.
Sign in to join this conversation.
new above
offline
Changing the theme now repaints the page background straight away instead of after a refresh. The small inline style in the page head that paints the background before the stylesheet loads (
bootCss) paintedhtmlandbodywith literal colors. Those came from the OS setting, or from the theme the server rendered with. The main stylesheet sets the background onhtmlbut not onbody, so when the theme menu (src/web/client.ts:1250) changeddata-themeon the root, the body kept the old color until a reload.src/design/themes.ts:bootCssis now one constant instead of a function of the server's theme. It keeps the system pair (light, plus a dark rule for when the OS prefers dark), then adds one rule per theme after it, in the formhtml[data-theme="x"],html[data-theme="x"] body{background-color:…;color-scheme:…}. Every page gets the same rules, so switching to any theme, or back to System, is covered without a reload. The style is 739 bytes, up from about 150.src/web/layout.ts: writes the constant. This is the only place that writes a boot style. Studio and board pages are rendered through this layout, so they are fixed too.test/themes.test.ts(new): checks the system pair comes first, that each theme has its rule after the dark rule with the right color andcolor-scheme, and that every other rule depends ondata-theme. It fails on the old code.test/web.test.ts: I changed two existing assertions because they pinned the old style. The page with no theme now has to carry the system pair plus every[data-theme]rule. The midnight page has to carry midnight's rule and the exact same style as a page with no theme.The new unit test and the type check pass here. I could not run
test/web.test.ts,test/board.test.tsortest/studio.test.ts: the sandbox refuses the Unix-socketlistentheir server setup needs. So the two changed assertions have not been run yet; the forge check is the first run of them.I chose not to drive the background through the stylesheet's CSS variables instead. The boot style has to paint before the stylesheet arrives, so it can't depend on those variables.
To try it: open the preview, pick Midnight from the theme menu, then Paper, then System. The background should change with each pick, with no refresh.
🤖 Generated with Claude Code
Closes #1240