diff --git a/packages/desktop/src/main/windows.ts b/packages/desktop/src/main/windows.ts index 4e6884f94d..df586add3e 100644 --- a/packages/desktop/src/main/windows.ts +++ b/packages/desktop/src/main/windows.ts @@ -3,6 +3,9 @@ import { app, BrowserWindow, dialog, net, nativeImage, nativeTheme, protocol } f 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 { resolveThemeVariant } from "@opencode-ai/ui/theme/resolve" +import oc2ThemeJson from "../../../ui/src/theme/themes/oc-2.json" import { PINCH_ZOOM_ENABLED_KEY } from "./constants" import { exportDebugLogs, write as writeLog } from "./logging" import { getStore } from "./store" @@ -17,6 +20,11 @@ const notificationPermission = "notifications" const rendererPermissions = new Set([clipboardWritePermission, notificationPermission]) const documentPolicyHeader = "Document-Policy" const jsCallStacksDocumentPolicy = "include-js-call-stacks-in-crash-reports" +const oc2Theme = oc2ThemeJson as DesktopTheme +const oc2Background = { + light: resolveThemeVariant(oc2Theme.light, false)["background-base"], + dark: resolveThemeVariant(oc2Theme.dark, true)["background-base"], +} protocol.registerSchemesAsPrivileged([ { @@ -46,6 +54,7 @@ export function setRelaunchHandler(handler: () => void) { export function setBackgroundColor(color: string) { backgroundColor = color + BrowserWindow.getAllWindows().forEach((win) => win.setBackgroundColor(color)) } export function getBackgroundColor(): string | undefined { @@ -65,6 +74,10 @@ function tone() { return nativeTheme.shouldUseDarkColors ? "dark" : "light" } +function defaultBackgroundColor() { + return oc2Background[tone()] +} + function overlay(theme: Partial = {}, zoom = 1) { const mode = theme.mode ?? tone() return { @@ -120,7 +133,7 @@ export function createMainWindow() { autoHideMenuBar: true, title: "OpenCode", icon: iconPath(), - backgroundColor, + backgroundColor: backgroundColor ?? defaultBackgroundColor(), ...(process.platform === "darwin" ? { titleBarStyle: "hidden" as const, @@ -178,7 +191,7 @@ export function createLoadingWindow() { show: true, autoHideMenuBar: true, icon: iconPath(), - backgroundColor, + backgroundColor: backgroundColor ?? defaultBackgroundColor(), ...(process.platform === "darwin" ? { titleBarStyle: "hidden" as const } : {}), ...(process.platform === "win32" ? {