Skip to content

fix(desktop): eliminate white flash on window resize#1380

Open
timmske wants to merge 1 commit intopingdotgg:mainfrom
timmske:fix/white-flash-on-resize
Open

fix(desktop): eliminate white flash on window resize#1380
timmske wants to merge 1 commit intopingdotgg:mainfrom
timmske:fix/white-flash-on-resize

Conversation

@timmske
Copy link

@timmske timmske commented Mar 24, 2026

What changed

Set BrowserWindow.backgroundColor to match the active theme so Electron paints the correct surface 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

Why

The BrowserWindow had no backgroundColor set. 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

  • PR is small and focused (30 lines, 2 files)
  • Changes and rationale clearly explained
  • bun fmt passes
  • bun lint passes (0 warnings, 0 errors)
  • bun typecheck passes (7/7)
  • bun run test — server test failures are pre-existing on main

Closes #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.backgroundColor from nativeTheme.shouldUseDarkColors and updates all open windows via setBackgroundColor when desktop:set-theme runs.

The web index.html adds a synchronous <head> script to apply the stored/system theme background (and dark class) 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

  • Adds an inline script in apps/web/index.html that sets document.documentElement.style.backgroundColor and the dark class synchronously before first paint, based on localStorage or prefers-color-scheme.
  • Sets backgroundColor on BrowserWindow at creation time via a new themeBackgroundColor() helper, so the native window matches the current theme before content renders.
  • Updates the SET_THEME_CHANNEL IPC handler to call setBackgroundColor on all existing windows when the theme changes.
  • Dark and light background colors (#161616 / #ffffff) are defined as constants aligned with the app's CSS tokens.

Macroscope summarized 7225859.

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
@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 99254885-da26-46a2-89ea-ff9ed2fe6c9e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@github-actions github-actions bot added size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: when the screen is resized in t3 code, a white flask appears

1 participant