The VS Code of video editing, built for agents.
TypeScript
Refactor Windows color mode handling and remove Mica implementation
konstantin-paulus4d4d2ebe3918
diff --git a/apps/desktop/WINDOWS.md b/apps/desktop/WINDOWS.mdindex cf768b9d..9494f851 100644--- a/apps/desktop/WINDOWS.md+++ b/apps/desktop/WINDOWS.md@@ -139,7 +139,7 @@ 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`- (`apps/web/src/lib/window-color-mode.ts`) and main calls+ (`TitleBarColorMode` in `apps/web/src/app.tsx`) and main calls`setTitleBarOverlay`. Theoverlay is coloured like the sidebar (`--sidebar`) with symbols in`--muted-foreground`, like the other title bar icons; the dark symbol colour@@ -404,42 +404,22 @@ gets the Windows 11 look.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 5-are 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.-- First run on Windows (2026-09-21): the material shows, but dark Mica- (around #202020) reads lighter than the macOS backdrop, which is tinted- with 7% grey at 0.9. In dark mode `--sidebar` is therefore that grey at 0.6- over the material instead of fully transparent; light Mica is within a shade- of `--sidebar` and takes no tint. The alpha is the knob. Since `--sidebar`- is translucent now, `bg-sidebar` must not stack: `WindowsTitleBar` has no- background and lets the editor root's show through.+`apps/cli`) is implemented but not yet confirmed on Windows. Task 3 (Mica) was+tried and dropped, see below. Tasks 4 and 5 are open.++Mica, tried on Windows on 2026-09-21 and reverted: the window stays solid.+The material worked with `titleBarStyle: "hidden"` and a transparent+`titleBarOverlay` colour, but it does not give the macOS look. Mica is a fixed+tint of the desktop wallpaper (around #202020 in dark mode), not a blur of+what is behind the window, so it read lighter than the macOS backdrop; laying+the app's 7% grey over it to match the depth left too little of the material+to be worth the moving parts. Those were: feature detection by build number+(22621), a flag from main to the page to make `--sidebar` transparent,+`nativeTheme.themeSource` following the app's theme preference (Windows tints+Mica from the app theme, not the page), and no stacked `bg-sidebar` once the+colour is translucent. The attempt is in commits 7145e69 and a34c00d if it is+picked up again; `backgroundMaterial: "acrylic"` is the option that actually+blurs the content behind the window.Tasks:@@ -454,7 +434,7 @@ Tasks:3. **Mica** (`main.ts`): on Windows 11 22H2+, `backgroundMaterial: "mica"`with a transparent `backgroundColor` gives the vibrancy look. Electron hashad bugs combining this with `titleBarOverlay`; treat as optional and- feature-detect by build number.+ feature-detect by build number. Dropped, see the status above.4. **arm64**: add `--arch=arm64` to the Windows CI matrix and a secondSquirrel output. Test on a Windows-on-ARM VM.5. **winget**: a manifest in `microsoft/winget-pkgs`, bumped by a workflowdiff --git a/apps/desktop/src/main-channels.ts b/apps/desktop/src/main-channels.tsindex d213e199..fd2de15e 100644--- a/apps/desktop/src/main-channels.ts+++ b/apps/desktop/src/main-channels.ts@@ -21,10 +21,6 @@ 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)@@ -194,11 +190,7 @@ export type MainRequestMap = {response: string | null;};[MAIN_CHANNELS.WINDOW_IS_FULLSCREEN]: { request: void; response: boolean };- [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_SET_COLOR_MODE]: { request: { mode: "light" | "dark" }; 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 6ec139ad..5b4cb2c3 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, nativeTheme, session, shell } from "electron";+import { app, BrowserWindow, nativeImage, 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 { BACKDROP_ARGUMENT, MAIN_CHANNELS } from "./main-channels";+import { MAIN_CHANNELS } from "./main-channels";import {compileProject,createProject,@@ -64,19 +64,6 @@ 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@@ -113,14 +100,9 @@ function applyBackdrop() {setNativeBackdrop(mainWindow.getNativeWindowHandle(), blur, red, green, blue, alpha);}-function setColorMode(mode: "dark" | "light", preference: "dark" | "light" | "system") {+function setColorMode(mode: "dark" | "light") {if (process.platform === "darwin" || !mainWindow || mainWindow.isDestroyed()) return;- // 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 });+ mainWindow.setTitleBarOverlay({ ...WINDOWS_OVERLAY_COLORS[mode], height: WINDOWS_OVERLAY_HEIGHT });}if (app.isPackaged && !squirrelLaunch && !process.argv.includes("--hidden")) {@@ -259,16 +241,10 @@ function createWindow(show = true) {if (process.platform === "win32") {options.titleBarStyle = "hidden" as const;- options.titleBarOverlay = { ...overlayColors("dark"), height: WINDOWS_OVERLAY_HEIGHT };+ options.titleBarOverlay = { ...WINDOWS_OVERLAY_COLORS.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");}@@ -355,9 +331,7 @@ 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, preference }) =>- setColorMode(mode, preference),- );+ mainBridge.handle(MAIN_CHANNELS.WINDOW_SET_COLOR_MODE, ({ mode }) => setColorMode(mode));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 ca412368..1793687d 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 { BACKDROP_ARGUMENT, MAIN_WIRE } from "./main-channels";+import { MAIN_WIRE } from "./main-channels";import { DAPI_WIRE } from "@diffusionstudio/dapi";import type { IpcRendererEvent } from "electron";@@ -17,15 +17,9 @@ 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 706c2e34..ef797f42 100644--- a/apps/web/src/app.tsx+++ b/apps/web/src/app.tsx@@ -10,8 +10,9 @@ 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';@@ -52,7 +53,11 @@ function BootSplash() {function TitleBarColorMode() {const { colorMode } = useColorMode();- createEffect(() => syncWindowColorMode(colorMode()));+ createEffect(() => {+ if (window.desktop?.platform === "win32") {+ mainBridge.call(MAIN_CHANNELS.WINDOW_SET_COLOR_MODE, { mode: 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 97555765..55c136dd 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,11 +14,25 @@ import {DropdownMenuSubTrigger,DropdownMenuGroup,} from "@/components/ui/dropdown-menu";-import { useColorMode } from "@kobalte/core";-import { storedThemePreference, syncWindowColorMode } from "@/lib/window-color-mode";+import { COLOR_MODE_STORAGE_KEY, useColorMode } from "@kobalte/core";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();@@ -38,13 +52,12 @@ export function PreferencesMenu() {createEffect(() => {const resolvedColorMode = colorMode();- setThemePreference(storedThemePreference() ?? resolvedColorMode);+ setThemePreference(getStoredThemePreference() ?? resolvedColorMode);});const setTheme = (nextTheme: Theme) => {setThemePreference(nextTheme);setColorMode(nextTheme);- syncWindowColorMode(colorMode());};const resetToDefaults = () => {diff --git a/apps/web/src/components/ui/windows-title-bar.tsx b/apps/web/src/components/ui/windows-title-bar.tsxindex da0cf8b6..21103264 100644--- a/apps/web/src/components/ui/windows-title-bar.tsx+++ b/apps/web/src/components/ui/windows-title-bar.tsx@@ -24,9 +24,6 @@ type WindowsTitleBarProps = {* interactive inside it has to opt out with `-webkit-app-region: no-drag`.* Its bottom border runs the full width, so the first row of the left sidebar* drops its own top border on Windows.- * It has no background of its own: the page root's `bg-sidebar` shows through- * the padding it sits in, and a second coat would double the tint `--sidebar`- * carries over Mica.* Renders nothing on other platforms; the editor clears it with* `--titlebar-height`. The dashboard has no such row: its sidebar header and* view headers line up with the controls instead.@@ -35,7 +32,7 @@ export function WindowsTitleBar(props: WindowsTitleBarProps) {return (<Show when={isWindowsDesktop()}><div- class="fixed inset-x-0 top-0 z-20 flex h-(--titlebar-height) border-b border-border"+ class="fixed inset-x-0 top-0 z-20 flex h-(--titlebar-height) border-b border-border bg-sidebar"style="-webkit-app-region: drag;"><divdiff --git a/apps/web/src/index.css b/apps/web/src/index.cssindex b91480cd..a3250234 100644--- a/apps/web/src/index.css+++ b/apps/web/src/index.css@@ -250,26 +250,6 @@--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);-}--/* Dark Mica sits around #202020, lighter than the macOS backdrop, which main- tints with `MACOS_BACKDROP` (7% grey at 0.9). The sidebars lay the same grey- over the material to land at that depth; raise the alpha to go darker. Light- Mica is already within a shade of `--sidebar` and takes no tint. */-[data-backdrop="mica"][data-kb-theme="dark"] {- --sidebar: hsla(0, 0%, 7%, 0.6);-}-@layer base {* {@apply border-border outline-ring/50 select-none;diff --git a/apps/web/src/index.tsx b/apps/web/src/index.tsxindex 515e5d9f..375640f6 100644--- a/apps/web/src/index.tsx+++ b/apps/web/src/index.tsx@@ -23,7 +23,6 @@ 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.tsdeleted file mode 100644index 72721c85..00000000--- a/apps/web/src/lib/window-color-mode.ts+++ /dev/null@@ -1,40 +0,0 @@-/* 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 e09328d9..71827199 100644--- a/apps/web/src/vite-env.d.ts+++ b/apps/web/src/vite-env.d.ts@@ -14,7 +14,6 @@ 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;