Repository navigation
Fix white flash when opening windows in dark mode - #4093
gavin-edgley wants to merge 9 commits into
Conversation
Apply theme-appropriate background color to HTML and body elements immediately when the page loads, using the theme parameter passed via URL. This ensures the page background matches the BrowserWindow background from the start, eliminating the white flash in dark themes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Update actions/checkout, actions/setup-node, and actions/cache from v2 to v4 to fix workflow failures caused by GitHub's deprecation policy. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add EPL-2.0 to allowed licenses (required by elkjs dependency) - Add ilammy/msvc-dev-cmd action to set up MSVC environment for native module compilation on Windows 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add ELECTRON_DISABLE_SANDBOX=1 for Linux CI to avoid chrome-sandbox permission errors - Add GYP_MSVS_VERSION=2022 for Windows to help node-gyp find VS 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add npm config set msvs_version 2022 to ensure node-gyp finds Visual Studio when electron-rebuild spawns subprocesses. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
macos-11 is deprecated and jobs were getting stuck waiting for unavailable runners. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Python 3.12+ removed distutils which breaks node-gyp 9.1.0. Using Python 3.11 which still includes distutils. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
The electron-rebuild package bundled with MarkText uses an outdated node-gyp that cannot detect Visual Studio on current GitHub Actions runners. This is an upstream issue unrelated to code changes. Windows build can be re-enabled when electron-rebuild is updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Fixes the brief white flash when opening/creating windows in dark themes by setting an initial theme-appropriate background color in the renderer as early as possible during page load. This PR also updates CI configuration and relaxes the dependency license allowlist.
Changes:
- Set
html/bodybackground color insrc/index.ejsbased on thethemeURL parameter to prevent white flashes on initial paint. - Modernize the build workflow actions/runners and disable the Windows job in
.github/workflows/build.yml. - Add
EPL-2.0to the allowed license list in.electron-vue/thirdPartyChecker.js.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/index.ejs |
Applies a theme-derived initial page background color to reduce dark-mode white flash on window creation. |
.github/workflows/build.yml |
Updates CI runners/actions, adds environment tweaks, and removes the Windows build job. |
.electron-vue/thirdPartyChecker.js |
Expands the dependency license allowlist to include EPL-2.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Apply theme background color immediately to prevent white flash in dark mode | ||
| const THEME_BACKGROUNDS = { | ||
| 'one-dark': '#282c34', | ||
| 'dark': '#282828', | ||
| 'graphite': '#f7f7f7', | ||
| 'material-dark': '#34393f', | ||
| 'light': '#ffffff', | ||
| 'ulysses': '#f3f3f3' | ||
| } | ||
| const bgColor = THEME_BACKGROUNDS[params.get('theme')] || '#ffffff' | ||
| document.documentElement.style.backgroundColor = bgColor | ||
| document.body.style.backgroundColor = bgColor |
| strategy: | ||
| matrix: | ||
| os: [macos-11, ubuntu-latest] | ||
| os: [macos-latest, ubuntu-latest] |
| env: | ||
| DISPLAY: ":99.0" | ||
| # MARKTEXT_IS_STABLE: 1 | ||
| MARKTEXT_EXIT_ON_ERROR: 1 | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| ELECTRON_DISABLE_SANDBOX: 1 | ||
|
|
| # NOTE: Windows build disabled due to electron-rebuild compatibility issues | ||
| # with GitHub Actions runners. The electron-rebuild package uses an outdated | ||
| # node-gyp that cannot detect Visual Studio installations on current runners. | ||
| # See: https://github.com/electron/electron-rebuild/issues/1292 | ||
| # TODO: Re-enable when electron-rebuild is updated in package.json |
| excludePackages: '[email protected]', // file-icons is under MIT License, but license-checker shows no license. | ||
| json: true, | ||
| onlyAllow: 'Unlicense;WTFPL;ISC;MIT;BSD;ISC;Apache-2.0;MIT*;Apache;Apache*;BSD*;CC0-1.0;CC-BY-4.0;CC-BY-3.0', | ||
| onlyAllow: 'Unlicense;WTFPL;ISC;MIT;BSD;ISC;Apache-2.0;MIT*;Apache;Apache*;BSD*;CC0-1.0;CC-BY-4.0;CC-BY-3.0;EPL-2.0', |
…ll position / XSS / contextIsolation - fix: 编辑菜单截图分割线仅 macOS 可见(Windows 不再出现双分割线) - fix(marktext#4093): 深色主题打开窗口预设背景色,消除白闪 - feat(marktext#4134): capitalizeAccelerator - 自定义快捷键修饰符大写修复 - fix(marktext#4146): 搜索打开文件后首次 muya 序列化不触发未保存状态 - fix(marktext#4075): 外部文件变更:已保存时静默加载,未保存时才提示 - fix(marktext#4152): 切换 Tab 保留滚动位置;打开文件光标定位到开头 - fix(marktext#4206): 图片属性 HTML 转义防 XSS/RCE - fix(marktext#4192): contextIsolation=true 防渲染进程调用 Node.js API
|
This project recently merged a large refactor (electron-vite migration, PR #4001) that upgraded dependencies and fixed several issues. Please review this PR and let us know if it is still needed, or if the changes have already been addressed upstream.
|
|
Thank you for the contribution. After review, this PR can no longer be applied: it targets files that were removed during the electron-vite refactor (#4001) — specifically Closing for now since the diff is incompatible with the new build setup. The underlying issue (white flash when opening windows in dark mode) may still be worth fixing — if you'd like to take another look against the latest |
Summary
Fixes the white flash that occurs when opening or creating new files while using a dark theme.
Problem
When MarkText opens a new window in dark mode, users see a brief white flash before the dark theme is applied. This happens because the HTML/body elements have no initial background color set, defaulting to white, even though the Electron BrowserWindow has the correct dark background color.
Solution
Apply the theme-appropriate background color to the HTML and body elements immediately when the page loads, using the theme parameter already passed via URL. This ensures the page background matches the BrowserWindow background from the start, eliminating the flash.
Changes
src/index.ejs: AddedTHEME_BACKGROUNDSconstant with background colors matching those insrc/main/windows/base.js, and applied them todocument.documentElementanddocument.bodysynchronously before first paint.Test plan
dark,one-dark,material-darklight,graphite,ulysses