The VS Code of video editing, built for agents.
TypeScript
Add tray menu icons and enhance theme support
konstantin-paulusdd961f9ec2f5
diff --git a/apps/desktop/assets/tray/menu/busy.png b/apps/desktop/assets/tray/menu/busy.pngnew file mode 100644index 00000000..3dac0611Binary files /dev/null and b/apps/desktop/assets/tray/menu/busy.png differdiff --git a/apps/desktop/assets/tray/menu/busy.svg b/apps/desktop/assets/tray/menu/busy.svgnew file mode 100644index 00000000..ed4d4525--- /dev/null+++ b/apps/desktop/assets/tray/menu/busy.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="#000" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round">+<path d="M6.5 2.5l1.25 3.25L11 7 7.75 8.25 6.5 11.5 5.25 8.25 2 7l3.25-1.25z"/><path d="M12 10l.6 1.4 1.4.6-1.4.6L12 14l-.6-1.4L10 12l1.4-.6z" fill="#000" stroke-width="0.75"/>+</svg>diff --git a/apps/desktop/assets/tray/menu/[email protected] b/apps/desktop/assets/tray/menu/[email protected]new file mode 100644index 00000000..e9ae07cfBinary files /dev/null and b/apps/desktop/assets/tray/menu/[email protected] differdiff --git a/apps/desktop/assets/tray/menu/hide.png b/apps/desktop/assets/tray/menu/hide.pngnew file mode 100644index 00000000..6f04b902Binary files /dev/null and b/apps/desktop/assets/tray/menu/hide.png differdiff --git a/apps/desktop/assets/tray/menu/hide.svg b/apps/desktop/assets/tray/menu/hide.svgnew file mode 100644index 00000000..2cb6edec--- /dev/null+++ b/apps/desktop/assets/tray/menu/hide.svg@@ -0,0 +1,4 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="#000" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round">+<mask id="gap"><rect width="16" height="16" fill="#fff" stroke="none"/><path d="M2.5 2.5l11 11" stroke="#000" stroke-width="3.25"/></mask>+<g mask="url(#gap)"><path d="M1.75 8S4 3.75 8 3.75 14.25 8 14.25 8 12 12.25 8 12.25 1.75 8 1.75 8z"/><circle cx="8" cy="8" r="2"/></g><path d="M2.5 2.5l11 11"/>+</svg>diff --git a/apps/desktop/assets/tray/menu/[email protected] b/apps/desktop/assets/tray/menu/[email protected]new file mode 100644index 00000000..65864737Binary files /dev/null and b/apps/desktop/assets/tray/menu/[email protected] differdiff --git a/apps/desktop/assets/tray/menu/open.png b/apps/desktop/assets/tray/menu/open.pngnew file mode 100644index 00000000..2f21d0baBinary files /dev/null and b/apps/desktop/assets/tray/menu/open.png differdiff --git a/apps/desktop/assets/tray/menu/open.svg b/apps/desktop/assets/tray/menu/open.svgnew file mode 100644index 00000000..031bcc89--- /dev/null+++ b/apps/desktop/assets/tray/menu/open.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="#000" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round">+<rect x="2" y="3" width="12" height="10" rx="2"/><path d="M2 6h12"/>+</svg>diff --git a/apps/desktop/assets/tray/menu/[email protected] b/apps/desktop/assets/tray/menu/[email protected]new file mode 100644index 00000000..fcd4a6ceBinary files /dev/null and b/apps/desktop/assets/tray/menu/[email protected] differdiff --git a/apps/desktop/assets/tray/menu/project.png b/apps/desktop/assets/tray/menu/project.pngnew file mode 100644index 00000000..e2cf4f0fBinary files /dev/null and b/apps/desktop/assets/tray/menu/project.png differdiff --git a/apps/desktop/assets/tray/menu/project.svg b/apps/desktop/assets/tray/menu/project.svgnew file mode 100644index 00000000..1539e8fb--- /dev/null+++ b/apps/desktop/assets/tray/menu/project.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="#000" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round">+<path d="M2 4.5A1.5 1.5 0 0 1 3.5 3h2.75l1.5 1.5h4.75A1.5 1.5 0 0 1 14 6v5.5a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 2 11.5z"/>+</svg>diff --git a/apps/desktop/assets/tray/menu/[email protected] b/apps/desktop/assets/tray/menu/[email protected]new file mode 100644index 00000000..fab5515eBinary files /dev/null and b/apps/desktop/assets/tray/menu/[email protected] differdiff --git a/apps/desktop/assets/tray/menu/quit.png b/apps/desktop/assets/tray/menu/quit.pngnew file mode 100644index 00000000..a3e0f3e0Binary files /dev/null and b/apps/desktop/assets/tray/menu/quit.png differdiff --git a/apps/desktop/assets/tray/menu/quit.svg b/apps/desktop/assets/tray/menu/quit.svgnew file mode 100644index 00000000..4788438b--- /dev/null+++ b/apps/desktop/assets/tray/menu/quit.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="#000" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round">+<path d="M8 2v5.5"/><path d="M4.75 4.25a5.25 5.25 0 1 0 6.5 0"/>+</svg>diff --git a/apps/desktop/assets/tray/menu/[email protected] b/apps/desktop/assets/tray/menu/[email protected]new file mode 100644index 00000000..c39badd9Binary files /dev/null and b/apps/desktop/assets/tray/menu/[email protected] differdiff --git a/apps/desktop/assets/tray/menu/ready.png b/apps/desktop/assets/tray/menu/ready.pngnew file mode 100644index 00000000..05cd853fBinary files /dev/null and b/apps/desktop/assets/tray/menu/ready.png differdiff --git a/apps/desktop/assets/tray/menu/ready.svg b/apps/desktop/assets/tray/menu/ready.svgnew file mode 100644index 00000000..98592df3--- /dev/null+++ b/apps/desktop/assets/tray/menu/ready.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="#000" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round">+<circle cx="8" cy="8" r="6"/><path d="M5.5 8.25l1.75 1.75 3.25-3.5"/>+</svg>diff --git a/apps/desktop/assets/tray/menu/[email protected] b/apps/desktop/assets/tray/menu/[email protected]new file mode 100644index 00000000..d1b177ebBinary files /dev/null and b/apps/desktop/assets/tray/menu/[email protected] differdiff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex 2415730b..52eb7a15 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -26,7 +26,8 @@"test": "vitest run","build:agent-host": "esbuild ../../packages/agent-chat/src/bin.ts --bundle --platform=node --format=esm --target=node20 --external:electron \"--external:@anthropic-ai/claude-agent-sdk-*\" --banner:js=\"import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);\" --outfile=dist/agent-host.mjs","make:ico": "python3 scripts/win-assets.py ico",- "make:spinner": "python3 scripts/win-assets.py spinner"+ "make:spinner": "python3 scripts/win-assets.py spinner",+ "make:tray-menu": "sh scripts/tray-menu-icons.sh"},"devDependencies": {"@electron-forge/cli": "^7.11.1",diff --git a/apps/desktop/scripts/tray-menu-icons.sh b/apps/desktop/scripts/tray-menu-icons.shnew file mode 100755index 00000000..2a63c2ec--- /dev/null+++ b/apps/desktop/scripts/tray-menu-icons.sh@@ -0,0 +1,15 @@+#!/bin/sh+# Regenerates the Windows tray menu icons: assets/tray/menu/<name>.svg ->+# <name>.png (16px) and <name>@2x.png (32px). Black on transparent; the app+# recolors them to match the menu's light or dark theme. macOS uses SF+# Symbols instead and does not need these.+#+# Needs rsvg-convert (brew install librsvg).++set -e+cd "$(dirname "$0")/../assets/tray/menu"+for svg in *.svg; do+ name="${svg%.svg}"+ rsvg-convert -w 16 -h 16 "$svg" -o "$name.png"+ rsvg-convert -w 32 -h 32 "$svg" -o "[email protected]"+donediff --git a/apps/desktop/src/tray.ts b/apps/desktop/src/tray.tsindex 91207003..1d0ed0b0 100644--- a/apps/desktop/src/tray.ts+++ b/apps/desktop/src/tray.ts@@ -8,7 +8,7 @@// the editor or quits.import { basename } from "node:path";-import { app, Menu, nativeImage, Tray } from "electron";+import { app, Menu, nativeImage, nativeTheme, Tray } from "electron";import idle1x from "../assets/tray/idleTemplate.png";import idle2x from "../assets/tray/[email protected]";@@ -16,6 +16,18 @@ import busy1x from "../assets/tray/busyTemplate.png";import busy2x from "../assets/tray/[email protected]";import win1x from "../assets/tray/win.png";import win2x from "../assets/tray/[email protected]";+import menuOpen1x from "../assets/tray/menu/open.png";+import menuOpen2x from "../assets/tray/menu/[email protected]";+import menuHide1x from "../assets/tray/menu/hide.png";+import menuHide2x from "../assets/tray/menu/[email protected]";+import menuReady1x from "../assets/tray/menu/ready.png";+import menuReady2x from "../assets/tray/menu/[email protected]";+import menuBusy1x from "../assets/tray/menu/busy.png";+import menuBusy2x from "../assets/tray/menu/[email protected]";+import menuProject1x from "../assets/tray/menu/project.png";+import menuProject2x from "../assets/tray/menu/[email protected]";+import menuQuit1x from "../assets/tray/menu/quit.png";+import menuQuit2x from "../assets/tray/menu/[email protected]";import type { NativeImage } from "electron";@@ -41,6 +53,50 @@ function image(x1: Uint8Array, x2: Uint8Array, template: boolean): NativeImage {return icon;}+type MenuIcon = "open" | "hide" | "ready" | "busy" | "project" | "quit";++// macOS draws SF Symbols in the menu's own color. Elsewhere the icons are+// black masks (scripts/tray-menu-icons.sh) recolored to the menu's text.+const SYMBOLS: Record<MenuIcon, string> = {+ open: "macwindow",+ hide: "eye.slash",+ ready: "checkmark.circle",+ busy: "sparkles",+ project: "folder",+ quit: "power",+};++const MASKS: Record<MenuIcon, [Uint8Array, Uint8Array]> = {+ open: [menuOpen1x, menuOpen2x],+ hide: [menuHide1x, menuHide2x],+ ready: [menuReady1x, menuReady2x],+ busy: [menuBusy1x, menuBusy2x],+ project: [menuProject1x, menuProject2x],+ quit: [menuQuit1x, menuQuit2x],+};++/** A mask's pixels filled with `rgb`, keeping its alpha; bitmaps are premultiplied BGRA. */+function tinted(png: Uint8Array, [r, g, b]: number[]) {+ const mask = nativeImage.createFromBuffer(Buffer.from(png));+ const { width, height } = mask.getSize();+ const buffer = mask.toBitmap();+ for (let i = 0; i < buffer.length; i += 4) {+ const a = buffer[i + 3] / 255;+ buffer[i] = Math.round(b * a);+ buffer[i + 1] = Math.round(g * a);+ buffer[i + 2] = Math.round(r * a);+ }+ return { buffer, width, height };+}++function menuIcon(name: MenuIcon, dark: boolean): NativeImage {+ if (process.platform === "darwin") return nativeImage.createMenuSymbol(SYMBOLS[name]);+ const color = dark ? [242, 242, 242] : [28, 28, 28];+ const icon = nativeImage.createEmpty();+ MASKS[name].forEach((png, i) => icon.addRepresentation({ scaleFactor: i + 1, ...tinted(png, color) }));+ return icon;+}+export class AppTray {private readonly deps: AppTrayDeps;private tray: Tray | null = null;@@ -50,6 +106,7 @@ export class AppTray {private lingerTimer: NodeJS.Timeout | null = null;private wasVisible = false;private toldStillRunning = false;+ private menuIcons = new Map<string, NativeImage>();constructor(deps: AppTrayDeps) {this.deps = deps;@@ -68,6 +125,7 @@ export class AppTray {// macOS opens the menu on click; elsewhere the menu is the right click// and a click opens the editor.if (process.platform !== "darwin") this.tray.on("click", () => this.deps.show());+ nativeTheme.on("updated", this.onThemeUpdated);this.refresh();}@@ -86,13 +144,15 @@ export class AppTray {tray.setContextMenu(Menu.buildFromTemplate([visible ?- { label: `Hide ${app.name}`, click: () => this.deps.hide() }- : { label: `Open ${app.name}`, click: () => this.deps.show() },+ { label: `Hide ${app.name}`, icon: this.icon("hide"), click: () => this.deps.hide() }+ : { label: `Open ${app.name}`, icon: this.icon("open"), click: () => this.deps.show() },{ type: "separator" },- { label: status, enabled: false },- ...(project ? [{ label: `Project: ${basename(project)}`, enabled: false }] : []),+ { label: status, icon: this.icon(this.busy ? "busy" : "ready"), enabled: false },+ ...(project ?+ [{ label: `Project: ${basename(project)}`, icon: this.icon("project"), enabled: false }]+ : []),{ type: "separator" },- { label: `Quit ${app.name}`, click: () => app.quit() },+ { label: `Quit ${app.name}`, icon: this.icon("quit"), click: () => app.quit() },]),);@@ -111,10 +171,22 @@ export class AppTray {destroy(): void {if (this.lingerTimer) clearTimeout(this.lingerTimer);+ nativeTheme.off("updated", this.onThemeUpdated);this.tray?.destroy();this.tray = null;}+ private readonly onThemeUpdated = () => this.refresh();++ /** The menu icon for the current theme, made once and reused. */+ private icon(name: MenuIcon): NativeImage {+ const dark = nativeTheme.shouldUseDarkColors;+ const key = `${name}:${dark}`;+ let icon = this.menuIcons.get(key);+ if (!icon) this.menuIcons.set(key, (icon = menuIcon(name, dark)));+ return icon;+ }+private updateBusy(): void {if (this.deps.active()) {if (this.lingerTimer) clearTimeout(this.lingerTimer);