Fix white/inverted flash when windows open
Three layers: windows are created hidden and revealed on the webview's first dom-ready (800ms fallback); the bun preload bakes the persisted theme data-attributes so the first paint is already themed; and index.html carries an inline background style covering the pre-stylesheet paint (values mirrored from styles.css tokens). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+15
-4
@@ -14,7 +14,7 @@ import { migrateLegacyDataDir } from "./store/paths";
|
||||
import { SettingsStore } from "./store/settings";
|
||||
import { AppTray } from "./tray";
|
||||
import { TransferEngine } from "./transfers/engine";
|
||||
import { buildPreload } from "./windows";
|
||||
import { buildPreload, showWhenReady } from "./windows";
|
||||
|
||||
const PROD_URL = "views://app/index.html";
|
||||
|
||||
@@ -56,6 +56,11 @@ const events = {
|
||||
const rpc = createAppRPC({ registry, engine, store, settings, edits, contextMenu, events });
|
||||
const url = await getMainViewUrl();
|
||||
|
||||
// Loaded before any window exists: the persisted theme is baked into every
|
||||
// window's preload so the first paint is already themed (no flash). Kept
|
||||
// fresh via the saveSettings flow below.
|
||||
let currentSettings = await settings.load();
|
||||
|
||||
const isMac = process.platform === "darwin";
|
||||
|
||||
const win = new BrowserWindow({
|
||||
@@ -73,16 +78,20 @@ const win = new BrowserWindow({
|
||||
...(isMac
|
||||
? { titleBarStyle: "hiddenInset" as const, trafficLightOffset: { x: 12, y: 13 } }
|
||||
: {}),
|
||||
// lets the UI pick the fused layout before first paint
|
||||
preload: buildPreload("main"),
|
||||
// lets the UI pick the fused layout + theme before first paint
|
||||
preload: buildPreload("main", currentSettings),
|
||||
rpc,
|
||||
// revealed on first dom-ready — avoids the unthemed native flash
|
||||
hidden: true,
|
||||
});
|
||||
showWhenReady(win);
|
||||
|
||||
const editors = new EditorWindows({
|
||||
registry,
|
||||
settings,
|
||||
edits,
|
||||
url,
|
||||
currentSettings: () => currentSettings,
|
||||
mainFrame: () => win.getFrame(),
|
||||
notifyMain: { pathRefresh: (info) => rpc.send.pathRefresh(info) },
|
||||
});
|
||||
@@ -90,6 +99,7 @@ const manager = new ManagerWindow({
|
||||
store,
|
||||
settings,
|
||||
url,
|
||||
currentSettings: () => currentSettings,
|
||||
mainFrame: () => win.getFrame(),
|
||||
notifyMain: {
|
||||
managerState: (info) => rpc.send.managerState(info),
|
||||
@@ -101,6 +111,7 @@ const manager = new ManagerWindow({
|
||||
|
||||
events.openEditor = (ctx) => editors.open(ctx);
|
||||
events.settingsChanged = (s) => {
|
||||
currentSettings = s; // future windows' preloads bake the fresh theme
|
||||
editors.broadcastSettings(s);
|
||||
manager.broadcastSettings(s);
|
||||
};
|
||||
@@ -199,7 +210,7 @@ events.sessionClosed = (info) => {
|
||||
editors.notifySessionClosed(info);
|
||||
};
|
||||
events.connectionsChanged = () => void applyApplicationMenu(store);
|
||||
void settings.load().then((s) => engine.setConcurrency(effectiveConcurrency(s)));
|
||||
engine.setConcurrency(effectiveConcurrency(currentSettings));
|
||||
|
||||
void applyApplicationMenu(store);
|
||||
ApplicationMenu.on("application-menu-clicked", (event) => {
|
||||
|
||||
Reference in New Issue
Block a user