The VS Code of video editing, built for agents.
TypeScript
feat: add credits display to node menu and update commands to include pricing logic
konstantin-paulus5aeb75118a14
diff --git a/apps/web/src/components/commands/node-menu.tsx b/apps/web/src/components/commands/node-menu.tsxindex d8cb4c1b..e5732255 100644--- a/apps/web/src/components/commands/node-menu.tsx+++ b/apps/web/src/components/commands/node-menu.tsx@@ -23,6 +23,7 @@ import {ContextMenuSubTrigger,ContextMenuTrigger,} from "@/components/ui/context-menu";+import { Icon } from "@/components/ui/icon";import { useCommands } from "@/context/commands";import { getDocumentEditor, useSelection } from "@/engine";@@ -288,6 +289,14 @@ function MenuSections(props: MenuSectionsProps) {<Show when={command.shortcut}>{(keys) => <ContextMenuShortcut>{keys().join("")}</ContextMenuShortcut>}</Show>+ <Show when={command.credits?.()}>+ {(credits) => (+ <ContextMenuShortcut class="flex items-center tracking-normal tabular-nums">+ <Icon name="ai-credits-small" class="-my-1" />+ {credits().toLocaleString()}+ </ContextMenuShortcut>+ )}+ </Show></ContextMenuItem>);};diff --git a/apps/web/src/components/commands/remove-background.tsx b/apps/web/src/components/commands/remove-background.tsxindex bfde4e47..cf818237 100644--- a/apps/web/src/components/commands/remove-background.tsx+++ b/apps/web/src/components/commands/remove-background.tsx@@ -7,7 +7,7 @@ import { useTransforms } from "@/components/genai/use-transforms";import { TransformBar } from "./transform-bar";export function RemoveBackgroundCommand() {- const { targets, run } = useTransforms();+ const { targets, run, price } = useTransforms();useCommand({id: "remove-background",@@ -17,6 +17,7 @@ export function RemoveBackgroundCommand() {keywords: ["cutout", "matte", "transparent"],ready: () => targets("removeBackground").length > 0,run: () => run("removeBackground"),+ credits: () => price("removeBackground"),bar: () => (<TransformBar type="removeBackground" verb="Remove the background of" empty="Select an image to cut out" />),diff --git a/apps/web/src/components/commands/upscale.tsx b/apps/web/src/components/commands/upscale.tsxindex 4a11528d..a861da42 100644--- a/apps/web/src/components/commands/upscale.tsx+++ b/apps/web/src/components/commands/upscale.tsx@@ -7,7 +7,7 @@ import { useTransforms } from "@/components/genai/use-transforms";import { TransformBar } from "./transform-bar";export function UpscaleCommand() {- const { targets, run } = useTransforms();+ const { targets, run, price } = useTransforms();useCommand({id: "upscale",@@ -17,6 +17,7 @@ export function UpscaleCommand() {keywords: ["resolution", "enhance", "sharpen"],ready: () => targets("upscale").length > 0,run: () => run("upscale"),+ credits: () => price("upscale"),bar: () => <TransformBar type="upscale" verb="Upscale" empty="Select an image or video to upscale" />,});diff --git a/apps/web/src/context/commands.tsx b/apps/web/src/context/commands.tsxindex f5810101..c77d0d3e 100644--- a/apps/web/src/context/commands.tsx+++ b/apps/web/src/context/commands.tsx@@ -111,6 +111,11 @@ export type Command = CommandAction & {order?: number;/** Whether it is offered right now; always, when left out. */available?(): boolean;+ /**+ * What carrying it out over the selection costs, in credits: shown beside+ * it in menus. Undefined while that isn't known, and for a command that is free.+ */+ credits?(): number | undefined;/*** False keeps it out of the palette and its recents, for a command only a* menu or shortcut reaches, like the one that opens the palette itself.