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

Closed opened this in answer to
Closed without merging

Changing the theme now repaints the page background right away instead of after a refresh. This is the fix from #1241 again: that pull was closed without merging while its check was still queued, and main still has the bug. The branch now has current main merged in, with no conflicts.

Notes

stopped closed without shipping deploy 44263bd

opened this

Changing the theme now repaints the page background right away instead of after a refresh. This is the fix from #1241 again: that pull was closed without merging while its check was still queued, and main still has the bug. The branch now has current main merged in, with no conflicts.

The small style in the page head that paints the background before the stylesheet loads (bootCss) used to depend on the theme the server rendered with. It painted html and body either from the OS setting or from that theme. The stylesheet colours html but not body, so when the theme menu (src/web/client.ts:1250) changed data-theme on the root, the body kept the old colour until the next full render.

  • src/design/themes.ts: bootCss is now one constant, the same on every page. It keeps the light/dark pair that follows the OS. After that pair it adds one rule per theme: html[data-theme="x"],html[data-theme="x"] body{background-color:…;color-scheme:…}. Each of these rules outranks the OS pair, so switching to any theme, or back to System, repaints at once. The style grows from about 150 bytes to 739.
  • src/web/layout.ts: writes the constant. It is the only file that writes a boot style. The studio and run pages the issue names render through this layout, so they are covered too.
  • test/themes.test.ts (new): checks that the OS pair comes first and that each theme's rule comes after the dark rule with the right colour and color-scheme. It also checks that every other rule depends on data-theme. It fails on the old code.
  • test/web.test.ts: two assertions changed because they pinned the old style. A page with no theme must now carry the OS pair plus every theme rule. The Midnight page must carry Midnight's rule and exactly the same style as a page with no theme.

test/themes.test.ts and the type check pass here. test/web.test.ts can't run in this sandbox, because it refuses to open the Unix socket the test server needs. So the two changed assertions in it have not been run yet; the forge check will be their first run.

I did not switch the background to the stylesheet's CSS variables: the boot style has to paint before the stylesheet arrives, so it can't use them.

To try it: open the preview and pick Midnight, then Paper, then System from the theme menu. The background should change with each pick, with no refresh.

🤖 Generated with Claude Code

Closes #1240

Closes #1240

commented

Parked by the crew: the check failed ("themes > no cookie means system: no data-theme, switcher present") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs