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: Split soundtrack keeps its stems wired without a model, and each stem opens or becomes an input
Claude0a3d84c18ca7
diff --git a/src/components/canvas/canvas-context.tsx b/src/components/canvas/canvas-context.tsxindex 658ff415..e7efd70a 100644--- a/src/components/canvas/canvas-context.tsx+++ b/src/components/canvas/canvas-context.tsx@@ -54,6 +54,7 @@ import {type RunReason,} from "@/lib/catalog/canvas";import type { Engine, Generation, GenerationStatus, ModelDef, Operation, OutputFile } from "@/lib/catalog/types";+import type { StemId } from "@/lib/av/split";import type { EngineMode } from "@/lib/api";export const ICONS: Record<string, LucideIcon> = {@@ -347,8 +348,8 @@ export interface EditorActions {patchClip: (nodeId: string, clipId: string, patch: Partial<ClipSettings>) => void;cancel: (id: string) => void;open: (id: string, index?: number) => void;- /** Add an input node holding this node's first output, wired nowhere yet. */- toInput: (id: string) => void;+ /** Add an input node holding this node's first output (or, on Split soundtrack, one stem), wired nowhere yet. */+ toInput: (id: string, stem?: StemId) => void;/*** Add an input node holding a file made for this node elsewhere (an open-engine dub), below it; `takeOver` moves* the node's outgoing connections onto it.diff --git a/src/components/canvas/canvas-editor.tsx b/src/components/canvas/canvas-editor.tsxindex df2604c7..506616f3 100644--- a/src/components/canvas/canvas-editor.tsx+++ b/src/components/canvas/canvas-editor.tsx@@ -44,6 +44,7 @@ import { Viewer } from "@/components/studio/viewer";import { useIsMobile } from "@/hooks/use-mobile";import { useElements, useEngine, useStatus, type EngineMode } from "@/lib/api";import { getModel } from "@/lib/catalog";+import { stemLabel, type StemId } from "@/lib/av/split";import { dualEngine, onEngine, runsOn } from "@/lib/catalog/engines";import {BOARD_LIMITS,@@ -78,6 +79,7 @@ import {OPEN_DUB_HINT,OUT,outputPorts,+ stemOutput,outputType,paletteItems,planCanvas,@@ -790,16 +792,17 @@ function Editor({ id, initial, view }: { id: string; initial: Canvas; view: Canv...ns.map((n) => ({ ...n, selected: false })),{ id: nid, type, position: snap({ x: src.position.x, y: src.position.y + (src.measured?.height ?? 360) + 48 }), data: { url: file.url, label: file.label ?? `From ${nodeLabel(toGraph([src], []).nodes[0])}` }, selected: true },]);- // Split soundtrack hands its first file (the dialogue) over: only its Dialogue connections move.- const moves = (e: Edge) => e.source === nodeId && (src.type !== "split-soundtrack" || (e.sourceHandle ?? OUT) === OUT);- const moved = takeOver ? latest.current.edges.filter(moves).length : 0;- if (moved) setEdges((es) => es.map((e) => (moves(e) ? { ...e, id: newId("e"), source: nid, sourceHandle: OUT } : e)));+ const moved = takeOver ? latest.current.edges.filter((e) => e.source === nodeId).length : 0;+ if (moved) setEdges((es) => es.map((e) => (e.source === nodeId ? { ...e, id: newId("e"), source: nid, sourceHandle: OUT } : e)));touch();toast(moved ? `Added as an input, connected where “${nodeLabel(toGraph([src], []).nodes[0])}” was` : "Added as an input — connect it anywhere");};- const toInput = (nodeId: string) => {- const out = results.get(nodeId)?.outputs.find((x) => KIND_INPUT[x.o.kind]);- if (out) addInput(nodeId, { url: out.o.url, kind: out.o.kind });+ /** `stem`: one of a Split soundtrack's stems, named on the new input ("Music from Split soundtrack"). */+ const toInput = (nodeId: string, stem?: StemId) => {+ const outputs = results.get(nodeId)?.outputs ?? [];+ const o = stem ? stemOutput(outputs.map((x) => x.o), stem) : outputs.find((x) => KIND_INPUT[x.o.kind])?.o;+ const src = latest.current.nodes.find((n) => n.id === nodeId);+ if (o && src) addInput(nodeId, { url: o.url, kind: o.kind, ...(stem && { label: `${stemLabel(stem)} from ${nodeLabel(toGraph([src], []).nodes[0])}` }) });};/** One clip of a Video concatenator: merged into what the node holds now (several clips report their lengths at once). */diff --git a/src/components/canvas/nodes.tsx b/src/components/canvas/nodes.tsxindex b9c46802..dd62bded 100644--- a/src/components/canvas/nodes.tsx+++ b/src/components/canvas/nodes.tsx@@ -16,6 +16,7 @@ import {ImagePlus,Library,Loader2,+ Maximize2,MoreHorizontal,Pencil,Pin,@@ -180,7 +181,7 @@ function OutPort({ type }: { type: PortType }) {* Split soundtrack's outputs: one row per stem, each with its own handle on the right, and the stem to play once the* node has run. A handle the node can't fill here is greyed out, with why.*/-function StemPorts({ ports, outputs }: { ports: OutputPortDef[]; outputs: OutputFile[] }) {+function StemPorts({ ports, outputs, onOpen }: { ports: OutputPortDef[]; outputs: OutputFile[]; onOpen: (index: number) => void }) {return (<div className="border-b py-1" role="list" aria-label="Stems">{ports.map((p) => {@@ -189,7 +190,17 @@ function StemPorts({ ports, outputs }: { ports: OutputPortDef[]; outputs: Output<div key={p.id} role="listitem" className="relative flex min-h-8 items-center gap-2 pr-3.5 pl-3 text-[11px]" title={p.disabled}><span className={cn("w-24 shrink-0 font-medium", p.disabled ? "text-subtle-foreground" : o ? "text-foreground" : "text-muted-foreground")}>{p.label}</span>{o ? (- <audio src={o.url} controls preload="none" aria-label={`${p.label} stem`} className={cn("h-7 w-full min-w-0 flex-1", NO_DRAG)} />+ <>+ <audio src={o.url} controls preload="none" aria-label={`${p.label} stem`} className={cn("h-7 w-full min-w-0 flex-1", NO_DRAG)} />+ <button+ onClick={() => onOpen(outputs.indexOf(o))}+ className={cn("grid size-6 shrink-0 place-items-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground", NO_DRAG)}+ aria-label={`Open ${p.label.toLowerCase()} stem`}+ title="Open"+ >+ <Maximize2 className="size-3.5" />+ </button>+ </>) : (<span className="min-w-0 flex-1 truncate text-right text-subtle-foreground">{p.disabled ? "Not available here" : ""}</span>)}@@ -782,7 +793,12 @@ const GeneratorNode = memo(function GeneratorNode({ id, type: flowType, data, se]),...(running ? [{ label: "Cancel", icon: Square, onSelect: () => actions.cancel(id) }] : []),{ label: data.pinned ? "Unpin result" : "Pin result", icon: data.pinned ? PinOff : Pin, onSelect: () => actions.update(id, { pinned: !data.pinned }), separatorBefore: !data.pinned },- ...(r.outputs.some((x) => ["image", "video", "audio"].includes(x.o.kind)) ? [{ label: "Use result as an input", icon: ImagePlus, onSelect: () => actions.toInput(id) }] : []),+ // Split soundtrack: one item per stem it made ("Use music as an input").+ ...(stems+ ? stems.flatMap((p) => (p.stem && stemOutput(r.outputs.map((x) => x.o), p.stem) ? [{ label: `Use ${p.label.toLowerCase()} as an input`, icon: ImagePlus, onSelect: () => actions.toInput(id, p.stem) }] : []))+ : r.outputs.some((x) => ["image", "video", "audio"].includes(x.o.kind))+ ? [{ label: "Use result as an input", icon: ImagePlus, onSelect: () => actions.toInput(id) }]+ : []),...(r.outputs.length? [{@@ -872,7 +888,7 @@ const GeneratorNode = memo(function GeneratorNode({ id, type: flowType, data, se}>{ports.length > 0 && <div className="border-b py-1">{ports.map((p) => <InPort key={p.id} port={p} count={v.counts[p.id] ?? 0} />)}</div>}- {stems && <StemPorts ports={stems} outputs={r.state === "succeeded" ? r.outputs.map((x) => x.o) : []} />}+ {stems && <StemPorts ports={stems} outputs={r.state === "succeeded" ? r.outputs.map((x) => x.o) : []} onOpen={(i) => actions.open(id, i)} />}<div className="space-y-2 p-3">{variants && (<div className={cn("inline-grid h-7 grid-cols-2 rounded-full bg-muted p-0.5 text-[12px] font-medium", NO_DRAG)} role="radiogroup" aria-label={`${variants[0]} or ${variants[1]}`}>@@ -1680,6 +1696,7 @@ function SourcePreview({ node }: { node: Source }) {if (node.stem) {const o = r.state === "succeeded" ? stemOutput(r.outputs.map((x) => x.o), node.stem) : undefined;if (o) return <OutputThumb o={o} onOpen={() => actions.open(node.id, r.outputs.findIndex((x) => x.o === o))} large />;+ if (r.state === "succeeded") return <div className="grid h-20 place-items-center rounded-lg bg-muted text-[11px] text-muted-foreground">No {stemLabel(node.stem).toLowerCase()} in this result</div>;} else if (r.outputs.length) return <OutputThumb o={r.outputs[0].o} onOpen={() => actions.open(node.id, 0)} large />;if (r.state !== "idle") return <Results id={node.id} r={r} compact />;return <div className="grid h-20 place-items-center rounded-lg bg-muted text-[11px] text-muted-foreground">Not run yet</div>;diff --git a/src/lib/catalog/canvas.ts b/src/lib/catalog/canvas.tsindex 4f3facaa..2122a4ed 100644--- a/src/lib/catalog/canvas.ts+++ b/src/lib/catalog/canvas.ts@@ -696,21 +696,27 @@ export function stemOutput<T extends { kind: string; meta?: Record<string, unknoreturn audio.find((o) => typeof o.meta?.stem === "string" && STEM_NAMES[stem].includes(o.meta.stem.toLowerCase()));}-/** Why a Split soundtrack node can't run on this install or board engine (it runs on your GPU only), or null. */+/**+ * Why a Split soundtrack node can't run on this install (it runs on your GPU only), or null. A node with no model yet,+ * or one the catalog no longer has, isn't an engine problem: describeNode asks for a model and its edges stay.+ */export function splitProblem(n: Pick<CanvasNode, "data">, mode: "both" | Engine = "both"): string | null {if (mode === "cloud") return CLOUD_ONLY_PROBLEM;const model = nodeModel(n, mode);- return model && runsOn(model, "open") ? null : CLOUD_SPLIT_PROBLEM;+ // A separator that isn't one of the node's (a cloud one such as Demucs, or a two-stem open one) is told to pick DBS.+ return model && !SPLIT_STEMS[model.id] ? `${model.name} can't split a soundtrack into its stems — pick ${splitModels()[0]?.name ?? "another model"}` : null;}/** A node's output handles: OUT with its type, Split soundtrack's four stems, or none. */export function outputPorts(graph: CanvasGraph, n: CanvasNode, mode: "both" | Engine = "both"): OutputPortDef[] {if (n.type === "split-soundtrack") {- const why = splitProblem(n, mode);+ // Only the install shuts the handles (a cloud-only one): a node still missing its model keeps its edges, and a+ // separator that makes fewer stems shuts the ones it doesn't make.+ const why = mode === "cloud" ? CLOUD_ONLY_PROBLEM : undefined;const model = nodeModel(n, mode);- const stems = (model && SPLIT_STEMS[model.id]) || [];+ const stems = model && SPLIT_STEMS[model.id];return SPLIT_HANDLES.map((h) => {- const disabled = why ?? (model && !stems.includes(h.stem) ? `${model.name} doesn't make a ${h.label.toLowerCase()} stem` : undefined);+ const disabled = why ?? (model && stems && !stems.includes(h.stem) ? `${model.name} doesn't make a ${h.label.toLowerCase()} stem` : undefined);return { id: h.id, label: h.label, type: "audio" as const, stem: h.stem, ...(disabled && { disabled }) };});}@@ -1420,11 +1426,11 @@ export function describeNode(graph: CanvasGraph, n: CanvasNode, ctx: DescribeConconst mode = ctx.engineMode ?? "both";// A Fuobe Original as it runs on the node's engine (its routes, its price).const model = nodeModel(n, mode);- // Split soundtrack runs on your GPU only: a cloud-only install, or a board with no open model for it, says so.+ // Split soundtrack runs on your GPU only: a cloud-only install says so, and a node on another separator is told to+ // pick DBS (a node with no model asks for one below).if (n.type === "split-soundtrack") {const why = splitProblem(n, mode);if (why) return { ...(model && { model }), costUsd: null, error: why };- if (model && !SPLIT_STEMS[model.id]) return { model, costUsd: null, error: `${model.name} can't split a soundtrack into its stems — pick ${splitModels()[0]?.name ?? "another model"}` };}// Dubbing has no open model: an open-only install says where it dubs instead. The concatenator's tools are// picked by engine, not by model.diff --git a/tests/canvas-split.test.ts b/tests/canvas-split.test.tsindex 00219a14..f346b3a3 100644--- a/tests/canvas-split.test.ts+++ b/tests/canvas-split.test.ts@@ -143,16 +143,32 @@ describe("Split soundtrack node", () => {expect(connectionError(g, { source: "split", sourceHandle: "music", target: "out", targetHandle: "in" }, "cloud")).toBe(CLOUD_ONLY_PROBLEM);});- it("with no open model for it, says it runs on open source", () => {+ it("with no model, asks for one and keeps its stem edges", () => {const g = board();const bare = { ...at(g, "split"), data: {} };- expect(describeNode(g, bare).error).toBe(CLOUD_SPLIT_PROBLEM);- expect(outputPorts(g, bare).every((p) => p.disabled === CLOUD_SPLIT_PROBLEM)).toBe(true);- // A board saved on another open separator (a vocals model with two stems) is told to pick DBS; a cloud one (Demucs)- // is not run in its place either.- expect(describeNode(g, { ...at(g, "split"), data: { modelId: "demucs" } }).error).toBe(CLOUD_SPLIT_PROBLEM);- const other = { ...at(g, "split"), data: { modelId: "oss-voice-separate" } };- expect(describeNode(g, other).error).toMatch(/can't split a soundtrack into its stems — pick DBS/);+ expect(describeNode(g, bare).error).toBe("Pick a model");+ expect(outputPorts(g, bare).every((p) => !p.disabled)).toBe(true);+ // Saved without a model (a template, the API, or a model gone from the catalog): no edge out of it is lost.+ const saved = { ...g, nodes: g.nodes.map((n) => (n.id === "split" ? bare : n)) };+ expect(cleanGraph(saved).edges).toHaveLength(g.edges.length);+ expect(parseGraph(saved)?.edges).toHaveLength(g.edges.length);+ const gone = { ...at(g, "split"), data: { modelId: "no-such-model" } };+ expect(describeNode(g, gone).error).toBe("That model is no longer in the catalog — pick another");+ });++ it("on another separator, is told to pick DBS (never run in its place) and keeps its edges", () => {+ const g = board();+ // A cloud one (Demucs) and an open one with two stems: both told to pick DBS, on an open board too.+ for (const modelId of ["demucs", "oss-voice-separate"]) {+ const other = { ...at(g, "split"), data: { modelId } };+ expect(describeNode(g, other).error).toMatch(/can't split a soundtrack into its stems — pick DBS/);+ expect(describeNode(g, other, { engineMode: "open" }).error).toMatch(/pick DBS/);+ expect(describeNode(g, other).error).not.toBe(CLOUD_SPLIT_PROBLEM);+ const saved = { ...g, nodes: g.nodes.map((n) => (n.id === "split" ? other : n)) };+ expect(cleanGraph(saved).edges).toHaveLength(g.edges.length);+ }+ // The install alone shuts the handles.+ expect(outputPorts(g, at(g, "split"), "cloud").every((p) => p.disabled === CLOUD_ONLY_PROBLEM)).toBe(true);});it("stays on the open engine when the board switches to the cloud", () => {