Skip to content

fix(desktop): seed full cached theme vars in boot script#1669

Closed
klopez4212 wants to merge 1 commit into
mainfrom
fix/bee-boot-cached-vars
Closed

fix(desktop): seed full cached theme vars in boot script#1669
klopez4212 wants to merge 1 commit into
mainfrom
fix/bee-boot-cached-vars

Conversation

@klopez4212

Copy link
Copy Markdown
Contributor

What

Follow-up to #1631. The cold-boot inline script in desktop/index.html applied only the cached --background and 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 :root values in theme.css, briefly painting a wrong-colored splash grainient until ThemeProvider.applyCachedVars() ran on mount.

Fix

Seed the full cached vars map on documentElement synchronously in the boot script, mirroring ThemeProvider.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

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread desktop/index.html
vars = parsed.vars;
if (vars) {
for (key in vars) {
if (Object.hasOwn(vars, key)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@klopez4212 klopez4212 closed this Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant