import { BrowserWindow } from "electrobun/bun"; import { DEFAULT_SETTINGS, type AppSettings } from "../shared/types"; /** * The skin THIS PROCESS booted with, frozen at startup by `initSessionSkin`. * * Every window must be built from this, never from the live settings snapshot. * The skin picks a whole component tree (bootstrapped from the preload-baked * __APP_SKIN) and the native frame (constructor-only), so it cannot change * without a restart — but the persisted setting CAN change mid-session. Reading * the live value would boot a newly opened editor or manager into the pending * skin while the main window still runs the old one: two windows, two trees, * two frames. * * Pinning it in one place makes that impossible rather than making each call * site remember. Everything else in the preload keeps using the live snapshot, * because theme/tone/accent/text-size genuinely do apply live. */ let sessionSkin: AppSettings["skin"] = DEFAULT_SETTINGS.skin; /** Call once, at startup, before any window is constructed. */ export function initSessionSkin(skin: AppSettings["skin"]): void { sessionSkin = skin; } /** * The preload globals every window gets. Single composition point: the UI * reads them in ui/src/app/platform.ts before first paint (window chrome and * root-component selection both depend on them). * * The persisted theme attributes are baked in here — mirroring the * delete/set logic of SettingsService.applyX — so the FIRST paint is already * themed (the inline