From 7dfc09e2d05b1a9f771a54d7a9369ae7b1601129 Mon Sep 17 00:00:00 2001 From: LukeParkerDev <10430890+Hona@users.noreply.github.com> Date: Tue, 19 May 2026 08:15:20 +1000 Subject: [PATCH 1/2] fix(desktop): keep native background in sync --- packages/desktop/src/main/windows.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/desktop/src/main/windows.ts b/packages/desktop/src/main/windows.ts index e1b87cad69..2daa36e917 100644 --- a/packages/desktop/src/main/windows.ts +++ b/packages/desktop/src/main/windows.ts @@ -29,6 +29,7 @@ const titlebarHeight = 40 export function setBackgroundColor(color: string) { backgroundColor = color + BrowserWindow.getAllWindows().forEach((win) => win.setBackgroundColor(color)) } export function getBackgroundColor(): string | undefined { @@ -48,6 +49,11 @@ function tone() { return nativeTheme.shouldUseDarkColors ? "dark" : "light" } +function defaultBackgroundColor() { + // Match OC-2 --background-base so native paints before the renderer theme loads do not flash white. + return tone() === "dark" ? "#101010" : "#f8f8f8" +} + function overlay(theme: Partial = {}, zoom = 1) { const mode = theme.mode ?? tone() return { @@ -89,7 +95,7 @@ export function createMainWindow() { autoHideMenuBar: true, title: "OpenCode", icon: iconPath(), - backgroundColor, + backgroundColor: backgroundColor ?? defaultBackgroundColor(), ...(process.platform === "darwin" ? { titleBarStyle: "hidden" as const, @@ -147,7 +153,7 @@ export function createLoadingWindow() { show: true, autoHideMenuBar: true, icon: iconPath(), - backgroundColor, + backgroundColor: backgroundColor ?? defaultBackgroundColor(), ...(process.platform === "darwin" ? { titleBarStyle: "hidden" as const } : {}), ...(process.platform === "win32" ? { From 9ce806769824635d800695dc4f8108c506f5babd Mon Sep 17 00:00:00 2001 From: LukeParkerDev <10430890+Hona@users.noreply.github.com> Date: Tue, 19 May 2026 08:23:45 +1000 Subject: [PATCH 2/2] refactor(desktop): derive fallback background from theme --- packages/desktop/src/main/windows.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/desktop/src/main/windows.ts b/packages/desktop/src/main/windows.ts index 2daa36e917..ae872be98a 100644 --- a/packages/desktop/src/main/windows.ts +++ b/packages/desktop/src/main/windows.ts @@ -1,8 +1,11 @@ import windowState from "electron-window-state" +import { resolveThemeVariant } from "@opencode-ai/ui/theme/resolve" import { app, BrowserWindow, net, nativeImage, nativeTheme, protocol } from "electron" import { dirname, isAbsolute, join, relative, resolve } from "node:path" import { fileURLToPath, pathToFileURL } from "node:url" import type { TitlebarTheme } from "../preload/types" +import type { DesktopTheme } from "@opencode-ai/ui/theme/types" +import oc2ThemeJson from "../../../ui/src/theme/themes/oc-2.json" const root = dirname(fileURLToPath(import.meta.url)) const rendererRoot = join(root, "../renderer") @@ -11,6 +14,11 @@ const rendererHost = "renderer" const clipboardWritePermission = "clipboard-sanitized-write" const notificationPermission = "notifications" const rendererPermissions = new Set([clipboardWritePermission, notificationPermission]) +const oc2Theme = oc2ThemeJson as DesktopTheme +const oc2Background = { + light: resolveThemeVariant(oc2Theme.light, false)["background-base"], + dark: resolveThemeVariant(oc2Theme.dark, true)["background-base"], +} protocol.registerSchemesAsPrivileged([ { @@ -50,8 +58,7 @@ function tone() { } function defaultBackgroundColor() { - // Match OC-2 --background-base so native paints before the renderer theme loads do not flash white. - return tone() === "dark" ? "#101010" : "#f8f8f8" + return oc2Background[tone()] } function overlay(theme: Partial = {}, zoom = 1) {