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: a Split soundtrack node with Dialogue, Music, Effects and Music & effects outputs
Claudeba57f62b8a6b
diff --git a/src/components/canvas/canvas-context.tsx b/src/components/canvas/canvas-context.tsxindex 40cc8b40..658ff415 100644--- a/src/components/canvas/canvas-context.tsx+++ b/src/components/canvas/canvas-context.tsx@@ -4,6 +4,7 @@ import {AtSign,AudioLines,AudioWaveform,+ Split,Building2,Castle,Clapperboard,@@ -75,6 +76,7 @@ export const ICONS: Record<string, LucideIcon> = {GalleryHorizontal,Columns3,AudioWaveform,+ Split,UserRound,Languages,Table,diff --git a/src/components/canvas/canvas-editor.tsx b/src/components/canvas/canvas-editor.tsxindex 7eccd14f..df2604c7 100644--- a/src/components/canvas/canvas-editor.tsx+++ b/src/components/canvas/canvas-editor.tsx@@ -77,6 +77,7 @@ import {nodeLabel,OPEN_DUB_HINT,OUT,+ outputPorts,outputType,paletteItems,planCanvas,@@ -598,9 +599,9 @@ function Editor({ id, initial, view }: { id: string; initial: Canvas; view: Canvconst g = toGraph([...latest.current.nodes, node], latest.current.edges);const c: Connection =connect.from === "source"- ? { source: connect.nodeId, sourceHandle: OUT, target: node.id, targetHandle: item.type === "output" ? PREVIEW_IN : (inputPorts(toGraph([node], []).nodes[0]).find((p) => acceptsType(p, connect.type))?.id ?? null) }+ ? { source: connect.nodeId, sourceHandle: connect.handleId ?? OUT, target: node.id, targetHandle: item.type === "output" ? PREVIEW_IN : (inputPorts(toGraph([node], []).nodes[0]).find((p) => acceptsType(p, connect.type))?.id ?? null) }: { source: node.id, sourceHandle: OUT, target: connect.nodeId, targetHandle: connect.handleId };- if (c.targetHandle && !connectionError(g, c)) {+ if (c.targetHandle && !connectionError(g, c, mode)) {setEdges((es) => [...(singleInput(g, c.target, c.targetHandle) ? es.filter((e) => !(e.target === c.target && e.targetHandle === c.targetHandle)) : es), { id: newId("e"), ...c }]);}}@@ -652,17 +653,17 @@ function Editor({ id, initial, view }: { id: string; initial: Canvas; view: Canv},[touch],);- const isValidConnection = useCallback((c: Connection | Edge) => !connectionError(toGraph(latest.current.nodes, latest.current.edges), c), []);+ const isValidConnection = useCallback((c: Connection | Edge) => !connectionError(toGraph(latest.current.nodes, latest.current.edges), c, mode), [mode]);const onConnect = useCallback((c: Connection) => {const g = toGraph(latest.current.nodes, latest.current.edges);- const err = connectionError(g, c);+ const err = connectionError(g, c, mode);if (err) return void toast.error(err);// A single input (start frame, video, audio…) takes the new edge instead of the old one.setEdges((es) => [...(singleInput(g, c.target, c.targetHandle) ? es.filter((e) => !(e.target === c.target && e.targetHandle === c.targetHandle)) : es), { id: newId("e"), ...c }]);touch();},- [touch],+ [touch, mode],);const disconnect = useCallback((edgeId: string) => {@@ -692,11 +693,12 @@ function Editor({ id, initial, view }: { id: string; initial: Canvas; view: Canvconst from = g.nodes.find((n) => n.id === state.fromNode!.id);if (!from) return;const fromSource = state.fromHandle?.type === "source";- const type = fromSource ? outputType(g, from) : inputPorts(from).find((p) => p.id === state.fromHandle?.id)?.type;+ // A Split soundtrack stem (or any node's OUT): the type of the handle the drag started from.+ const type = fromSource ? outputPorts(g, from, mode).find((p) => p.id === (state.fromHandle?.id ?? OUT) && !p.disabled)?.type : inputPorts(from).find((p) => p.id === state.fromHandle?.id)?.type;if (!type) return;openMenuAt(pt.clientX, pt.clientY, { nodeId: from.id, handleId: state.fromHandle?.id ?? null, from: fromSource ? "source" : "target", type });},- [openMenuAt],+ [openMenuAt, mode],);const palette = useMemo(() => paletteItems(mode, engine), [mode, engine]);@@ -788,8 +790,10 @@ 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 },]);- 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)));+ // 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)));touch();toast(moved ? `Added as an input, connected where “${nodeLabel(toGraph([src], []).nodes[0])}” was` : "Added as an input — connect it anywhere");};diff --git a/src/components/canvas/nodes.tsx b/src/components/canvas/nodes.tsxindex 69389312..b9c46802 100644--- a/src/components/canvas/nodes.tsx+++ b/src/components/canvas/nodes.tsx@@ -92,6 +92,10 @@ import {nodeOps,OPEN_DUB_HINT,OUT,+ edgeStem,+ outputPorts,+ stemOutput,+ type OutputPortDef,TABLE_LIMITS,tableRows,outputType,@@ -111,6 +115,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 { stemLabel, type StemId } from "@/lib/av/split";import { dubResult, languageStage, type DubSessionView, type DubStage } from "@/lib/av/dub";import { DUB_LANGUAGES, supportsTarget } from "@/lib/av/languages";import { matchSpokenLanguage, spokenLanguageName, spokenLanguageOptions } from "@/lib/speech-languages";@@ -171,6 +176,40 @@ 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[] }) {+ return (+ <div className="border-b py-1" role="list" aria-label="Stems">+ {ports.map((p) => {+ const o = stemOutput(outputs, p.stem);+ return (+ <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)} />+ ) : (+ <span className="min-w-0 flex-1 truncate text-right text-subtle-foreground">{p.disabled ? "Not available here" : ""}</span>+ )}+ <Handle+ type="source"+ position={Position.Right}+ id={p.id}+ isConnectable={!p.disabled}+ className={cn("canvas-handle canvas-handle-out", p.disabled && "opacity-40")}+ style={{ "--port": PORT_COLOR[p.type] } as React.CSSProperties}+ aria-label={`${p.label} output (${PORT_TYPE_LABEL[p.type]})`}+ title={p.disabled ?? `${p.label} out — drag to connect`}+ />+ </div>+ );+ })}+ </div>+ );+}+// ---------------------------------------------------------------------------// Menus: the ⋯ button and right-click show the same items (keyboard users get Rename, Connect and Disconnect)@@ -214,14 +253,21 @@ function portLabel(n: CanvasNode | undefined, handle: string | null | undefined)function ConnectItems({ id, kit }: { id: string; kit: MenuKit }) {const actions = useEditorActions();const graph = actions.getGraph();+ const { mode } = useEditorGlobals();const options: { key: string; label: string; c: Connection }[] = [];- for (const t of [...graph.nodes].sort(byBoardPosition)) {- if (t.id === id || t.type === "note") continue;- const handles = t.type === "output" ? [PREVIEW_IN] : inputPorts(t).map((p) => p.id);- for (const h of handles) {- const c: Connection = { source: id, sourceHandle: OUT, target: t.id, targetHandle: h };- if (graph.edges.some((e) => e.source === id && e.target === t.id && e.targetHandle === h) || connectionError(graph, c)) continue;- options.push({ key: `${t.id}:${h}`, label: `${nodeLabel(t)} · ${portLabel(t, h)}`, c });+ const self = graph.nodes.find((n) => n.id === id);+ // Split soundtrack offers each of its stems ("Music → Mux · Audio"); every other node its one output.+ const outs = self ? outputPorts(graph, self, mode).filter((p) => !p.disabled) : [];+ const many = outs.length > 1;+ for (const out of outs) {+ for (const t of [...graph.nodes].sort(byBoardPosition)) {+ if (t.id === id || t.type === "note") continue;+ const handles = t.type === "output" ? [PREVIEW_IN] : inputPorts(t).map((p) => p.id);+ for (const h of handles) {+ const c: Connection = { source: id, sourceHandle: out.id, target: t.id, targetHandle: h };+ if (graph.edges.some((e) => e.source === id && (e.sourceHandle ?? OUT) === out.id && e.target === t.id && e.targetHandle === h) || connectionError(graph, c, mode)) continue;+ options.push({ key: `${out.id}:${t.id}:${h}`, label: `${many ? `${out.label} → ` : ""}${nodeLabel(t)} · ${portLabel(t, h)}`, c });+ }}}if (!options.length) return <kit.Item disabled>Nothing on the board takes this output</kit.Item>;@@ -374,6 +420,7 @@ function NodeShell({data,selected,out,+ outsInBody,badge,menu = [],footer,@@ -386,6 +433,8 @@ function NodeShell({data: CanvasNodeData;selected: boolean;out?: PortType | null;+ /** The output handles are drawn in the body (Split soundtrack's stems), not in the header. */+ outsInBody?: boolean;badge?: React.ReactNode;menu?: MenuItem[];footer?: React.ReactNode;@@ -440,7 +489,7 @@ function NodeShell({</DropdownMenuContent></DropdownMenu>)}- {out && <OutPort type={out} />}+ {out && !outsInBody && <OutPort type={out} />}</div>{children}{footer}@@ -676,6 +725,7 @@ const GeneratorNode = memo(function GeneratorNode({ id, type: flowType, data, seconst model = useMemo(() => nodeModel(node, g.mode), [node, g.mode]);const ports = useMemo(() => inputPorts(node), [node]);const out = outputType(EMPTY_GRAPH, node);+ const stems = useMemo(() => (type === "split-soundtrack" ? outputPorts(EMPTY_GRAPH, node, g.mode) : null), [type, node, g.mode]);const r = v.results;const ops = useMemo(() => nodeOps(node, model), [node, model]);const auto = type === "model" && ops.length > 1;@@ -696,7 +746,7 @@ const GeneratorNode = memo(function GeneratorNode({ id, type: flowType, data, se// Handles change with the model and op: tell React Flow to re-measure them (React Flow measures new nodes itself).const updateInternals = useUpdateNodeInternals();- const portKey = `${ports.map((p) => p.id).join(",")}|${out}`;+ const portKey = `${ports.map((p) => p.id).join(",")}|${out}|${stems?.map((p) => `${p.id}${p.disabled ? "-" : ""}`).join(",") ?? ""}`;const measuredKey = useRef(portKey);useEffect(() => {if (measuredKey.current === portKey) return;@@ -778,6 +828,7 @@ const GeneratorNode = memo(function GeneratorNode({ id, type: flowType, data, sedata={data}selected={!!selected}out={out}+ outsInBody={!!stems}menu={menu}tone={running ? "running" : r.state === "failed" ? "failed" : undefined}badge={@@ -821,6 +872,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) : []} />}<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]}`}>@@ -878,7 +930,8 @@ const GeneratorNode = memo(function GeneratorNode({ id, type: flowType, data, se<Table className="size-3.5 shrink-0" /> Runs once per table row: {v.rows === 1 ? "1 run" : `${v.rows} runs`}</p>)}- <Results id={id} r={r} />+ {/* Split soundtrack plays its stems on their own rows, by their handles. */}+ {!(stems && r.state === "succeeded") && <Results id={id} r={r} />}{error && r.state !== "failed" && (<p className={cn("flex items-start gap-1.5 text-[12px] leading-snug", v.runError ? "text-destructive" : "text-warning")}><AlertCircle className="mt-px size-3.5 shrink-0" />@@ -1569,18 +1622,21 @@ const CloneVoiceNode = memo(function CloneVoiceNode({ id, data, selected }: Node// ---------------------------------------------------------------------------// Output preview and notes-type Source = Pick<CanvasNode, "id" | "type" | "data">;+/** A node feeding an Output node, with the stem it hands on (an edge from a Split soundtrack handle). */+type Source = Pick<CanvasNode, "id" | "type" | "data"> & { key: string; stem?: StemId };-const sameSources = (a: Source[], b: Source[]) => a.length === b.length && a.every((s, i) => s.id === b[i].id && s.type === b[i].type && s.data === b[i].data);+const sameSources = (a: Source[], b: Source[]) => a.length === b.length && a.every((s, i) => s.key === b[i].key && s.type === b[i].type && s.data === b[i].data);/** What feeds an Output node, top to bottom. */const selectSources = (s: EditorSnapshot, id: string): Source[] =>s.graph.edges.filter((e) => e.target === id)- .map((e) => s.byId.get(e.source))- .filter((n): n is CanvasNode => !!n)- .sort((a, b) => a.position.y - b.position.y || a.position.x - b.position.x)- .map((n) => ({ id: n.id, type: n.type, data: n.data }));+ .flatMap((e) => {+ const n = s.byId.get(e.source);+ return n ? [{ n, stem: edgeStem(n, e.sourceHandle) }] : [];+ })+ .sort((a, b) => a.n.position.y - b.n.position.y || a.n.position.x - b.n.position.x)+ .map(({ n, stem }) => ({ id: n.id, key: stem ? `${n.id}:${stem}` : n.id, type: n.type, data: n.data, ...(stem && { stem }) }));/** The saved width (templates set one), not React Flow's measured width (that would feed back). */const selectWidth = (s: EditorSnapshot, id: string) => s.byId.get(id)?.width;@@ -1601,9 +1657,12 @@ const OutputNode = memo(function OutputNode({ id, type, data, selected }: NodePr) : (<div className={cn("grid gap-2", sources.length > 2 && w >= 540 ? "grid-cols-3" : sources.length > 1 ? "grid-cols-2" : "grid-cols-1")}>{sources.map((s) => (- <figure key={s.id} className="min-w-0 space-y-1">+ <figure key={s.key} className="min-w-0 space-y-1"><SourcePreview node={s} />- <figcaption className="truncate text-[11px] text-muted-foreground">{nodeLabel(s)}</figcaption>+ <figcaption className="truncate text-[11px] text-muted-foreground">+ {nodeLabel(s)}+ {s.stem ? ` · ${stemLabel(s.stem)}` : ""}+ </figcaption></figure>))}</div>@@ -1617,7 +1676,11 @@ function SourcePreview({ node }: { node: Source }) {const actions = useEditorActions();const r = useNodeResults(node.id);if (isGenerator(node)) {- if (r.outputs.length) return <OutputThumb o={r.outputs[0].o} onOpen={() => actions.open(node.id, 0)} large />;+ // A Split soundtrack stem: that one of its outputs.+ 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 />;+ } 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>;}@@ -1768,6 +1831,7 @@ export const NODE_TYPES = {tts: GeneratorNode,"voice-change": GeneratorNode,"clean-voice": GeneratorNode,+ "split-soundtrack": GeneratorNode,"clone-voice": CloneVoiceNode,translate: GeneratorNode,concat: GeneratorNode,diff --git a/src/lib/catalog/canvas.ts b/src/lib/catalog/canvas.tsindex 5005d036..620742df 100644--- a/src/lib/catalog/canvas.ts+++ b/src/lib/catalog/canvas.ts@@ -15,6 +15,7 @@ import { chainedWaitMessage, keyframeChain } from "./keyframes";import { estimateCost, inferOperation, planGeneration, routesFor, type Plan } from "./plan";import { replacedBy, replacementOf } from "./replaced";import { REGEN_COPY, REGEN_MODEL } from "./regenerate";+import { CLOUD_ONLY_PROBLEM, CLOUD_SPLIT_PROBLEM, SPLIT_MODEL, STEMS, type StemId } from "@/lib/av/split";import {OPERATION_LABELS,OPERATION_OUTPUT,@@ -57,6 +58,7 @@ export type CanvasNodeType =| "tts"| "voice-change"| "clean-voice"+ | "split-soundtrack"| "clone-voice"| "translate"| "concat"@@ -237,6 +239,8 @@ export const NODE_SPECS: Record<CanvasNodeType, NodeSpec> = {"voice-change": { type: "voice-change", label: "Change voice", group: "Utilities", icon: "AudioWaveform", ops: ["voice-change"], description: "Say a recording again in another voice, keeping its timing" },// NVIDIA RE-USE on the open engine only (nothing like it is hosted on fal or Replicate): hidden on a cloud-only install."clean-voice": { type: "clean-voice", label: "Clean up voice", group: "Utilities", icon: "AudioLines", ops: ["enhance-voice"], description: "Remove noise, echo and room sound from speech" },+ // DBS on the open engine only (nothing like it is hosted; src/lib/av/split.ts): four output handles, one per stem.+ "split-soundtrack": { type: "split-soundtrack", label: "Split soundtrack", group: "Utilities", icon: "Split", ops: ["separate-audio"], description: "Dialogue, music and effects from any soundtrack, each on its own output" },"clone-voice": { type: "clone-voice", label: "Clone voice", group: "Inputs", icon: "UserRound", description: "A voice sample (or one of your saved voices) to speak with" },translate: { type: "translate", label: "Translate", group: "Utilities", icon: "Languages", ops: ["translate", "dub"], variants: ["text", "video"], description: "Translate a text, or dub a video into another language" },concat: { type: "concat", label: "Assemble film", group: "Utilities", icon: "Film", ops: ["concat"], description: "Up to 50 clips in one film: trim and mute each, pick the frame" },@@ -246,7 +250,7 @@ export const NODE_SPECS: Record<CanvasNodeType, NodeSpec> = {note: { type: "note", label: "Sticky note", group: "Output", icon: "StickyNote", description: "A note on the board (not run)" },};-export const GENERATOR_TYPES = new Set<CanvasNodeType>(["model", "join", "frame", "upscale", "bg-remove", "tts", "voice-change", "clean-voice", "translate", "concat", "restore"]);+export const GENERATOR_TYPES = new Set<CanvasNodeType>(["model", "join", "frame", "upscale", "bg-remove", "tts", "voice-change", "clean-voice", "split-soundtrack", "translate", "concat", "restore"]);export const isGenerator = (n: Pick<CanvasNode, "type">) => GENERATOR_TYPES.has(n.type);/** Entries of the Add-node palette (several entries can make the same node type). */@@ -290,6 +294,7 @@ export const PALETTE: PaletteItem[] = [{ ...pick("tts"), id: "tts", keywords: "voice speech narration clone" },{ ...pick("voice-change"), id: "voice-change", keywords: "voice changer speech to speech revoice convert" },{ ...pick("clean-voice"), id: "clean-voice", keywords: "denoise enhance speech noise clean up voice echo reverb podcast" },+ { ...pick("split-soundtrack"), id: "split-soundtrack", keywords: "separate stems dialogue music effects soundtrack remove vocals speech isolate dbs" },{ ...pick("clone-voice"), id: "clone-voice", keywords: "voice sample clone my voice speaker" },{ ...pick("translate"), id: "translate", data: { mediaKind: "text" }, keywords: "language translate dub localize subtitles" },{ ...pick("concat"), id: "concat", keywords: "concatenate join merge stitch edit trim mute film assemble" },@@ -321,6 +326,8 @@ export function paletteItems(mode: "both" | "open" | "cloud" = "both", engine?:if (hit) return hit;// Clean up voice has no cloud route: a cloud-only install doesn't offer it at all.const items = PALETTE.filter((p) => (p.id !== "model-text" || MODELS.some((m) => m.kind === "text" && !m.hidden)) && !(mode === "cloud" && p.id === "clean-voice")).map((p): PaletteItem => {+ // Split soundtrack runs on your GPU only (DBS is hosted nowhere): a cloud board or a cloud-only install says so.+ if (p.type === "split-soundtrack" && (mode === "cloud" || engine === "cloud")) return { ...p, disabled: mode === "cloud" ? CLOUD_ONLY_PROBLEM : CLOUD_SPLIT_PROBLEM };const fixed = p.data?.modelId ? getModel(p.data.modelId) : undefined;if (fixed && !runsOn(fixed, "cloud") && (mode === "cloud" || engine === "cloud")) return { ...p, disabled: mode === "cloud" ? GPU_ONLY_INSTALL : GPU_ONLY_ENTRY };if (mode === "both" || !isGenerator(p) || defaultModelForNode({ type: p.type, data: p.data ?? {} }, mode)) return p;@@ -436,6 +443,8 @@ const KIND_OP: Record<MediaKind, Operation> = { image: "t2i", video: "t2v", audi/** The model a new generator node starts with. */export function defaultModelForNode(n: Pick<CanvasNode, "type" | "data">, engine: Engine): ModelDef | undefined {if (n.type === "concat") return getModel(CONCAT_MODELS[engine]);+ // Split soundtrack: only a model that makes its stems, never another separator in its place (none on the cloud).+ if (n.type === "split-soundtrack") return splitModels().find((m) => runsOn(m, engine));if (n.type === "model") {const kind = n.data.mediaKind ?? "image";return defaultModelFor(n.data.op ?? KIND_OP[kind], engine) ?? MODELS.find((m) => m.engine === engine && !m.hidden && m.kind === kind);@@ -470,6 +479,7 @@ export function modelChoices(n: Pick<CanvasNode, "type" | "data">): ModelDef[] {return MODELS.filter((m) => !m.hidden && (!kind || m.kind === kind) && !needsMarks(m) && m.routes.some((r) => !UNSUPPORTED_OPS.has(r.op)));}if (n.type === "concat") return Object.values(CONCAT_MODELS).flatMap((id) => getModel(id) ?? []);+ if (n.type === "split-soundtrack") return splitModels();const ops = nodeOps(n);return MODELS.filter((m) => ops.some((op) => supportsOp(m, op)) && (!m.hidden || ops.includes("frame")) && !needsMarks(m));}@@ -626,6 +636,87 @@ export function outputType(_graph: CanvasGraph, n: CanvasNode): PortType | nullreturn toPortType(n.data.mediaKind ?? "image");}+// ---------------------------------------------------------------------------+// Output handles: one OUT per node, except Split soundtrack (DBS D8), whose four handles each carry one stem+// into the next node's chain (ChainSlot.stem, read by pickOutput on the server).++export interface OutputPortDef {+ /** The handle id an edge saves as its sourceHandle. */+ id: string;+ label: string;+ type: PortType;+ /** Split soundtrack: the stem this handle carries. */+ stem?: StemId;+ /** Why nothing can be taken from this handle here (the node's model can't make that stem, or can't run here). */+ disabled?: string;+}++/**+ * Split soundtrack's handles, in the order the node shows them. Dialogue is OUT itself, so an edge drawn or saved without+ * a handle (OUT, null) takes the dialogue, the stem a chain without one takes anyway; "voice" is read as OUT too.+ */+export const SPLIT_HANDLES: { id: string; stem: StemId; label: string }[] = STEMS.map((s) => ({ id: s.id === "voice" ? OUT : s.id, stem: s.id, label: s.label }));++/**+ * The stems each separator the node may run makes (the open engine's DBS: all four). Only these models are offered: the+ * cloud has none while DBS is hosted nowhere, and Demucs (a music separator) is never put in its place.+ */+export const SPLIT_STEMS: Record<string, readonly StemId[]> = {+ [SPLIT_MODEL]: ["voice", "music", "effects", "background"],+};++const splitModels = (): ModelDef[] => Object.keys(SPLIT_STEMS).flatMap((id) => getModel(id) ?? []);++/** A Split soundtrack handle's id as stored (OUT for Dialogue, also for "voice" and no handle), or undefined when it has none such. */+export function splitHandle(handle: string | null | undefined): string | undefined {+ if (!handle || handle === "voice") return OUT;+ return SPLIT_HANDLES.some((h) => h.id === handle) ? handle : undefined;+}++/** The stem an edge out of a Split soundtrack node carries (undefined for any other node, or a handle it doesn't have). */+export function edgeStem(source: Pick<CanvasNode, "type"> | undefined, handle: string | null | undefined): StemId | undefined {+ if (source?.type !== "split-soundtrack") return undefined;+ const id = splitHandle(handle);+ return SPLIT_HANDLES.find((h) => h.id === id)?.stem;+}++/** The names a separator may give each stem (as the server's pickOutput reads them). */+const STEM_NAMES: Record<StemId, string[]> = {+ voice: ["voice", "vocals", "speech", "target"],+ music: ["music"],+ effects: ["effects", "sfx"],+ background: ["background", "accompaniment", "instrumental", "residual", "no_vocals"],+};++/** A result's output for one stem (meta.stem), as the next step takes it; without a stem, the first audio. */+export function stemOutput<T extends { kind: string; meta?: Record<string, unknown> }>(outputs: readonly T[], stem: StemId | undefined): T | undefined {+ const audio = outputs.filter((o) => o.kind === "audio");+ if (!stem) return audio[0];+ return 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. */+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 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);+ const model = nodeModel(n, mode);+ 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);+ return { id: h.id, label: h.label, type: "audio" as const, stem: h.stem, ...(disabled && { disabled }) };+ });+ }+ const type = outputType(graph, n);+ return type ? [{ id: OUT, label: PORT_TYPE_LABEL[type], type }] : [];+}+/** Which ports accept which types: a voice input also takes plain audio (a sample straight from a file or a model). */export function acceptsType(port: PortDef | "preview", type: PortType): boolean {if (port === "preview") return type !== "element";@@ -721,14 +812,18 @@ export interface Connection {}/** Why this edge can't be drawn, or null when it can. */-export function connectionError(graph: CanvasGraph, c: Connection): string | null {+export function connectionError(graph: CanvasGraph, c: Connection, mode: "both" | Engine = "both"): string | null {const nodes = nodeMap(graph);const s = nodes.get(c.source);const t = nodes.get(c.target);if (!s || !t) return "That node no longer exists";if (s.id === t.id) return "A node can't feed itself";- const type = outputType(graph, s);- if (!type || (c.sourceHandle && c.sourceHandle !== OUT)) return `${nodeLabel(s)} has no output`;+ // Split soundtrack: one of its four stems (Dialogue for OUT or no handle); every other node: OUT.+ const handle = s.type === "split-soundtrack" ? splitHandle(c.sourceHandle) : !c.sourceHandle || c.sourceHandle === OUT ? OUT : undefined;+ const out = handle ? outputPorts(graph, s, mode).find((p) => p.id === handle) : undefined;+ if (!out) return `${nodeLabel(s)} has no ${s.type === "split-soundtrack" && c.sourceHandle ? `${c.sourceHandle} ` : ""}output`;+ if (out.disabled) return out.disabled;+ const type = out.type;if (t.type === "output") {if (c.targetHandle && c.targetHandle !== PREVIEW_IN) return "Unknown input";if (!acceptsType("preview", type)) return "Elements go into a model's Elements input";@@ -740,7 +835,7 @@ export function connectionError(graph: CanvasGraph, c: Connection): string | nulif (t.type === "concat" && graph.edges.filter((e) => e.target === t.id && e.source !== s.id).length >= CONCAT_LIMITS.clips) return `Assemble film takes up to ${CONCAT_LIMITS.clips} clips`;// Rows from a table: one table per node, and Join clips can't take a clip per row (the concatenator can).if (graph.nodes.some((n) => n.type === "table")) {- const withEdge: CanvasGraph = { ...graph, edges: [...graph.edges, { id: "", source: s.id, target: t.id, sourceHandle: OUT, targetHandle: c.targetHandle ?? null }] };+ const withEdge: CanvasGraph = { ...graph, edges: [...graph.edges, { id: "", source: s.id, target: t.id, sourceHandle: handle, targetHandle: c.targetHandle ?? null }] };const rows = rowsFeeding(withEdge, t);if (rows && "error" in rows) return rows.error;if (rows && t.type === "join") return "Join clips takes one clip per input. Assemble film joins a clip per row";@@ -765,7 +860,7 @@ type Source =| { kind: "text"; text: string }| { kind: "media"; url: string }| { kind: "element"; handle: string }- | { kind: "node"; nodeId: string };+ | { kind: "node"; nodeId: string; stem?: StemId };const SLOT: Record<InputPortId, ChainSlot["slot"] | null> = {prompt: "prompt",@@ -851,7 +946,8 @@ export interface NodeDescription extends Partial<NodeRequest> {error?: string;}-function sourceOf(graph: CanvasGraph, s: CanvasNode): Source | { error: string } {+/** What a node hands on along an edge (`handle`: the edge's sourceHandle, which picks a Split soundtrack stem). */+function sourceOf(graph: CanvasGraph, s: CanvasNode, handle?: string | null): Source | { error: string } {if (s.type === "prompt") return { kind: "text", text: (s.data.text ?? "").trim() };// A table is read row by row (rowRequest); read whole, it is its first row.if (s.type === "table") {@@ -862,7 +958,7 @@ function sourceOf(graph: CanvasGraph, s: CanvasNode): Source | { error: string }// A sample wired in wins over the node's own file (a recording, a generated voice).const e = graph.edges.find((x) => x.target === s.id && x.targetHandle === "audio");const from = e && graph.nodes.find((n) => n.id === e.source);- if (from && from.type !== "clone-voice") return sourceOf(graph, from);+ if (from && from.type !== "clone-voice") return sourceOf(graph, from, e.sourceHandle);return s.data.url ? { kind: "media", url: s.data.url } : { error: `Add a voice sample to “${nodeLabel(s)}”: record, upload or pick a saved voice` };}if (MEDIA_INPUT_TYPE[s.type]) {@@ -870,7 +966,10 @@ function sourceOf(graph: CanvasGraph, s: CanvasNode): Source | { error: string }return s.data.url ? { kind: "media", url: s.data.url } : { error: `Add ${what} to “${nodeLabel(s)}”` };}if (s.type === "element") return s.data.handle ? { kind: "element", handle: s.data.handle } : { error: `Pick an element in “${nodeLabel(s)}”` };- if (isGenerator(s)) return { kind: "node", nodeId: s.id };+ if (isGenerator(s)) {+ const stem = edgeStem(s, handle);+ return { kind: "node", nodeId: s.id, ...(stem && { stem }) };+ }return { error: `${nodeLabel(s)} has no output` };}@@ -966,7 +1065,7 @@ function buildRequest(graph: CanvasGraph, n: CanvasNode, model: ModelDef, singleconst s = nodes.get(e.source)!;const type = outputType(graph, s);if (!type || !acceptsType(port, type)) return { error: `${nodeLabel(s)} can't go into ${port.label}` };- const src = sourceOf(graph, s);+ const src = sourceOf(graph, s, e.sourceHandle);if ("error" in src) return src;list.push(src);}@@ -1006,7 +1105,8 @@ function buildRequest(graph: CanvasGraph, n: CanvasNode, model: ModelDef, singleif (!field || !src) continue;if (src.kind === "media") inputs[field] = src.url;else if (src.kind === "node") {- chain.push({ slot: SLOT[port.id]! });+ // A stem from Split soundtrack: the step takes that one of its outputs (pickOutput's meta.stem).+ chain.push({ slot: SLOT[port.id]!, ...(src.stem && { stem: src.stem }) });deps.push(src.nodeId);}}@@ -1319,6 +1419,12 @@ 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.+ 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.if (!model) {@@ -1733,9 +1839,12 @@ export function cleanGraph(graph: CanvasGraph): CanvasGraph {const g: CanvasGraph = { ...graph, nodes, edges: [] };const ids = new Set(nodes.map((n) => n.id));const seen = new Set<string>();- for (const e of graph.edges) {- if (!ids.has(e.source) || !ids.has(e.target)) continue;- const key = `${e.source}|${e.sourceHandle ?? ""}|${e.target}|${e.targetHandle ?? ""}`;+ const types = new Map(nodes.map((n) => [n.id, n.type]));+ for (const edge of graph.edges) {+ if (!ids.has(edge.source) || !ids.has(edge.target)) continue;+ // A Split soundtrack edge saved as "voice" (or with no handle) is its Dialogue handle, OUT.+ const e = types.get(edge.source) === "split-soundtrack" && edge.sourceHandle && edge.sourceHandle !== OUT && splitHandle(edge.sourceHandle) === OUT ? { ...edge, sourceHandle: OUT } : edge;+ const key = `${e.source}|${e.sourceHandle && e.sourceHandle !== OUT ? e.sourceHandle : ""}|${e.target}|${e.targetHandle ?? ""}`;if (seen.has(key)) continue;const without = { ...g, edges: g.edges };if (connectionError(without, e)) continue;diff --git a/src/server/canvas.ts b/src/server/canvas.tsindex a9dc3520..a2e4e25c 100644--- a/src/server/canvas.ts+++ b/src/server/canvas.ts@@ -99,9 +99,11 @@ const NODE_TYPES = ["tts","voice-change","clean-voice",+ "split-soundtrack","clone-voice","translate","concat",+ "restore","table","output","note",diff --git a/tests/canvas-split.test.ts b/tests/canvas-split.test.tsnew file mode 100644index 00000000..00219a14--- /dev/null+++ b/tests/canvas-split.test.ts@@ -0,0 +1,215 @@+import { describe, expect, it } from "vitest";+import {+ cleanGraph,+ connectionError,+ convertEngine,+ defaultModelForNode,+ describeNode,+ edgeStem,+ modelChoices,+ NODE_SPECS,+ OUT,+ outputPorts,+ paletteItems,+ planCanvas,+ SPLIT_HANDLES,+ splitHandle,+ stemOutput,+ type CanvasEdge,+ type CanvasGraph,+ type CanvasNode,+} from "@/lib/catalog/canvas";+import { CLOUD_ONLY_PROBLEM, CLOUD_SPLIT_PROBLEM, SPLIT_MODEL } from "@/lib/av/split";+import { pickOutput } from "@/server/generations";+import { parseGraph } from "@/server/canvas";+import type { OutputFile } from "@/lib/catalog/types";++// Canvas Split soundtrack node (DBS D8, docs/research/dbs-separation-7.md §9): four stem handles, each carrying its stem+// into the next node's chain; open engine only (samAudioCloud is false), disabled on the cloud with a reason.++const node = (id: string, type: CanvasNode["type"], x: number, y: number, data: CanvasNode["data"] = {}): CanvasNode => ({ id, type, position: { x, y }, data });+const edge = (source: string, target: string, targetHandle: string, sourceHandle: string | null = OUT): CanvasEdge => ({ id: `${source}:${sourceHandle}>${target}:${targetHandle}`, source, sourceHandle, target, targetHandle });++/** A video → Split soundtrack; Dialogue → Transcribe (Qwen3-ASR); Music & effects + the video → Add soundtrack (mux). */+function board(): CanvasGraph {+ return {+ nodes: [+ node("clip", "video-input", 0, 0, { url: "/api/files/u/scene.mp4" }),+ node("split", "split-soundtrack", 400, 0, { modelId: SPLIT_MODEL }),+ node("asr", "model", 800, 0, { modelId: "oss-qwen3-asr", mediaKind: "text" }),+ node("mux", "model", 800, 400, { modelId: "oss-mux", mediaKind: "video", op: "mux" }),+ node("out", "output", 1200, 0),+ ],+ edges: [+ edge("clip", "split", "video"),+ edge("split", "asr", "audio", OUT),+ edge("split", "mux", "audio", "background"),+ edge("clip", "mux", "video"),+ edge("split", "out", "in", "music"),+ ],+ };+}++const at = (g: CanvasGraph, id: string) => g.nodes.find((n) => n.id === id)!;++describe("Split soundtrack node", () => {+ it("is a utility running separate-audio on DBS, the only model it offers", () => {+ expect(NODE_SPECS["split-soundtrack"]).toMatchObject({ label: "Split soundtrack", group: "Utilities", ops: ["separate-audio"] });+ expect(defaultModelForNode({ type: "split-soundtrack", data: {} }, "open")?.id).toBe(SPLIT_MODEL);+ // Nothing on the cloud: never Demucs or another separator in DBS's place.+ expect(defaultModelForNode({ type: "split-soundtrack", data: {} }, "cloud")).toBeUndefined();+ expect(modelChoices({ type: "split-soundtrack", data: {} }).map((m) => m.id)).toEqual([SPLIT_MODEL]);+ });++ it("has four labelled stem handles, Dialogue on OUT", () => {+ const g = board();+ const ports = outputPorts(g, at(g, "split"));+ expect(ports.map((p) => [p.id, p.label, p.stem, p.type])).toEqual([+ [OUT, "Dialogue", "voice", "audio"],+ ["music", "Music", "music", "audio"],+ ["effects", "Effects", "effects", "audio"],+ ["background", "Music & effects", "background", "audio"],+ ]);+ expect(ports.every((p) => !p.disabled)).toBe(true);+ expect(SPLIT_HANDLES).toHaveLength(4);+ // Every other node keeps one OUT.+ expect(outputPorts(g, at(g, "clip"))).toEqual([{ id: OUT, label: "Video", type: "video" }]);+ expect(outputPorts(g, at(g, "out"))).toEqual([]);+ });++ it("reads OUT, no handle and 'voice' as Dialogue", () => {+ expect([splitHandle(null), splitHandle(undefined), splitHandle(OUT), splitHandle("voice"), splitHandle("music"), splitHandle("drums")]).toEqual([OUT, OUT, OUT, OUT, "music", undefined]);+ const split = { type: "split-soundtrack" as const };+ expect([edgeStem(split, null), edgeStem(split, "voice"), edgeStem(split, "effects"), edgeStem(split, "background")]).toEqual(["voice", "voice", "effects", "background"]);+ expect(edgeStem({ type: "model" }, "music")).toBeUndefined();+ });++ it("checks edges by handle", () => {+ const g = board();+ expect(connectionError(g, { source: "split", sourceHandle: "effects", target: "out", targetHandle: "in" })).toBeNull();+ expect(connectionError(g, { source: "split", sourceHandle: "drums", target: "out", targetHandle: "in" })).toBe("Split soundtrack has no drums output");+ // A stem is audio: it can't be a video input.+ expect(connectionError(g, { source: "split", sourceHandle: "music", target: "mux", targetHandle: "video" })).toBe("Audio can't go into Video");+ // Other nodes have only OUT.+ expect(connectionError(g, { source: "clip", sourceHandle: "music", target: "out", targetHandle: "in" })).toBe("Video has no output");+ });++ it("carries each handle's stem into the next node's chain", () => {+ const g = board();+ const asr = describeNode(g, at(g, "asr"));+ expect(asr.error).toBeUndefined();+ expect(asr.plan?.op).toBe("transcribe");+ expect(asr.request).toMatchObject({ modelId: "oss-qwen3-asr", chain: [{ slot: "audio", stem: "voice" }] });+ expect(asr.deps).toEqual(["split"]);+ const mux = describeNode(g, at(g, "mux"));+ expect(mux.error).toBeUndefined();+ expect(mux.request).toMatchObject({ modelId: "oss-mux", op: "mux", inputs: { video: "/api/files/u/scene.mp4" }, chain: [{ slot: "audio", stem: "background" }] });+ const split = describeNode(g, at(g, "split"));+ expect(split.request).toMatchObject({ modelId: SPLIT_MODEL, op: "separate-audio", inputs: { video: "/api/files/u/scene.mp4" } });+ expect(split.request?.chain).toBeUndefined();+ });++ it("a stem takes that output of the split's result on the server, and on the board", () => {+ const outputs: OutputFile[] = (["voice", "music", "effects", "background"] as const).map((stem) => ({ kind: "audio", url: `/api/files/${stem}.flac`, meta: { stem } }));+ for (const h of SPLIT_HANDLES) {+ expect(pickOutput(outputs, { slot: "audio", stem: h.stem })?.url).toBe(`/api/files/${h.stem}.flac`);+ expect(stemOutput(outputs, h.stem)?.url).toBe(`/api/files/${h.stem}.flac`);+ }+ expect(stemOutput([{ kind: "audio", url: "/x", meta: { stem: "sfx" } }], "effects")?.url).toBe("/x");+ });++ it("a different handle into the same input changes the node's request (it runs again)", () => {+ const g = board();+ const before = describeNode(g, at(g, "asr")).request;+ const moved: CanvasGraph = { ...g, edges: g.edges.map((e) => (e.target === "asr" ? { ...e, sourceHandle: "music" } : e)) };+ expect(describeNode(moved, at(moved, "asr")).request?.chain).toEqual([{ slot: "audio", stem: "music" }]);+ expect(describeNode(moved, at(moved, "asr")).request).not.toEqual(before);+ });++ it("plans on the open engine: one DBS job, then the steps that take its stems", () => {+ const plan = planCanvas(board(), { engineMode: "open" });+ expect(plan.errors).toEqual([]);+ expect(plan.steps.map((s) => s.nodeId)).toEqual(["split", "asr", "mux"]);+ expect(plan.steps[0].request.modelId).toBe(SPLIT_MODEL);+ expect(plan.costUsd).toBe(0);+ expect(planCanvas(board()).errors).toEqual([]);+ });++ it("is refused on a cloud-only install, with its handles disabled", () => {+ const g = board();+ const plan = planCanvas(g, { engineMode: "cloud" });+ expect(plan.errors.find((e) => e.nodeId === "split")?.message).toBe(CLOUD_ONLY_PROBLEM);+ expect(outputPorts(g, at(g, "split"), "cloud").every((p) => p.disabled === CLOUD_ONLY_PROBLEM)).toBe(true);+ 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", () => {+ 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/);+ });++ it("stays on the open engine when the board switches to the cloud", () => {+ const { graph, missing } = convertEngine(board(), "cloud");+ expect(missing).toContain("split");+ expect(at(graph, "split").data.modelId).toBe(SPLIT_MODEL);+ });++ it("is in the palette, disabled with a reason on a cloud board or install", () => {+ const item = (mode: "both" | "open" | "cloud", engine?: "open" | "cloud") => paletteItems(mode, engine).find((p) => p.id === "split-soundtrack");+ expect(item("both", "open")?.disabled).toBeUndefined();+ expect(item("open")?.disabled).toBeUndefined();+ expect(item("both", "cloud")?.disabled).toBe(CLOUD_SPLIT_PROBLEM);+ expect(item("cloud")?.disabled).toBe(CLOUD_ONLY_PROBLEM);+ });+});++describe("Split soundtrack on a saved board", () => {+ it("keeps every stem edge through cleanGraph and the server's parse", () => {+ const g = board();+ const parsed = parseGraph(JSON.parse(JSON.stringify(g)))!;+ expect(parsed).not.toBeNull();+ expect(parsed.nodes.map((n) => n.type)).toContain("split-soundtrack");+ expect(parsed.edges.map((e) => e.sourceHandle).sort()).toEqual(["background", "music", OUT, OUT, OUT].sort());+ expect(cleanGraph(parsed)).toEqual(parsed);+ });++ it("reads an edge saved without a handle, or as 'voice', as Dialogue", () => {+ const g = board();+ const old: CanvasGraph = { ...g, edges: g.edges.map((e) => (e.target === "asr" ? { ...e, sourceHandle: null } : e)) };+ const kept = cleanGraph(old);+ expect(kept.edges.find((e) => e.target === "asr")?.sourceHandle).toBeNull();+ expect(describeNode(kept, at(kept, "asr")).request?.chain).toEqual([{ slot: "audio", stem: "voice" }]);+ const voice: CanvasGraph = { ...g, edges: [...g.edges.map((e) => (e.target === "asr" ? { ...e, sourceHandle: "voice" } : e)), edge("split", "asr", "audio", OUT)] };+ const clean = cleanGraph(voice);+ // "voice" becomes OUT, and the same edge twice is kept once.+ expect(clean.edges.filter((e) => e.target === "asr").map((e) => e.sourceHandle)).toEqual([OUT]);+ });++ it("drops an edge from a handle the node doesn't have", () => {+ const g = board();+ const bad: CanvasGraph = { ...g, edges: [...g.edges, edge("split", "out", "in", "drums")] };+ expect(cleanGraph(bad).edges).toHaveLength(g.edges.length);+ });++ it("old boards with one OUT per node load as before", () => {+ const old: CanvasGraph = {+ nodes: [node("a", "audio-input", 0, 0, { url: "/api/files/u/a.wav" }), node("v", "voice-change", 400, 0, { modelId: "elevenlabs-voice-changer" }), node("o", "output", 800, 0)],+ edges: [edge("a", "v", "audio"), { id: "x", source: "v", target: "o", sourceHandle: null, targetHandle: "in" }],+ };+ expect(parseGraph(old)!.edges).toHaveLength(2);+ expect(cleanGraph(old).edges).toEqual(old.edges);+ });++ it("every node type can be saved", () => {+ for (const type of Object.keys(NODE_SPECS) as CanvasNode["type"][]) {+ expect(parseGraph({ nodes: [node("n", type, 0, 0)], edges: [] }), type).not.toBeNull();+ }+ });+});