fix(desktop): eliminate white flash on window resize#1380
Open
timmske wants to merge 1 commit intopingdotgg:mainfrom
Open
fix(desktop): eliminate white flash on window resize#1380timmske wants to merge 1 commit intopingdotgg:mainfrom
timmske wants to merge 1 commit intopingdotgg:mainfrom
Conversation
Set BrowserWindow.backgroundColor to match the active theme so Electron paints the correct color while the renderer catches up during resize. - Read nativeTheme.shouldUseDarkColors at window creation to pick the initial background (#161616 dark, #ffffff light). - Update all windows via setBackgroundColor when the user switches themes. - Add a synchronous <script> in index.html <head> that applies the stored theme background and .dark class before first paint, preventing the flash on initial page load as well. Closes pingdotgg#1349
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Set
BrowserWindow.backgroundColorto match the active theme so Electron paints the correct surface color while the renderer catches up during resize.nativeTheme.shouldUseDarkColorsat window creation to pick the initial background (#161616dark,#fffffflight)setBackgroundColorwhen the user switches themes<script>inindex.html<head>that applies the stored theme background and.darkclass before first paintWhy
The
BrowserWindowhad nobackgroundColorset. During resize Electron briefly exposes unpainted native window area, which defaults to white — producing the flash reported in #1349.Screenshots
Before: white flash visible during resize (see video in #1349)
After: background matches theme, no flash during resize
Checklist
bun fmtpassesbun lintpasses (0 warnings, 0 errors)bun typecheckpasses (7/7)bun run test— server test failures are pre-existing onmainCloses #1349
Note
Low Risk
Low risk UI polish: only adjusts window/background color behavior on theme change and initial load, with minimal impact beyond theming/paint timing.
Overview
Prevents white flashing by setting the native window background to match the current theme.
Electron now initializes
BrowserWindow.backgroundColorfromnativeTheme.shouldUseDarkColorsand updates all open windows viasetBackgroundColorwhendesktop:set-themeruns.The web
index.htmladds a synchronous<head>script to apply the stored/system theme background (anddarkclass) before first paint.Written by Cursor Bugbot for commit 7225859. This will update automatically on new commits. Configure here.
Note
Fix white flash on window resize and initial load in desktop app
apps/web/index.htmlthat setsdocument.documentElement.style.backgroundColorand thedarkclass synchronously before first paint, based onlocalStorageorprefers-color-scheme.backgroundColoronBrowserWindowat creation time via a newthemeBackgroundColor()helper, so the native window matches the current theme before content renders.SET_THEME_CHANNELIPC handler to callsetBackgroundColoron all existing windows when the theme changes.#161616/#ffffff) are defined as constants aligned with the app's CSS tokens.Macroscope summarized 7225859.