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
Studios: the empty Image, Video and Edit studios show what they make
Adarshd7db9f8c6016
diff --git a/src/app/(studio)/edit/page.tsx b/src/app/(studio)/edit/page.tsxindex 5a417cfd..22d68361 100644--- a/src/app/(studio)/edit/page.tsx+++ b/src/app/(studio)/edit/page.tsx@@ -1,9 +1,10 @@import type { Metadata } from "next";import { Studio } from "@/components/studio/studio";+import { studioExamples } from "@/lib/studio-examples";import { EDIT_STUDIO } from "@/lib/studios";export const metadata: Metadata = { title: "Edit image" };export default function Page() {- return <Studio config={EDIT_STUDIO} />;+ return <Studio config={EDIT_STUDIO} examples={studioExamples("edit")} />;}diff --git a/src/app/(studio)/image/page.tsx b/src/app/(studio)/image/page.tsxindex 4c712490..a8d5afe7 100644--- a/src/app/(studio)/image/page.tsx+++ b/src/app/(studio)/image/page.tsx@@ -1,9 +1,10 @@import type { Metadata } from "next";import { Studio } from "@/components/studio/studio";+import { studioExamples } from "@/lib/studio-examples";import { IMAGE_STUDIO } from "@/lib/studios";export const metadata: Metadata = { title: "Create image" };export default function Page() {- return <Studio config={IMAGE_STUDIO} />;+ return <Studio config={IMAGE_STUDIO} examples={studioExamples("image")} />;}diff --git a/src/app/(studio)/video/page.tsx b/src/app/(studio)/video/page.tsxindex 9a8a4324..73a25f13 100644--- a/src/app/(studio)/video/page.tsx+++ b/src/app/(studio)/video/page.tsx@@ -1,9 +1,10 @@import type { Metadata } from "next";import { Studio } from "@/components/studio/studio";+import { studioExamples } from "@/lib/studio-examples";import { VIDEO_STUDIO } from "@/lib/studios";export const metadata: Metadata = { title: "Create video" };export default function Page() {- return <Studio config={VIDEO_STUDIO} />;+ return <Studio config={VIDEO_STUDIO} examples={studioExamples("video")} />;}diff --git a/src/components/home/showcase-tile.tsx b/src/components/home/showcase-tile.tsxindex 3740b435..0c4132db 100644--- a/src/components/home/showcase-tile.tsx+++ b/src/components/home/showcase-tile.tsx@@ -19,7 +19,25 @@ const FOUR_UP = "(min-width: 640px) and (max-width: 767px), (min-width: 1024px)"* picture, fetched first. Tiles 5 to 8 are hidden (and never fetched) where the wall has two columns; where it has* four, they're on the first screen, so they're asked for with the page, not after its layout as a lazy image is.*/-export function ShowcaseTile({ card, kind, caption, href, index }: { card: PresetCardData; kind: string; caption: string; href: string; index: number }) {+export function ShowcaseTile({+ card,+ kind,+ caption,+ href,+ index,+ sizes = SIZES,+ small = false,+}: {+ card: PresetCardData;+ kind: string;+ caption: string;+ href: string;+ index: number;+ /** How wide the tile shows, where it isn't on Home's wall (a studio's row of four, under its composer). */+ sizes?: string;+ /** A tile that is small at every width (a studio's row): it gets the taller, darker shade of a phone's tile. */+ small?: boolean;+}) {const { ref, playing, asked, handlers } = usePreviewPlayback<HTMLAnchorElement>(card.id, card.preview);const still = card.preview.rest?.src ?? card.preview.poster;if (index >= 4) preload(still, { as: "image", imageSrcSet: `${thumbOf(still)} 320w, ${still} 512w`, imageSizes: SIZES, media: FOUR_UP });@@ -42,7 +60,7 @@ export function ShowcaseTile({ card, kind, caption, href, index }: { card: Preseplaying={playing}asked={asked}place={staggered(index)}- sizes={SIZES}+ sizes={sizes}loading={index < 4 ? "eager" : "lazy"}fetchPriority={index === 0 ? "high" : undefined}/>@@ -50,7 +68,10 @@ export function ShowcaseTile({ card, kind, caption, href, index }: { card: Prese{/* A small tile (a phone's, or four across a tablet) is short: a taller, darker shade keeps its white words readable over a bright picture. */}<spanaria-hidden- className="pointer-events-none absolute inset-x-0 bottom-0 h-[45%] bg-gradient-to-t from-black/65 to-transparent max-md:h-[70%] max-md:via-black/40 max-md:from-black/75"+ className={cn(+ "pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t to-transparent",+ small ? "h-[70%] via-black/40 from-black/75" : "h-[45%] from-black/65 max-md:h-[70%] max-md:via-black/40 max-md:from-black/75",+ )}/><span aria-hidden className="pointer-events-none absolute inset-x-3 bottom-2.5 flex min-w-0 flex-col text-left text-white [text-shadow:0_1px_2px_rgb(0_0_0/30%)]"><span className="hidden text-[11px] tracking-wide text-white/75 uppercase xl:block">{kind}</span>diff --git a/src/components/studio/studio-page.tsx b/src/components/studio/studio-page.tsxindex 32bdfd12..1d25717e 100644--- a/src/components/studio/studio-page.tsx+++ b/src/components/studio/studio-page.tsx@@ -4,7 +4,7 @@ import { ArrowRight, ArrowUp, Loader2, Upload } from "lucide-react";import Link from "next/link";import dynamic from "next/dynamic";import { useSearchParams } from "next/navigation";-import { Suspense, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";+import { memo, Suspense, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";import { nanoid } from "nanoid";import { toast } from "sonner";import { SidebarTrigger } from "@/components/ui/sidebar";@@ -20,6 +20,7 @@ import { currentModelId, migrateRequest } from "@/lib/catalog/replaced";import { matchSpokenLanguage } from "@/lib/speech-languages";import { SoulPresetCards } from "@/components/moodboards/soul-preset-cards";import type { StudioCatalog } from "@/lib/studio-catalog";+import type { StudioExample } from "@/lib/studio-examples";import { cn } from "@/lib/utils";import { ComposerBridgeCtx, useComposerBridge, type ComposerBridge } from "./attachments";import { CatalogProvider, useCatalog } from "./catalog";@@ -193,6 +194,8 @@ const EMPTY: Generation[] = [];/** The preset card (U23) is its own chunk: only app pages and studios with a motion or effect picked load it. */const PresetHeader = dynamic(() => import("@/components/preset-header").then((m) => m.PresetHeader));+/** The example covers are one too: only the studios that show them (Image, Video, Edit) load it. */+const ShowcaseTile = dynamic(() => import("@/components/home/showcase-tile").then((m) => m.ShowcaseTile));/** While a preset (app, camera motion, effect) is active and the feed is empty: what it does and what to add, above the composer. */function ActivePresetHeader() {@@ -243,6 +246,38 @@ function PromptSuggestions({ suggestions }: { suggestions: string[] }) {);}+/** A row tile's width: half a phone, else a quarter of the row (1000 px at most). */+const EXAMPLE_SIZES = "(min-width: 640px) 240px, 50vw";++/** The row's tiles. Memoized: the row reads the draft (below), and typing shouldn't re-render four playing covers. */+const ExampleTiles = memo(function ExampleTiles({ examples }: { examples: StudioExample[] }) {+ return (+ <div className="grid grid-cols-2 gap-3 sm:grid-cols-4">+ {examples.map((e, i) => (+ <ShowcaseTile key={e.card.id} card={e.card} kind={e.kind} caption={e.caption} href={e.href} index={i} sizes={EXAMPLE_SIZES} small />+ ))}+ </div>+ );+});++/**+ * "See what it makes": real covers from the studio's own presets (src/lib/studio-examples.ts) under the empty+ * composer, each opening its app or picking its motion or effect. Hidden while a preset is picked: its own card is+ * above the composer then.+ */+function StudioExamples({ examples }: { examples: StudioExample[] }) {+ const { draft } = useStudio();+ if (draft.presetId) return null;+ return (+ <section aria-labelledby="studio-examples" className="mx-auto w-full max-w-[1000px] px-3 pb-10 sm:px-6">+ <h2 id="studio-examples" className="mb-2 text-center text-[12.5px] font-medium text-muted-foreground">+ See what it makes+ </h2>+ <ExampleTiles examples={examples} />+ </section>+ );+}+/*** The picked open model's state on the viewer's GPU (the GPU pre-flight), left of the engine switch: a pill that opens* the guided fix. Its own component, so the draft it reads re-renders only this.@@ -281,7 +316,7 @@ function StudioHeader({ title, header, tabs }: { title: string; header?: React.R);}-function StudioBody({ header, tabs }: { header?: React.ReactNode; tabs?: React.ReactNode }) {+function StudioBody({ header, tabs, examples }: { header?: React.ReactNode; tabs?: React.ReactNode; examples?: StudioExample[] }) {// Config and actions only: the draft lives in the composer, so typing doesn't re-render the page or the feed.const { config, setDraft } = useStudioActions();const [engine, setEngine] = useEngine();@@ -380,6 +415,7 @@ function StudioBody({ header, tabs }: { header?: React.ReactNode; tabs?: React.R{!hasItems && config.suggestions && <PromptSuggestions suggestions={config.suggestions} />}{!hasItems && config.signature && <SoulPresetCards />}+ {!hasItems && !!examples?.length && <StudioExamples examples={examples} />}{dragging && (<div className="pointer-events-none absolute inset-0 z-40 grid place-items-center bg-overlay p-8">@@ -408,6 +444,8 @@ interface StudioPageProps {initialRefs?: string[];/** Prompt to start with when the URL doesn't carry one (e.g. "@Maya "). */initialPrompt?: string;+ /** Real covers of what the studio makes, under the empty composer (`studioExamples()` in a server component). */+ examples?: StudioExample[];}type DraftProps = Omit<StudioPageProps, "catalog">;@@ -497,7 +535,17 @@ function HandoffSync({* opens after HandoffSync took `go` out of the address (a microtask), so the card's way back is the studio with the* prompt filled in. While who is looking isn't known yet, the run is sent and its refusal opens the same card.*/-function StudioSession({ header, tabs, sync }: { header?: React.ReactNode; tabs?: React.ReactNode; sync: Omit<React.ComponentProps<typeof HandoffSync>, "onStart"> }) {+function StudioSession({+ header,+ tabs,+ examples,+ sync,+}: {+ header?: React.ReactNode;+ tabs?: React.ReactNode;+ examples?: StudioExample[];+ sync: Omit<React.ComponentProps<typeof HandoffSync>, "onStart">;+}) {const [startRequest, setStartRequest] = useState(0);const guest = useIsGuest();const onStart = useCallback(() => {@@ -506,7 +554,7 @@ function StudioSession({ header, tabs, sync }: { header?: React.ReactNode; tabs?}, [guest]);return (<StartRequestCtx.Provider value={startRequest}>- <StudioBody header={header} tabs={tabs} />+ <StudioBody header={header} tabs={tabs} examples={examples} /><HandoffSync {...sync} onStart={onStart} /></StartRequestCtx.Provider>);@@ -517,7 +565,7 @@ function StudioSession({ header, tabs, sync }: { header?: React.ReactNode; tabs?* by HandoffSync alone), so the composer the shell painted is the one you type into: nothing* typed or focused before hydration is lost.*/-function StudioDraft({ config, header, tabs, initialRefs, initialPrompt }: DraftProps) {+function StudioDraft({ config, header, tabs, initialRefs, initialPrompt, examples }: DraftProps) {const [engine, setEngine] = useEngine();const catalog = useCatalog();const bridge = useMemo<ComposerBridge>(() => ({ current: null }), []);@@ -566,7 +614,7 @@ function StudioDraft({ config, header, tabs, initialRefs, initialPrompt }: Draft<ComposerBridgeCtx.Provider value={bridge}><PresetUrlCtx.Provider value={presetUrl}><StudioProvider key={start.epoch} config={config} initial={initial}>- <StudioSession header={header} tabs={tabs} sync={{ startKey: start.key, start: initial, build: buildRef, adopt: adoptRef, follow: followRef, ownRef, ready: catalog.ready, onNavigate }} />+ <StudioSession header={header} tabs={tabs} examples={examples} sync={{ startKey: start.key, start: initial, build: buildRef, adopt: adoptRef, follow: followRef, ownRef, ready: catalog.ready, onNavigate }} /></StudioProvider></PresetUrlCtx.Provider></ComposerBridgeCtx.Provider>diff --git a/src/components/studio/studio.tsx b/src/components/studio/studio.tsxindex 1f9b354f..cf5211af 100644--- a/src/components/studio/studio.tsx+++ b/src/components/studio/studio.tsx@@ -5,7 +5,8 @@ import { StudioPage } from "./studio-page";/*** Server entry for a studio page: picks the models this studio needs on the server and passes* them down, so the browser never loads the full model catalog. Use it from `page.tsx`:- * `<Studio config={VIDEO_STUDIO} />`.+ * `<Studio config={VIDEO_STUDIO} />`. A studio that shows what it makes under its empty composer passes+ * `examples={studioExamples("video")}`: four slim cards, picked on the server as well (src/lib/studio-examples.ts).*/export function Studio(props: Omit<ComponentProps<typeof StudioPage>, "catalog">) {return <StudioPage {...props} catalog={studioCatalog(props.config)} />;diff --git a/src/lib/studio-examples.ts b/src/lib/studio-examples.tsnew file mode 100644index 00000000..c35f39e6--- /dev/null+++ b/src/lib/studio-examples.ts@@ -0,0 +1,56 @@+/**+ * What the empty Image, Video and Edit studios show under the composer: four real covers each, so a first visit sees+ * what the studio makes before it types anything. Server only, like Home's showcase it borrows from: the page gets+ * four slim cards, and the catalog stays here (tests/studio-examples.test.ts checks every id, cover and line).+ */+import "server-only";+import { getPreset } from "@/lib/catalog";+import { HOME_EFFECTS, HOME_MOTIONS, HOME_REVEALS, HOME_WALL, homeCard, presetHref } from "@/lib/home-showcase";+import type { PresetType } from "@/lib/catalog/types";+import type { PresetCardData } from "@/lib/preset-cards";++export type ExampleStudio = "image" | "video" | "edit";++/**+ * Each studio's four, in the order they show. A line of its own where Home has none for that preset, else Home's+ * (HOME_CAPTION_MAX.card holds either whole on a phone's tile).+ */+export const STUDIO_EXAMPLES: Record<ExampleStudio, { id: string; caption?: string }[]> = {+ image: [+ { id: "app-sketch-to-real", caption: "A rough sketch, made a real photo" },+ { id: "app-style-transfer", caption: "Any photo, redrawn as anime" },+ { id: "app-virtual-try-on" },+ { id: "app-product-shot" },+ ],+ video: [{ id: "motion-fpv-drone" }, { id: "effect-flame-on" }, { id: "motion-bullet-time" }, { id: "effect-angel-wings" }],+ edit: [+ { id: "app-relight" },+ { id: "app-colorize", caption: "Black & white photos, in full color" },+ { id: "app-outfit-swap" },+ { id: "app-hairstyle-try-on" },+ ],+};++/** A tile of the studio's row: its cover, what kind of preset it is, its line, and where it opens. */+export interface StudioExample {+ card: PresetCardData;+ kind: string;+ caption: string;+ href: string;+}++const homeCaptions = new Map<string, string>([...HOME_WALL, ...HOME_EFFECTS, ...HOME_MOTIONS, ...HOME_REVEALS].map((t) => [t.id, t.caption]));++/** The kind a tile names (from xl, as Home's wall does): the apps here all wipe from a before to an after. */+const KIND: Record<PresetType, string> = { app: "App · before → after", motion: "Camera motion", effect: "Effect" };++/** The studio's row, as cards (each resting on its peak frame, as on Home). */+export function studioExamples(studio: ExampleStudio): StudioExample[] {+ return STUDIO_EXAMPLES[studio].map(({ id, caption }) => {+ // homeCard throws for an id the catalog doesn't have, so the build fails rather than the page.+ const card = homeCard(id);+ const line = caption ?? homeCaptions.get(id);+ if (!line) throw new Error(`The ${studio} studio's example ${id} has no line`);+ return { card, kind: KIND[getPreset(id)!.type], caption: line, href: presetHref(id) };+ });+}diff --git a/tests/studio-examples.test.ts b/tests/studio-examples.test.tsnew file mode 100644index 00000000..6bc88c8b--- /dev/null+++ b/tests/studio-examples.test.ts@@ -0,0 +1,83 @@+import fs from "node:fs";+import path from "node:path";+import { describe, expect, it, vi } from "vitest";+import { getPreset } from "@/lib/catalog";+import { HOME_CAPTION_MAX } from "@/lib/home-showcase";+import { thumbOf } from "@/lib/preset-cards";+import { PRESET_PEAKS } from "@/lib/preset-peaks.generated";+import { PRESET_PREVIEWS } from "@/lib/preset-previews.generated";+import { STUDIO_EXAMPLES, studioExamples, type ExampleStudio } from "@/lib/studio-examples";++// home-showcase.ts (which the examples borrow from) imports next/cache for its own showcase.+vi.mock("next/cache", () => ({ cacheLife: () => {} }));++/*+ * The empty Image, Video and Edit studios' row of examples (src/lib/studio-examples.ts) against the catalog and the+ * files in public/: every preset it names is real and has its cover, clip and small copies, and every line fits.+ */++const root = process.cwd();+const exists = (url: string) => (fs.statSync(path.join(root, "public", url), { throwIfNoEntry: false })?.size ?? 0) > 0;+const studios = Object.keys(STUDIO_EXAMPLES) as ExampleStudio[];++describe("the studios' examples", () => {+ it("shows four for each of Image, Video and Edit, none twice", () => {+ expect(studios.sort()).toEqual(["edit", "image", "video"]);+ for (const s of studios) {+ const ids = STUDIO_EXAMPLES[s].map((e) => e.id);+ expect(ids, s).toHaveLength(4);+ expect(new Set(ids).size, s).toBe(4);+ }+ });++ it("names real presets, each with its cover, its clip and their small copies", () => {+ for (const s of studios) {+ for (const { card } of studioExamples(s)) {+ expect(getPreset(card.id), card.id).toBeDefined();+ const cover = PRESET_PREVIEWS[card.id];+ expect(cover, `${card.id} has a real cover`).toBeDefined();+ expect(card.preview.poster, card.id).toBe(cover.poster);+ expect(exists(cover.poster), cover.poster).toBe(true);+ expect(exists(thumbOf(cover.poster)), thumbOf(cover.poster)).toBe(true);+ expect(cover.video, `${card.id} has a clip`).toBeDefined();+ expect(exists(cover.video!), cover.video).toBe(true);+ // An effect or an app rests on its peak frame, as on Home; a camera motion on its poster.+ if (card.id.startsWith("motion-")) expect(card.preview.rest, card.id).toBeUndefined();+ else {+ expect(PRESET_PEAKS[card.id], card.id).toBeDefined();+ expect(exists(card.preview.rest!.src), card.preview.rest!.src).toBe(true);+ expect(exists(thumbOf(card.preview.rest!.src)), thumbOf(card.preview.rest!.src)).toBe(true);+ }+ }+ }+ });++ it("gives each a line that fits a phone's tile whole, and says what kind it is", () => {+ for (const s of studios) {+ for (const e of studioExamples(s)) {+ expect(e.caption.length, e.card.id).toBeGreaterThan(0);+ expect(e.caption.length, e.card.id).toBeLessThanOrEqual(HOME_CAPTION_MAX.card);+ expect(e.kind, e.card.id).toBe({ app: "App · before → after", motion: "Camera motion", effect: "Effect" }[getPreset(e.card.id)!.type]);+ }+ }+ });++ it("opens an app on its own page, and picks a motion or effect in the Video studio", () => {+ const [image, video] = [studioExamples("image"), studioExamples("video")];+ expect(image[0].href).toBe(`/apps/${image[0].card.id}`);+ for (const e of video) expect(e.href, e.card.id).toBe(`/video?preset=${e.card.id}`);+ // Edit and Image show apps, Video shows what its studio picks.+ for (const s of ["image", "edit"] as const) for (const e of studioExamples(s)) expect(getPreset(e.card.id)!.type, e.card.id).toBe("app");+ for (const e of video) expect(["motion", "effect"], e.card.id).toContain(getPreset(e.card.id)!.type);+ });++ it("stays on the server: the studio page takes only its type, and loads the tiles in their own chunk", () => {+ const read = (...p: string[]) => fs.readFileSync(path.join(root, "src", ...p), "utf8");+ expect(read("lib", "studio-examples.ts")).toMatch(/^import "server-only";$/m);+ const page = read("components", "studio", "studio-page.tsx");+ expect(page).toMatch(/^import type \{ StudioExample \} from "@\/lib\/studio-examples";$/m);+ expect(page).toMatch(/dynamic\(\(\) => import\("@\/components\/home\/showcase-tile"\)/);+ expect(page).not.toMatch(/^import [^;]*from "@\/components\/home\/showcase-tile";$/m);+ for (const s of studios) expect(read("app", "(studio)", s, "page.tsx"), s).toContain(`examples={studioExamples("${s}")}`);+ });+});