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
Genjutsu: its row of examples shows its own group swap
Adarshc6ddea1b235c
diff --git a/src/lib/studio-covers.ts b/src/lib/studio-covers.tsindex 2562e834..e04209a6 100644--- a/src/lib/studio-covers.ts+++ b/src/lib/studio-covers.ts@@ -2,8 +2,8 @@* Covers that belong to a studio rather than to a preset: one of the studio's own examples, cut into a cover by the* same pipeline as a preset's (pnpm eval:covers --from-masters, gen-preset-peaks, gen-preset-hd) and listed with them* under its own id (preset-covers.generated.ts, preset-previews.generated.ts). Home's card for the studio, its entry- * in the menus and its next step under a result show it. Each names its card as a preset's would; no preset has the- * same id. Pure data, so the server and the browser share it.+ * in the menus, its next step under a result and the studio's own row of examples (studio-examples.ts) show it. Each+ * names its card as a preset's would; no preset has the same id. Pure data, so the server and the browser share it.*/export interface StudioCover {/** The card's name, as a preset card's (its alt text and tooltip). */@@ -14,6 +14,8 @@ export interface StudioCover {category: string;/** A key of PRESET_ICONS (src/components/preset-icons.ts). */icon: string;+ /** Where its card opens in a row of examples: its studio, in the mode that made it, with that example in view. */+ href: string;}export const STUDIO_COVERS: Record<string, StudioCover> = {@@ -23,6 +25,7 @@ export const STUDIO_COVERS: Record<string, StudioCover> = {description: "Two people swapped in one take: the kiss on the cheek, the laugh and the light stay as filmed.",category: "Genjutsu",icon: "Users",+ href: "/genjutsu?mode=character&example=genjutsu-character.1",},};diff --git a/src/lib/studio-examples.ts b/src/lib/studio-examples.tsindex 936c6ddd..1de03d8b 100644--- a/src/lib/studio-examples.ts+++ b/src/lib/studio-examples.ts@@ -8,6 +8,7 @@ import "server-only";import { getPreset } from "@/lib/catalog";import { HOME_EFFECTS, HOME_MOTIONS, HOME_REVEALS, HOME_WALL, homeCard, presetHref } from "@/lib/home-showcase";import { PRESET_BEFORE_AFTER } from "@/lib/preset-before-after.generated";+import { STUDIO_COVERS, isStudioCover } from "@/lib/studio-covers";import type { PresetType } from "@/lib/catalog/types";import type { PresetCardData } from "@/lib/preset-cards";@@ -39,7 +40,8 @@ const SEE = "See what it makes";* Each studio's row: the line above it, and its tiles in the order they show (four; Mixed Media's "How it works" has* one). A tile's line is its own here, else EXAMPLE_LINES', else Home's (HOME_CAPTION_MAX.card holds any of them whole* on a phone's tile). Video's tiles pick their move in the studio itself; Image's, Edit's and Upscale's are apps, each on a page- * of its own, and their heading says so. Ads Studio and Ad Multiplier share the "ads" row.+ * of its own, and their heading says so. A tile can also be a studio's own cover (studio-covers.ts), which opens its+ * studio: Genjutsu's group swap. Ads Studio and Ad Multiplier share the "ads" row.*/export const STUDIO_EXAMPLES: Record<ExampleStudio, { heading: string; tiles: { id: string; caption?: string }[] }> = {image: {@@ -74,7 +76,7 @@ export const STUDIO_EXAMPLES: Record<ExampleStudio, { heading: string; tiles: {"video-tools": { heading: SEE, tiles: [{ id: "app-remove-background" }, { id: "app-object-remover" }, { id: "app-relight" }, { id: "app-match-colors" }] },audio: { heading: SEE, tiles: [{ id: "app-clean-up-voice" }, { id: "app-talking-photo" }, { id: "app-rap-god" }, { id: "app-asmr-classic" }] },layers: { heading: SEE, tiles: [{ id: "app-text-edit" }, { id: "app-relight" }, { id: "app-object-remover" }, { id: "app-change-background" }] },- genjutsu: { heading: SEE, tiles: [{ id: "app-recast" }, { id: "app-character-swap" }, { id: "app-video-face-swap" }, { id: "effect-turning-metal" }] },+ genjutsu: { heading: SEE, tiles: [{ id: "app-recast" }, { id: "app-character-swap" }, { id: "app-video-face-swap" }, { id: "genjutsu-group-swap" }] },"character-swap": { heading: SEE, tiles: [{ id: "app-character-swap" }, { id: "app-recast" }, { id: "app-face-swap" }, { id: "app-video-face-swap" }] },"image-to-3d": { heading: SEE, tiles: [{ id: "app-image-to-3d" }, { id: "app-3d-rotation" }, { id: "app-product-360" }, { id: "app-3d-figure" }] },katana: { heading: SEE, tiles: [{ id: "app-clipcut" }, { id: "app-urban-cuts" }, { id: "app-sticker-match-cut" }, { id: "effect-jump-transition" }] },@@ -83,7 +85,7 @@ export const STUDIO_EXAMPLES: Record<ExampleStudio, { heading: string; tiles: {"mixed-media": { heading: "See a look play out", tiles: [{ id: "effect-paper" }] },};-/** What each cover shows, for the presets Home has no line for (one line per preset, whichever studio shows it). */+/** What each cover shows, for the presets and studio covers Home has no line for (one line each, whichever studio shows it). */export const EXAMPLE_LINES: Record<string, string> = {"app-recast": "A new dancer takes the stage","app-video-face-swap": "A new face in the back seat",@@ -112,7 +114,6 @@ export const EXAMPLE_LINES: Record<string, string> = {"app-remove-background": "Cut out clean, every curl kept","app-relight": "Grey skies to golden hour","app-character-swap": "He steps into her place by the lake",- "effect-turning-metal": "His skin turns to liquid chrome","app-face-swap": "A new face, same suit and light","app-image-to-3d": "A teapot photo, now a 3D model","app-3d-rotation": "A black gown turns full circle",@@ -129,6 +130,7 @@ export const EXAMPLE_LINES: Record<string, string> = {"app-packshot": "A handbag, cut out on clean white","app-clean-up-voice": "A noisy brasserie, a clear voice","effect-paper": "Whale and sea, redrawn in cut paper",+ "genjutsu-group-swap": "Two people swapped in one take",};/** A tile of the studio's row: its cover, what kind of preset it is, its line, and where it opens. */@@ -154,22 +156,27 @@ const KIND: Record<PresetType, string> = { app: "App", motion: "Camera motion",const BEFORE_AFTER = "App · before → after";export function exampleKind(id: string): string {- const type = getPreset(id)!.type;+ const type = getPreset(id)?.type;+ // A studio's own cover (no preset has its id) names its studio.+ if (!type) return isStudioCover(id) ? STUDIO_COVERS[id].category : KIND.app;if (type !== "app") return KIND[type];return homeKinds.get(id) ?? (PRESET_BEFORE_AFTER[id] ? BEFORE_AFTER : KIND.app);}+/** Where a tile opens: a studio's cover its studio, a preset its own page (presetHref). */+const exampleHref = (id: string) => (isStudioCover(id) ? STUDIO_COVERS[id].href : presetHref(id));+/** The studio's row, as cards (each resting on its peak frame, as on Home). */export function studioExamples(studio: ExampleStudio): StudioExampleRow {const { heading, tiles } = STUDIO_EXAMPLES[studio];return {heading,tiles: tiles.map(({ id, caption }) => {- // homeCard throws for an id the catalog doesn't have, so the build fails rather than the page.+ // homeCard throws for an id that is neither in the catalog nor a studio's cover, so the build fails rather than the page.const card = homeCard(id);const line = caption ?? EXAMPLE_LINES[id] ?? homeCaptions.get(id);if (!line) throw new Error(`The ${studio} studio's example ${id} has no line`);- return { card, kind: exampleKind(id), caption: line, href: presetHref(id) };+ return { card, kind: exampleKind(id), caption: line, href: exampleHref(id) };}),};}diff --git a/tests/examples-catalog.test.ts b/tests/examples-catalog.test.tsindex 3df13218..7155cba1 100644--- a/tests/examples-catalog.test.ts+++ b/tests/examples-catalog.test.ts@@ -8,6 +8,7 @@ import { HUB_MODES, type HubKind } from "@/lib/hubs";import { GENJUTSU_MODES } from "@/lib/catalog/genjutsu";import { appStudio, EDIT_STUDIO, IMAGE_STUDIO, INPAINT_STUDIO, UPSCALE_STUDIO, VIDEO_STUDIO } from "@/lib/studios";import { EXAMPLE_MEDIA } from "@/lib/examples/media.generated";+import { STUDIO_COVERS, isStudioCover } from "@/lib/studio-covers";import { EXAMPLE_CAPTION_MAX, EXAMPLE_WORDS_MAX, EXAMPLES_HEADING, MORE_HEADING, exampleFits, type ExampleCard, type ExampleMedia } from "@/lib/examples/types";import type { Draft } from "@/components/studio/studio-context";@@ -219,7 +220,10 @@ describe("the examples' catalog", () => {expect(row!.heading, s).toBe(MORE_HEADING);for (const c of row!.cards) {expect(c.load, c.id).toMatchObject({ via: "look" });- expect((c.load as { href?: string }).href, c.id).toMatch(/^\/(apps\/app-[a-z0-9-]+|video\?preset=[a-z0-9-]+)$/);+ // A studio's own cover opens its studio (studio-covers.ts); a preset's its own page.+ const cover = c.id.replace(/^more\./, "");+ if (isStudioCover(cover)) expect((c.load as { href?: string }).href, c.id).toBe(STUDIO_COVERS[cover].href);+ else expect((c.load as { href?: string }).href, c.id).toMatch(/^\/(apps\/app-[a-z0-9-]+|video\?preset=[a-z0-9-]+)$/);}}}diff --git a/tests/studio-examples.test.ts b/tests/studio-examples.test.tsindex c03fc664..b32264bb 100644--- a/tests/studio-examples.test.ts+++ b/tests/studio-examples.test.ts@@ -7,7 +7,9 @@ import { thumbOf } from "@/lib/preset-cards";import { PRESET_BEFORE_AFTER } from "@/lib/preset-before-after.generated";import { PRESET_PEAKS } from "@/lib/preset-peaks.generated";import { PRESET_PREVIEWS } from "@/lib/preset-previews.generated";+import { STUDIO_COVERS, isStudioCover } from "@/lib/studio-covers";import { EXAMPLE_LINES, STUDIO_EXAMPLES, studioExamples, type ExampleStudio } from "@/lib/studio-examples";+import plan from "@/lib/examples/plan.json";// home-showcase.ts (which the examples borrow from) imports next/cache for its own showcase.vi.mock("next/cache", () => ({ cacheLife: () => {} }));@@ -61,10 +63,10 @@ describe("the studios' examples", () => {}});- it("names real presets, each with its cover, its clip, its peak frame and their small copies", () => {+ it("names real presets (or a studio's own cover), each with its cover, its clip, its peak frame and their small copies", () => {for (const s of studios) {for (const { card } of studioExamples(s).tiles) {- expect(getPreset(card.id), card.id).toBeDefined();+ expect(getPreset(card.id) ?? (isStudioCover(card.id) ? STUDIO_COVERS[card.id] : undefined), 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);@@ -89,10 +91,16 @@ describe("the studios' examples", () => {for (const e of studioExamples(s).tiles) {expect(e.caption.length, e.card.id).toBeGreaterThan(0);expect(e.caption.length, e.card.id).toBeLessThanOrEqual(HOME_CAPTION_MAX.card);- const type = getPreset(e.card.id)!.type;- // An app whose cover wipes from a before to an after (Home's wall says so, or it has Home's HD pair) says so.- const kind =- type === "motion" ? "Camera motion" : type === "effect" ? "Effect" : (wallKinds.get(e.card.id) ?? (PRESET_BEFORE_AFTER[e.card.id] ? "App · before → after" : "App"));+ const type = getPreset(e.card.id)?.type;+ // An app whose cover wipes from a before to an after (Home's wall says so, or it has Home's HD pair) says so; a+ // studio's own cover names its studio.+ const kind = !type+ ? STUDIO_COVERS[e.card.id].category+ : type === "motion"+ ? "Camera motion"+ : type === "effect"+ ? "Effect"+ : (wallKinds.get(e.card.id) ?? (PRESET_BEFORE_AFTER[e.card.id] ? "App · before → after" : "App"));expect(e.kind, e.card.id).toBe(kind);}}@@ -114,10 +122,15 @@ describe("the studios' examples", () => {}});- it("opens an app on its own page, and picks a motion or effect in the Video studio", () => {+ it("opens an app on its own page, picks a motion or effect in the Video studio, and opens a studio's cover in its studio", () => {for (const s of studios) {for (const e of studioExamples(s).tiles) {- expect(e.href, e.card.id).toBe(getPreset(e.card.id)!.type === "app" ? `/apps/${e.card.id}` : `/video?preset=${e.card.id}`);+ const href = isStudioCover(e.card.id)+ ? STUDIO_COVERS[e.card.id].href+ : getPreset(e.card.id)!.type === "app"+ ? `/apps/${e.card.id}`+ : `/video?preset=${e.card.id}`;+ expect(e.href, e.card.id).toBe(href);}}// Edit and Image show apps, Video shows what its studio picks.@@ -125,6 +138,24 @@ describe("the studios' examples", () => {for (const e of studioExamples("video").tiles) expect(["motion", "effect"], e.card.id).toContain(getPreset(e.card.id)!.type);});+ it("shows Genjutsu's own group swap in its row, opening its Character swap mode on that example", () => {+ const row = studioExamples("genjutsu").tiles;+ const own = row.find((e) => e.card.id === "genjutsu-group-swap");+ expect(own, "Genjutsu's row has its group swap").toBeDefined();+ expect(own!.card.name).toBe("Group swap");+ expect(own!.caption).toBe("Two people swapped in one take");+ expect(own!.kind).toBe("Genjutsu");+ // No effect stands for Genjutsu: its row shows swaps of people.+ for (const e of row) expect(getPreset(e.card.id)?.type, e.card.id).not.toBe("effect");+ // Every studio cover's link names its studio's mode and an example of that mode (plan.json).+ for (const [id, c] of Object.entries(STUDIO_COVERS)) {+ const url = new URL(c.href, "https://fuobe.com");+ expect(url.pathname, id).toBe(`/${c.category.toLowerCase()}`);+ const example = (plan as { id: string; surface: string }[]).find((r) => r.id === url.searchParams.get("example"));+ expect(example?.surface, id).toBe(`tool:${url.pathname.slice(1)}/${url.searchParams.get("mode")}`);+ }+ });+it("stays on the server: the pages and the rows take only the examples' types", () => {expect(read("lib", "studio-examples.ts")).toMatch(/^import "server-only";$/m);expect(read("lib", "examples", "catalog.ts")).toMatch(/^import "server-only";$/m);