The VS Code of video editing, built for agents.
TypeScript
Implement Windows Mica support and enhance color mode handling
konstantin-paulus7145e692bee9
diff --git a/apps/desktop/WINDOWS.md b/apps/desktop/WINDOWS.mdindex 56b07223..11346cc2 100644--- a/apps/desktop/WINDOWS.md+++ b/apps/desktop/WINDOWS.md@@ -72,9 +72,13 @@ Goal: a `Diffusion Studio Setup.exe` built by CI (unsigned) that installs,launches, opens a project, and exports a video. Nothing about CLI, MCP, orchrome yet.-Status: implemented on macOS, not yet run on Windows. Every task below is-in place; `.github/workflows/build-windows.yml` (workflow_dispatch) is the-next step, followed by the acceptance checks on a Windows machine. Squirrel's+Status: the dev build runs on a Windows machine (2026-09-21), which covers+`npm install` with the patches and the npm scripts in task 1 that the dev+path uses. The installer has not been built or run yet: tasks 2 to 5 are in+place but unexercised, so `.github/workflows/build-windows.yml`+(workflow_dispatch) is the next step, followed by the acceptance checks.+One fix came out of the dev run: `basename` in `packages/assets/src/types.ts`+split on `/` only and now handles backslashes and trailing separators. Squirrel's`iconUrl` points at `assets/icon.ico` on `main`, so Add/Remove Programsshows the icon only once this lands there.@@ -130,16 +134,38 @@ Acceptance:Goal: the window looks and behaves like a first-class Windows app.-Status: implemented on macOS, not yet run on Windows. Differences from the-tasks as written:+Status: running on Windows in the dev build (2026-09-21), not yet checked+from an installer. The acceptance list below has not been walked item by item+(scaling factors in particular). Differences from the tasks as written:- The app has a light/dark switch, so the overlay cannot be one fixed colour.The renderer reports the color mode over `WINDOW_SET_COLOR_MODE`- (`use-title-bar-color-mode.ts`) and main calls `setTitleBarOverlay`.+ (`apps/web/src/lib/window-color-mode.ts`) and main calls+ `setTitleBarOverlay`. The+ overlay is coloured like the sidebar (`--sidebar`) with symbols in+ `--muted-foreground`, like the other title bar icons; the dark symbol colour+ is that token flattened onto the sidebar, since the overlay takes opaque+ colours only (`WINDOWS_OVERLAY_COLORS` in `main.ts`).+- The editor draws its own title bar on Windows instead of only clearing the+ controls: `WindowsTitleBar` (`apps/web/src/components/ui/windows-title-bar.tsx`),+ filled by `EditorTitleBar` in `sidebar-left.tsx`. It is a fixed 40px row+ under the overlay with three cells: the project menu and layout toggles at+ the width of the left sidebar, the project name centered over the main+ column, and an empty cell at the width of the inspector where the native+ controls sit. The whole row drags the window; interactive children opt out+ with `-webkit-app-region: no-drag`. The editor root pads by+ `--titlebar-height`, which is 40px under `[data-platform=win32]` and 0+ elsewhere, and has to match `WINDOWS_OVERLAY_HEIGHT` in `main.ts`. The row+ stays up when the UI is hidden, so `FloatingProjectHeader` is not rendered+ on Windows, and the first row of the left sidebar drops its top border.+- The dashboard has no such row. Its sidebar header becomes+ `DashboardSidebarTitleBar`, one 40px row level with the controls, and the+ search bar and the billing header shrink to 40px and drag the window.- The clearance is one CSS variable, `--titlebar-controls-width` in`index.css`, built from the `titlebar-area` env variables; it is 0 wherever- there is no overlay. Only the inspector header sits under the controls and- uses it. The chat header moved into the left sidebar since this plan was- written and needs nothing.+ there is no overlay. The dashboard search bar is the only content under the+ controls and pads by it; the title bar's controls cell uses it as a minimum+ width. The inspector header sits below the title bar now and needs nothing,+ as does the chat header, which moved into the left sidebar.Tasks:@@ -376,10 +402,41 @@ Acceptance:Goal: developing on a Windows machine is as easy as on macOS, and the appgets the Windows 11 look.-Status: tasks 1 and 2 implemented on macOS, not yet run on Windows-(`scripts/dev-desktop.mjs`, `npm run shim:create` in `apps/cli`). Tasks 3 to 5+Status: task 1 runs on Windows: the dev build starts through+`scripts/dev-desktop.mjs` (2026-09-21). Task 2 (`npm run shim:create` in+`apps/cli`) is implemented but not yet confirmed on Windows. Task 3 (Mica) is+implemented on macOS and has not run on Windows yet; see below. Tasks 4 and 5are open.+How Mica is wired, and what to look at on hardware:+- `main.ts` turns it on from the build number (`WINDOWS_MICA`, 22621 and up):+ `backgroundMaterial: "mica"`, a transparent `backgroundColor`, and a+ transparent overlay colour so the controls sit on the material like the+ rest of the title bar. Older systems keep the solid window.+- Main tells the page through `additionalArguments`+ (`BACKDROP_ARGUMENT` in `main-channels.ts`); the preload exposes it as+ `window.desktop.backdrop` and `index.tsx` sets `<html data-backdrop>`. Under+ `[data-backdrop="mica"]` the page background and `--sidebar` go transparent,+ the same two rules macOS has for vibrancy. The main column keeps+ `--background`, so the material shows in the sidebars and the title bar.+- Windows tints Mica from the app theme, not from the page, so+ `WINDOW_SET_COLOR_MODE` now carries the user's preference next to the+ resolved mode and main sets `nativeTheme.themeSource` to it. The preference+ and not the mode, because pinning the theme also pins+ `prefers-color-scheme`, which "System theme" resolves from. The preferences+ menu reports a change of preference itself, since the resolved mode may not+ move.+- To check: the material shows at all with `titleBarStyle: "hidden"` plus the+ overlay (Electron has had bugs there); the transparent overlay colour is+ accepted and the controls' hover states still read; light, dark, and system+ themes each tint correctly, including switching between them; maximize,+ restore, fullscreen, and snap keep the material, the rounded corners, and+ the resize border; the unfocused window (Windows swaps Mica for a solid+ fallback colour by design) still looks right; no white flash on launch.+ If the sidebars read too light against the main column, give `--sidebar` a+ partial tint under `[data-backdrop="mica"]` in `index.css` instead of full+ transparency.+Tasks:1. **`scripts/dev-desktop.mjs`**: port reclaim uses `lsof` and `ps`; treediff --git a/apps/desktop/src/main-channels.ts b/apps/desktop/src/main-channels.tsindex fd2de15e..d213e199 100644--- a/apps/desktop/src/main-channels.ts+++ b/apps/desktop/src/main-channels.ts@@ -21,6 +21,10 @@ export const MAIN_WIRE = {export type MainWireChannel = (typeof MAIN_WIRE)[keyof typeof MAIN_WIRE];+// How main tells the preload which backdrop the window has (`additionalArguments`),+// so the page goes transparent only where there is a material behind it.+export const BACKDROP_ARGUMENT = "--window-backdrop=";+// Logical channels. Two categories:// • Renderer→Main requests (request + response)// • Main→Renderer events (push, no response)@@ -190,7 +194,11 @@ export type MainRequestMap = {response: string | null;};[MAIN_CHANNELS.WINDOW_IS_FULLSCREEN]: { request: void; response: boolean };- [MAIN_CHANNELS.WINDOW_SET_COLOR_MODE]: { request: { mode: "light" | "dark" }; response: void };+ [MAIN_CHANNELS.WINDOW_SET_COLOR_MODE]: {+ // `mode` is what the app shows, `preference` what the user picked.+ request: { mode: "light" | "dark"; preference: "light" | "dark" | "system" };+ response: void;+ };[MAIN_CHANNELS.WINDOW_CAPTURE]: { request: void; response: ScreenshotResult };[MAIN_CHANNELS.FILE_TRANSFER]: {request: { selector: string; absolutePath: string };diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.tsindex 5b4cb2c3..6ec139ad 100644--- a/apps/desktop/src/main.ts+++ b/apps/desktop/src/main.ts@@ -2,7 +2,7 @@* License, v. 2.0. If a copy of the MPL was not distributed with this* file, You can obtain one at http://mozilla.org/MPL/2.0/. */-import { app, BrowserWindow, nativeImage, session, shell } from "electron";+import { app, BrowserWindow, nativeImage, nativeTheme, session, shell } from "electron";import { dirname, join } from "node:path";import { existsSync } from "node:fs";import { mkdir, open, rename, unlink } from "node:fs/promises";@@ -19,7 +19,7 @@ import { trackEvent, trackInstall } from "./analytics";import { setupAppMenu } from "./menu";import { handleSquirrelEvent } from "./squirrel";import { mainBridge } from "./main-manager";-import { MAIN_CHANNELS } from "./main-channels";+import { BACKDROP_ARGUMENT, MAIN_CHANNELS } from "./main-channels";import {compileProject,createProject,@@ -64,6 +64,19 @@ const WINDOWS_OVERLAY_COLORS = {dark: { color: "#121212", symbolColor: "#a1a1a1" },light: { color: "#f7f7f7", symbolColor: "#737373" },};+// Mica, the Windows counterpart of the macOS vibrancy, exists from Windows 11+// 22H2 (build 22621). Older systems keep the solid window.+const WINDOWS_MICA_MIN_BUILD = 22621;+const WINDOWS_MICA =+ process.platform === "win32" &&+ Number(process.getSystemVersion().split(".")[2]) >= WINDOWS_MICA_MIN_BUILD;++// With Mica the controls sit on the material like the rest of the title bar,+// so the overlay paints no colour of its own.+function overlayColors(mode: "dark" | "light") {+ const colors = WINDOWS_OVERLAY_COLORS[mode];+ return WINDOWS_MICA ? { ...colors, color: "#00000000" } : colors;+}// A Squirrel.Windows install/update/uninstall launch: housekeeping only, the// app quits on its own. Decided first so nothing below starts a service or@@ -100,9 +113,14 @@ function applyBackdrop() {setNativeBackdrop(mainWindow.getNativeWindowHandle(), blur, red, green, blue, alpha);}-function setColorMode(mode: "dark" | "light") {+function setColorMode(mode: "dark" | "light", preference: "dark" | "light" | "system") {if (process.platform === "darwin" || !mainWindow || mainWindow.isDestroyed()) return;- mainWindow.setTitleBarOverlay({ ...WINDOWS_OVERLAY_COLORS[mode], height: WINDOWS_OVERLAY_HEIGHT });+ // Windows tints Mica from the app theme, not from the page, so the theme+ // follows the app's switch. It takes the preference rather than the resolved+ // mode: pinning it to "dark" would also pin `prefers-color-scheme`, and+ // "System theme" could never see the OS change again.+ if (WINDOWS_MICA) nativeTheme.themeSource = preference;+ mainWindow.setTitleBarOverlay({ ...overlayColors(mode), height: WINDOWS_OVERLAY_HEIGHT });}if (app.isPackaged && !squirrelLaunch && !process.argv.includes("--hidden")) {@@ -241,10 +259,16 @@ function createWindow(show = true) {if (process.platform === "win32") {options.titleBarStyle = "hidden" as const;- options.titleBarOverlay = { ...WINDOWS_OVERLAY_COLORS.dark, height: WINDOWS_OVERLAY_HEIGHT };+ options.titleBarOverlay = { ...overlayColors("dark"), height: WINDOWS_OVERLAY_HEIGHT };options.autoHideMenuBar = true;options.backgroundColor = WINDOWS_OVERLAY_COLORS.dark.color;+ if (WINDOWS_MICA) {+ options.backgroundMaterial = "mica" as const;+ options.backgroundColor = "#00000000";+ options.webPreferences!.additionalArguments = [`${BACKDROP_ARGUMENT}mica`];+ }+if (!app.isPackaged) {options.icon = join(app.getAppPath(), "assets", "icon-dev.png");}@@ -331,7 +355,9 @@ if (squirrelLaunch) {takePendingDeepLink(MAIN_CHANNELS.CHECKOUT_CALLBACK),);mainBridge.handle(MAIN_CHANNELS.WINDOW_IS_FULLSCREEN, () => mainWindow?.isFullScreen() ?? false);- mainBridge.handle(MAIN_CHANNELS.WINDOW_SET_COLOR_MODE, ({ mode }) => setColorMode(mode));+ mainBridge.handle(MAIN_CHANNELS.WINDOW_SET_COLOR_MODE, ({ mode, preference }) =>+ setColorMode(mode, preference),+ );mainBridge.handle(MAIN_CHANNELS.WINDOW_CAPTURE, async () => {if (!mainWindow || mainWindow.isDestroyed()) throw new Error("No main window");const image = await mainWindow.webContents.capturePage(undefined, { stayHidden: true });diff --git a/apps/desktop/src/preload.ts b/apps/desktop/src/preload.tsindex 1793687d..ca412368 100644--- a/apps/desktop/src/preload.ts+++ b/apps/desktop/src/preload.ts@@ -3,7 +3,7 @@* file, You can obtain one at http://mozilla.org/MPL/2.0/. */import { contextBridge, ipcRenderer, webUtils } from "electron";-import { MAIN_WIRE } from "./main-channels";+import { BACKDROP_ARGUMENT, MAIN_WIRE } from "./main-channels";import { DAPI_WIRE } from "@diffusionstudio/dapi";import type { IpcRendererEvent } from "electron";@@ -17,9 +17,15 @@ const ALLOWED_MAIN_TO_RENDERER: ReadonlySet<string> = new Set([DAPI_WIRE.CANCEL,]);+// The material behind the window, when main gave it one: the page is+// transparent only then. macOS always has vibrancy and is keyed on `platform`.+const backdrop =+ process.argv.find((arg) => arg.startsWith(BACKDROP_ARGUMENT))?.slice(BACKDROP_ARGUMENT.length) ?? null;+contextBridge.exposeInMainWorld("desktop", {getPathForFile,platform: process.platform,+ backdrop,send,on,});diff --git a/apps/web/src/app.tsx b/apps/web/src/app.tsxindex ef797f42..706c2e34 100644--- a/apps/web/src/app.tsx+++ b/apps/web/src/app.tsx@@ -10,9 +10,8 @@ import { AppContextMenu } from "@/components/app-context-menu";import { AuthProvider, useAuth } from '@/context/auth';import { PersistRoute } from '@/lib/persist-route';+import { syncWindowColorMode } from '@/lib/window-color-mode';import { useColorMode } from "@kobalte/core";-import { mainBridge } from "@/lib/ipc";-import { MAIN_CHANNELS } from "@desktop/main-channels";import { EditorApi } from '@/dapi';import { UpgradeDialog } from '@/components/upgrade-dialog';import { PurchaseSuccess } from '@/components/purchase-success';@@ -53,11 +52,7 @@ function BootSplash() {function TitleBarColorMode() {const { colorMode } = useColorMode();- createEffect(() => {- if (window.desktop?.platform === "win32") {- mainBridge.call(MAIN_CHANNELS.WINDOW_SET_COLOR_MODE, { mode: colorMode() });- };- });+ createEffect(() => syncWindowColorMode(colorMode()));return null;}diff --git a/apps/web/src/components/sidebar-left/project-menu/preferences-menu.tsx b/apps/web/src/components/sidebar-left/project-menu/preferences-menu.tsxindex 55c136dd..97555765 100644--- a/apps/web/src/components/sidebar-left/project-menu/preferences-menu.tsx+++ b/apps/web/src/components/sidebar-left/project-menu/preferences-menu.tsx@@ -14,25 +14,11 @@ import {DropdownMenuSubTrigger,DropdownMenuGroup,} from "@/components/ui/dropdown-menu";-import { COLOR_MODE_STORAGE_KEY, useColorMode } from "@kobalte/core";+import { useColorMode } from "@kobalte/core";+import { storedThemePreference, syncWindowColorMode } from "@/lib/window-color-mode";import { createEffect, createSignal } from "solid-js";import type { Theme } from "./types";-const getStoredThemePreference = (): Theme | undefined => {- if (typeof window === "undefined") return undefined;-- try {- const stored = window.localStorage.getItem(COLOR_MODE_STORAGE_KEY);- if (stored === "light" || stored === "dark" || stored === "system") {- return stored;- }- } catch {- // ignore storage access errors and fall back to resolved color mode- }-- return undefined;-};-export function PreferencesMenu() {const { colorMode, setColorMode } = useColorMode();@@ -52,12 +38,13 @@ export function PreferencesMenu() {createEffect(() => {const resolvedColorMode = colorMode();- setThemePreference(getStoredThemePreference() ?? resolvedColorMode);+ setThemePreference(storedThemePreference() ?? resolvedColorMode);});const setTheme = (nextTheme: Theme) => {setThemePreference(nextTheme);setColorMode(nextTheme);+ syncWindowColorMode(colorMode());};const resetToDefaults = () => {diff --git a/apps/web/src/index.css b/apps/web/src/index.cssindex a3250234..5d1ccc82 100644--- a/apps/web/src/index.css+++ b/apps/web/src/index.css@@ -250,6 +250,18 @@--sidebar: hsla(0, 0%, 0%, 0);}+/* Windows 11 desktop: the same with Mica, which main turns on where the system+ has it. Mica follows the app theme and stays up in fullscreen, so neither+ needs an exception here. */+[data-backdrop="mica"],+[data-backdrop="mica"] body {+ background: transparent;+}++[data-backdrop="mica"] {+ --sidebar: hsla(0, 0%, 0%, 0);+}+@layer base {* {@apply border-border outline-ring/50 select-none;diff --git a/apps/web/src/index.tsx b/apps/web/src/index.tsxindex 375640f6..515e5d9f 100644--- a/apps/web/src/index.tsx+++ b/apps/web/src/index.tsx@@ -23,6 +23,7 @@ document.addEventListener('contextmenu', (e) => e.preventDefault())if (window.desktop) {document.documentElement.dataset.platform = window.desktop.platform;+ if (window.desktop.backdrop) document.documentElement.dataset.backdrop = window.desktop.backdrop;const origRequest = FileSystemHandle.prototype.requestPermission;FileSystemHandle.prototype.queryPermission = async function (desc) {diff --git a/apps/web/src/lib/window-color-mode.ts b/apps/web/src/lib/window-color-mode.tsnew file mode 100644index 00000000..72721c85--- /dev/null+++ b/apps/web/src/lib/window-color-mode.ts@@ -0,0 +1,40 @@+/* This Source Code Form is subject to the terms of the Mozilla Public+ * License, v. 2.0. If a copy of the MPL was not distributed with this+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */++import { COLOR_MODE_STORAGE_KEY } from "@kobalte/core";++import { mainBridge } from "@/lib/ipc";+import { MAIN_CHANNELS } from "@desktop/main-channels";++export type ThemePreference = "light" | "dark" | "system";++/** What the user picked in the theme menu, which Kobalte keeps in localStorage. */+export function storedThemePreference(): ThemePreference | undefined {+ if (typeof window === "undefined") return undefined;++ try {+ const stored = window.localStorage.getItem(COLOR_MODE_STORAGE_KEY);+ if (stored === "light" || stored === "dark" || stored === "system") {+ return stored;+ }+ } catch {+ // ignore storage access errors and fall back to resolved color mode+ }++ return undefined;+}++/**+ * Tells the Windows desktop build which theme the app shows, so the native+ * window controls and the Mica backdrop match it. Called when the resolved+ * mode changes and when the preference does: going from "dark" to "system" on+ * a dark OS changes only the latter.+ */+export function syncWindowColorMode(mode: "light" | "dark"): void {+ if (window.desktop?.platform !== "win32") return;+ mainBridge.call(MAIN_CHANNELS.WINDOW_SET_COLOR_MODE, {+ mode,+ preference: storedThemePreference() ?? mode,+ });+}diff --git a/apps/web/src/vite-env.d.ts b/apps/web/src/vite-env.d.tsindex 71827199..e09328d9 100644--- a/apps/web/src/vite-env.d.ts+++ b/apps/web/src/vite-env.d.ts@@ -14,6 +14,7 @@ declare global {chrome: any;desktop?: {platform: string;+ backdrop: string | null;send(channel: string, payload: unknown): void;on(channel: string, cb: (payload: unknown) => void): (() => void);getPathForFile(file: File): string;