The VS Code of video editing, built for agents.
TypeScript
Implement setup status and verification enhancements
konstantin-paulusf053820268ce
diff --git a/apps/desktop/src/main-channels.ts b/apps/desktop/src/main-channels.tsindex 22995f0d..6b615aad 100644--- a/apps/desktop/src/main-channels.ts+++ b/apps/desktop/src/main-channels.ts@@ -34,6 +34,7 @@ export const MAIN_CHANNELS = {AUTH_GET_PENDING_CALLBACK: "auth:get-pending-callback",CHECKOUT_GET_PENDING_CALLBACK: "checkout:get-pending-callback",SETUP_ENSURE: "setup:ensure",+ SETUP_STATUS: "setup:status",WINDOW_IS_FULLSCREEN: "window:is-fullscreen",WINDOW_CAPTURE: "window:capture",FILE_TRANSFER: "file:transfer",@@ -157,6 +158,12 @@ export type SetupResult = {skills: string[];};+export type SetupStatus = {+ /** Every agent config on this machine points at this build's MCP server. */+ mcp: boolean;+ cli: "present" | "missing" | "declined" | "unavailable";+};+export type { SourceEdit, WriteResult };export type MainChannel = (typeof MAIN_CHANNELS)[keyof typeof MAIN_CHANNELS];@@ -184,7 +191,11 @@ export type MainRequestMap = {request: void;response: string | null;};- [MAIN_CHANNELS.SETUP_ENSURE]: { request: void; response: SetupResult };+ [MAIN_CHANNELS.SETUP_ENSURE]: {+ request: { cli?: CliMode };+ response: SetupResult;+ };+ [MAIN_CHANNELS.SETUP_STATUS]: { request: void; response: SetupStatus };[MAIN_CHANNELS.WINDOW_IS_FULLSCREEN]: { request: void; response: boolean };[MAIN_CHANNELS.WINDOW_CAPTURE]: { request: void; response: ScreenshotResult };[MAIN_CHANNELS.FILE_TRANSFER]: {diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.tsindex 15b60ebd..6a9a1a15 100644--- a/apps/desktop/src/main.ts+++ b/apps/desktop/src/main.ts@@ -12,7 +12,7 @@ import { updateElectronApp } from "update-electron-app";import { DapiServer } from "./dapi/server";import { enableHeadless, isHeadless } from "./headless";import { agentLaunchUrl, listAgents } from "./agent-detect";-import { ensureSetup } from "./setup";+import { ensureSetup, setupStatus, verifySetup } from "./setup";import { trackInstall } from "./analytics";import { setupAppMenu } from "./menu";import { mainBridge } from "./main-manager";@@ -292,7 +292,8 @@ if (app.requestSingleInstanceLock()) {});mainBridge.handle(MAIN_CHANNELS.APP_OPEN_EXTERNAL, ({ url }) => shell.openExternal(url));mainBridge.handle(MAIN_CHANNELS.APP_SHOW_IN_FOLDER, ({ path }) => shell.showItemInFolder(path));- mainBridge.handle(MAIN_CHANNELS.SETUP_ENSURE, () => ensureSetup({ cli: "auto" }));+ mainBridge.handle(MAIN_CHANNELS.SETUP_ENSURE, ({ cli }) => ensureSetup({ cli }));+ mainBridge.handle(MAIN_CHANNELS.SETUP_STATUS, () => setupStatus());mainBridge.handle(MAIN_CHANNELS.AUTH_GET_PENDING_CALLBACK, () =>takePendingDeepLink(MAIN_CHANNELS.AUTH_CALLBACK),);@@ -392,8 +393,7 @@ if (app.requestSingleInstanceLock()) {if (url) deliverDeepLink(url);dapi.start();- // Setup as far as it goes without a password prompt- ensureSetup({ cli: "skip" });+ verifySetup();trackInstall();createWindow(!isHiddenLaunch(process.argv));});diff --git a/apps/desktop/src/mcp-install.ts b/apps/desktop/src/mcp-install.tsindex f9a2c339..dfcdfa37 100644--- a/apps/desktop/src/mcp-install.ts+++ b/apps/desktop/src/mcp-install.ts@@ -66,6 +66,16 @@ function upToDate(target: AgentTarget, current: McpServerSpec): boolean {return typeof entry.command === "string" ? registered.command === entry.command : registered.url === current.url;}+/**+ * Whether every agent config this machine needs already points at this build.+ */+export function mcpRegistered(): boolean {+ const current = spec();+ const reachable = targetAgents()+ .filter((target) => !(needsBinary(target) && current.command === ""));+ return reachable.length > 0 && reachable.every((target) => upToDate(target, current));+}+export function registerMcp(): McpRegisterResult {// A quarantined first launch runs from a translocated read-only mount whose// path won't survive the next launch — registering it would dangle.diff --git a/apps/desktop/src/setup.ts b/apps/desktop/src/setup.tsindex a6e3233d..4063fb93 100644--- a/apps/desktop/src/setup.ts+++ b/apps/desktop/src/setup.ts@@ -7,10 +7,10 @@ import { existsSync, rmSync, writeFileSync } from "node:fs";import { join } from "node:path";import { installCli, isCliInstalled } from "./cli-install";-import { healMcpRegistrations, registerMcp } from "./mcp-install";+import { healMcpRegistrations, mcpRegistered, registerMcp } from "./mcp-install";import { pruneLegacySkills } from "./skills-cleanup";-import type { CliMode, CliSetupResult, SetupResult } from "./main-channels";+import type { CliMode, CliSetupResult, SetupResult, SetupStatus } from "./main-channels";// Linking the CLI needs an admin password, so a refusal has to be// remembered: asking again on the next handoff is how a prompt turns into@@ -65,3 +65,27 @@ export async function ensureSetup({ cli = "auto" }: { cli?: CliMode } = {}): Proconst mcp = registerMcp();return { mcp, cli: await ensureCli(cli), skills };}++/**+ * The launch pass. It repairs entries this app already owns.+ */+export function verifySetup(): SetupStatus {+ pruneLegacySkills();+ healMcpRegistrations();+ return setupStatus();+}++/** What the CLI half of setup would find, without asking for a password. */+function cliStatus(): SetupStatus["cli"] {+ if (isCliInstalled()) return "present";+ if (!app.isPackaged) return "unavailable";+ return existsSync(declinedPath()) ? "declined" : "missing";+}++/**+ * Whether the agent configs already point at this build, and where the `dapi`+ * symlink stands.+ */+export function setupStatus(): SetupStatus {+ return { mcp: mcpRegistered(), cli: cliStatus() };+}diff --git a/apps/web/src/components/canvas/canvas.tsx b/apps/web/src/components/canvas/canvas.tsxindex bdb2754b..628b5fb1 100644--- a/apps/web/src/components/canvas/canvas.tsx+++ b/apps/web/src/components/canvas/canvas.tsx@@ -10,6 +10,7 @@ import { droppedFiles, importFiles } from "@/engine/asset-actions";import { Toolbar } from "./toolbar";import { DrawOverlay } from "./draw-overlay";import { DesktopAppBanner } from "./desktop-app-banner";+import { McpSetupBanner } from "./mcp-setup-banner";import { toast } from "somoto"import { SceneInitOverlay } from "./scene-init-overlay";import { ASSET_DRAG_TYPE } from "@/components/sidebar-left/folder-item";@@ -77,6 +78,7 @@ export function Canvas() {><Toolbar /><DesktopAppBanner />+ <McpSetupBanner /><DrawOverlay /><SceneInitOverlay /><EngineCanvas />diff --git a/apps/web/src/components/canvas/mcp-setup-banner.tsx b/apps/web/src/components/canvas/mcp-setup-banner.tsxnew file mode 100644index 00000000..90dfa859--- /dev/null+++ b/apps/web/src/components/canvas/mcp-setup-banner.tsx@@ -0,0 +1,123 @@+/* 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 { Show, createResource, createSignal, onCleanup } from "solid-js";+import { toast } from "somoto";++import { Button } from "@/components/ui/button";+import { Icon } from "@/components/ui/icon";+import { useEditorApi } from "@/dapi";+import { agentSetupStatus, connectAgents, setupPending } from "@/lib/agents";+import { track } from "@/lib/analytics";+import { createStoredSignal } from "@/lib/store";+import { store } from "@/init";++import type { SetupResult } from "@/lib/agents";++// The same artwork the download promo uses — one card, two steps of the+// same story, so the second one is recognisably the first one's sequel.+const BANNER_IMAGE = new URL("@/assets/images/desktop-app-banner.png", import.meta.url).href;++/**+ * The desktop counterpart of {@link DesktopAppBanner}: same card, same+ * corner, but for the step after installing the app — pointing the coding+ * agents on this machine at its MCP server. It appears only while there is+ * something left to do (`setup:status` checks the agent configs and the+ * `dapi` symlink both, without writing either), and goes away the moment+ * setup completes, whether from this button or the app menu.+ */+export function McpSetupBanner() {+ const { isDesktop } = useEditorApi();+ const [dismissed, setDismissed] = createStoredSignal(+ store.define("canvas.mcp-setup-banner-dismissed", false),+ );+ const [status, { refetch }] = createResource(agentSetupStatus);+ const [busy, setBusy] = createSignal(false);++ // Connecting can also happen from the app menu, and the admin prompt takes+ // the window's focus with it — coming back is the moment to look again.+ const handleFocus = () => void refetch();+ window.addEventListener("focus", handleFocus);+ onCleanup(() => window.removeEventListener("focus", handleFocus));++ const handleDismiss = () => {+ track("mcp_setup_banner_dismissed", { source: "canvas_banner" });+ setDismissed(true);+ };++ const handleConnect = async () => {+ if (busy()) return;+ setBusy(true);++ try {+ const result = await connectAgents();+ track("mcp_setup_connected", { source: "canvas_banner", cli: result.cli.status });+ toast("Your agents are connected", { description: describe(result) });+ } catch (e) {+ toast.error("Could not connect your agents", {+ description: (e as Error).message,+ });+ } finally {+ setBusy(false);+ // The card hides itself once nothing is left to do.+ await refetch();+ }+ };++ return (+ <Show when={isDesktop && !dismissed() && setupPending(status())}>+ <div class="absolute bottom-4 left-4 z-10 flex w-[220px] flex-col gap-1 rounded-md border border-border bg-background pb-3 shadow-[0px_0px_1px_2px_rgba(0,0,0,0.12),0px_4px_12px_8px_rgba(0,0,0,0.12)]">+ <div class="relative aspect-[220/122] w-full overflow-hidden rounded-t-md">+ <img src={BANNER_IMAGE} alt="" class="pointer-events-none size-full object-cover" />+ <button+ type="button"+ aria-label="Dismiss"+ class="absolute right-1 top-1 text-muted-foreground transition-colors hover:text-foreground"+ onClick={handleDismiss}+ >+ <Icon name="close-remove" />+ </button>+ </div>+ <div class="flex flex-col gap-3 px-3">+ <div class="flex flex-col gap-0.5">+ <div class="flex h-7 items-center">+ <span class="truncate text-xs font-450 leading-4 text-foreground">+ Connect your coding agents+ </span>+ </div>+ <p class="text-xs leading-4 text-muted-foreground">+ Point Claude Code, Codex, or another coding agent at this app so it can analyze+ footage and edit your project.+ </p>+ </div>+ <Button+ variant="secondary"+ class="w-full gap-1"+ disabled={busy()}+ onClick={handleConnect}+ >+ <Show when={busy()} fallback="Connect agents">+ <Icon name="spinner-loader" class="animate-spin" />+ Connecting…+ </Show>+ </Button>+ </div>+ </div>+ </Show>+ );+}++/** What the toast says about a finished setup, one line per step that did something. */+function describe({ mcp, cli }: SetupResult): string {+ const lines: string[] = [];++ if (mcp.status === "registered") {+ lines.push(`${mcp.agents.join(", ")} can now reach this app — restart the agent to pick it up.`);+ }+ if (cli.status === "installed") lines.push('The "dapi" command is now on your PATH.');+ if (cli.status === "cancelled") lines.push('Skipped linking the "dapi" command line tool.');+ if (cli.status === "error") lines.push(`The "dapi" command could not be linked: ${cli.error}`);++ return lines.join(" ");+}diff --git a/apps/web/src/lib/agents.ts b/apps/web/src/lib/agents.tsindex efe2a108..f5889b8d 100644--- a/apps/web/src/lib/agents.ts+++ b/apps/web/src/lib/agents.ts@@ -12,9 +12,9 @@import { MAIN_CHANNELS } from "@desktop/main-channels";import { mainBridge } from "@/lib/ipc";-import type { AgentInfo } from "@desktop/main-channels";+import type { AgentInfo, SetupResult, SetupStatus } from "@desktop/main-channels";-export type { AgentInfo };+export type { AgentInfo, SetupResult, SetupStatus };/*** The icon file for each agent, by the id `agent-links.ts` gives it. Kept on@@ -69,6 +69,36 @@ export async function launchAgent(export async function ensureAgentSetup(): Promise<void> {if (!window.desktop) return;- const { mcp } = await mainBridge.call(MAIN_CHANNELS.SETUP_ENSURE, undefined);+ const { mcp } = await mainBridge.call(MAIN_CHANNELS.SETUP_ENSURE, {});if (mcp.status === "error") throw new Error(mcp.error);}++/**+ * The same steps as {@link ensureAgentSetup}, for a user who asked for them+ * by name rather than by sending a prompt: the CLI symlink is offered again+ * even after an earlier refusal, and the whole result comes back so the+ * caller can say what was done.+ */+export async function connectAgents(): Promise<SetupResult> {+ if (!window.desktop) throw new Error("Connecting agents needs the desktop app");++ const result = await mainBridge.call(MAIN_CHANNELS.SETUP_ENSURE, { cli: "force" });+ if (result.mcp.status === "error") throw new Error(result.mcp.error);+ return result;+}++/**+ * What setup would find on this machine, without doing any of it.+ */+export async function agentSetupStatus(): Promise<SetupStatus | null> {+ if (!window.desktop) return null;+ return mainBridge.call(MAIN_CHANNELS.SETUP_STATUS, undefined);+}++/**+ * Whether `status` leaves anything worth offering to do.+ */+export function setupPending(status: SetupStatus | null | undefined): boolean {+ if (!status) return false;+ return !status.mcp || status.cli === "missing";+}