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
Runs show the settings they are made at, and say before a run when a value is made differently
Adarshc8dbfd50e326
diff --git a/src/components/assist/plan-jobs.tsx b/src/components/assist/plan-jobs.tsxindex b8d57834..33262329 100644--- a/src/components/assist/plan-jobs.tsx+++ b/src/components/assist/plan-jobs.tsx@@ -51,6 +51,13 @@ export function PlanJobs({ jobs, fold = 6, className }: { jobs: PlannedJob[]; fo</span></p><p className={cn("mt-0.5 text-[13px] break-words", j.op === "memory" ? "text-foreground" : "line-clamp-2 text-muted-foreground")}>{j.prompt}</p>+ {!j.error && !!j.changes?.length && (+ <ul className="mt-1 space-y-0.5 text-[12px] leading-snug text-muted-foreground">+ {j.changes.map((c) => (+ <li key={c}>{c}</li>+ ))}+ </ul>+ )}{j.error && (<p className="mt-1 flex items-start gap-1 text-[12px] text-destructive"><CircleAlert className="mt-0.5 size-3 shrink-0" /> {j.error}diff --git a/src/components/canvas/nodes.tsx b/src/components/canvas/nodes.tsxindex 32d61e44..f762b1b9 100644--- a/src/components/canvas/nodes.tsx+++ b/src/components/canvas/nodes.tsx@@ -116,6 +116,9 @@ import {} from "@/lib/catalog/canvas";import { OPERATION_LABELS, type Engine, type MediaKind, type ModelDef, type Operation, type OutputFile } from "@/lib/catalog/types";import { OPERATION_PLACE, opTakes, settingUnavailable } from "@/lib/catalog/route-takes";+import { fittedSettings, type SettingChange } from "@/lib/catalog/fitted";+import type { Unavailable } from "@/lib/unavailable";+import { UnavailableNote } from "@/components/ui/unavailable";import { settingsShape } from "@/lib/composer";import { formatCost } from "@/lib/format";import { dubResult, languageStage, type DubSessionView, type DubStage } from "@/lib/av/dub";@@ -636,7 +639,8 @@ function OptionSelect<T extends string | number>({);}-function ModelOptions({ id, model, data, runOp }: { id: string; model: ModelDef; data: CanvasNodeData; runOp?: Operation }) {+/** A node's settings; on a read-only board (a phone) only what its run makes differently is said, without the fix. */+function ModelOptions({ id, model, data, runOp, readOnly }: { id: string; model: ModelDef; data: CanvasNodeData; runOp?: Operation; readOnly?: boolean }) {const actions = useEditorActions();const p = data.params ?? {};const o = model.options;@@ -700,8 +704,33 @@ function ModelOptions({ id, model, data, runOp }: { id: string; model: ModelDef;);if (o.sliders?.length) items.push(<div key="sliders" className={NO_DRAG}><SlidersChip model={model} values={extra} onChange={setExtra} /></div>);if (o.controls?.length) items.push(<div key="controls" className={NO_DRAG}><ControlsChip controls={o.controls} values={extra} onChange={setExtra} op={op} /></div>);- if (!items.length) return null;- return <div className={cn("flex flex-wrap gap-1 [&_button]:h-7 [&_button]:text-[12px]", NO_DRAG)}>{items}</div>;+ // A value the node holds that its run makes differently (a model switch kept 2K; a template set 4K): said before the+ // run, with the value it is made at one tap away.+ const changes = op ? fittedSettings(model, op, { ...d, ...p }).changes : [];+ if ((readOnly || !items.length) && !changes.length) return null;+ return (+ <>+ {!readOnly && items.length > 0 && <div className={cn("flex flex-wrap gap-1 [&_button]:h-7 [&_button]:text-[12px]", NO_DRAG)}>{items}</div>}+ {changes.map((c) => (+ <UnavailableNote key={c.setting} className={cn("mt-0", NO_DRAG)} reason={{ why: c.note, fix: readOnly ? undefined : fixFor(c, set) }} onClose={() => undefined} />+ ))}+ </>+ );+}++const FIX_PARAM: Partial<Record<SettingChange["setting"], "resolution" | "aspectRatio" | "duration" | "seed" | "numOutputs">> = {+ resolution: "resolution",+ aspectRatio: "aspectRatio",+ duration: "duration",+ seed: "seed",+ numOutputs: "numOutputs",+};++/** The one-tap fix for a held value its run makes differently: pick the value it is made at. */+function fixFor(c: SettingChange, set: (patch: Partial<NonNullable<CanvasNodeData["params"]>>) => void): Unavailable["fix"] {+ if (c.use === undefined) return undefined;+ const key = FIX_PARAM[c.setting];+ return key ? { label: `Use ${c.made}`, run: () => set({ [key]: c.use }) } : undefined;}/** A model's numeric settings behind one chip (the studio composer shows them in its settings panel). */@@ -949,7 +978,7 @@ const GeneratorNode = memo(function GeneratorNode({ id, type: flowType, data, seclassName={cn("field-sizing-content max-h-36 min-h-14 w-full resize-none rounded-lg bg-muted px-2.5 py-2 text-[13px] leading-snug outline-none placeholder:text-subtle-foreground focus:ring-2 focus:ring-brand-faint", NO_DRAG)}/>)}- {model && !g.readOnly && type !== "concat" && <ModelOptions id={id} model={model} data={data} runOp={v.op} />}+ {model && type !== "concat" && <ModelOptions id={id} model={model} data={data} runOp={v.op} readOnly={g.readOnly} />}{v.rows && (<p className="flex items-center gap-1.5 text-[12px] text-muted-foreground"><Table className="size-3.5 shrink-0" /> Runs once per table row: {v.rows === 1 ? "1 run" : `${v.rows} runs`}diff --git a/src/components/cinema/cinema-feed.tsx b/src/components/cinema/cinema-feed.tsxindex 1d6a9022..7ec70000 100644--- a/src/components/cinema/cinema-feed.tsx+++ b/src/components/cinema/cinema-feed.tsx@@ -1,5 +1,6 @@"use client";+import { shownSettings } from "@/lib/catalog/made";import {Box,CalendarDays,@@ -220,7 +221,7 @@ function TileMenu({ u, folders, projectId, handlers, onDelete }: { u: Unit; foldconst finish = o?.kind === "video" && !u.tile && !finished.has(u.g.id) ? finishIn2k(u.g, engineMode) : null;const ownSetup = finish?.perSecond === null ? "regenerate:cinema-finish" : undefined;const press = useOwnSetupPress();- const seconds = Number(u.g.request.params?.duration ?? 0);+ const seconds = Number(shownSettings(u.g).duration ?? 0);const finishPrice = !finish ? "" : finish.perSecond === null ? "Free" : seconds > 0 ? `≈ ${formatCost(finish.perSecond * seconds)}` : `$${finish.perSecond.toFixed(2)}/s`;return (<DropdownMenu>@@ -500,7 +501,8 @@ function TileView({<div className="pointer-events-none absolute inset-x-0 bottom-0 flex items-end justify-between gap-1 bg-gradient-to-t from-black/65 to-transparent p-2 pt-8 opacity-100 transition-opacity sm:opacity-0 sm:group-focus-within/tile:opacity-100 sm:group-hover/tile:opacity-100"><div className="flex min-w-0 flex-wrap gap-1">{step && <Badge>{step}</Badge>}- {u.output?.kind === "video" && g.request.params?.duration ? <Badge>{g.request.params.duration}s</Badge> : null}+ {/* The length it was made at (a route that rounds 5 s to 7 s says 7s). */}+ {u.output?.kind === "video" && shownSettings(g).duration ? <Badge>{shownSettings(g).duration}s</Badge> : null}</div><div className="pointer-events-auto flex shrink-0 items-center gap-0.5">{u.output?.kind === "video" && (diff --git a/src/components/faceless/settings-form.tsx b/src/components/faceless/settings-form.tsxindex 19efc0e5..ad4b722c 100644--- a/src/components/faceless/settings-form.tsx+++ b/src/components/faceless/settings-form.tsx@@ -265,7 +265,13 @@ export function EpisodeSettingsForm({)}{video && video.resolutions.length > 1 && (<Section title="Quality" hint={frames ? "The size the camera moves render at: no model runs, larger sizes take longer and more memory." : undefined}>- <Segmented label="Quality" value={resolution ?? ""} options={video.resolutions.map((r) => ({ value: r, label: r }))} onChange={(r) => onChange({ resolution: r })} />+ <Segmented label="Quality" value={resolution ?? ""} options={video.resolutions.map((r) => {+ // A quality the clips are made at differently: muted, with why and the one they are made at.+ const fit = video.madeAt?.[r];+ return { value: r, label: r, unavailable: fit && { why: fit.why, fix: { label: `Use ${fit.made}`, run: () => onChange({ resolution: fit.made }) } } };+ })}+ onChange={(r) => onChange({ resolution: r })}+ /></Section>)}<p className="text-[12px] text-muted-foreground">diff --git a/src/components/marketing/model-info.ts b/src/components/marketing/model-info.tsindex 8a36e69c..ce797747 100644--- a/src/components/marketing/model-info.ts+++ b/src/components/marketing/model-info.ts@@ -1,6 +1,6 @@import { getModel } from "@/lib/catalog";import { FORMATS, formatModels, MULTIPLIER_MODELS, UGC_MODELS, type FormatId } from "@/lib/catalog/marketing";-import { opTakes } from "@/lib/catalog/route-takes";+import { opTakes, takesValue } from "@/lib/catalog/route-takes";import type { Engine, ModelDef } from "@/lib/catalog/types";/**@@ -40,7 +40,10 @@ function editSizes(m: ModelDef): Pick<ModelInfo, "editSizes"> {if (!op) return {};// The open recreate (motion transfer) is sent no size: its graph makes its own.if (m.engine === "open" || !opTakes(m, op).resolution) return { editSizes: false };- return m.options.resolutions?.length ? { editSizes: [...m.options.resolutions] } : {};+ // Only the sizes its edit route makes (a size it would fit to another shows as unavailable, with the one it makes).+ const made = opTakes(m, op).resolutions;+ const sizes = (m.options.resolutions ?? []).filter((r) => takesValue(made, r));+ return sizes.length ? { editSizes: sizes } : m.options.resolutions?.length ? { editSizes: [...m.options.resolutions] } : {};}/** Every model a marketing flow can name, by id. */diff --git a/src/components/marketing/runs.tsx b/src/components/marketing/runs.tsxindex 178e5387..c87e1d02 100644--- a/src/components/marketing/runs.tsx+++ b/src/components/marketing/runs.tsx@@ -1,6 +1,7 @@"use client";import { useQueryClient } from "@tanstack/react-query";+import { shownSettings } from "@/lib/catalog/made";import { AlertCircle, Check, Circle, Download, Loader2, MoreHorizontal, Repeat2, Type, X } from "lucide-react";import dynamic from "next/dynamic";import { useEffect, useMemo, useRef, useState } from "react";@@ -51,7 +52,8 @@ function StepChip({ g }: { g: Generation }) {}function runRatio(run: MarketingRun, g?: Generation): number {- const ar = g?.request.params?.aspectRatio ?? g?.aspectRatio ?? undefined;+ // The shape it was made at.+ const ar = (g && shownSettings(g).aspectRatio) ?? g?.aspectRatio ?? undefined;return ratioValue(ar && ar !== "auto" ? ar : undefined, g?.kind === "video" ? 9 / 16 : 3 / 4);}diff --git a/src/components/studio/made-note.tsx b/src/components/studio/made-note.tsxnew file mode 100644index 00000000..9b0c9706--- /dev/null+++ b/src/components/studio/made-note.tsx@@ -0,0 +1,20 @@+import { changeLine } from "@/lib/catalog/made";+import type { Generation } from "@/lib/catalog/types";+import { cn } from "@/lib/utils";++/**+ * Under a finished run (the feed card, the run details): each setting it was made at differently from what it asked, in+ * one small muted line ("Quality: asked for 2K · made at 1080p (the most this model makes)"). Nothing when it made+ * what it asked.+ */+export function MadeNote({ g, className }: { g: Pick<Generation, "made">; className?: string }) {+ const changes = g.made?.changes ?? [];+ if (!changes.length) return null;+ return (+ <ul className={cn("space-y-0.5 text-[11.5px] leading-snug text-pretty text-muted-foreground", className)} aria-label="Made differently from what was asked">+ {changes.map((c) => (+ <li key={c.setting + c.label}>{changeLine(c)}</li>+ ))}+ </ul>+ );+}diff --git a/src/lib/assist.ts b/src/lib/assist.tsindex 089df831..d395a4bd 100644--- a/src/lib/assist.ts+++ b/src/lib/assist.ts@@ -28,6 +28,8 @@ export interface PlannedJob {error?: string;/** A short extra line on the card (a studio's step, what a step waits for). */note?: string;+ /** What the run makes differently from what it asks (src/lib/catalog/fitted.ts: "… makes up to 1080p, so this is made at 1080p"). */+ changes?: string[];/** One step of a pipeline: it only starts when every step can, so one error blocks the run. */atomic?: boolean;/**diff --git a/src/lib/catalog/cinema.ts b/src/lib/catalog/cinema.tsindex 5b365a0b..928aeb4a 100644--- a/src/lib/catalog/cinema.ts+++ b/src/lib/catalog/cinema.ts@@ -10,7 +10,8 @@ import { localOnly, needsToken, triggerOf } from "./loras";import { QMA_MODEL, qmaLabel, qmaView } from "@/lib/qma";import { studioResolutions } from "./regenerate";import { ANGLES_2511_LORA } from "./open-tools";-import { composeShots, estimateCost, planGeneration, routesFor } from "./plan";+import { composeShots, estimateCost, inferOperation, planGeneration, routesFor } from "./plan";+import { fittedSettings } from "./fitted";import { soulRecipe } from "./soul";import { planTurnaround, type TurnaroundInput } from "./turnaround";import { planFlyAround } from "./fly-around";@@ -2583,6 +2584,25 @@ export function worldTake(input: Pick<CinemaGenerateInput, "world">): CinemaTake/** Everything a Generate press would run, priced, without running it (the browser shows it live). */export function planCinema(input: CinemaGenerateInput, ctx: CinemaContext): CinemaPlan {+ return withRouteNotes(planCinemaSteps(input, ctx));+}++/**+ * A plan with what its steps' routes make differently from what they ask (fitted.ts: a model whose hosted route makes up to+ * 1080p, a length its route rounds), said under the prompt bar before Generate.+ */+function withRouteNotes(plan: CinemaPlan): CinemaPlan {+ const notes = [...plan.notes];+ for (const s of plan.steps) {+ const m = getModel(s.request.modelId);+ if (!m || m.engine === "open") continue;+ const op = s.request.op ?? inferOperation(m, s.request);+ for (const c of fittedSettings(m, op, { ...m.defaults, ...s.request.params }, { negativePrompt: s.request.negativePrompt }).changes) if (!notes.includes(c.note)) notes.push(c.note);+ }+ return notes.length === plan.notes.length ? plan : { ...plan, notes };+}++function planCinemaSteps(input: CinemaGenerateInput, ctx: CinemaContext): CinemaPlan {const i = { ...input, settings: input.settings ?? {}, prompt: input.prompt ?? "" };switch (i.action) {case "grid":diff --git a/src/lib/catalog/faceless.ts b/src/lib/catalog/faceless.tsindex eddbd065..2a1205fd 100644--- a/src/lib/catalog/faceless.ts+++ b/src/lib/catalog/faceless.ts@@ -2,6 +2,7 @@ import { describeMove, KEN_BURNS_FPS, sceneMoves } from "@/lib/av/ken-burns";import { SPLIT_MODEL } from "@/lib/av/split";import { COPY_JOIN_VIDEOS, lengthRange, plannedDurations } from "./clip-lengths";import { estimateCost } from "./plan";+import { settingChange } from "./fitted";import { REGEN_FINISH_TIER, REGEN_MODEL, regenFinishSteps, sixteenFpsModel, type FinishStep } from "./regenerate";import { pricingAt } from "./promo";import type { ChainSlot, Engine, Generation, GenerationRequest, ModelDef } from "./types";@@ -882,7 +883,10 @@ export function resolveModels(settings: EpisodeSettings, narrationChars: number,const video = frames ? m.kenBurns : settings.videoModel && m.videoChoices.includes(settings.videoModel) ? settings.videoModel : m.video;const videoDef = lookup(video);const offered = videoDef?.options.resolutions ?? [];- const wanted = settings.resolution && offered.includes(settings.resolution) ? settings.resolution : (DEFAULT_RESOLUTION[video]?.[settings.animation] ?? videoDef?.defaults?.resolution ?? offered[0] ?? "720p");+ // A quality its clips are made at differently is sent as the one they are made at, so the episode says what it is.+ const asked = settings.resolution && offered.includes(settings.resolution) ? settings.resolution : undefined;+ const fit = asked && videoDef ? settingChange(videoDef, "i2v", "resolution", asked)?.use : undefined;+ const wanted = asked ? (fit !== undefined ? (offered.find((o) => o.toLowerCase() === String(fit).toLowerCase()) ?? String(fit)) : asked) : (DEFAULT_RESOLUTION[video]?.[settings.animation] ?? videoDef?.defaults?.resolution ?? offered[0] ?? "720p");const sample = settings.voice?.kind === "sample";const narration = settings.engine === "open" ? m.narration : sample ? m.cloneNarration : narrationChars > m.narrationMaxChars ? m.longNarration : m.narration;// Style references win; attached source images otherwise go to a model that reads them.@@ -2098,10 +2102,21 @@ export function defaultSettings(engine: Engine, genre: GenreInfo, o: { explainer};}+/** The qualities a video model's clips from stills are made at differently (fitted.ts), for the Quality picker. */+function clipFits(m: ModelDef): { madeAt?: Record<string, { made: string; why: string }> } {+ const out: Record<string, { made: string; why: string }> = {};+ for (const r of m.options.resolutions ?? []) {+ const c = settingChange(m, "i2v", "resolution", r);+ if (c?.use !== undefined) out[r] = { made: String(c.use), why: c.note };+ }+ return Object.keys(out).length ? { madeAt: out } : {};+}+/** Narrator voices and video model choices for the browser (built on the server, so the client needs no catalog). */export interface PickerData {voices: { id: string; name: string; hint?: string }[];- videoModels: { id: string; name: string; engine: Engine; resolutions: string[] }[];+ /** `madeAt`: a quality its clips (from stills) are made at differently, and the one they are made at, with why. */+ videoModels: { id: string; name: string; engine: Engine; resolutions: string[]; madeAt?: Record<string, { made: string; why: string }> }[];/** The music bed's models per engine, each with the longest bed it makes in one go (seconds; longer films loop it). */musicModels?: { id: string; name: string; engine: Engine; maxSeconds: number }[];/** Frame by frame's camera move per engine (Ken Burns) and the qualities it renders at (none: the still's own size). */@@ -2118,7 +2133,7 @@ export function pickerData(lookup: ModelLookup): PickerData {const videoModels = (["cloud", "open"] as const).flatMap((engine) =>ENGINE_MODELS[engine].videoChoices.flatMap((id) => {const m = lookup(id);- return m ? [{ id, name: m.name, engine, resolutions: m.options.resolutions ?? [] }] : [];+ return m ? [{ id, name: m.name, engine, resolutions: m.options.resolutions ?? [], ...clipFits(m) }] : [];}),);const musicModels = (["cloud", "open"] as const).flatMap((engine) =>diff --git a/src/lib/catalog/fitted.ts b/src/lib/catalog/fitted.tsnew file mode 100644index 00000000..4d8a1b52--- /dev/null+++ b/src/lib/catalog/fitted.ts@@ -0,0 +1,210 @@+import { listWords } from "@/lib/unavailable";+import { fitLength, fitValue, framedLength, inRange, seedValue } from "./payload";+import { MAX_RESULTS, routesFor } from "./plan";+import { OPERATION_PLACE, routeDrops, routeTakes } from "./route-takes";+import { tierWords, type MadeSettings, type SettingChange } from "./made";+import type { GenParams, ModelDef, ModelRoute, Operation, ProviderId } from "./types";++export { changeLine, shownSettings, tierWords, type FittedSetting, type MadeSettings, type SettingChange } from "./made";++/*+ * What a run is actually made at. A hosted route sends only the fields its map names and fits a value it doesn't take to+ * the closest one it does (buildPayload: a 2K run on MiniMax H3 Max Turbo goes as 1080P). This says so, from the same+ * rules, for every surface: before a run (a note with a one-tap fix) and after it (the made value, and "Asked for 2K ·+ * made at 1080p"). It reads a route's field map on the server and its summary (route.takes) in the browser.+ */++/** Operations whose result keeps the shape of what goes in (a start frame, the clip extended). */+const SHAPE_FROM_INPUT: Partial<Record<Operation, string>> = { i2v: "the start frame's shape", flf2v: "the start frame's shape", extend: "the clip's shape" };++const QUIET_PLACE = new Set<Operation>(["t2i", "t2v", "edit"]);++const secs = (n: number) => `${Math.round(n * 100) / 100}s`;++/** "720p" → 720, "2K" → 2000 (the same order fitValue sorts tiers in). */+function tierSize(v: string): number {+ const m = /^(\d+(?:\.\d+)?)\s*([pk])$/i.exec(v.trim());+ return m ? Number(m[1]) * (m[2].toLowerCase() === "k" ? 1000 : 1) : NaN;+}++/** The route a run goes to: the one its provider names (a finished run), else the first (where a run goes first). */+export function runRoute(model: Pick<ModelDef, "routes">, op: Operation, params?: GenParams, provider?: ProviderId): ModelRoute | undefined {+ const routes = routesFor(model as ModelDef, op, params);+ return (provider && routes.find((r) => r.provider === provider)) || routes[0];+}++/**+ * The settings a run on `model` is made at, from what it asks (`params`, as stored or about to be sent), and each change in+ * plain words. Nothing changes on the open engine or on routes that take every setting (a GPU graph, Fuobe's own routes).+ */+export function fittedSettings(+ model: Pick<ModelDef, "id" | "name" | "engine" | "routes" | "defaults">,+ op: Operation,+ params: GenParams | undefined,+ opts: { provider?: ProviderId; negativePrompt?: string } = {},+): MadeSettings {+ const p = params ?? {};+ const made: MadeSettings = {+ ...(p.aspectRatio !== undefined && { aspectRatio: p.aspectRatio }),+ ...(p.resolution !== undefined && { resolution: p.resolution }),+ ...(p.duration !== undefined && { duration: p.duration }),+ ...(p.seed !== undefined && p.seed >= 0 && { seed: p.seed }),+ ...(p.numOutputs !== undefined && { numOutputs: p.numOutputs }),+ changes: [],+ };+ const changes = made.changes;+ const name = model.name;+ // A request for more results than a run makes (an API call, Assist) makes the most it does.+ if (p.numOutputs !== undefined && p.numOutputs > MAX_RESULTS) {+ made.numOutputs = MAX_RESULTS;+ changes.push({ setting: "numOutputs", label: "Results", asked: String(p.numOutputs), made: String(MAX_RESULTS), reason: `the most one run makes`, note: `A run makes up to ${MAX_RESULTS} results, so this one makes ${MAX_RESULTS}`, use: MAX_RESULTS });+ }+ const route = model.engine === "open" ? undefined : runRoute(model, op, p, opts.provider);+ const takes = route && routeTakes(route, model.id);+ // The parts of the field map that fit numbers (the server's map, or what the browser keeps of it).+ const limits = route?.map ?? route?.preview;+ if (!route || (!takes && !limits)) return made;+ // Where its own limits apply, for modes with limits of their own ("from a start frame"); none for words alone or an edit.+ const place = !QUIET_PLACE.has(op) && OPERATION_PLACE[op] ? ` ${OPERATION_PLACE[op]}` : "";+ // A default every studio fills in (a shape for a start frame) that the route doesn't send isn't a choice: it is left out+ // of the made settings without a word.+ const filled = (k: "aspectRatio" | "resolution" | "duration", v: unknown) => v === "auto" || (model.defaults as Record<string, unknown> | undefined)?.[k] === v;++ // Quality.+ const res = p.resolution;+ if (res !== undefined && takes?.resolutions === false) {+ delete made.resolution;+ if (!filled("resolution", res)) changes.push({ setting: "resolution", label: "Quality", asked: tierWords(res), made: "Its own", reason: `this model sets its own quality${place}`, note: `${name} sets its own quality${place}, so ${tierWords(res)} isn't sent` });+ } else if (res !== undefined && Array.isArray(takes?.resolutions)) {+ const list = takes.resolutions;+ const fit = fitValue(list, res, "tier");+ if (fit === undefined) {+ delete made.resolution;+ if (!filled("resolution", res)) changes.push({ setting: "resolution", label: "Quality", asked: tierWords(res), made: "Its own", reason: `this model makes ${listWords(list.map(tierWords))}`, note: `${name} makes ${listWords(list.map(tierWords))}${place}, so it picks its own quality` });+ } else if (fit.toLowerCase() === res.toLowerCase()) made.resolution = fit;+ else {+ made.resolution = fit;+ const sizes = list.map(tierSize).filter((n) => Number.isFinite(n));+ const most = tierSize(fit) === Math.max(...sizes) && tierSize(res) > tierSize(fit);+ const least = tierSize(fit) === Math.min(...sizes) && tierSize(res) < tierSize(fit);+ const reason = most ? "the most this model makes" : least ? "the least this model makes" : `this model makes ${listWords(list.map(tierWords))}`;+ const note = most+ ? `${name} makes up to ${tierWords(fit)}${place}, so this is made at ${tierWords(fit)}`+ : least+ ? `${name} makes ${tierWords(fit)} or more${place}, so this is made at ${tierWords(fit)}`+ : `${name} makes ${listWords(list.map(tierWords))}${place}, so this is made at ${tierWords(fit)}`;+ changes.push({ setting: "resolution", label: "Quality", asked: tierWords(res), made: tierWords(fit), reason, note, use: fit });+ }+ }++ // Shape.+ const ar = p.aspectRatio;+ if (ar !== undefined && takes?.aspectRatios === false) {+ delete made.aspectRatio;+ const own = SHAPE_FROM_INPUT[op] ?? "its own shape";+ if (!filled("aspectRatio", ar)) changes.push({ setting: "aspectRatio", label: "Aspect ratio", asked: ar, made: own[0].toUpperCase() + own.slice(1), reason: SHAPE_FROM_INPUT[op] ? `this model keeps ${own}` : "this model sets its own shape", note: `${name} keeps ${own}${place}, so ${ar} isn't sent` });+ } else if (ar !== undefined && Array.isArray(takes?.aspectRatios)) {+ const list = takes.aspectRatios;+ const fit = fitValue(list, ar, "ratio");+ if (fit === undefined) {+ delete made.aspectRatio;+ const own = SHAPE_FROM_INPUT[op] ?? "its own shape";+ if (!filled("aspectRatio", ar)) changes.push({ setting: "aspectRatio", label: "Aspect ratio", asked: ar, made: own[0].toUpperCase() + own.slice(1), reason: `this model makes ${listWords(list)}`, note: `${name} makes ${listWords(list)}${place}, so it keeps ${own}`, use: list[0] });+ } else if (fit.toLowerCase() === ar.toLowerCase()) made.aspectRatio = fit;+ else {+ made.aspectRatio = fit;+ changes.push({ setting: "aspectRatio", label: "Aspect ratio", asked: ar, made: fit, reason: "the closest shape this model makes", note: `${name} doesn't make ${ar}${place}, so this is made at ${fit}, the closest shape it makes`, use: fit });+ }+ }++ // Length (one take: shots set their own).+ const d = p.duration;+ if (d !== undefined && !p.shots?.length) {+ if (takes?.durations === false) {+ delete made.duration;+ if (!filled("duration", d)) changes.push({ setting: "duration", label: "Duration", asked: secs(d), made: "The clip's", reason: "this model keeps the clip's length", note: `${name} keeps the clip's length${place}, so ${secs(d)} isn't sent` });+ } else {+ let fit = Array.isArray(takes?.durations) ? fitLength(takes.durations, d) : d;+ // A frame-count route (Wan 2.2 fast: 81–121 frames) makes the length its frames come to.+ const framed = framedLength(limits?.numFrames, fit, p.fps);+ if (framed !== undefined) fit = framed;+ // A length field the API limits (FieldMap.ranges), on the server's map.+ const key = route.map?.duration?.key;+ const range = key ? route.map?.ranges?.[key] : undefined;+ if (range && (route.map?.duration?.multiplier ?? 1) === 1) fit = inRange(fit, range);+ if (Math.abs(fit - d) > 1e-6) {+ made.duration = fit;+ const lengths = Array.isArray(takes?.durations) ? [...takes.durations].sort((a, b) => a - b) : undefined;+ const most = lengths ? fit === lengths[lengths.length - 1] && d > fit : range?.max !== undefined && fit === range.max && d > fit;+ const reason = most ? "the longest this model makes" : lengths ? `this model makes ${listWords(lengths.map(secs))} clips` : "the closest length this model makes";+ const note = most+ ? `${name} makes up to ${secs(fit)}${place}, so this is ${secs(fit)}`+ : lengths+ ? `${name} makes ${listWords(lengths.map(secs))} clips${place}, so this is ${secs(fit)}`+ : `${name} makes ${secs(fit)} clips for this length${place}`;+ changes.push({ setting: "duration", label: "Duration", asked: secs(d), made: secs(fit), reason, note, use: fit });+ }+ }+ }++ // Each shot's words, cut where the API takes fewer (Kling 4.0: 512 characters a shot).+ const shotMax = route.map?.multiShot?.maxPrompt;+ if (shotMax && p.shots?.length) {+ const long = p.shots.map((s, i) => ({ i, n: s.prompt.length })).filter((s) => s.n > shotMax);+ if (long.length) {+ const which = listWords(long.map((s) => String(s.i + 1)));+ changes.push({+ setting: "shots",+ label: long.length === 1 ? `Shot ${which}` : `Shots ${which}`,+ asked: `${Math.max(...long.map((s) => s.n)).toLocaleString("en-US")} characters`,+ made: `${shotMax.toLocaleString("en-US")} characters`,+ reason: "the most this model reads a shot",+ note: `${name} reads up to ${shotMax.toLocaleString("en-US")} characters a shot, so the words of shot ${which} are cut there`,+ });+ }+ }++ // Seed.+ const seed = p.seed;+ if (seed !== undefined && seed >= 0) {+ const range = route.map?.seedRange;+ if (takes?.seed === false) {+ delete made.seed;+ changes.push({ setting: "seed", label: "Seed", asked: String(seed), made: "Random", reason: "this model takes no seed here", note: `${name} takes no seed${place}, so each run is new` });+ } else if (range && seedValue(range, seed) !== seed) {+ const sent = seedValue(range, seed);+ made.seed = sent;+ changes.push({ setting: "seed", label: "Seed", asked: String(seed), made: String(sent), reason: `this model takes seeds up to ${range[1].toLocaleString("en-US")}`, note: `${name} takes seeds from ${range[0]} to ${range[1].toLocaleString("en-US")}, so seed ${seed} is sent as ${sent}`, use: sent });+ }+ }++ // Settings the route has no field for (the run's note names them: routeDrops).+ const drops = routeDrops(route, model.id, { negativePrompt: opts.negativePrompt, params: p });+ if (drops.includes("a negative prompt")) {+ changes.push({ setting: "negativePrompt", label: "Negative prompt", asked: "Yours", made: "Not sent", reason: "this model reads no negative prompt here", note: `${name} reads no negative prompt${place}, so it isn't sent` });+ }+ if (drops.includes("the sound switch")) {+ changes.push({ setting: "generateAudio", label: "Sound", asked: "Off", made: "Its own", reason: "this model has no sound switch here", note: `${name} has no sound switch${place}: it makes its own sound` });+ }+ return made;+}++/** The made settings a finished run carries (Generation.made): only when something differs from what it asked. */+export function madeOfRun(+ model: Pick<ModelDef, "id" | "name" | "engine" | "routes" | "defaults"> | undefined,+ run: { op: Operation; provider?: ProviderId; request: { params?: GenParams; negativePrompt?: string } },+): MadeSettings | undefined {+ if (!model) return undefined;+ const made = fittedSettings(model, run.op, run.request.params, { provider: run.provider, negativePrompt: run.request.negativePrompt });+ return made.changes.length ? made : undefined;+}++/** The change one value of a setting makes on this mode (a picker's option), or undefined when it is made as picked. */+export function settingChange(+ model: Pick<ModelDef, "id" | "name" | "engine" | "routes" | "defaults">,+ op: Operation,+ setting: "aspectRatio" | "resolution" | "duration",+ value: string | number,+): SettingChange | undefined {+ return fittedSettings(model, op, { [setting]: value }).changes.find((c) => c.setting === setting);+}diff --git a/src/lib/catalog/made.ts b/src/lib/catalog/made.tsnew file mode 100644index 00000000..ddf49f0b--- /dev/null+++ b/src/lib/catalog/made.ts@@ -0,0 +1,53 @@+import type { GenParams } from "./types";++/*+ * What a finished run was made at, for the views that show it (the feed card, the run details, the Library). Kept apart+ * from fitted.ts, which works it out from the field maps, so these views load no catalog code.+ */++export type FittedSetting = "aspectRatio" | "resolution" | "duration" | "seed" | "numOutputs" | "negativePrompt" | "generateAudio" | "shots";++/** One setting the run makes differently from what it asks. */+export interface SettingChange {+ setting: FittedSetting;+ /** The setting's name as the run details say it ("Quality"). */+ label: string;+ /** What was asked and what is made, as shown ("2K", "1080p"; "Its own" when the setting isn't sent). */+ asked: string;+ made: string;+ /** Why, short, for after a run: "the most this model makes". */+ reason: string;+ /** The whole sentence, for before a run: "MiniMax H3 Max Turbo makes up to 1080p, so this is made at 1080p". */+ note: string;+ /** The value to pick instead (a picker's "Use 1080p"), when there is one. */+ use?: string | number;+}++/** The settings a run is made at (undefined: not sent, the model picks), and what differs from the request. */+export interface MadeSettings {+ aspectRatio?: string;+ resolution?: string;+ duration?: number;+ seed?: number;+ numOutputs?: number;+ changes: SettingChange[];+}++/** "1080P" → "1080p", "2k" → "2K"; other values as they are. */+export function tierWords(v: string): string {+ const m = /^(\d+(?:\.\d+)?)\s*([pk])$/i.exec(v.trim());+ return m ? `${m[1]}${m[2].toLowerCase() === "k" ? "K" : "p"}` : v;+}++/** A run's settings as made (its `made`, else what it asked), for the feed card and the run details. */+export function shownSettings(g: { request: { params?: GenParams }; made?: MadeSettings }): { aspectRatio?: string; resolution?: string; duration?: number; seed?: number } {+ const p = g.request.params ?? {};+ const m = g.made;+ if (!m) return { aspectRatio: p.aspectRatio, resolution: p.resolution && tierWords(p.resolution), duration: p.duration, seed: p.seed };+ return { aspectRatio: m.aspectRatio, resolution: m.resolution && tierWords(m.resolution), duration: m.duration, seed: m.seed };+}++/** "Asked for 2K · made at 1080p (the most this model makes)": one line per change, for under a finished run. */+export function changeLine(c: SettingChange): string {+ return `${c.label}: asked for ${c.asked} · made at ${c.made} (${c.reason})`;+}diff --git a/src/lib/catalog/payload.ts b/src/lib/catalog/payload.tsindex a2a37f77..8caaca8c 100644--- a/src/lib/catalog/payload.ts+++ b/src/lib/catalog/payload.ts@@ -73,13 +73,18 @@ function putEnum(out: Record<string, unknown>, field: string | EnumField, value:type Range = NonNullable<FieldMap["ranges"]>[string];/** A number inside an API's limits: rounded for whole-number fields, then clamped. */-function inRange(n: number, r: Range): number {+export function inRange(n: number, r: Range): number {let v = r.integer ? Math.round(n) : n;if (r.min !== undefined) v = Math.max(r.min, v);if (r.max !== undefined) v = Math.min(r.max, v);return v;}+/** The seed a route sends for `seed` (FieldMap.seedRange: a seed outside the API's range wraps into it). */+export function seedValue(range: readonly [number, number] | undefined, seed: number): number {+ return range ? range[0] + (seed % (range[1] - range[0] + 1)) : seed;+}+/** How many frames a frame-count route renders for the clip (FieldMap.numFrames), or undefined when its length is unknown. */export function numFramesValue(f: NonNullable<FieldMap["numFrames"]>, input: Pick<GenInput, "sourceDuration" | "duration" | "fps" | "sourceFps">): number | undefined {// Extend adds the length picked; other routes render the clip's own length when there is one.@@ -403,10 +408,7 @@ export function buildPayload(map: FieldMap, input: GenInput): Record<string, unk// provider's route may list fewer).if (map.duration && input.duration !== undefined) out[map.duration.key] = timeValue(map.duration, fitLength(map.duration.accepts, input.duration));if (map.numOutputs && input.numOutputs !== undefined) out[map.numOutputs] = input.numOutputs;- if (map.seed && input.seed !== undefined && input.seed >= 0) {- const r = map.seedRange;- out[map.seed] = r ? r[0] + (input.seed % (r[1] - r[0] + 1)) : input.seed;- }+ if (map.seed && input.seed !== undefined && input.seed >= 0) out[map.seed] = seedValue(map.seedRange, input.seed);if (map.generateAudio && input.generateAudio !== undefined) {const g = map.generateAudio;if (typeof g === "string") out[g] = input.generateAudio;diff --git a/src/lib/catalog/plan.ts b/src/lib/catalog/plan.tsindex 168a8203..31deef7b 100644--- a/src/lib/catalog/plan.ts+++ b/src/lib/catalog/plan.ts@@ -185,6 +185,9 @@ function fitToRoutes(model: ModelDef, op: Operation, req: GenerationRequest, parreturn out;}+/** The most results one run makes (a request for more makes this many). */+export const MAX_RESULTS = 8;+/** Fewer characters than this of the overall prompt in front of a capped shot prompt say too little: it is left out. */const MIN_SHOT_LEAD = 40;@@ -781,7 +784,7 @@ export function planGeneration(params = controlSets(model, params);- const requested = Math.max(1, Math.min(8, params.numOutputs ?? 1));+ const requested = Math.max(1, Math.min(MAX_RESULTS, params.numOutputs ?? 1));// A route with no count field makes one result a call (Nano Banana Pro, Qwen Image Edit): each result is its own job, never// a count the API never sees.const maxPerJob = oneEachCall(model, op) ? 1 : Math.max(1, model.options.maxOutputs ?? 1);diff --git a/src/lib/catalog/types.ts b/src/lib/catalog/types.tsindex 7abcff2a..32bfcf9e 100644--- a/src/lib/catalog/types.ts+++ b/src/lib/catalog/types.ts@@ -10,6 +10,7 @@import type { CameraKey } from "@/lib/camera-path";import type { SignatureRecord } from "./palettes";import type { RunTrouble } from "@/lib/diagnose";+import type { MadeSettings } from "./made";export type Engine = "cloud" | "open";@@ -1572,6 +1573,12 @@ export interface Generation {* the API rounds). Only on the answer that creates it; not stored.*/notes?: string[];+ /**+ * The settings it is made at, when they differ from what it asked (src/lib/catalog/fitted.ts: a 2K run on a model+ * that makes up to 1080P is made at 1080P), with each change in words. Worked out from the run's model, mode and+ * request whenever it is read, so older runs carry it too.+ */+ made?: MadeSettings;}/** Why a ComfyUI run failed, when the GPU was missing something (generations.fix_json). */diff --git a/src/server/assist/tools.ts b/src/server/assist/tools.tsindex 16fb68b5..abc9a9b7 100644--- a/src/server/assist/tools.ts+++ b/src/server/assist/tools.ts@@ -9,6 +9,8 @@ import { offeredModels } from "../model-access";import { dualEngine, runsOn } from "@/lib/catalog/engines";import { pricingAt } from "@/lib/catalog/promo";import { currentModelId } from "@/lib/catalog/replaced";+import { fittedSettings } from "@/lib/catalog/fitted";+import { opTakes } from "@/lib/catalog/route-takes";import { LAYOUT_PARAM, parseLayout } from "@/lib/layout-prompt";import { OPERATION_LABELS, type ChainSlot, type GenerationRequest, type MediaKind, type ModelDef, type Operation } from "@/lib/catalog/types";import { type PlannedJob, totalCost } from "@/lib/assist";@@ -44,6 +46,18 @@ const ref = z.string().describe("A file URL from the chat: an attachment or an e/** Output kinds: "text" = transcripts, translations and scripts; "model3d" = 3D models (.glb). */const KINDS = ["image", "video", "audio", "text", "model3d"] as const;+/** The sizes, shapes and lengths each mode of a hosted model makes, where its routes list them (Assist picks among them). */+function madeIn(m: ModelDef): { onlyMakes?: Record<string, Record<string, (string | number)[]>> } {+ if (m.engine === "open") return {};+ const out: Record<string, Record<string, (string | number)[]>> = {};+ for (const op of new Set(m.routes.map((r) => r.op))) {+ const t = opTakes(m, op);+ const l = { ...(t.resolutions && { resolutions: t.resolutions }), ...(t.aspectRatios && { aspectRatios: t.aspectRatios }), ...(t.durations && { durations: t.durations }) };+ if (Object.keys(l).length) out[op] = l;+ }+ return Object.keys(out).length ? { onlyMakes: out } : {};+}+function summarize(m: ModelDef) {const o = m.options;// The price of the day asked: a launch price while it lasts (the note says when it ends).@@ -78,6 +92,8 @@ function summarize(m: ModelDef) {...(o.aspectRatios && { aspectRatios: o.aspectRatios }),...(o.resolutions && { resolutions: o.resolutions }),...(o.durations && { durations: o.durations }),+ // What each mode's hosted routes make, where they list it: another value is made at the closest one (fitted.ts).+ ...madeIn(m),...(o.maxImages && { maxReferenceImages: o.maxImages }),...(o.maxOutputs && { maxOutputsPerRun: o.maxOutputs }),...(o.audio && { nativeAudio: o.audio === "always" ? "always on" : "optional" }),@@ -477,7 +493,9 @@ function chainJobs(jobs: JobInput[], engine?: "cloud" | "open"): ChainedJob[] {function plannedJob(c: ChainedJob): PlannedJob {if (c.preview) {const p = c.preview;- return { tool: "generate", modelId: p.model.id, modelName: p.model.name, kind: outputKind(p.op, p.model), op: p.op, prompt: c.job.prompt, count: p.outputs, costUsd: p.costUsd, demo: p.demo };+ // A value the model's route makes differently (2K on a model that makes up to 1080p) is said on the card before it runs.+ const changes = fittedSettings(p.model, p.op, { ...p.model.defaults, ...c.req.params }, { provider: p.route.provider, negativePrompt: c.req.negativePrompt }).changes.map((x) => x.note);+ return { tool: "generate", modelId: p.model.id, modelName: p.model.name, kind: outputKind(p.op, p.model), op: p.op, prompt: c.job.prompt, count: p.outputs, costUsd: p.costUsd, demo: p.demo, ...(changes.length && { changes }) };}const m = getModel(c.job.model_id);return { tool: "generate", modelId: c.job.model_id, modelName: m?.name ?? c.job.model_id, kind: m?.kind ?? "image", op: (c.job.op as Operation) ?? "t2i", prompt: c.job.prompt, count: 0, costUsd: 0, demo: false, error: c.error };diff --git a/tests/fitted-settings.test.ts b/tests/fitted-settings.test.tsnew file mode 100644index 00000000..447ffa47--- /dev/null+++ b/tests/fitted-settings.test.ts@@ -0,0 +1,158 @@+import { describe, expect, it } from "vitest";+import { getModel, getPreset, MODELS } from "@/lib/catalog";+import { changeLine, fittedSettings, madeOfRun, shownSettings, tierWords } from "@/lib/catalog/fitted";+import { buildPayload } from "@/lib/catalog/payload";+import { planGeneration } from "@/lib/catalog/plan";+import type { EnumField, ModelDef } from "@/lib/catalog/types";+import { slimModel } from "@/lib/studio-catalog";++/**+ * What a run is made at, said the same way everywhere: a value its route doesn't take is fitted by the rules the payload+ * uses (a 2K run on MiniMax H3 Max Turbo is made at 1080P), and the change is said in plain words, before and after it.+ */+const model = (id: string): ModelDef => {+ const m = getModel(id);+ if (!m) throw new Error(`no ${id}`);+ return m;+};+const turbo = model("minimax-h3-max-turbo");++describe("quality", () => {+ it("a size above the most a model makes is made at its most, and says so", () => {+ for (const asked of ["2K", "4K"]) {+ const made = fittedSettings(turbo, "t2v", { resolution: asked });+ expect(made.resolution).toBe("1080P");+ expect(made.changes).toEqual([+ expect.objectContaining({+ setting: "resolution",+ label: "Quality",+ asked,+ made: "1080p",+ reason: "the most this model makes",+ note: "MiniMax H3 Max Turbo makes up to 1080p, so this is made at 1080p",+ use: "1080P",+ }),+ ]);+ expect(changeLine(made.changes[0])).toBe(`Quality: asked for ${asked} · made at 1080p (the most this model makes)`);+ }+ });++ it("a size the model makes is no change, in any case", () => {+ for (const asked of ["1080p", "1080P", "768P", "480p"]) expect(fittedSettings(turbo, "t2v", { resolution: asked }).changes).toEqual([]);+ });++ it("matches what the payload sends and what the plan runs", () => {+ const sent = buildPayload(turbo.routes.find((r) => r.op === "t2v")!.map!, { prompt: "a", resolution: "4K" });+ expect(sent.resolution).toBe(fittedSettings(turbo, "t2v", { resolution: "4K" }).resolution);+ const plan = planGeneration({ feature: "video", modelId: turbo.id, op: "t2v", prompt: "a city at night", params: { resolution: "2K" } }, getModel, getPreset);+ expect(plan.params.resolution).toBe("1080P");+ });++ it("every hosted route's fitted size is the one its payload sends", () => {+ let checked = 0;+ for (const m of MODELS.filter((x) => x.engine === "cloud" && !x.id.startsWith("fuobe-")))+ for (const r of m.routes) {+ const f = r.map?.resolution;+ if (!f || typeof f === "string" || !f.accepts?.length || (f as EnumField).values || r.map?.size || r.map?.upscaleFactor) continue;+ for (const asked of ["4K", "2K", "1080p", "720p", "480p"]) {+ const sent = buildPayload(r.map!, { prompt: "a", resolution: asked })[f.key];+ const made = fittedSettings(m, r.op, { resolution: asked }, { provider: r.provider });+ const route = m.routes.filter((x) => x.op === r.op).find((x) => x.provider === r.provider);+ if (route !== r) continue;+ expect(made.resolution, `${m.id} ${r.op} ${asked}`).toBe(sent);+ checked++;+ }+ }+ expect(checked).toBeGreaterThan(20);+ });++ it("reads the same in the browser (route.takes) as on the server (the field map)", () => {+ const slim = slimModel(turbo);+ expect(fittedSettings(slim, "t2v", { resolution: "2K", aspectRatio: "5:4" })).toEqual(fittedSettings(turbo, "t2v", { resolution: "2K", aspectRatio: "5:4" }));+ });+});++describe("shape", () => {+ it("a shape the model doesn't make is made at the closest", () => {+ const made = fittedSettings(turbo, "t2v", { aspectRatio: "5:4" });+ expect(made.aspectRatio).toBe("4:3");+ expect(made.changes[0]).toMatchObject({ setting: "aspectRatio", asked: "5:4", made: "4:3", reason: "the closest shape this model makes", use: "4:3" });+ });++ it("a start frame keeps its shape: a filled-in default says nothing, a picked shape says so", () => {+ const quiet = fittedSettings(turbo, "i2v", { aspectRatio: turbo.defaults?.aspectRatio ?? "16:9", resolution: "768P" });+ expect(quiet.aspectRatio).toBeUndefined();+ const picked = turbo.defaults?.aspectRatio === "9:16" ? "1:1" : "9:16";+ const said = fittedSettings(turbo, "i2v", { aspectRatio: picked });+ expect(said.aspectRatio).toBeUndefined();+ expect(said.changes[0]).toMatchObject({ setting: "aspectRatio", asked: picked, made: "The start frame's shape" });+ });+});++describe("length, seed, count, shots", () => {+ it("a length a route doesn't take is the one it makes", () => {+ const veo = model("veo-3-1");+ const short = fittedSettings(veo, "extend", { duration: 5 });+ expect(short.duration).toBe(7);+ expect(short.changes[0]).toMatchObject({ setting: "duration", asked: "5s", made: "7s" });+ const long = fittedSettings(veo, "extend", { duration: 10 });+ expect(long.changes[0]).toMatchObject({ made: "7s", reason: "the longest this model makes" });+ });++ it("a seed outside the route's range is sent inside it", () => {+ const made = fittedSettings(model("wan-3"), "t2v", { seed: 4294967295 });+ expect(made.seed).toBe(2147483647);+ expect(made.changes[0]).toMatchObject({ setting: "seed", asked: "4294967295", made: "2147483647" });+ expect(fittedSettings(model("wan-3"), "t2v", { seed: 42 }).changes).toEqual([]);+ });++ it("a route with no seed field makes a new picture each run", () => {+ const m = model("seedream-5-pro");+ const route = m.routes.find((r) => r.op === "t2i")!;+ const made = fittedSettings(m, "t2i", { seed: 42 }, { provider: route.provider });+ expect(made.seed).toBeUndefined();+ expect(made.changes.map((c) => c.setting)).toContain("seed");+ });++ it("more results than a run makes are the most it makes", () => {+ const made = fittedSettings(turbo, "t2v", { numOutputs: 12 });+ expect(made.numOutputs).toBe(8);+ expect(made.changes[0]).toMatchObject({ setting: "numOutputs", asked: "12", made: "8" });+ });++ it("a shot's words over the API's limit are cut there", () => {+ const shots = [+ { prompt: "a".repeat(600), duration: 3 },+ { prompt: "short", duration: 2 },+ ];+ const made = fittedSettings(model("kling-4"), "t2v", { shots });+ expect(made.changes).toEqual([expect.objectContaining({ setting: "shots", label: "Shot 1", asked: "600 characters", made: "512 characters" })]);+ });++ it("nothing changes on the open engine", () => {+ const open = MODELS.find((m) => m.engine === "open" && m.kind === "video")!;+ expect(fittedSettings(open, open.routes[0].op, { resolution: "4K", aspectRatio: "7:3", seed: 9e9 }).changes).toEqual([]);+ });+});++describe("a finished run", () => {+ it("carries the made settings only when something changed", () => {+ expect(madeOfRun(turbo, { op: "t2v", provider: "fal", request: { params: { resolution: "1080p" } } })).toBeUndefined();+ const made = madeOfRun(turbo, { op: "t2v", provider: "fal", request: { params: { resolution: "2K", aspectRatio: "16:9", duration: 5 } } });+ expect(made).toMatchObject({ resolution: "1080P", aspectRatio: "16:9", duration: 5 });+ expect(madeOfRun(undefined, { op: "t2v", request: {} })).toBeUndefined();+ });++ it("shows the made value, else what it asked", () => {+ const params = { resolution: "2K", aspectRatio: "16:9", duration: 5 };+ expect(shownSettings({ request: { params } })).toEqual({ aspectRatio: "16:9", resolution: "2K", duration: 5, seed: undefined });+ const made = madeOfRun(turbo, { op: "t2v", request: { params } });+ expect(shownSettings({ request: { params }, made })).toMatchObject({ resolution: "1080p", aspectRatio: "16:9", duration: 5 });+ });++ it("writes tiers the way the pickers do", () => {+ expect(tierWords("1080P")).toBe("1080p");+ expect(tierWords("2k")).toBe("2K");+ expect(tierWords("auto")).toBe("auto");+ });+});