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: phrases that follow the job while it is made
Adarsha0634919f795
diff --git a/src/components/home-view.tsx b/src/components/home-view.tsxindex 39c85463..97ee8911 100644--- a/src/components/home-view.tsx+++ b/src/components/home-view.tsx@@ -25,6 +25,7 @@ import { placeholdersOn } from "@/lib/demo-mode";import { userTitle } from "@/lib/library";import { NEW_CREATION_PARAM } from "@/lib/nav";import { cn } from "@/lib/utils";+import { RunWords } from "@/components/run-words";// The viewer is only needed once a recent result is opened.const Viewer = lazy(() => import("@/components/studio/viewer").then((m) => ({ default: m.Viewer })));@@ -121,7 +122,7 @@ function RecentWaiting({ g, title, failed }: { g: Generation; title: string; fai{!failed && <RunAura />}<span className="relative flex min-w-0 items-start gap-1.5 text-[12px] leading-snug font-medium">{failed ? <CircleAlert className="mt-px size-4 shrink-0 text-muted-foreground" aria-hidden /> : <RunRing fraction={st?.stage === "in-line" ? null : (st?.fraction ?? null)} stage={st?.stage ?? "creating"} />}- <span className="line-clamp-2">{words}</span>+ <span className="line-clamp-2">{failed ? words : <RunWords g={g} words={words} />}</span></span><span className="relative mt-0.5 line-clamp-2 pl-[22px] text-[11px] leading-snug text-muted-foreground">{what}</span>{!failed && place && <span className="relative line-clamp-1 pl-[22px] text-[11px] text-muted-foreground">{place}</span>}diff --git a/src/components/library/asset-card.tsx b/src/components/library/asset-card.tsxindex 8fa5f917..0824c140 100644--- a/src/components/library/asset-card.tsx+++ b/src/components/library/asset-card.tsx@@ -24,6 +24,7 @@ import { DRAG_TYPE } from "./folders";import { ReviewBadge } from "./review";import { autoLine } from "@/lib/auto-image";import type { Layout } from "./view-options";+import { RunWords } from "@/components/run-words";/** Stable callbacks from the Library (refs inside), so cards re-render only when their own data changes. */export interface CardApi {@@ -83,7 +84,9 @@ export function StatusCover({ g, small, actionable }: { g: Generation; small?: b<div className="absolute inset-x-0 bottom-0 space-y-1 bg-gradient-to-t from-background/85 via-background/45 to-transparent p-3 pt-10"><p className="flex items-center gap-2 text-[13px] font-medium"><RunRing fraction={st.stage === "creating" ? st.fraction : null} stage={st.stage} />- <span className="truncate">{label}</span>+ <span className="truncate">+ <RunWords g={g} words={label} />+ </span></p>{place && <p className="truncate text-[11px] text-muted-foreground">{place}</p>}<p className="text-[11px] text-muted-foreground tabular-nums">@@ -352,7 +355,12 @@ export const AssetCard = memo(function AssetCard({{stack ? `${stack.label} · ` : `${g.modelName ?? g.modelId} · ${OPERATION_LABELS[g.op]} · `}{trashed ? `${trashDaysLeft(g.deletedAt!)} days left in Trash` : timeAgo(g.createdAt)}{/* "Rendering", as the Status filter calls it: "In progress" is a review status. */}- {!stack && g.status !== "succeeded" && ` · ${listStatus(g)}`}+ {!stack && g.status !== "succeeded" && (+ <>+ {" · "}+ <RunWords g={g} words={listStatus(g)} />+ </>+ )}</p>{/* What made a run of Auto ("Auto · made with Krea 2 Realism"), and what changed while it ran ("Made with Krea 2 Realism · Ideogram 4 declined this one" on Ideogram 4 picked by name). */}{!stack && autoLine(g) && <p className="truncate text-[12px] text-muted-foreground">{autoLine(g)}</p>}diff --git a/src/components/run-words.tsx b/src/components/run-words.tsxnew file mode 100644index 00000000..d43de1b5--- /dev/null+++ b/src/components/run-words.tsx@@ -0,0 +1,38 @@+"use client";++import { useEffect, useState } from "react";+import type { Generation } from "@/lib/catalog/types";+import { creatingLabel, creatingParts, PHRASE_MS, PHRASE_SETS, phraseAt, phraseSetOf } from "@/lib/job-phrases";++/**+ * A run's words on its card or row. A person's run on this studio's GPUs that is being made shows a phrase about its own+ * job in place of "Creating" (src/lib/job-phrases.ts), the next one every PHRASE_MS with a gentle fade (none with+ * reduced motion), and the percent after it. A screen reader hears the same stable words throughout ("Creating, 40%"),+ * never each phrase. Any other words show as they are.+ */+export function RunWords({ g, words }: { g: Pick<Generation, "id" | "op" | "kind" | "place" | "status">; words: string }) {+ const parts = g.place === "pool" && g.status === "running" ? creatingParts(words) : null;+ const [tick, setTick] = useState(0);+ const on = !!parts;+ useEffect(() => {+ if (!on) return;+ const t = setInterval(() => setTick((n) => n + 1), PHRASE_MS);+ return () => clearInterval(t);+ }, [on]);+ if (!parts) return <>{words}</>;+ const set = phraseSetOf({ op: g.op, kind: g.kind });+ // Counted from the run's own first phrase (the same on the server's render and the browser's).+ const { phrase, index } = phraseAt(set, g.id, (tick % PHRASE_SETS[set].length) * PHRASE_MS);+ const after = parts.percent ? parts.rest.replace(/^ · \d{1,3}%/, "") : parts.rest;+ return (+ <>+ <span className="sr-only">{`${creatingLabel(parts.percent)}${after}`}</span>+ <span aria-hidden="true" aria-live="off" data-phrase={set}>+ <span key={index} className="animate-in duration-700 fade-in-0 motion-reduce:animate-none">+ {phrase}+ </span>+ {parts.rest}+ </span>+ </>+ );+}diff --git a/src/components/studio/feed.tsx b/src/components/studio/feed.tsxindex 69dd6d40..7be3c892 100644--- a/src/components/studio/feed.tsx+++ b/src/components/studio/feed.tsx@@ -49,6 +49,7 @@ import { shownSettings } from "@/lib/catalog/made";import { NextSteps } from "@/components/nav/next-steps";import { reservedRowHeight, useArrival, useEnter, useFollowRow, useLiveRun, useMakingCard } from "./feed-motion";import { AiTag, useAiTag } from "./ai-tag";+import { RunWords } from "@/components/run-words";export { MediaThumb } from "./result-media";export { downloadName } from "@/lib/library";@@ -201,7 +202,9 @@ export function PendingTile({ g, ratio }: { g: Generation; ratio: number }) {{/* Always a sign it is on its way (a ring: its progress, or turning), with the run's own words beside it. */}<p title={label} className="flex items-start gap-2 text-[13px] leading-snug font-medium"><RunRing fraction={ring} stage={st.stage} />- <span className="line-clamp-2">{label}</span>+ <span className="line-clamp-2">+ <RunWords g={g} words={label} />+ </span></p>{place && (<p title={place} className="line-clamp-2 pl-6 text-[11px] text-muted-foreground">diff --git a/src/lib/job-phrases.ts b/src/lib/job-phrases.tsnew file mode 100644index 00000000..c7c90e8d--- /dev/null+++ b/src/lib/job-phrases.ts@@ -0,0 +1,179 @@+/**+ * The words a person's run on this install's GPUs shows while it is made, in place of "Creating": a few short phrases+ * about its own job, chosen by its operation and what it makes (never by its prompt), one after another every+ * PHRASE_MS. A job that isn't certain gets the neutral set; a phrase about motion, light or sound only appears on a job+ * that makes or changes them.+ *+ * Pure: the run cards and the tests share it.+ */+import type { MediaKind, Operation } from "./catalog/types";+import { POOL_WORDS } from "./relay";++export const PHRASE_SETS = {+ picture: ["Composing", "Shaping the light", "Adding fine detail"],+ edit: ["Making your changes", "Matching the light", "Blending it in"],+ upscale: ["Sharpening the details", "Restoring fine detail", "Cleaning it up"],+ cutout: ["Tracing the edges", "Separating the subject", "Cleaning the edges"],+ video: ["Setting up the shot", "Adding motion", "Getting the light right"],+ videoChange: ["Following every frame", "Keeping it consistent", "Matching the motion"],+ videoTools: ["Processing every frame", "Keeping it smooth"],+ sound: ["Tuning the sound", "Finding the rhythm", "Mixing it down"],+ model3d: ["Building the shape", "Shaping the surfaces"],+ neutral: ["Working on it", "Taking care of the details", "Making it just right"],+} as const satisfies Record<string, readonly string[]>;++export type PhraseSet = keyof typeof PHRASE_SETS;++/** How long each phrase shows. */+export const PHRASE_MS = 7_000;++/** By output kind: an operation that works on pictures or on clips alike. */+const byKind = (image: PhraseSet, video: PhraseSet) => (kind: MediaKind | null | undefined): PhraseSet => (kind === "image" ? image : kind === "video" ? video : "neutral");++/** 3D words only on a run that made a 3D model (a scene made for a picture model, a body drawn over a photo: neutral). */+const as3d = (kind: MediaKind | null | undefined): PhraseSet => (kind === "model3d" ? "model3d" : "neutral");++/** Every operation's set (a function: it follows what the run makes). */+const OP_SETS: Record<Operation, PhraseSet | ((kind: MediaKind | null | undefined) => PhraseSet)> = {+ // A picture from words.+ t2i: "picture",+ // Picture edits.+ edit: "edit",+ inpaint: "edit",+ outpaint: "edit",+ "face-swap": byKind("edit", "videoChange"),+ relight: "edit",+ "watermark-remove": "edit",+ "picture-frame": "edit",+ "color-match": byKind("edit", "videoTools"),+ overlay: "edit",+ // Upscale and restore.+ "upscale-image": "upscale",+ "upscale-video": "upscale",+ "restore-video": "upscale",+ // Cut-outs, masks and mattes.+ "bg-remove": "cutout",+ "bg-remove-video": "cutout",+ // A video from words or pictures.+ t2v: "video",+ i2v: "video",+ flf2v: "video",+ ref2v: "video",+ keyframes: "video",+ extend: "video",+ avatar: "video",+ "insert-moment": "video",+ "camera-path": "video",+ "world-turn": "video",+ // A video changed.+ v2v: "videoChange",+ "motion-transfer": "videoChange",+ "video-swap": "videoChange",+ "video-insert": "videoChange",+ "remove-object": "videoChange",+ "group-swap": "videoChange",+ "scene-edit": "videoChange",+ "face-fix-video": "videoChange",+ "relight-video": "videoChange",+ reframe: "videoChange",+ finalize: "videoChange",+ "picture-video": "videoChange",+ composite: "videoChange",+ lipsync: "videoChange",+ // Video tools.+ interpolate: "videoTools",+ "sdr-to-hdr": "videoTools",+ "export-video": "videoTools",+ trim: "videoTools",+ concat: "videoTools",+ "images-to-video": "videoTools",+ "still-motion": "videoTools",+ "depth-video": "videoTools",+ "tone-video": "videoTools",+ captions: "videoTools",+ mux: "videoTools",+ "body-capture-video": "videoTools",+ // Sound and music.+ tts: "sound",+ sfx: "sound",+ music: "sound",+ v2a: "sound",+ dialogue: "sound",+ "voice-change": "sound",+ "voice-design": "sound",+ "speech-edit": "sound",+ "separate-audio": "sound",+ "enhance-voice": "sound",+ level: "sound",+ timeline: "sound",+ mix: "sound",+ "audio-loop": "sound",+ "audio-join": "sound",+ "song-extend": "sound",+ "song-remix": "sound",+ "song-stems": "sound",+ // 3D.+ "image-to-3d": "model3d",+ "scene-3d": as3d,+ splat: "model3d",+ "text-to-3d": "model3d",+ "rig-3d": "model3d",+ "refine-3d": "model3d",+ "retexture-3d": "model3d",+ "body-capture": as3d,+ // Anything else: the neutral set.+ grade: "neutral",+ motion: "neutral",+ dub: "neutral",+ frame: "neutral",+ "extract-frames": "neutral",+ layers: "neutral",+ "text-layers": "neutral",+ transcribe: "neutral",+ translate: "neutral",+ write: "neutral",+ vectorize: "neutral",+ ocr: "neutral",+ "face-mosaic": "neutral",+ "watermark-scan": "neutral",+ "describe-video": "neutral",+};++/** The phrase set of a run's job, by its operation and what it makes (none known: the neutral set). */+export function phraseSetOf(job: { op?: string | null; kind?: MediaKind | string | null }): PhraseSet {+ const set = job.op && Object.hasOwn(OP_SETS, job.op) ? OP_SETS[job.op as Operation] : undefined;+ if (!set) return "neutral";+ return typeof set === "function" ? set(job.kind as MediaKind | null | undefined) : set;+}++/** A small number from a run's id, so tiles side by side start on different phrases. */+function idSeed(id: string): number {+ let h = 0;+ for (let i = 0; i < id.length; i++) h = (h * 31 + id.charCodeAt(i)) >>> 0;+ return h;+}++/** The phrase a run shows at `now`: from its own starting phrase, the next one every PHRASE_MS. */+export function phraseAt(set: PhraseSet, id: string, now: number): { phrase: string; index: number } {+ const list = PHRASE_SETS[set];+ const index = (idSeed(id) + Math.floor(Math.max(0, now) / PHRASE_MS)) % list.length;+ return { phrase: list[index], index };+}++/** Every phrase a running job may show in place of "Creating". */+export const JOB_PHRASES: ReadonlySet<string> = new Set(Object.values(PHRASE_SETS).flat());++/**+ * A run's words split where "Creating" (or one of its phrases) starts them: what follows ("· 40%", "· about 3 min+ * left"), and the percent. Null: words that don't start with it ("In line", "Almost done", a failure).+ */+export function creatingParts(words: string | null | undefined): { rest: string; percent: string | null } | null {+ if (!words) return null;+ const head = [POOL_WORDS.working, ...JOB_PHRASES].find((w) => words === w || words.startsWith(`${w} · `));+ if (!head) return null;+ const rest = words.slice(head.length);+ return { rest, percent: /^ · (\d{1,3}%)/.exec(rest)?.[1] ?? null };+}++/** The stable words a screen reader hears for a running job ("Creating, 40%"), whichever phrase shows. */+export const creatingLabel = (percent: string | null): string => (percent ? `${POOL_WORDS.working}, ${percent}` : POOL_WORDS.working);diff --git a/src/lib/run-progress.ts b/src/lib/run-progress.tsindex da4a930f..10ead400 100644--- a/src/lib/run-progress.ts+++ b/src/lib/run-progress.ts@@ -20,6 +20,7 @@* Pure: the server and the tests share it.*/+import { JOB_PHRASES } from "./job-phrases";import { madeNoun, makingWords, POOL_WORDS, type MadeKind } from "./relay";/** Where each stage ends on the bar. */@@ -298,7 +299,9 @@ export const isPoolRunWords = (m: string | null | undefined): m is string => {if (!m) return false;// Each may say about how long is left (withLeft).const words = m.replace(/ · about \d+ min left$/, "");- return words === POOL_WORDS.working || words === POOL_WORDS.gettingReady || words === POOL_WORDS.finishing || POOL_PERCENT.test(words);+ if (words === POOL_WORDS.working || words === POOL_WORDS.gettingReady || words === POOL_WORDS.finishing || POOL_PERCENT.test(words)) return true;+ // A job's phrase in place of "Creating" (src/lib/job-phrases.ts), with its percent or without.+ return JOB_PHRASES.has(words.replace(/ · \d{1,3}%$/, ""));};/** Has a person's run on this install's GPUs started, as these words say ("Creating", a percent, "Almost done")? */diff --git a/tests/job-phrases.test.ts b/tests/job-phrases.test.tsnew file mode 100644index 00000000..e30feeb4--- /dev/null+++ b/tests/job-phrases.test.ts@@ -0,0 +1,125 @@+import { describe, expect, it } from "vitest";+import { MODELS } from "@/lib/catalog";+import { OPERATION_OUTPUT, operationOutput, type MediaKind, type Operation } from "@/lib/catalog/types";+import { creatingLabel, creatingParts, JOB_PHRASES, PHRASE_MS, PHRASE_SETS, phraseAt, phraseSetOf, type PhraseSet } from "@/lib/job-phrases";+import { isPoolRunWords } from "@/lib/run-progress";+import { POOL_WORDS } from "@/lib/relay";++/** Phrases about motion or frames in sequence, about light, and about sound. */+const MOTION = new Set(["Adding motion", "Matching the motion", "Following every frame", "Processing every frame", "Keeping it smooth"]);+const LIGHT = new Set(["Shaping the light", "Matching the light", "Getting the light right"]);+const SOUND = new Set(["Tuning the sound", "Finding the rhythm", "Mixing it down"]);+/** The operations that make or change sound. */+const SOUND_OPS = new Set<string>(["tts", "sfx", "music", "v2a", "dialogue", "voice-change", "voice-design", "speech-edit", "separate-audio", "enhance-voice", "level", "timeline", "mix", "audio-loop", "audio-join", "song-extend", "song-remix", "song-stems"]);++/** What a job of this operation and output may be told: the rules every phrase set must keep. */+function check(op: string, kind: MediaKind): string[] {+ const set = phraseSetOf({ op, kind });+ const phrases: readonly string[] = PHRASE_SETS[set];+ const problems: string[] = [];+ const say = (why: string) => problems.push(`${op} (${kind}) → ${set}: ${why}`);+ if (kind !== "video" && phrases.some((p) => MOTION.has(p))) say("a motion phrase on a job that makes no clip");+ if (kind !== "image" && kind !== "video" && phrases.some((p) => LIGHT.has(p))) say("a light phrase on a job that makes no picture");+ if (!SOUND_OPS.has(op) && phrases.some((p) => SOUND.has(p))) say("a sound phrase on a silent job");+ if (set === "model3d" && kind !== "model3d") say("3D words on a job that makes no 3D model");+ if (set === "cutout" && op !== "bg-remove" && op !== "bg-remove-video") say("cut-out words on a job that cuts nothing out");+ return problems;+}++describe("phrases that follow the job", () => {+ it("each set is the words given, plain and with no emoji", () => {+ expect(PHRASE_SETS.picture).toEqual(["Composing", "Shaping the light", "Adding fine detail"]);+ expect(PHRASE_SETS.edit).toEqual(["Making your changes", "Matching the light", "Blending it in"]);+ expect(PHRASE_SETS.upscale).toEqual(["Sharpening the details", "Restoring fine detail", "Cleaning it up"]);+ expect(PHRASE_SETS.cutout).toEqual(["Tracing the edges", "Separating the subject", "Cleaning the edges"]);+ expect(PHRASE_SETS.video).toEqual(["Setting up the shot", "Adding motion", "Getting the light right"]);+ expect(PHRASE_SETS.videoChange).toEqual(["Following every frame", "Keeping it consistent", "Matching the motion"]);+ expect(PHRASE_SETS.videoTools).toEqual(["Processing every frame", "Keeping it smooth"]);+ expect(PHRASE_SETS.sound).toEqual(["Tuning the sound", "Finding the rhythm", "Mixing it down"]);+ expect(PHRASE_SETS.model3d).toEqual(["Building the shape", "Shaping the surfaces"]);+ expect(PHRASE_SETS.neutral).toEqual(["Working on it", "Taking care of the details", "Making it just right"]);+ for (const p of JOB_PHRASES) expect(p).toMatch(/^[A-Z][a-z ]+$/);+ });++ it("every catalog route keeps the rules: no motion on stills, no sound on silent jobs, no light without pictures", () => {+ const problems: string[] = [];+ for (const m of MODELS) for (const r of m.routes ?? []) problems.push(...check(r.op, operationOutput(r.op, m.kind)));+ expect(problems).toEqual([]);+ });++ it("every operation keeps the rules for what it makes", () => {+ const problems: string[] = [];+ for (const op of Object.keys(OPERATION_OUTPUT) as Operation[]) {+ for (const kind of ["image", "video", "audio", "text", "model3d"] as MediaKind[]) {+ if (operationOutput(op, kind) !== kind && OPERATION_OUTPUT[op] !== kind) continue;+ problems.push(...check(op, kind));+ }+ }+ expect(problems).toEqual([]);+ });++ it("the sets by job", () => {+ const cases: [string | null, MediaKind | null, PhraseSet][] = [+ ["t2i", "image", "picture"],+ ["edit", "image", "edit"],+ ["inpaint", "image", "edit"],+ ["outpaint", "image", "edit"],+ ["face-swap", "image", "edit"],+ ["upscale-image", "image", "upscale"],+ ["upscale-video", "video", "upscale"],+ ["restore-video", "video", "upscale"],+ ["bg-remove", "image", "cutout"],+ ["bg-remove-video", "video", "cutout"],+ ["t2v", "video", "video"],+ ["i2v", "video", "video"],+ ["video-swap", "video", "videoChange"],+ ["group-swap", "video", "videoChange"],+ ["scene-edit", "video", "videoChange"],+ ["face-fix-video", "video", "videoChange"],+ ["motion-transfer", "video", "videoChange"],+ ["interpolate", "video", "videoTools"],+ ["export-video", "video", "videoTools"],+ ["sdr-to-hdr", "video", "videoTools"],+ ["trim", "video", "videoTools"],+ ["music", "audio", "sound"],+ ["tts", "audio", "sound"],+ ["image-to-3d", "model3d", "model3d"],+ ["transcribe", "text", "neutral"],+ ["no-such-op", "video", "neutral"],+ [null, "video", "neutral"],+ ];+ for (const [op, kind, set] of cases) expect(phraseSetOf({ op, kind }), `${op}`).toBe(set);+ });++ it("starts on a phrase picked from the run, and moves on every 7 seconds", () => {+ expect(PHRASE_MS).toBe(7_000);+ const a = phraseAt("video", "run-a", 0);+ const next = phraseAt("video", "run-a", PHRASE_MS);+ expect(next.index).toBe((a.index + 1) % PHRASE_SETS.video.length);+ expect(phraseAt("video", "run-a", PHRASE_MS - 1).index).toBe(a.index);+ const starts = new Set(["a", "b", "c", "d", "e", "f", "g", "h"].map((id) => phraseAt("neutral", id, 0).index));+ expect(starts.size).toBeGreaterThan(1);+ });++ it("splits a run's words where Creating starts them, and gives screen readers stable words", () => {+ expect(creatingParts("Creating · 40%")).toEqual({ rest: " · 40%", percent: "40%" });+ expect(creatingParts("Creating · 40% · about 3 min left")).toEqual({ rest: " · 40% · about 3 min left", percent: "40%" });+ expect(creatingParts("Creating · about 2 min left")).toEqual({ rest: " · about 2 min left", percent: null });+ expect(creatingParts("Creating")).toEqual({ rest: "", percent: null });+ expect(creatingParts("Adding motion · 40%")).toEqual({ rest: " · 40%", percent: "40%" });+ expect(creatingParts(POOL_WORDS.inLine)).toBeNull();+ expect(creatingParts(POOL_WORDS.gettingReady)).toBeNull();+ expect(creatingParts(POOL_WORDS.finishing)).toBeNull();+ expect(creatingLabel("40%")).toBe("Creating, 40%");+ expect(creatingLabel(null)).toBe("Creating");+ });++ it("every phrase passes for a running job's words, with its percent and time left or without", () => {+ for (const p of JOB_PHRASES) {+ expect(isPoolRunWords(p)).toBe(true);+ expect(isPoolRunWords(`${p} · 40%`)).toBe(true);+ expect(isPoolRunWords(`${p} · 40% · about 3 min left`)).toBe(true);+ }+ expect(isPoolRunWords("Rolling camera · 40%")).toBe(false);+ });+});