The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Canvas: Run group tells what it will run and what it costs; Translate starts an open-engine dub in Translate & dub
Claudeea5cdc6ba3df
diff --git a/src/components/canvas/board.tsx b/src/components/canvas/board.tsxindex 10a2dee1..c4e65c1b 100644--- a/src/components/canvas/board.tsx+++ b/src/components/canvas/board.tsx@@ -5,9 +5,10 @@ import { Check, MoreHorizontal, Pencil, Play, RotateCcw, Trash2, Ungroup } fromimport { memo, useEffect, useRef, useState } from "react";import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";-import { newId, type CanvasGraph } from "@/lib/catalog/canvas";+import { getModel } from "@/lib/catalog";+import { ancestors, newId, type CanvasGraph } from "@/lib/catalog/canvas";import { BOARD_COLOR_LABEL, BOARD_COLORS, BOARD_LIMITS, COMMENT_AUTHOR, groupMembers, strokePath, type BoardColor, type CanvasComment, type CanvasGroup, type CanvasShape } from "@/lib/catalog/canvas-board";-import { timeAgo } from "@/lib/format";+import { formatCost, timeAgo } from "@/lib/format";import { cn } from "@/lib/utils";import { useEditorActions, useEditorGlobals, useEditorSelector, type EditorSnapshot } from "./canvas-context";import type { FlowNode } from "./nodes";@@ -155,6 +156,46 @@ const selectGroupCount = (s: EditorSnapshot, id: string) => {return g ? groupMembers(s.graph, g).length : 0;};+/** What Run group would start: the group's nodes that need to run, and what they need upstream. */+interface GroupPlan {+ steps: number;+ usd: number;+ unknown: boolean;+ /** The models the steps run (a demo run is free whatever they cost). */+ models: string;+}+const sameGroupPlan = (a: GroupPlan, b: GroupPlan) => a.steps === b.steps && a.usd === b.usd && a.unknown === b.unknown && a.models === b.models;+const selectGroupPlan = (s: EditorSnapshot, id: string): GroupPlan => {+ const g = s.graph.groups?.find((x) => x.id === id);+ if (!g) return { steps: 0, usd: 0, unknown: false, models: "" };+ const members = groupMembers(s.graph, g).map((n) => n.id);+ const scope = new Set([...members, ...ancestors(s.graph, members)]);+ const steps = s.plan.steps.filter((st) => scope.has(st.nodeId));+ return {+ steps: steps.length,+ usd: Math.round(steps.reduce((n, st) => n + (st.costUsd ?? 0), 0) * 1000) / 1000,+ unknown: steps.some((st) => st.costUsd === null),+ models: [...new Set(steps.map((st) => st.request.modelId))].join(" "),+ };+};++/** Mounted only while the Run group tooltip is open: the price is worked out then, not on every keystroke. */+function GroupPrice({ id }: { id: string }) {+ const p = useEditorSelector(selectGroupPlan, id, sameGroupPlan);+ const { isDemo } = useEditorGlobals();+ if (!p.steps) return <>Everything in this group is up to date</>;+ const demo = p.models.split(" ").every((mid) => {+ const m = getModel(mid);+ return !!m && isDemo(m);+ });+ const price = demo ? "demo, free" : p.unknown ? "price unknown" : p.usd === 0 ? "free" : `≈ ${formatCost(p.usd)}`;+ return (+ <>+ Runs {p.steps === 1 ? "1 node" : `${p.steps} nodes`} (with what they need) · {price}+ </>+ );+}+const GroupNode = memo(function GroupNode({ id, data, selected }: NodeProps<FlowNode>) {const actions = useEditorActions();const { readOnly, running } = useEditorGlobals();@@ -207,7 +248,9 @@ const GroupNode = memo(function GroupNode({ id, data, selected }: NodeProps<Flow<Play className="size-3" /> Run group</button></TooltipTrigger>- <TooltipContent>Runs the nodes in this group, and what they need</TooltipContent>+ <TooltipContent>+ <GroupPrice id={id} />+ </TooltipContent></Tooltip><DropdownMenu><DropdownMenuTrigger asChild>diff --git a/src/components/canvas/nodes.tsx b/src/components/canvas/nodes.tsxindex 91e412e9..eb6cea99 100644--- a/src/components/canvas/nodes.tsx+++ b/src/components/canvas/nodes.tsx@@ -107,6 +107,7 @@ import {} from "@/lib/catalog/canvas";import { OPERATION_LABELS, type Engine, type MediaKind, type ModelDef, type OutputFile } from "@/lib/catalog/types";import { formatCost } from "@/lib/format";+import { DUB_LANGUAGES, supportsTarget } from "@/lib/av/languages";import { matchSpokenLanguage, spokenLanguageName, spokenLanguageOptions } from "@/lib/speech-languages";import { keyCombo } from "@/lib/keys";import { cn } from "@/lib/utils";@@ -818,7 +819,7 @@ const GeneratorNode = memo(function GeneratorNode({ id, type: flowType, data, se)}{type === "concat" ? (<ConcatPanel id={id} data={data} engine={model?.engine ?? g.engine} />- ) : (+ ) : v.error === OPEN_DUB_HINT ? null : (<div className={cn("flex flex-wrap items-center gap-1.5 [&>button]:h-7 [&>button]:text-[12px]", g.readOnly && "pointer-events-none")}>{choices.length ? (<div className={NO_DRAG}>@@ -865,16 +866,62 @@ const GeneratorNode = memo(function GeneratorNode({ id, type: flowType, data, se{error}</p>)}- {error === OPEN_DUB_HINT && (- <Link href="/audio/translate" className={cn(chip, "w-fit")}>- Open Translate & dub- </Link>- )}+ {error === OPEN_DUB_HINT && !g.readOnly && <OpenDub id={id} data={data} />}</div></NodeShell>);}, sameNodeProps);+// ---------------------------------------------------------------------------+// Translate a video on the open engine: the dub is made step by step in Translate & dub (the translation is+// reviewed before it's spoken), so the node starts it there with its clip and language.++const OPEN_DUB_LANGUAGES = DUB_LANGUAGES.filter((l) => supportsTarget("open", l));++const selectVideoIn = (s: EditorSnapshot, id: string): string | undefined => {+ const e = s.graph.edges.find((x) => x.target === id && x.targetHandle === "video");+ const src = e && s.byId.get(e.source);+ if (!src) return undefined;+ return src.type === "video-input" ? src.data.url : s.views.get(src.id)?.results.outputs.find((x) => x.o.kind === "video")?.o.url;+};++function OpenDub({ id, data }: { id: string; data: CanvasNodeData }) {+ const actions = useEditorActions();+ const video = useEditorSelector(selectVideoIn, id);+ const lang = data.params?.targetLanguage && OPEN_DUB_LANGUAGES.some((l) => l.code === data.params?.targetLanguage) ? data.params.targetLanguage : undefined;+ const [started, setStarted] = useState<string | null>(null);+ const [busy, setBusy] = useState(false);+ const start = async () => {+ if (!video || !lang) return;+ setBusy(true);+ try {+ const res = await fetch("/api/dub", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ engine: "open", mode: "steps", video, targets: [lang], source: "auto", title: data.label || "Canvas dub" }) });+ const body = (await res.json().catch(() => ({}))) as { id?: string; error?: string };+ if (!res.ok || !body.id) throw new Error(body.error ?? "Couldn't start the dub");+ setStarted(body.id);+ toast.success("Dub started", { description: "Check the translation in Translate & dub, then have it spoken" });+ } catch (e) {+ toast.error((e as Error).message);+ } finally {+ setBusy(false);+ }+ };+ return (+ <div className={cn("flex flex-wrap items-center gap-1.5", NO_DRAG)}>+ <OptionSelect label="Dub into" value={lang} options={OPEN_DUB_LANGUAGES.map((l) => l.code)} onChange={(v) => actions.update(id, { params: { ...data.params, targetLanguage: v } })} format={(v) => OPEN_DUB_LANGUAGES.find((l) => l.code === v)?.name ?? v} />+ {started ? (+ <Link href={`/audio/translate?dub=${started}`} className={chip}>+ Review the dub+ </Link>+ ) : (+ <button className={chip} onClick={() => void start()} disabled={!video || !lang || busy} title={!video ? "Connect a video (an upload, or a finished clip)" : !lang ? "Pick the language to dub into" : "Free on your GPU"}>+ {busy ? <Loader2 className="size-3 animate-spin" /> : <Play className="size-3" />} Start in Translate & dub+ </button>+ )}+ </div>+ );+}+// ---------------------------------------------------------------------------// Video concatenator: the film's frame, and each clip's cut and sound in the order they playdiff --git a/src/lib/catalog/canvas.ts b/src/lib/catalog/canvas.tsindex 59de8f78..d93cfa2f 100644--- a/src/lib/catalog/canvas.ts+++ b/src/lib/catalog/canvas.ts@@ -1101,7 +1101,7 @@ function concatRequest(graph: CanvasGraph, n: CanvasNode, model: ModelDef): Node}/** A Translate node set to video with no cloud model allowed: where the open engine dubs. */-export const OPEN_DUB_HINT = "Dubbing a video here runs on the cloud (ElevenLabs Dubbing, HeyGen). On the open engine, dub it in Dub, where you check the translation before it's spoken";+export const OPEN_DUB_HINT = "Dubbing a video on a canvas runs on the cloud (ElevenLabs Dubbing, HeyGen). On the open engine it's made in Translate & dub, where you check the translation before it's spoken: start it from here";export interface DescribeContext {engineMode?: "both" | "open" | "cloud";