11import windowState from "electron-window-state"
2+ import { resolveThemeVariant } from "@opencode-ai/ui/theme/resolve"
3+ import type { DesktopTheme } from "@opencode-ai/ui/theme/types"
24import { app , BrowserWindow , dialog , net , nativeImage , nativeTheme , protocol } from "electron"
35import { dirname , isAbsolute , join , relative , resolve } from "node:path"
46import { fileURLToPath , pathToFileURL } from "node:url"
7+ import oc2ThemeJson from "../../../ui/src/theme/themes/oc-2.json"
58import type { TitlebarTheme } from "../preload/types"
69import { exportDebugLogs , write as writeLog } from "./logging"
710import { createUnresponsiveSampler } from "./unresponsive"
@@ -15,6 +18,11 @@ const notificationPermission = "notifications"
1518const rendererPermissions = new Set ( [ clipboardWritePermission , notificationPermission ] )
1619const documentPolicyHeader = "Document-Policy"
1720const jsCallStacksDocumentPolicy = "include-js-call-stacks-in-crash-reports"
21+ const oc2Theme = oc2ThemeJson as DesktopTheme
22+ const oc2Background = {
23+ light : resolveThemeVariant ( oc2Theme . light , false ) [ "background-base" ] ,
24+ dark : resolveThemeVariant ( oc2Theme . dark , true ) [ "background-base" ] ,
25+ }
1826
1927protocol . registerSchemesAsPrivileged ( [
2028 {
@@ -41,6 +49,7 @@ export function setRelaunchHandler(handler: () => void) {
4149
4250export function setBackgroundColor ( color : string ) {
4351 backgroundColor = color
52+ BrowserWindow . getAllWindows ( ) . forEach ( ( win ) => win . setBackgroundColor ( color ) )
4453}
4554
4655export function getBackgroundColor ( ) : string | undefined {
@@ -60,6 +69,10 @@ function tone() {
6069 return nativeTheme . shouldUseDarkColors ? "dark" : "light"
6170}
6271
72+ function defaultBackgroundColor ( ) {
73+ return oc2Background [ tone ( ) ]
74+ }
75+
6376function overlay ( theme : Partial < TitlebarTheme > = { } , zoom = 1 ) {
6477 const mode = theme . mode ?? tone ( )
6578 return {
@@ -101,7 +114,7 @@ export function createMainWindow() {
101114 autoHideMenuBar : true ,
102115 title : "OpenCode" ,
103116 icon : iconPath ( ) ,
104- backgroundColor,
117+ backgroundColor : backgroundColor ?? defaultBackgroundColor ( ) ,
105118 ...( process . platform === "darwin"
106119 ? {
107120 titleBarStyle : "hidden" as const ,
@@ -159,7 +172,7 @@ export function createLoadingWindow() {
159172 show : true ,
160173 autoHideMenuBar : true ,
161174 icon : iconPath ( ) ,
162- backgroundColor,
175+ backgroundColor : backgroundColor ?? defaultBackgroundColor ( ) ,
163176 ...( process . platform === "darwin" ? { titleBarStyle : "hidden" as const } : { } ) ,
164177 ...( process . platform === "win32"
165178 ? {
0 commit comments