# fix\(web\): keep environment themes on reload · PR \#23861 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/23861)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: open

Source repository: Unavailable fork

Source branch: fix/theme-flash-on-reload

Target branch: main

Head commit: 005ad22101207e347e5b8c91576b77de8cf19996

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/23861)

[Commits](https://git.cafe/pingdotgg/t3code/pull/23861/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/23861/diffs?format=markdown)

## Description

---

## Problem

With an environment theme selected (a theme file in `~/.t3/userdata/themes` that the server publishes), every reload paints the stock theme first: stock black or white, with the blue accent and sidebar header, until the server connects and the real theme replaces it. It happens in light and dark mode, and is most visible in dark.

## Change

Environment themes only arrive from the server after the app connects, and the client never stored them, so the boot script in `index.html` had nothing to paint. After connecting, a theme list that hadn't arrived yet was also treated as empty for a moment.

The web app now caches the server's themes in localStorage, the same way custom themes are already stored for boot. The boot script and the first render paint from that cache. In the server config projection, `undefined` now means "not received yet" and `[]` means "no themes", so the cache is only replaced once the server's theme update arrives. Deleting the last theme still clears it.

## Scope and approval

Small fix for an obvious bug, extending the existing custom-theme boot storage. No new settings.

## Verification

- New `themeBoot.test.ts` case fails without the fix. Affected tests pass (63), and `vp run check:changed` passes.
- macOS desktop app: reloads in light, dark and System mode paint the environment theme from the first frame.
- Switching environments, browser build: a different palette under the same theme id replaces the cached one, an environment with no themes empties the cache, and switching back restores the theme.

Reload in the desktop app, dark mode on the left and light mode on the right, both clips starting at the reload.

Before:

<img src="https://raw.githubusercontent.com/Claudesaul/t3code/pr-assets/theme-flash/before.gif?v=2" width="100%">

After:

<img src="https://raw.githubusercontent.com/Claudesaul/t3code/pr-assets/theme-flash/after.gif?v=2" width="100%">

Model: Claude Opus 5.5, reviewed by GPT-6.1-Sol. Harness: Claude Code through T3 Code.

