Skip to content

Commit 9ce8067

Browse files
committed
refactor(desktop): derive fallback background from theme
1 parent 7dfc09e commit 9ce8067

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

packages/desktop/src/main/windows.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import windowState from "electron-window-state"
2+
import { resolveThemeVariant } from "@opencode-ai/ui/theme/resolve"
23
import { app, BrowserWindow, net, nativeImage, nativeTheme, protocol } from "electron"
34
import { dirname, isAbsolute, join, relative, resolve } from "node:path"
45
import { fileURLToPath, pathToFileURL } from "node:url"
56
import type { TitlebarTheme } from "../preload/types"
7+
import type { DesktopTheme } from "@opencode-ai/ui/theme/types"
8+
import oc2ThemeJson from "../../../ui/src/theme/themes/oc-2.json"
69

710
const root = dirname(fileURLToPath(import.meta.url))
811
const rendererRoot = join(root, "../renderer")
@@ -11,6 +14,11 @@ const rendererHost = "renderer"
1114
const clipboardWritePermission = "clipboard-sanitized-write"
1215
const notificationPermission = "notifications"
1316
const rendererPermissions = new Set([clipboardWritePermission, notificationPermission])
17+
const oc2Theme = oc2ThemeJson as DesktopTheme
18+
const oc2Background = {
19+
light: resolveThemeVariant(oc2Theme.light, false)["background-base"],
20+
dark: resolveThemeVariant(oc2Theme.dark, true)["background-base"],
21+
}
1422

1523
protocol.registerSchemesAsPrivileged([
1624
{
@@ -50,8 +58,7 @@ function tone() {
5058
}
5159

5260
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"
61+
return oc2Background[tone()]
5562
}
5663

5764
function overlay(theme: Partial<TitlebarTheme> = {}, zoom = 1) {

0 commit comments

Comments
 (0)