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
Image and Edit studios: a "MiniMax H3 Image is here" card above the composer
Adarsh4edb2b06e902
diff --git a/src/components/studio/release-nudge.tsx b/src/components/studio/release-nudge.tsxnew file mode 100644index 00000000..7c3b83eb--- /dev/null+++ b/src/components/studio/release-nudge.tsx@@ -0,0 +1,161 @@+"use client";++import { useId, useSyncExternalStore } from "react";+import { useEngine, useHydrated, useStatus } from "@/lib/api";+import { useHere } from "@/hooks/use-pool-rules";+import { HOME_RELEASE, releaseArtSrc } from "@/lib/home-release";+import { nudgeKey, RELEASE_NUDGE, releaseRunsFor } from "@/lib/release-nudge";+import { cn } from "@/lib/utils";+import { useCatalog } from "./catalog";+import { useStudio } from "./studio-context";++/**+ * "MiniMax H3 Image is here": the newest open model's card above the Image and Edit studios' composer: the release+ * Home shows (HOME_RELEASE in src/lib/home-release.ts), with the card's own lines and pictures (src/lib/release-nudge.ts). Try it puts the composer on that model with its own+ * settings, the words typed so far kept, as picking it in the model menu does; Not now puts the card away in this browser.+ * It shows only where the viewer can run the model (releaseRunsFor), and not while that model is picked. Nothing renders+ * before hydration or while the browser's answer isn't read, so the static shell and the first render match.+ */++const CHANGE = "fuobe:release-nudge";+/** Put away in this page's life when the browser keeps no storage (a private window that refuses it). */+const away = new Set<string>();++function subscribe(cb: () => void) {+ window.addEventListener("storage", cb);+ window.addEventListener(CHANGE, cb);+ return () => {+ window.removeEventListener("storage", cb);+ window.removeEventListener(CHANGE, cb);+ };+}++function putAway(key: string) {+ away.add(key);+ try {+ localStorage.setItem(key, "1");+ } catch {+ // No storage: this page's memory keeps it away.+ }+ window.dispatchEvent(new Event(CHANGE));+}++/** Put away in this browser (or this page, without storage)? The server says yes, so the shell renders nothing. */+function usePutAway(key: string): boolean {+ return useSyncExternalStore(+ subscribe,+ () => {+ if (away.has(key)) return true;+ try {+ return localStorage.getItem(key) === "1";+ } catch {+ return false;+ }+ },+ () => true,+ );+}++/** The composer this studio shows (a studio left earlier stays in the page, hidden, with a composer of its own). */+const composerBox = () => [...document.querySelectorAll<HTMLElement>("[data-studio] [data-composer]")].find((el) => el.offsetParent !== null)?.querySelector("textarea");++export function ReleaseNudge({ studio, docked }: { studio: "image" | "edit"; docked?: boolean }) {+ const r = HOME_RELEASE;+ const key = nudgeKey(r);+ const { config, draft, setDraft } = useStudio();+ const catalog = useCatalog();+ const [engine, setEngine] = useEngine();+ const status = useStatus().data;+ const here = useHere();+ const hydrated = useHydrated();+ const gone = usePutAway(key);+ const titleId = useId();+ const model = catalog.getModel(r.modelId);+ const shows =+ hydrated &&+ !gone &&+ !!model &&+ !config.preset &&+ !draft.presetId &&+ draft.modelId !== r.modelId &&+ model.routes.some((x) => config.ops.includes(x.op)) &&+ releaseRunsFor({ status, here, model, offered: catalog.offered(r.modelId, "open"), vramGb: RELEASE_NUDGE.vramGb });+ if (!shows) return null;++ const done = () => {+ putAway(key);+ requestAnimationFrame(() => composerBox()?.focus({ preventScroll: true }));+ };+ const tryIt = () => {+ const from = catalog.getModel(draft.modelId);+ // As the model menu picks it: its own settings (2K, its default shape, Prompt helper off), the words and files kept.+ setDraft((d) => ({+ modelId: model.id,+ params: { ...model.defaults, numOutputs: d.params.numOutputs, enhancePrompt: d.params.enhancePrompt, seed: d.params.seed },+ ...(from?.options.looks && !model.options.looks && { presetId: undefined, presetStrength: undefined }),+ }));+ if (engine !== model.engine) setEngine(model.engine);+ done();+ };++ return (+ <section+ aria-labelledby={titleId}+ data-release-nudge=""+ className={cn(+ "relative mx-auto w-full overflow-hidden rounded-2xl border bg-card text-left shadow-sm motion-safe:animate-pop-in",+ docked ? "mb-2 max-w-[800px]" : "mb-3 max-w-[760px]",+ )}+ >+ <div className="flex flex-col gap-3 p-3 sm:flex-row sm:items-center sm:gap-4 sm:pr-3.5">+ <div className="flex min-w-0 flex-1 items-center gap-3.5">+ {/* Three of the pictures it made, fanned like prints: what the model does, before any words. */}+ <div aria-hidden className="relative h-12 w-[4.25rem] shrink-0">+ {RELEASE_NUDGE.art.map((slug, i) => (+ <picture key={slug}>+ <source type="image/avif" srcSet={`${releaseArtSrc(slug, 480, "avif")} 480w`} sizes="36px" />+ <img+ src={releaseArtSrc(slug, 480, "webp")}+ alt=""+ width={36}+ height={48}+ loading="lazy"+ decoding="async"+ draggable={false}+ className={cn(+ "absolute top-0 h-12 w-9 rounded-md object-cover shadow-sm ring-2 ring-card",+ i === 0 && "left-0 -rotate-[7deg]",+ i === 1 && "left-[1rem] z-10",+ i === 2 && "left-[2rem] rotate-[7deg]",+ )}+ />+ </picture>+ ))}+ </div>+ <div className="min-w-0">+ <h2 id={titleId} className="text-[14px] leading-tight font-semibold text-foreground">+ {r.name} is here+ </h2>+ <p className="mt-0.5 text-[12.5px] leading-snug text-pretty text-muted-foreground">{RELEASE_NUDGE.lines[studio]}</p>+ </div>+ </div>+ <div className="flex shrink-0 items-center gap-1.5 pl-[5.125rem] sm:pl-0">+ <button+ type="button"+ onClick={tryIt}+ className="inline-flex h-8 items-center rounded-full bg-primary px-3.5 text-[13px] font-medium text-primary-foreground transition hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card focus-visible:outline-none"+ >+ Try it+ </button>+ <button+ type="button"+ onClick={done}+ className="inline-flex h-8 items-center rounded-full px-3 text-[13px] font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none"+ >+ Not now+ </button>+ </div>+ </div>+ </section>+ );+}diff --git a/src/components/studio/studio-context.tsx b/src/components/studio/studio-context.tsxindex cd7c4cac..42773b16 100644--- a/src/components/studio/studio-context.tsx+++ b/src/components/studio/studio-context.tsx@@ -41,6 +41,8 @@ export interface StudioConfig {/** Preset picker shown in the composer. */presetPicker?: "motion" | "effect";preset?: Preset;+ /** The newest open model's "is here" card above the composer, with this studio's line (src/lib/release-nudge.ts). */+ releaseNudge?: "image" | "edit";defaultModels: { cloud: string; open: string };/*** An app's models on each engine (withRecipe, src/lib/catalog/preset-recipes.ts): the one its preview was made withdiff --git a/src/components/studio/studio-page.tsx b/src/components/studio/studio-page.tsxindex 29275539..4749e034 100644--- a/src/components/studio/studio-page.tsx+++ b/src/components/studio/studio-page.tsx@@ -33,6 +33,7 @@ import { HoldFilesForGuests } from "./hold-files";import { EngineSwitch } from "./engine-switch";import { HubHeaderExtras, useInHub } from "./hub-chrome";import { Feed } from "./feed";+import { ReleaseNudge } from "./release-nudge";import { applyExample, draftFromGeneration, initialDraft, slot } from "./draft";import { PresetUrlCtx, StartRequestCtx, StudioProvider, usePresetUrl, useStudio, useStudioActions, type Draft, type StudioConfig } from "./studio-context";@@ -650,6 +651,7 @@ function StudioBody({ header, tabs, examples }: { header?: React.ReactNode; tabs<DockedExamples /></div>)}+ {config.releaseNudge && <ReleaseNudge studio={config.releaseNudge} docked={hasItems} />}<div data-composer className={cn("mx-auto w-full", hasItems ? "max-w-[800px]" : "max-w-[760px]")}><HoldFilesForGuests><Composer docked={hasItems} />diff --git a/src/lib/release-nudge.ts b/src/lib/release-nudge.tsnew file mode 100644index 00000000..e7719deb--- /dev/null+++ b/src/lib/release-nudge.ts@@ -0,0 +1,53 @@+import { openEngineReady, type ConnectionState } from "./connections";+import { HOME_RELEASE } from "./home-release";+import { minVramBytesFor } from "./lanes";+import { runsGoHere } from "./pool-rules";+import { runsHere, type Here } from "./runnable-here";+import type { ModelDef } from "./catalog/types";++/**+ * The studios' "is here" card for the newest open model (src/components/studio/release-nudge.tsx): the release is Home's+ * (HOME_RELEASE in src/lib/home-release.ts: its model, name, day and pictures), and this is the card's own part. Browser-+ * safe. The next release swaps HOME_RELEASE and these lines and pictures; its new model and day give the browser's "Not+ * now" a new key, so the card shows again to everyone who put the last one away.+ */+export const RELEASE_NUDGE = {+ /** The card's line in each studio that shows it (StudioConfig.releaseNudge). */+ lines: {+ image: "Photoreal people and products, painting, illustration and exact lettering.",+ edit: "Edits with up to 5 pictures, from photoreal people and products to exact lettering.",+ },+ /** Three of the release's pictures (slugs of HOME_RELEASE.art): left, middle (on top) and right of the card's fan. */+ art: ["emerald-watch", "couture-dunes", "gold-leaf-beauty"],+ /** The graphics memory the model's lane needs, in GB (the requirements index's): a visitor's own smaller GPU isn't offered it. */+ vramGb: 32,+} as const;++export type ReleaseStudio = keyof typeof RELEASE_NUDGE.lines;++/** The browser's key for "Not now" (and for Try it, after which the card isn't needed): one per release. */+export const nudgeKey = (r: { modelId: string; released: string } = HOME_RELEASE) => `fuobe:release-nudge:${r.modelId}:${r.released}`;++/** The parts of GET /api/status the card reads. */+export type NudgeStatus = ConnectionState & {+ viewer?: { hosted?: boolean; prefer?: "pool"; runOn?: string; gpu: { connected: boolean; vramBytes?: number } };+};++/**+ * Whether the viewer can run the release's model here now, so the card may offer it: the install runs open models, the+ * model is switched on, and the viewer's open runs have somewhere to go that takes it. The owner: his ComfyUI (or its+ * placeholder results) is connected, and on the workers one of them runs it. A guest or an account: this install's GPUs+ * run it for them (hosted runs, src/lib/runnable-here.ts), or its own GPU is connected and, where its size is known, large+ * enough. Unknown: no. Nothing here is ever said to the viewer: where it can't run, the card just doesn't show.+ */+export function releaseRunsFor(o: { status: NudgeStatus | undefined; here: Here | null; model: Pick<ModelDef, "id" | "kind" | "engine"> | undefined; offered: boolean; vramGb?: number }): boolean {+ const { status: s, model } = o;+ if (!s || !model || model.engine !== "open" || !o.offered || s.engineMode === "cloud") return false;+ if (o.here && !runsHere(o.here, model)) return false;+ const v = s.viewer;+ if (!v) return openEngineReady(s);+ if (runsGoHere(v)) return true;+ if (!v.gpu.connected) return false;+ const need = o.vramGb ? minVramBytesFor(o.vramGb) : 0;+ return !v.gpu.vramBytes || v.gpu.vramBytes >= need;+}diff --git a/src/lib/studios.ts b/src/lib/studios.tsindex b8955111..3ba2b911 100644--- a/src/lib/studios.ts+++ b/src/lib/studios.ts@@ -25,6 +25,8 @@ export const IMAGE_STUDIO: StudioConfig = {// Auto picks the open model for each run (src/lib/auto-image.ts): MiniMax H3 Image first where the GPU can take it, then// Krea 2 Realism (MOSS-Image for lettering), Qwen-Image 2.1 for edits. The default for everyone: the owner, an account and a guest.defaultModels: { cloud: "nano-banana-pro", open: AUTO_IMAGE },+ // The newest open model's card above the composer (src/components/studio/release-nudge.tsx).+ releaseNudge: "image",// A model's own settings (MOSS-Image's Quality, Ideogram's speed) sit under "Options".controlsTitle: "Options",// Layout mode: boxes on the picture, one row each, read in place by MOSS-Image, FLUX.3, FLUX 3 Klein and Ideogram 4.5.@@ -59,6 +61,7 @@ export const EDIT_STUDIO: StudioConfig = {live: true,related: { href: "/apps/app-watermark-remover", label: "Remove watermarks, captions and logos automatically" },defaultModels: { cloud: "nano-banana-pro", open: "oss-qwen-image-21" },+ releaseNudge: "edit",suggestions: ["Make it golden hour","Remove the people in the background",diff --git a/tests/release-nudge.test.ts b/tests/release-nudge.test.tsnew file mode 100644index 00000000..829f895b--- /dev/null+++ b/tests/release-nudge.test.ts@@ -0,0 +1,118 @@+import fs from "node:fs";+import path from "node:path";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { createElement } from "react";+import { renderToStaticMarkup } from "react-dom/server";+import { describe, expect, it, vi } from "vitest";++/*+ * The studios' "is here" card for the newest open model (src/components/studio/release-nudge.tsx, src/lib/release-nudge.ts):+ * its release is the one Home shows (src/lib/home-release.ts), it offers the model only where the viewer can run it, and+ * the static shell renders nothing (the browser's "Not now" is read after hydration).+ */++vi.mock("next/cache", () => ({ cacheLife: () => {} }));+vi.mock("next/navigation", () => ({+ useRouter: () => ({ prefetch: () => {}, push: () => {}, replace: () => {}, back: () => {}, refresh: () => {} }),+ usePathname: () => "/image",+ useSearchParams: () => new URLSearchParams(),+}));++const { RELEASE_NUDGE, nudgeKey, releaseRunsFor } = await import("@/lib/release-nudge");+const { HOME_RELEASE } = await import("@/lib/home-release");+const { getModel } = await import("@/lib/catalog");+const { IMAGE_STUDIO, EDIT_STUDIO, INPAINT_STUDIO } = await import("@/lib/studios");+const { ReleaseNudge } = await import("@/components/studio/release-nudge");+const { CatalogProvider } = await import("@/components/studio/catalog");+const { StudioProvider } = await import("@/components/studio/studio-context");+const { initialDraft } = await import("@/components/studio/draft");+const { studioCatalog } = await import("@/lib/studio-catalog");++const model = getModel(HOME_RELEASE.modelId)!;+const owner = (o: Record<string, unknown> = {}) => ({ providers: { comfyui: { configured: true } }, engineMode: "both" as const, ...o });+const visitor = (v: Record<string, unknown>, o: Record<string, unknown> = {}) => ({ providers: {}, engineMode: "both" as const, viewer: { gpu: { connected: false }, ...v }, ...o });+const runs = (status: Parameters<typeof releaseRunsFor>[0]["status"], more: Partial<Parameters<typeof releaseRunsFor>[0]> = {}) =>+ releaseRunsFor({ status, here: null, model, offered: true, vramGb: RELEASE_NUDGE.vramGb, ...more });++describe("the latest release's data", () => {+ it("is the model Home shows, an open image model that makes pictures from words and edits", () => {+ expect(model).toMatchObject({ name: HOME_RELEASE.name, engine: "open", kind: "image" });+ expect(model.routes.map((r) => r.op).sort()).toEqual(["edit", "t2i"]);+ expect(model.defaults).toMatchObject({ resolution: "2K" });+ // The Prompt helper stays off unless asked.+ expect(model.options.controls?.find((c) => c.param === "promptHelper")?.default ?? "off").toBe("off");+ // "Not now" is per release: the next model or day is a new key.+ expect(nudgeKey()).toBe(`fuobe:release-nudge:${HOME_RELEASE.modelId}:${HOME_RELEASE.released}`);+ expect(nudgeKey({ modelId: "oss-next", released: "2027-01-03" })).not.toBe(nudgeKey());+ expect(RELEASE_NUDGE.art).toHaveLength(3);+ for (const slug of RELEASE_NUDGE.art) expect(HOME_RELEASE.art.map((a) => a.slug)).toContain(slug);+ // The lane's need is the requirements index's.+ const index = JSON.parse(fs.readFileSync(path.join(process.cwd(), "workflows/comfyui/requirements.json"), "utf8")) as { workflows: Record<string, { vramGb: number }> };+ for (const r of model.routes) expect(index.workflows[r.endpoint].vramGb, r.endpoint).toBe(RELEASE_NUDGE.vramGb);+ });++ it("is shown in the Image and Edit studios, each with its own line, and nowhere else", () => {+ expect(IMAGE_STUDIO.releaseNudge).toBe("image");+ expect(EDIT_STUDIO.releaseNudge).toBe("edit");+ expect(INPAINT_STUDIO.releaseNudge).toBeUndefined();+ for (const line of Object.values(RELEASE_NUDGE.lines)) {+ expect(line.length).toBeGreaterThan(30);+ // Plain and positive: no prices, no refusals.+ expect(line).not.toMatch(/\$|can't|cannot|isn't|not available/i);+ }+ });+});++describe("who the card offers the model to", () => {+ it("the owner whose ComfyUI is connected, on an install that runs open models", () => {+ expect(runs(owner())).toBe(true);+ expect(runs(owner({ engineMode: "open" }))).toBe(true);+ expect(runs(owner({ engineMode: "cloud" }))).toBe(false);+ expect(runs(owner({ providers: {} }))).toBe(false);+ // On the workers, only while one of them runs it.+ expect(runs(owner(), { here: { owner: true, rules: {} } })).toBe(true);+ expect(runs(owner(), { here: { owner: true, rules: { own: { [model.id]: { need: "gpu" } as never } } } })).toBe(false);+ });++ it("a guest or an account whose runs go to this install's GPUs, while they run it", () => {+ const pooled = visitor({ kind: "guest", hosted: true });+ expect(runs(pooled, { here: { owner: false, rules: {} } })).toBe(true);+ expect(runs(pooled, { here: { owner: false, rules: { deny: [model.id] } } })).toBe(false);+ expect(runs(visitor({ kind: "account", hosted: true }), { here: { owner: false, rules: { kinds: { image: false } } } })).toBe(false);+ });++ it("an account on its own GPU: when it is connected and, where its size is known, large enough", () => {+ expect(runs(visitor({ kind: "account", gpu: { connected: true, vramBytes: 32 * 2 ** 30 } }))).toBe(true);+ // An RTX 5090 reads a little under 32 GiB.+ expect(runs(visitor({ kind: "account", gpu: { connected: true, vramBytes: 31.5 * 2 ** 30 } }))).toBe(true);+ expect(runs(visitor({ kind: "account", gpu: { connected: true } }))).toBe(true);+ expect(runs(visitor({ kind: "account", gpu: { connected: true, vramBytes: 24 * 2 ** 30 } }))).toBe(false);+ expect(runs(visitor({ kind: "account", gpu: { connected: false } }))).toBe(false);+ expect(runs(visitor({ kind: "guest" }))).toBe(false);+ });++ it("nobody while the status is unknown or the model is switched off", () => {+ expect(runs(undefined)).toBe(false);+ expect(runs(owner(), { offered: false })).toBe(false);+ expect(runs(owner(), { model: undefined })).toBe(false);+ });+});++describe("the card in the studio", () => {+ it("renders nothing in the static shell, so the first render after hydration matches it", () => {+ const catalog = studioCatalog(IMAGE_STUDIO);+ const draft = initialDraft(IMAGE_STUDIO, new URLSearchParams(), "open", { getModel, getPreset: () => undefined });+ const html = renderToStaticMarkup(+ createElement(+ QueryClientProvider,+ { client: new QueryClient() },+ createElement(CatalogProvider, {+ catalog,+ config: IMAGE_STUDIO,+ children: createElement(StudioProvider, { config: IMAGE_STUDIO, initial: draft, children: createElement(ReleaseNudge, { studio: "image" }) }),+ }),+ ),+ );+ expect(html).toBe("");+ });+});