Skip to content

fix(ui): apply the saved theme before paint to avoid a light flash - #360

Open
cavidelizade wants to merge 4 commits into
Devlaner:mainfrom
cavidelizade:fix/theme-fouc
Open

cavidelizade wants to merge 4 commits into
Devlaner:mainfrom
cavidelizade:fix/theme-fouc

Conversation

@cavidelizade

Copy link
Copy Markdown
Contributor

Summary

Users with a dark or pink theme saw a flash of the light theme on every page load.

Linked issues

Closes #348

Type of change

  • Bug fix (fix:)

Surface

  • UI (apps/web/)

What changed

index.html hardcoded data-theme="light" and the real theme was only reconciled once React ran (a useLayoutEffect in ThemeContext). Added a small blocking script in the <head> that reads devlane-theme from localStorage, mirrors ThemeContext's values and system fallback, and sets data-theme before the bundle paints. Dropped the hardcoded data-theme="light" since the script now owns it (and light is the attribute-less default).

Test plan

  • npm run build succeeds
  • Manual: with devlane-theme set to dark, a reload paints dark immediately instead of flashing light

Notes

The issue also mentions cross-tab sync via the storage event. Left that out to keep this focused on the flash, happy to add it if you want it here.

AI assistance

  • AI tools were used, tool(s): Claude Code (Opus 4.8), commits carry a Co-Authored-By: trailer

index.html hardcoded data-theme="light" and the real theme was only applied
once React ran, so dark and pink users saw a flash of light on every load. Add
a tiny blocking script in the head that reads devlane-theme from localStorage
(same key, values and system fallback as ThemeContext) and sets data-theme
before the bundle paints.

Closes Devlaner#348

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cavidelizade
cavidelizade requested a review from a team as a code owner July 16, 2026 20:55
@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 31 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f1bdb418-5175-4015-bc75-5868681592ec
Commits

Reviewing files that changed from the base of the PR and between df31029 and 40bfc39.

Files selected for processing: 1
  • apps/web/index.html
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

martian56 and others added 3 commits October 25, 2026 12:13
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.

Flash of light theme on load for dark/pink users

2 participants