fix(desktop): seed full cached theme vars in boot script#1669
fix(desktop): seed full cached theme vars in boot script#1669klopez4212 wants to merge 1 commit into
Conversation
The cold-boot inline script in index.html applied only the cached --background and the light/dark class before React mounts. The restored setup loading gate's grainient reads other theme vars too (--chart-5, --chart-3, --chart-2, --primary, --foreground), so a cached non-Latte theme (houston/buzz/custom) painted the splash grainient from the static Catppuccin :root values until ThemeProvider.applyCachedVars() ran on mount — a brief wrong-colored splash. Seed the full cached vars map on documentElement synchronously, mirroring ThemeProvider.applyCachedVars(), so the pre-React paint matches the themed gate for any cached theme. Follow-up to #1631 review.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 92caf40966
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| vars = parsed.vars; | ||
| if (vars) { | ||
| for (key in vars) { | ||
| if (Object.hasOwn(vars, key)) { |
There was a problem hiding this comment.
Avoid Object.hasOwn in the untranspiled boot script
In WebViews that only provide the ES2020 baseline, this throws because Object.hasOwn is ES2022, and this classic inline script is not transpiled by the desktop build. When a user has cached theme vars on one of those WebViews, the throw is caught before any cached vars, background color, or light/dark class are applied, so the cold-boot FOUC this patch is meant to fix comes back. Use an ES2020-safe check such as Object.prototype.hasOwnProperty.call(vars, key) or iterate Object.entries(vars) instead.
Useful? React with 👍 / 👎.
What
Follow-up to #1631. The cold-boot inline script in
desktop/index.htmlapplied only the cached--backgroundand the light/dark class before React mounts. But the restored setup loading gate's grainient reads several other theme vars —--chart-5,--chart-3,--chart-2,--primary,--foreground(desktop/src/shared/styles/globals/animations.css,.buzz-setup-loading-shell/.buzz-setup-grainient__wash).So with a cached non-Latte theme (
houston/buzz/custom), the pre-React paint resolved those vars from the static Catppuccin:rootvalues intheme.css, briefly painting a wrong-colored splash grainient untilThemeProvider.applyCachedVars()ran on mount.Fix
Seed the full cached
varsmap ondocumentElementsynchronously in the boot script, mirroringThemeProvider.applyCachedVars()(desktop/src/shared/theme/ThemeProvider.tsx:209-230). Now the pre-React paint matches the themed gate for any cached theme, not just the default.Addresses the last open review thread on #1631.
Testing
check:px-textgreen;index.htmlis biome-format-ignored.just ci'sdesktop-tauri-clippycurrently fails onmainwith pre-existing unused-import/dead-code errors inagent_settings.rsandarchive/store.rs(last touched by fix(agents): surface provider errors structurally instead of raw dumps #1653/fix(desktop): scope observer feed by channel and add session-boundary dividers #1634) — unrelated to this one-file frontend change.