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
Merge branch 'r4/video-keyframes' into claude/fuobe-parity-4
Claudec0f02c2ce1f2
diff --cc src/components/studio/composer.tsxindex 30295193,c27ff915..1ddc61e4--- a/src/components/studio/composer.tsx+++ b/src/components/studio/composer.tsx@@@ -1,21 -1,52 +1,58 @@@"use client";- import { ArrowUp, AtSign, Loader2, Sparkles, X } from "lucide-react";+ import { ArrowUp, AtSign, GalleryHorizontalEnd, Loader2, Sparkles, X } from "lucide-react";import dynamic from "next/dynamic";+import Link from "next/link";import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";+import { flushSync } from "react-dom";import { toast } from "sonner";import { Button } from "@/components/ui/button";import { Kbd } from "@/components/ui/kbd";import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";import { estimateCost, planGeneration, routesFor } from "@/lib/catalog/plan";-import type { GenerationRequest, MediaKind, ModelDef, Operation, Preset } from "@/lib/catalog/types";-import { enhance, useCreateGeneration, useElements, useEngine, useHydrated, useStatus } from "@/lib/api";+import type { GenerationRequest, MediaKind, ModelDef, Operation, Preset, VideoFormat } from "@/lib/catalog/types";+import { formatsOf } from "@/lib/av/formats";+import { enhance, useClipFacts, useCreateGeneration, useElements, useEngine, useHydrated, useStatus } from "@/lib/api";import { applyMentions, type StudioElement } from "@/lib/catalog/elements";import { applySketch, stripMotionPaths } from "@/lib/catalog/sketch";- import { blockerFor, blockerLine, clipBlocker, clipOutcome, costLabel, filterModels, firstMissingSlot, namedImageSlots, needsMask, PLACEHOLDER, pushRecent, settingsShape, showsPrompt, startStep } from "@/lib/composer";+ import {+ chainGapProblem,+ chainTiming,+ frameSupport,+ framesBlocker,+ framesDuration,+ framesDurations,+ framesNote,+ FRAMES_MODELS,+ frameTimes,+ keyframeChain,+ moveFrameAt,+ OPEN_MIN_GAP,+ type FrameSupport,+ } from "@/lib/catalog/keyframes";+ import {+ blockerFor,++ blockerLine,++ clipBlocker,++ clipOutcome,+ costLabel,+ enterFrames,+ filterModels,+ firstMissingSlot,+ framesRequest,+ framesShape,+ framesSlots,+ framesUploading,+ leaveFrames,+ namedImageSlots,+ needsMask,+ onImageChange,+ PLACEHOLDER,- promptShown,+ pushRecent,+ settingsShape,++ showsPrompt,+ startStep,+ } from "@/lib/composer";import { formatCost } from "@/lib/format";import { cn } from "@/lib/utils";import { AttachMenu } from "./attach-menu";@@@ -227,14 -279,11 +292,16 @@@ export function Composer({ docked }: {// operation are known up front and the blocker can name the slot in the studio's own words.// Studios that need one of several inputs (Lipsync: a portrait or a video) name the group.const anyOf = preset?.inputs ? undefined : config.anyOf;- const missing = firstMissingSlot(slots, draft.slots, anyOf);- const uploading = Object.values(draft.slots).some((v) => v?.uploading) || draft.refs.some((r) => r.uploading);+ // Frames mode has its own strip: the start frame is frame 1 (a camera motion's start frame tile isn't asked for).+ const askedSlots = framesOn ? framesSlots(slots) : slots;+ const missing = firstMissingSlot(askedSlots, draft.slots, anyOf);+ const uploading = Object.values(draft.slots).some((v) => v?.uploading) || draft.refs.some((r) => r.uploading) || (framesOn && framesUploading(draft.frames));- const engineError = lockedModel && preset && !(engine === "open" ? preset.open : preset.cloud) ? `${preset.name} has no ${engine === "open" ? "open-source" : "cloud"} version yet` : null;+ // Export without a ComfyUI to write it (none connected, or the install runs cloud APIs only): say so and offer the cloud route.+ // A cloud-only install refuses open models, and with demo mode off nothing else runs it, so Generate says why.+ const comfyMissing = !!config.comfyOnly && !!status && (engineMode === "cloud" || !status.providers.comfyui?.configured);+ const comfyBlock = comfyMissing && model?.engine === "open" && (engineMode === "cloud" || status?.demoMode === "off") ? "Needs ComfyUI: see the note below" : null;+ const engineError =+ (lockedModel && preset && !(engine === "open" ? preset.open : preset.cloud) ? `${preset.name} has no ${engine === "open" ? "open-source" : "cloud"} version yet` : null) ?? comfyBlock;let op: Operation | undefined;let cost: number | null = null;let planError: string | null = null;@@@ -247,10 -296,15 +314,15 @@@const first = slots.find((s) => s.key === g[0]);if (first && !g.some((k) => planSlots[k]?.ref)) planSlots[first.key] = { ref: PLACEHOLDER[first.accept], preview: "", kind: first.accept };}- const { request: planned } = prepare({ ...draft, slots: planSlots, refs: draft.refs.map((r) => stand(r, r.kind) as SlotValue) });+ const { request: planned } = prepare({+ ...draft,+ slots: planSlots,+ refs: draft.refs.map((r) => stand(r, r.kind) as SlotValue),+ frames: draft.frames?.map((f) => ({ ...f, value: stand(f.value, "image") as SlotValue })),+ });const plan = planGeneration({ ...planned, prompt: planned.prompt || (config.promptOptional ? " " : "") }, catalog.getModel, catalog.getPreset);op = plan.op;- cost = estimateCost(plan.model, plan.params, plan.jobs);+ cost = estimateCost(plan.model, plan.params, plan.jobs, plan.op);} catch (e) {planError = (e as Error).message;}@@@ -264,10 -314,10 +336,11 @@@const promptMissing =!config.promptOptional && !opts.promptless && !opts.promptOptional && preset?.userPrompt !== "none" && preset?.userPrompt !== "optional" && !draft.prompt.trim() && !draft.params.shots?.some((s) => s.prompt.trim());const blocker = blockerFor({- loading: !catalog.ready ? "Loading models…" : presetLoading ? "Loading presets…" : null,+ // A model outside the studio's slice (remembered, or handed over) is known once the full catalog arrives: loading until then, not "Pick a model".+ loading: !catalog.ready || (!model && !catalog.complete) ? "Loading models…" : presetLoading ? "Loading presets…" : null,model: !!model,engineError,+ frames: framesOn && model ? (framesBlocker(model, draft.frames!.length) ?? (framesGap ? { message: framesGap } : null)) : null,missing,uploading,maskMissing: needsMask(model, config.sketch, draft.slots),@@@ -333,30 -383,10 +406,31 @@@// Studios with the Moodboard chip pick Soul's styles there (its Curated tab), not in a second Style chip.const soulStyles = !!config.signature && (opts.presets?.source === "soul-v1" || opts.presets?.source === "soul-v2");const opNote = op && model ? routesFor(model, op)[0]?.note : undefined;- const showPrompt = promptShown(config.hidePrompt, preset?.userPrompt, model?.options.promptless);+ // Booleans in, not the model's options object: the React Compiler keeps the memos above.+ const showPrompt = showsPrompt({ hidePrompt: config.hidePrompt, modelPrompt: config.modelPrompt }, { promptless: !!opts.promptless, promptOptional: !!opts.promptOptional }, preset?.userPrompt);const effectiveOp = studioOp ?? op;- const baseShape = settingsShape(model, effectiveOp, config.kind, showPrompt, p, config.ops);+ // SDR to HDR, Export: every format the studio's models on this engine write; picking one this model doesn't+ // write moves the request to the model that does (EXR frames → LTX 2.3 HDR on the cloud).+ const engineModels = useMemo(() => models.filter((m) => m.engine === (model?.engine ?? engine)), [models, model?.engine, engine]);+ const studioFormats = useMemo(() => (config.formatPicker ? formatsOf(engineModels) : undefined), [config.formatPicker, engineModels]);+ const writerOf = (f: VideoFormat) => (model?.options.formats?.includes(f) ? model : engineModels.find((m) => m.options.formats?.includes(f)));+ const pickFormat = (f: VideoFormat) => {+ const m = writerOf(f);+ if (!m || m.id === model?.id) return setP({ format: f });+ setDraft((d) => ({ modelId: m.id, params: { ...m.defaults, format: f, numOutputs: d.params.numOutputs, seed: d.params.seed } }));+ };+ const formatVia = (f: VideoFormat) => {+ const m = writerOf(f);+ // "via LTX 2.3 HDR": the name without what it makes in brackets (the format already says it).+ return m && m.id !== model?.id ? `via ${m.name.replace(/\s*\([^)]*\)$/, "")}` : undefined;+ };+ // Enhance writes a scene; a tool's optional words (FLUX.3 Upscale's details) stay as typed.- const shape = settingsShape(model, effectiveOp, config.kind, showPrompt && !config.hidePrompt, p, config.ops, studioFormats);++ const baseShape = settingsShape(model, effectiveOp, config.kind, showPrompt && !config.hidePrompt, p, config.ops, studioFormats);+ const shape = framesCtx ? framesShape(baseShape, framesCtx.chained) : baseShape;+ const outcome = config.clipFacts && draft.slots.video?.ref ? clipOutcome(effectiveOp, facts, p, model) : null;+ const video = draft.slots.video?.ref;+ const alternative = config.comfyOnly?.alternative;+ const alternativeHref = alternative && `${alternative.href}${video?.startsWith("/api/files/") ? `&video=${encodeURIComponent(video)}` : ""}`;const demo = !!(model && status && status.demoMode !== "off" && !model.routes.some((r) => status.providers[r.provider]?.configured));const costText = costLabel({ demo, cost }, formatCost);@@@ -365,37 -395,12 +439,38 @@@const hasAttachment = slots.some((s) => draft.slots[s.key]) || draft.refs.length > 0;// Tools whose only input is a list of clips (Join clips) keep their "Add clip" tile in view.const showAttachments =- (slots.length > 0 || !!config.multiRef) && (hasAttachment || !!missing || !!slots.find((s) => s.required && !draft.slots[s.key]) || (!!config.multiRef && !showPrompt));+ framesOn ||+ ((slots.length > 0 || !!config.multiRef) && (hasAttachment || !!missing || !!slots.find((s) => s.required && !draft.slots[s.key]) || (!!config.multiRef && !showPrompt)));const collapsed = docked && !focused;// Docked and not focused, the tiles fold into one chip on the toolbar (the composer stays one line).- const attached = [...slots.map((s) => draft.slots[s.key]), ...draft.refs].filter((v): v is SlotValue => !!v);+ const attached = [...slots.map((s) => draft.slots[s.key]), ...draft.refs, ...(draft.frames ?? []).map((f) => f.value)].filter((v): v is SlotValue => !!v);+ // Phones can't hover Generate for its tooltip, and a folded composer hides the tile it points at:+ // there the blocker is a line under the toolbar (blockerLine), and tapping it opens that tile (the+ // file picker, or the paint tool), as the tap is the click the browser needs for a picker.+ const line = blockerLine(blocker, collapsed);+ const blockerSlot = blocker?.slot ?? (config.multiRef && config.hidePrompt && draft.refs.length < 2 ? "refs" : undefined);+ const openBlocked = (key: string) => {+ flushSync(() => setFocused(true));+ const tile = root.current?.querySelector<HTMLElement>(`[data-slot-key="${key}"]`);+ const control = tile?.matches("button") ? tile : tile?.querySelector<HTMLButtonElement>('button[aria-label$=": upload"]');+ pulseSlot(root.current, key);+ // The focus moves into the tile (the press itself didn't take it), so leaving the composer folds it again.+ const target = control ?? tile?.querySelector<HTMLElement>("button");+ if (target) {+ target.focus({ preventScroll: true });+ control?.click();+ return;+ }+ // Nothing to focus: the next press outside the composer folds it.+ const fold = (e: PointerEvent) => {+ if (root.current?.contains(e.target as Node) || root.current?.contains(document.activeElement)) return;+ document.removeEventListener("pointerdown", fold, true);+ setFocused(false);+ };+ document.addEventListener("pointerdown", fold, true);+ };+// A blocker toast goes away once it's out of date: the photo attached, the prompt typed (or the next blocker is a different one).const blocking = blocker?.message;useEffect(() => {diff --cc src/components/studio/studio-context.tsxindex 784f3bac,2f14177b..1de62c39--- a/src/components/studio/studio-context.tsx+++ b/src/components/studio/studio-context.tsx@@@ -52,20 -46,8 +53,22 @@@ export interface StudioConfigsignature?: boolean;/** Models the studio can be moved to (by the signature chips) beyond its picker list and defaults: kept in its model slice. */extraModels?: string[];+ /**+ * Read the attached clip's header (length, size, frame rate): prices count its seconds and the composer+ * says what comes out ("24 → 60 fps", "1280×720 → 3840×2160"). Upscale hub video modes.+ */+ clipFacts?: boolean;+ /** Offer every output format of the studio's models on this engine; picking one another model writes moves the request there (SDR to HDR, Export). */+ formatPicker?: boolean;+ /** The models' enum settings chip ("Director" by default; "Options" for a tool's settings such as Topaz's model). */+ controlsTitle?: string;+ /**+ * Tools only ComfyUI runs (Export): what to say when none is connected or the install runs cloud APIs only,+ * and a cloud route to offer instead (`href` gets `&video=<the attached clip>`).+ */+ comfyOnly?: { note: string; alternative?: { label: string; href: string } };+ /** Frames mode (Video studio): up to 10 stills, each at its own time in the clip, instead of a start and an end frame. */+ frames?: boolean;}export interface Draft {diff --cc src/lib/catalog/canvas.tsindex ab1fdc42,139da736..a4f7c956--- a/src/lib/catalog/canvas.ts+++ b/src/lib/catalog/canvas.ts@@@ -863,7 -867,9 +867,9 @@@ export function describeNode(graph: Canif ("error" in built) return { model, costUsd: null, error: built.error };try {const plan = planGeneration(withPlaceholders(built.request), getModel, getPreset);+ // A film built clip by clip is planned from its inputs when it starts: it can't wait for another node (said before Run).+ if (built.deps.length && plan.op === "keyframes" && keyframeChain(plan.model)) return { ...built, model, costUsd: null, error: chainedWaitMessage(plan.model.name) };- return { ...built, model, plan, costUsd: estimateCost(plan.model, plan.params, plan.jobs) };+ return { ...built, model, plan, costUsd: estimateCost(plan.model, plan.params, plan.jobs, plan.op) };} catch (e) {return { ...built, model, costUsd: null, error: (e as Error).message };}diff --cc src/lib/composer.tsindex 5b825a06,1fdceb18..2808cfc2--- a/src/lib/composer.ts+++ b/src/lib/composer.ts@@@ -3,11 -3,8 +3,12 @@@* blocker messages, attachment placement and model-picker grouping. No catalog import here, so* nothing in this file pulls the model list into the browser bundle.*/+import { FORMAT_INFO } from "./av/formats";+import { fpsPlan, fpsSummary } from "./av/fps";+import { targetShortEdge, upscaledSize, upscaleFactorFor, upscaleTier } from "./av/upscale";+import { wholeClipProblem, wholeClipTool } from "./av/video-finish";+ import { addFrameAt, frameTimes, framesInputs, removeFrameAt, spread, type FrameSupport } from "./catalog/keyframes";-import { COLORMAPS, type Engine, type GenParams, type InputSlot, type MatteOutput, type MediaKind, type ModelDef, type Operation, type Preset } from "./catalog/types";+import { COLORMAPS, type Engine, type GenParams, type InputSlot, type MatteOutput, type MediaKind, type ModelDef, type Operation, type Preset, type VideoFormat } from "./catalog/types";import { spokenLanguageName } from "./speech-languages";// ---------------------------------------------------------------------------@@@ -364,14 -211,10 +373,14 @@@ export function missingMessage(m: Missireturn `Add ${orList(m.group.map((s) => slotMessage(s.label).replace(/^Add /, "")))}`;}+const WRITE_PROMPT = "Write a prompt first";+export interface Blocker {message: string;- /** The attachment to point at (pulse) when Generate is pressed ("mask": the Paint area tile). */- slot?: InputSlot["key"];+ /** The attachment to point at (pulse) when Generate is pressed ("mask": the Paint area tile; "frames": Frames mode's Add frame tile). */+ slot?: InputSlot["key"] | "frames";+ /** Passes by itself or is plain to see (loading, uploading, the empty prompt box): never spelled out under the composer. */+ quiet?: boolean;}/**@@@ -405,15 -250,15 +416,16 @@@ export function blockerFor(s:planError?: string | null;promptMissing: boolean;}): Blocker | null {- if (s.loading) return { message: s.loading };+ if (s.loading) return { message: s.loading, quiet: true };if (!s.model) return { message: "Pick a model" };if (s.engineError) return { message: s.engineError };+ if (s.frames) return s.frames;if (s.missing) return { message: missingMessage(s.missing), slot: s.missing.key };- if (s.uploading) return { message: "Uploading…" };+ if (s.uploading) return { message: "Uploading…", quiet: true };if (s.maskMissing) return { message: "Paint the area to change", slot: "mask" };- if (s.planError) return { message: s.planError };- if (s.promptMissing) return { message: "Write a prompt first" };+ // The planner says "Write a prompt first" too (an empty prompt on a model that needs one): as quiet as the composer's own.+ if (s.planError) return s.planError === WRITE_PROMPT ? { message: WRITE_PROMPT, quiet: true } : { message: s.planError };+ if (s.promptMissing) return { message: WRITE_PROMPT, quiet: true };return null;}diff --cc src/server/generations.tsindex e0f41078,c16cbbe6..220c12ea--- a/src/server/generations.ts+++ b/src/server/generations.ts@@@ -8,8 -8,8 +8,9 @@@ import { withSignatureWords } from "@/limport { applySketch, stripMotionPaths } from "@/lib/catalog/sketch";import { cueText, type Cue } from "@/lib/cues";import { HELPER_FEATURES, HELPER_SUFFIX, isReviewStatus, type AssetUse, type ReviewFilter } from "@/lib/library";+import { upscaleTier } from "@/lib/av/upscale";- import { estimateCost, planGeneration, routesFor } from "@/lib/catalog/plan";+ import { chainedWaitMessage, keyframeChain } from "@/lib/catalog/keyframes";+ import { estimateCost, inferOperation, planGeneration, routesFor } from "@/lib/catalog/plan";import { keepMatte } from "@/lib/catalog/payload";import {LAST_FRAME_CHAIN,