The VS Code of video editing, built for agents.
TypeScript
feat: add project folder commands and enhance command ordering in palette
konstantin-paulus96d7242faa38
diff --git a/apps/web/src/assets/icons/README.md b/apps/web/src/assets/icons/README.mdindex 82fb76cf..ce83c21b 100644--- a/apps/web/src/assets/icons/README.md+++ b/apps/web/src/assets/icons/README.md@@ -103,7 +103,7 @@ Save the file as `<name>.svg`, using the Figma name without `icon.24.` (`icon.24A few icons stay on their own grid on purpose:-- **Brand logos** (`agent.*`, `claude`, `codex`, `social.*`, `diffusion-logo*`) are moved to the 25 frame without reshaping.+- **Brand logos** (`agent.*`, `editor.*`, `claude`, `codex`, `social.*`, `diffusion-logo*`) are moved to the 25 frame without reshaping.- **The `large-*` provider logos** are left as exported.- **`frame`** (20×20, shown at 20 px), **`folder-thumbnail`** (32×24) and **`vertical-knob-line`** are drawn for their own sizes.- **`line-join-*`** use a 15×15 grid because they are shown at 14 px.diff --git a/apps/web/src/assets/icons/editor.vscode.svg b/apps/web/src/assets/icons/editor.vscode.svgnew file mode 100644index 00000000..3b657637--- /dev/null+++ b/apps/web/src/assets/icons/editor.vscode.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path fill-rule="evenodd" clip-rule="evenodd" d="M15.5322 19.651C15.7606 19.74 16.021 19.7343 16.2515 19.6233L19.2368 18.1869C19.5505 18.0359 19.75 17.7184 19.75 17.3701V7.6299C19.75 7.2816 19.5505 6.9642 19.2368 6.8132L16.2515 5.3767C15.949 5.2311 15.595 5.2668 15.3295 5.4598C15.2915 5.4874 15.2554 5.5182 15.2215 5.5521L9.5065 10.766L7.0171 8.8764C6.7854 8.7005 6.4613 8.7149 6.2461 8.9107L5.4476 9.637C5.1844 9.8764 5.1841 10.2906 5.447 10.5305L7.6058 12.5L5.447 14.4696C5.1841 14.7094 5.1844 15.1236 5.4476 15.3631L6.2461 16.0893C6.4613 16.2851 6.7854 16.2995 7.0171 16.1236L9.5065 14.234L15.2215 19.4479C15.3119 19.5384 15.4181 19.6065 15.5322 19.651ZM16.1272 9.2083L11.7908 12.5L16.1272 15.7917V9.2083Z" fill="currentColor" fill-opacity="0.64"/>+</svg>diff --git a/apps/web/src/assets/icons/editor.zed.svg b/apps/web/src/assets/icons/editor.zed.svgnew file mode 100644index 00000000..3ac2b08c--- /dev/null+++ b/apps/web/src/assets/icons/editor.zed.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">+<path fill-rule="evenodd" clip-rule="evenodd" d="M7.2188 6.8125C6.9944 6.8125 6.8125 6.9944 6.8125 7.2188V16.1562H6V7.2188C6 6.5457 6.5457 6 7.2188 6H18.1034C18.6463 6 18.9181 6.6564 18.5343 7.0403L11.8304 13.7441H13.7188V12.9062H14.5312V13.9473C14.5312 14.2838 14.2584 14.5566 13.9219 14.5566H11.0179L9.6214 15.9531H15.9531V10.875H16.7656V15.9531C16.7656 16.4018 16.4018 16.7656 15.9531 16.7656H8.8089L7.387 18.1875H17.7812C18.0056 18.1875 18.1875 18.0056 18.1875 17.7812V8.8438H19V17.7812C19 18.4543 18.4543 19 17.7812 19H6.8966C6.3537 19 6.0819 18.3436 6.4657 17.9597L13.1442 11.2812H11.2812V12.0938H10.4688V11.0781C10.4688 10.7416 10.7416 10.4688 11.0781 10.4688H13.9567L15.3786 9.0469H9.0469V14.125H8.2344V9.0469C8.2344 8.5981 8.5981 8.2344 9.0469 8.2344H16.1911L17.613 6.8125H7.2188Z" fill="currentColor" fill-opacity="0.64"/>+</svg>diff --git a/apps/web/src/components/commands/index.tsx b/apps/web/src/components/commands/index.tsxindex 7fcfd3d8..15974f69 100644--- a/apps/web/src/components/commands/index.tsx+++ b/apps/web/src/components/commands/index.tsx@@ -9,6 +9,7 @@ import { ExportCurrentFrameCommand } from "./export-current-frame";import { ExportVideoCommand } from "./export-video";import { GenerateCommand } from "./generate";import { MakeVideoCommand } from "./make-video";+import { ProjectFolderCommands } from "./project-folder";import { RemoveBackgroundCommand } from "./remove-background";import { RerunCommand } from "./rerun";import { ReuseSettingsCommand } from "./reuse-settings";@@ -22,7 +23,8 @@ export { ReloadWindowCommand } from "./reload-window";/*** The canvas's commands: what to generate, what the selected media can be- * run through, the toolbar's tools, and the keyboard shortcuts.+ * run through, the toolbar's tools, the keyboard shortcuts, and where else+ * the project folder can be opened.*/export function CanvasCommands() {return (@@ -50,6 +52,7 @@ export function CanvasCommands() {<ToolCommand tool={ToolType.PEN} /><ToolCommand tool={ToolType.TEXT} /><ShortcutCommands />+ <ProjectFolderCommands /></>);}diff --git a/apps/web/src/components/commands/palette.tsx b/apps/web/src/components/commands/palette.tsxindex a34af160..16c5d531 100644--- a/apps/web/src/components/commands/palette.tsx+++ b/apps/web/src/components/commands/palette.tsx@@ -73,7 +73,8 @@ type ListedSection = { name: string; commands: RegisteredCommand[] };/*** The commands on offer that match `search`, in sections. Without a search,- * sections in `SECTIONS` order and commands in the order they registered;+ * sections in `SECTIONS` order and commands by `order`, then in the order+ * they registered;* with one, the best match first, and the section it is in. cmdk scores,* but leaves the order alone under Solid.*/@@ -86,7 +87,12 @@ function rank(commands: RegisteredCommand[], search: string): ListedSection[] {score: query ? defaultFilter(command.title, query, [command.group, ...(command.keywords ?? [])]) : 1,})).filter((match) => match.score >= MIN_SCORE)- .sort((a, b) => b.score - a.score || SECTIONS.indexOf(a.command.group) - SECTIONS.indexOf(b.command.group));+ .sort(+ (a, b) =>+ b.score - a.score ||+ SECTIONS.indexOf(a.command.group) - SECTIONS.indexOf(b.command.group) ||+ (a.command.order ?? 0) - (b.command.order ?? 0),+ );const byName = new Map<string, RegisteredCommand[]>();for (const { command } of matches) {diff --git a/apps/web/src/components/commands/project-folder.tsx b/apps/web/src/components/commands/project-folder.tsxnew file mode 100644index 00000000..1762088c--- /dev/null+++ b/apps/web/src/components/commands/project-folder.tsx@@ -0,0 +1,74 @@+/* 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 { For, createResource } from "solid-js";+import { toast } from "somoto";+import { useCommand } from "@/context/commands";+import { useProject } from "@/context/project";+import { listEditors, openInEditor, revealPath } from "@/lib/shell";+import { isWindowsDesktop } from "@/projects";++import type { EditorId, EditorInfo } from "@/lib/shell";++/** Each editor's logo. */+const EDITOR_ICONS: Record<EditorId, string> = {+ vscode: "editor.vscode",+ cursor: "agent.cursor",+ zed: "editor.zed",+};++/**+ * The project folder's commands, as the File menu has them: showing it in+ * Finder (Explorer on Windows), and opening it in each code editor installed+ * here. Desktop only; off it there is no folder to show.+ */+export function ProjectFolderCommands() {+ const project = useProject();+ const [editors] = createResource(listEditors, { initialValue: [] });++ const handleReveal = async () => {+ try {+ await revealPath(project.dir());+ } catch (e) {+ toast.error("Failed to show the folder", { description: (e as Error).message });+ }+ };++ useCommand({+ id: "show-project-folder",+ title: isWindowsDesktop() ? "Show in Explorer" : "Show in Finder",+ group: "Window",+ icon: "navigation.folder",+ keywords: ["reveal", "project folder", "files", "finder", "explorer"],+ available: () => Boolean(window.desktop && project.dir()),+ run: () => void handleReveal(),+ });++ return <For each={editors()}>{(editor) => <OpenInEditorCommand editor={editor} />}</For>;+}++function OpenInEditorCommand(props: { editor: EditorInfo }) {+ const project = useProject();+ const { editor } = props;++ const handleOpen = async () => {+ try {+ await openInEditor(editor.id, project.dir());+ } catch (e) {+ toast.error(`Failed to open in ${editor.label}`, { description: (e as Error).message });+ }+ };++ useCommand({+ id: `open-in-editor:${editor.id}`,+ title: `Open in ${editor.label}`,+ group: "Window",+ icon: EDITOR_ICONS[editor.id],+ keywords: ["code editor", "project folder", "jsx", "source", editor.id],+ available: () => Boolean(project.dir()),+ run: () => void handleOpen(),+ });++ return null;+}diff --git a/apps/web/src/components/commands/reload-window.tsx b/apps/web/src/components/commands/reload-window.tsxindex e9d4ad20..88e3be70 100644--- a/apps/web/src/components/commands/reload-window.tsx+++ b/apps/web/src/components/commands/reload-window.tsx@@ -13,6 +13,7 @@ export function ReloadWindowCommand() {icon: "reload",keywords: ["refresh", "restart"],shortcut: ["⌘", "R"],+ order: 1,run: () => window.location.reload(),});diff --git a/apps/web/src/context/commands.tsx b/apps/web/src/context/commands.tsxindex 13ad9244..1dda6daa 100644--- a/apps/web/src/context/commands.tsx+++ b/apps/web/src/context/commands.tsx@@ -57,6 +57,11 @@ export type Command = CommandAction & {keywords?: string[];/** The keys it is bound to, one cap each (["⌘", "K"]); shown, not bound. */shortcut?: string[];+ /**+ * Where it is listed in its section, lowest first; 0 when left out.+ * Commands with the same index keep the order they registered in.+ */+ order?: number;/** Whether it is offered right now; always, when left out. */available?(): boolean;};