Skip to content

Commit 7dfc09e

Browse files
committed
fix(desktop): keep native background in sync
1 parent ce09fc8 commit 7dfc09e

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

packages/desktop/src/main/windows.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const titlebarHeight = 40
2929

3030
export function setBackgroundColor(color: string) {
3131
backgroundColor = color
32+
BrowserWindow.getAllWindows().forEach((win) => win.setBackgroundColor(color))
3233
}
3334

3435
export function getBackgroundColor(): string | undefined {
@@ -48,6 +49,11 @@ function tone() {
4849
return nativeTheme.shouldUseDarkColors ? "dark" : "light"
4950
}
5051

52+
function defaultBackgroundColor() {
53+
// Match OC-2 --background-base so native paints before the renderer theme loads do not flash white.
54+
return tone() === "dark" ? "#101010" : "#f8f8f8"
55+
}
56+
5157
function overlay(theme: Partial<TitlebarTheme> = {}, zoom = 1) {
5258
const mode = theme.mode ?? tone()
5359
return {
@@ -89,7 +95,7 @@ export function createMainWindow() {
8995
autoHideMenuBar: true,
9096
title: "OpenCode",
9197
icon: iconPath(),
92-
backgroundColor,
98+
backgroundColor: backgroundColor ?? defaultBackgroundColor(),
9399
...(process.platform === "darwin"
94100
? {
95101
titleBarStyle: "hidden" as const,
@@ -147,7 +153,7 @@ export function createLoadingWindow() {
147153
show: true,
148154
autoHideMenuBar: true,
149155
icon: iconPath(),
150-
backgroundColor,
156+
backgroundColor: backgroundColor ?? defaultBackgroundColor(),
151157
...(process.platform === "darwin" ? { titleBarStyle: "hidden" as const } : {}),
152158
...(process.platform === "win32"
153159
? {

0 commit comments

Comments
 (0)