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
Dub, Relight and Swap Studio: controls say what they reach
Adarsh7a41bdd14237
diff --git a/src/components/av/language-picker.tsx b/src/components/av/language-picker.tsxindex 0bd75391..465617d9 100644--- a/src/components/av/language-picker.tsx+++ b/src/components/av/language-picker.tsx@@ -9,7 +9,36 @@ import { DUB_LANGUAGES, type DubLanguage } from "@/lib/av/languages";import { cn } from "@/lib/utils";/** The spoken language: detected, or one of the list. */-export function SourceLanguageSelect({ value, onChange, id, languages = DUB_LANGUAGES }: { value: string; onChange: (v: string) => void; id?: string; languages?: DubLanguage[] }) {+export function SourceLanguageSelect({+ value,+ onChange,+ id,+ languages = DUB_LANGUAGES,+ unavailable,+}: {+ value: string;+ onChange: (v: string) => void;+ id?: string;+ languages?: DubLanguage[];+ /** Why the model doesn't take a spoken language (HeyGen detects it itself): the menu rests on Detect and says why. */+ unavailable?: string;+}) {+ if (unavailable)+ return (+ <div className="flex min-w-0 flex-col gap-1">+ <Select value="auto" disabled>+ <SelectTrigger id={id} className="h-9 w-full cursor-not-allowed rounded-full sm:w-52" aria-label="Spoken language" aria-describedby={id ? `${id}-why` : undefined}>+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ <SelectItem value="auto">Detect automatically</SelectItem>+ </SelectContent>+ </Select>+ <p id={id ? `${id}-why` : undefined} className="text-[12px] leading-snug text-muted-foreground">+ {unavailable}+ </p>+ </div>+ );return (<Select value={value} onValueChange={onChange}><SelectTrigger id={id} className="h-9 w-full rounded-full sm:w-52" aria-label="Spoken language">diff --git a/src/components/dub/dub-studio.tsx b/src/components/dub/dub-studio.tsxindex c1398b4e..3c717430 100644--- a/src/components/dub/dub-studio.tsx+++ b/src/components/dub/dub-studio.tsx@@ -293,7 +293,13 @@ function NewDub({ onStarted }: { onStarted: (id: string) => void }) {<Label htmlFor="dub-source" className="text-[13px] sm:w-32">Spoken language</Label>- <SourceLanguageSelect id="dub-source" value={source} onChange={setSource} />+ {/* HeyGen's one-shot dub is sent no spoken language: it hears it itself (dub.ts oneShotRequests). */}+ <SourceLanguageSelect+ id="dub-source"+ value={source}+ onChange={setSource}+ unavailable={oneShot && model !== "elevenlabs-dubbing" ? `${ONE_SHOT[model].name} detects the spoken language itself. To set it, pick ElevenLabs or “Review the script first”` : undefined}+ /></div><div className="flex flex-col gap-1.5 sm:flex-row sm:items-start"><span className="pt-1.5 text-[13px] font-medium sm:w-32">Translate into</span>diff --git a/src/components/relight/relight-tool.tsx b/src/components/relight/relight-tool.tsxindex 42f43ef6..2fc2e181 100644--- a/src/components/relight/relight-tool.tsx+++ b/src/components/relight/relight-tool.tsx@@ -780,6 +780,8 @@ export function RelightTool({ app }: { app?: { name: string; description: string<Switch id={glowId} checked={glow} onCheckedChange={setGlowAsked} /><label htmlFor={glowId} className="text-[13px]">Glow+ {/* A marker for where each light sits: the saved picture never has it (renderFull). */}+ <span className="block text-[12px] text-muted-foreground">On screen only: shows where each light sits</span></label></div>{owner && (diff --git a/src/components/swap-studio/stage-anchors.tsx b/src/components/swap-studio/stage-anchors.tsxindex e92d5ee5..605da27f 100644--- a/src/components/swap-studio/stage-anchors.tsx+++ b/src/components/swap-studio/stage-anchors.tsx@@ -25,7 +25,10 @@ export function AnchorMaker({ id, project, clip, shotId, segment, estimate }: Piconst importer = useSwapEdit(id);const engine = project.engine;const models = estimate?.anchors ?? ANCHOR_MODELS[engine].map((m) => ({ ...m, costUsd: null, offered: true }));- const [modelId, setModelId] = useState<string>(models.find((m) => m.offered)?.id ?? ANCHOR_MODELS[engine][0].id);+ const [asked, setModelId] = useState<string | undefined>();+ // The pick is read against the current list each time: another engine's model, or one switched off since, falls back to+ // the first that is on, which is what the Select shows, the request sends and the toast names.+ const modelId = models.find((m) => m.id === asked && m.offered)?.id ?? models.find((m) => m.offered)?.id ?? ANCHOR_MODELS[engine][0].id;const [importing, setImporting] = useState(false);const file = useRef<HTMLInputElement>(null);const picked = models.find((m) => m.id === modelId);diff --git a/src/lib/catalog/route-takes.ts b/src/lib/catalog/route-takes.tsindex ad9e0536..c8bc1675 100644--- a/src/lib/catalog/route-takes.ts+++ b/src/lib/catalog/route-takes.ts@@ -39,12 +39,32 @@ export function routeTakes(route: ModelRoute, modelId: string): RouteTakes | undreturn route.map ? takesFromMap(route, modelId) : route.takes;}-/** Whether every route of the operation makes one result a call (no count field): several results are several jobs. */+/**+ * Whether every route of the operation makes one result a call (no count field): several results are several jobs. A model+ * with one route that takes a count (Nano Banana Pro on fal) keeps its native batch; its other route's single result is the+ * server's to split (routeDrops names it).+ */export function oneEachCall(model: Pick<ModelDef, "id" | "routes">, op: Operation): boolean {const routes = model.routes.filter((r) => r.op === op);return routes.length > 0 && routes.every((r) => routeTakes(r, model.id)?.outputs === false);}+/**+ * The settings a run asks for that the route it goes to has no field for (Nano Banana Pro on Replicate takes no seed; Qwen+ * Image Edit on Replicate no negative prompt), in words for the run's note: the composer offers them because another route+ * of the model reads them.+ */+export function routeDrops(route: ModelRoute, modelId: string, req: { negativePrompt?: string; params?: { seed?: number; generateAudio?: boolean; numOutputs?: number } }): string[] {+ const t = routeTakes(route, modelId);+ if (!t) return [];+ return [+ t.outputs === false && (req.params?.numOutputs ?? 1) > 1 && "a number of results",+ t.seed === false && req.params?.seed !== undefined && "a seed",+ t.negativePrompt === false && !!req.negativePrompt?.trim() && "a negative prompt",+ t.audio === false && req.params?.generateAudio === false && "the sound switch",+ ].filter((x): x is string => !!x);+}+/** What an operation's routes take together (a run goes to one of them): a value any of them takes counts. */export interface OpTakes {/** The ratios / sizes / lengths they take; undefined = any. */diff --git a/tests/inert-controls.test.ts b/tests/inert-controls.test.tsindex e6c29507..86474fc4 100644--- a/tests/inert-controls.test.ts+++ b/tests/inert-controls.test.ts@@ -97,3 +97,28 @@ describe("studio pickers say what the picked model can't do", () => {expect(src("src/components/mixed-media/mixed-studio.tsx")).toContain("const gpuCap = !cloud && r !== \"1K\";");});});++describe("Dub, Relight and Swap Studio", () => {+ it("Dub: HeyGen's one shot says it detects the spoken language, ElevenLabs keeps the menu", async () => {+ const { createElement } = await import("react");+ const { renderToStaticMarkup } = await import("react-dom/server");+ const { SourceLanguageSelect } = await import("@/components/av/language-picker");+ const html = renderToStaticMarkup(createElement(SourceLanguageSelect, { id: "s", value: "es", onChange: () => {}, unavailable: "HeyGen Translate detects the spoken language itself" }));+ expect(html).toContain("detects the spoken language itself");+ expect(html).toContain("disabled");+ const dub = src("src/components/dub/dub-studio.tsx");+ expect(dub).toContain('unavailable={oneShot && model !== "elevenlabs-dubbing"');+ // The reason holds: only ElevenLabs' one shot is sent the spoken language.+ expect(src("src/lib/av/dub.ts")).toContain('...(o.model === "elevenlabs-dubbing" && source && { sourceLanguage: source })');+ });++ it("Relight: Glow says it is on screen only, as the saved picture has none", () => {+ expect(src("src/components/relight/relight-tool.tsx")).toContain("On screen only: shows where each light sits");+ expect(src("src/components/relight/relight-tool.tsx")).toContain("glow: false,");+ });++ it("Swap Studio: the anchor model shown is the one sent, after an engine switch or a model switched off", () => {+ const s = src("src/components/swap-studio/stage-anchors.tsx");+ expect(s).toContain("const modelId = models.find((m) => m.id === asked && m.offered)?.id ?? models.find((m) => m.offered)?.id");+ });+});diff --git a/tests/route-takes.test.ts b/tests/route-takes.test.tsindex fb404656..fb4175e9 100644--- a/tests/route-takes.test.ts+++ b/tests/route-takes.test.ts@@ -1,7 +1,7 @@import { describe, expect, it } from "vitest";-import { getModel, getPreset } from "@/lib/catalog";+import { getModel, getPreset, MODELS } from "@/lib/catalog";import { planGeneration } from "@/lib/catalog/plan";-import { oneEachCall, opTakes, settingUnavailable, takesFromMap } from "@/lib/catalog/route-takes";+import { oneEachCall, opTakes, routeDrops, settingUnavailable, takesFromMap } from "@/lib/catalog/route-takes";import type { ModelDef } from "@/lib/catalog/types";import { settingsShape } from "@/lib/composer";import { slimModel } from "@/lib/studio-catalog";@@ -75,10 +75,21 @@ describe("several results from a route with no count field", () => {expect(plan.perJobOutputs).toBe(1);});- it("keeps one call for a route that takes a count", () => {- const nb = model("nano-banana-pro");- expect(oneEachCall(nb, "t2i")).toBe(false);- const plan = planGeneration({ feature: "image", modelId: nb.id, prompt: "a red chair in a white room", params: { numOutputs: 3 } }, getModel, getPreset);+ it("keeps one call where every route takes a count", () => {+ const m = MODELS.find((x) => x.engine === "cloud" && (x.options.maxOutputs ?? 1) > 1 && x.routes.some((r) => r.op === "t2i") && x.routes.filter((r) => r.op === "t2i").every((r) => r.map?.numOutputs));+ if (!m) throw new Error("no such model");+ expect(oneEachCall(m, "t2i")).toBe(false);+ const plan = planGeneration({ feature: "image", modelId: m.id, prompt: "a red chair in a white room", params: { numOutputs: 2 } }, getModel, getPreset);expect(plan.jobs).toBe(1);});++ it("names the settings the route a run goes to has no field for", () => {+ const nb = model("nano-banana-pro");+ const rep = nb.routes.find((r) => r.provider === "replicate" && r.op === "t2i")!;+ const fal = nb.routes.find((r) => r.provider === "fal" && r.op === "t2i")!;+ expect(routeDrops(rep, nb.id, { params: { seed: 7 } })).toEqual(["a seed"]);+ expect(routeDrops(fal, nb.id, { params: { seed: 7 } })).toEqual([]);+ expect(routeDrops(rep, nb.id, { params: {} })).toEqual([]);+ expect(routeDrops(rep, nb.id, { params: { numOutputs: 3 } })).toEqual(["a number of results"]);+ });});