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 #1381

Closed opened this in answer to
Closed without merging

Switching the theme now repaints the page background straight away, with no refresh. I couldn't run test/web.test.ts or test/web-ui.test.ts here. This sandbox blocks the unix socket the test servers listen on, so both fail at startup, and web-ui fails the same way without my change.

Notes

stopped closed without shipping deploy 0b4e084

opened this

Switching the theme now repaints the page background straight away, with no refresh. I couldn't run test/web.test.ts or test/web-ui.test.ts here. This sandbox blocks the unix socket the test servers listen on, so both fail at startup, and web-ui fails the same way without my change. The new socket-free test passes. tsc didn't run either, because it can't find the bun types in this sandbox.

The fix. The boot style in src/design/themes.ts (bootCss) now ends with one rule per theme, written after the OS media rule:

html[data-theme="X"],html[data-theme="X"] body{background-color:…;color-scheme:…}

The theme menu already sets data-theme on the root, so those rules now take effect on the live page. Choosing "system" removes the attribute, and the OS pair applies again. The colors still come from the same THEMES table, so there are no new literals to keep in sync.

Which pages. bootCss is the only place a boot style is written, and src/web/layout.ts is its only caller. studio/app.ts and studio/run.ts have no boot style of their own.

Why #1311 failed. The old test asserted the page contains no data-theme= at all. That is no longer true, because the boot style mentions it. I changed that test to check that the <html> tag carries no data-theme attribute, which is what it was meant to check. I also updated the boot-style regexes in test/web.test.ts to match, and added a loop there that checks every theme has its rule.

Tests. The new test/boot-css.test.ts needs no server. It checks that a page with no choice paints the OS pair and then has every [data-theme] rule after the media rule. It also checks that a chosen theme paints its own ground and still has all the rules.

Left out. I didn't change client.ts. The switcher already does the right thing, and the CSS was the gap.

To try it. Open any page, pick a different theme from the menu, and the background changes at once. Then pick "system" and it follows the OS again.

🤖 Generated with Claude Code

Closes #1240

commented

Parked by the crew: the check failed ("themes > system clears the cookie; junk never sticks") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs