Skip to content

armgit / fuobe

Public Imported from GitHub
0

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.

Merge branch 'claude/fuobe-parity-4' into o/n7-2-layout-mode

Claude46a217de053a
diff --cc src/components/studio/composer.tsx
index 3112b5e5,e9252146..a924b76a
--- a/src/components/studio/composer.tsx
+++ b/src/components/studio/composer.tsx
@@@ -1,16 -1,18 +1,18 @@@
"use client";
- import { ArrowUp, AtSign, GalleryHorizontalEnd, LayoutDashboard, Loader2, Sparkles, X } from "lucide-react";
-import { ArrowUp, AtSign, Cloud, Cpu, GalleryHorizontalEnd, Loader2, Sparkles, X } from "lucide-react";
++import { ArrowUp, AtSign, Cloud, Cpu, GalleryHorizontalEnd, LayoutDashboard, Loader2, Sparkles, X } from "lucide-react";
import dynamic from "next/dynamic";
import Link from "next/link";
- import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { flushSync } from "react-dom";
import { toast } from "sonner";
+ import { openAddKey } from "@/components/keys/your-keys";
import { Button } from "@/components/ui/button";
import { Kbd } from "@/components/ui/kbd";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
- import { estimateCost, layoutCanvas, planGeneration, routesFor, type Plan } from "@/lib/catalog/plan";
- import type { Engine, GenerationRequest, MediaKind, ModelDef, Operation, Preset, VideoFormat } from "@/lib/catalog/types";
+ import { useToday } from "@/hooks/use-today";
-import { estimateCost, imageLimit, planGeneration, routesFor } from "@/lib/catalog/plan";
++import { estimateCost, imageLimit, layoutCanvas, planGeneration, routesFor, type Plan } from "@/lib/catalog/plan";
+ import type { Engine, GenerationRequest, MediaKind, ModelDef, Operation, Preset, PresetRoute, VideoFormat } from "@/lib/catalog/types";
import { dualEngine } from "@/lib/catalog/engines";
import { locksByDefault } from "@/lib/catalog/palettes";
import { DEFAULT_LOOK, lookCard } from "@/lib/catalog/soul-cards";
@@@ -453,10 -589,9 +609,10 @@@ export function Composer({ docked }: {
});
const plan = planGeneration({ ...planned, prompt: planned.prompt || (config.promptOptional ? " " : "") }, catalog.getModel, catalog.getPreset);
op = plan.op;
+ laid = plan.layout;
// A run with LoRAs (a Soul look) goes to the route's LoRA endpoint, which has its own price.
const withLoras = plan.loras.length > 0 && routesFor(plan.model, plan.op).some((r) => !!r.loraEndpoint);
- cost = estimateCost(plan.model, plan.params, plan.jobs, plan.op, withLoras);
+ cost = estimateCost(plan.model, plan.params, plan.jobs, plan.op, withLoras, today);
loraPriceUnknown = withLoras && !!plan.model.pricing?.lorasUnknown;
// A relight effect relights the start frame first (free on the GPU, about $0.04 in the cloud).
if (cost !== null) cost += prestepCost(preset, plan.model.id, engine);
@@@ -1057,9 -1178,12 +1289,13 @@@
value={model}
engine={engine}
onEngineChange={setEngine}
- defaultModels={config.defaultModels}
- onChange={pickModel}
+ defaultModels={defaults}
+ ops={pickerOps}
+ onChange={appChoice ? pickAppModel : pickModel}
+ recipe={recipeModel}
+ flat={appChoice}
+ madeWith={madeWith}
+ boxes={layoutOn}
/>
) : (
<Chip icon={Loader2} disabled className="[&>svg]:animate-spin">
diff --cc src/components/studio/model-picker.tsx
index b56c6409,fd4964d8..421fb84a
--- a/src/components/studio/model-picker.tsx
+++ b/src/components/studio/model-picker.tsx
@@@ -6,14 -7,17 +7,18 @@@ import { KEY_ADDED_EVENT, openAddKey }
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Command, CommandGroup, CommandInput, CommandItem, CommandList } from "@/components/ui/command";
+ import { RowDot } from "@/components/gpu/readiness-chip";
+ import { badgeFor, useGpuBadges } from "@/hooks/use-gpu";
import { useIsMobile } from "@/hooks/use-mobile";
- import { type Engine, type ModelDef } from "@/lib/catalog/types";
+ import { useToday } from "@/hooks/use-today";
+ import type { Badge as BadgeT } from "@/lib/gpu/types";
+ import { type Engine, type ModelDef, type Operation } from "@/lib/catalog/types";
import { useEngineMode, useStatus } from "@/lib/api";
- import { bestForStudio, groupModels, toggleIn } from "@/lib/composer";
+ import { groupModels, studioBest, toggleIn } from "@/lib/composer";
+import { readsBoxes } from "@/lib/layout-prompt";
- import { formatCost } from "@/lib/format";
- import { ISOLATED_NOTE } from "@/lib/model-rows";
+ import { ISOLATED_NOTE, pickerPrice } from "@/lib/model-rows";
import { cn } from "@/lib/utils";
+ import { addKeyLabel, billedTo, CLOUD_KEY, needsKey, type CloudProvider } from "@/lib/your-keys";
import { EngineSwitch } from "./engine-switch";
import { ResponsivePanel } from "./responsive-panel";
import { RECENT_MODELS, STARRED_MODELS, useStoredList } from "./stored-list";
@@@ -81,16 -79,27 +80,30 @@@ function ModelRow(
selected,
starred,
showEngine,
+ boxes,
+ today,
onStar,
+ gpu,
+ gpuName,
+ needs,
+ made,
}: {
m: ModelDef;
selected: boolean;
starred: boolean;
showEngine: boolean;
+ /** Layout mode: a "Reads boxes" badge on the models that place boxes by their coordinates. */
+ boxes?: boolean;
+ /** The browser's day: a launch price holds through its last day (null until hydrated: no price shown for one). */
+ today: number | null;
onStar: () => void;
+ /** Its state on the viewer's GPU (the GPU pre-flight). */
+ gpu?: BadgeT | null;
+ gpuName?: string;
+ /** An account's paid model it has no key for yet: dimmed, "Add your fal.ai key" in place of the price. */
+ needs?: CloudProvider[] | null;
+ /** The active preset's live preview was made with this model. */
+ made?: boolean;
}) {
return (
<>
@@@ -101,10 -110,11 +114,15 @@@
{m.name}
{starred && <span className="sr-only">, starred</span>}
</span>
+ {/* A dimmed row on a phone: the name first (its badges would cut it to "Na…"). */}
- {needs ? (
+ {boxes && readsBoxes(m) ? (
+ <Badge variant="secondary" className="h-4 shrink-0 rounded-[4px] bg-brand-faint px-1 text-[10px] font-medium text-brand-text">
+ Reads boxes
+ </Badge>
++ ) : needs ? (
+ <span className="contents max-sm:hidden">
+ <ModelBadges model={m} max={2} />
+ </span>
) : (
<ModelBadges model={m} max={2} />
)}
@@@ -155,8 -180,14 +188,16 @@@ interface PickerProps
engine: Engine;
onEngineChange: (e: Engine) => void;
defaultModels?: { cloud: string; open: string };
+ /** Layout mode: the models that read boxes come first, badged. */
+ boxes?: boolean;
+ /** The operations the studio offers, its main one first: "Best for this studio" ranks the models that do it. */
+ ops?: Operation[];
+ /** The model the active preset's preview was made with (its recipe): first in "Best for this studio". */
+ recipe?: string;
+ /** A short list in its own order (an app's models): one group, no Recent, Starred or Best. */
+ flat?: boolean;
+ /** The model the active preset's live preview really came from: "Used for this preview" on its row. */
+ madeWith?: string;
}
/**
@@@ -189,24 -267,37 +277,41 @@@ export function ModelPicker(props: Pick
}
/** The searchable list (mounted by the popover / sheet only while it shows). */
- function PickerList({ models, value, onChange, engine, onEngineChange, defaultModels, boxes, onPicked }: PickerProps & { onPicked: () => void }) {
+ function PickerList({
+ models,
+ value,
+ onChange,
+ engine,
+ onEngineChange,
+ defaultModels,
++ boxes,
+ ops,
+ recipe,
+ flat,
+ madeWith,
+ onPicked,
+ onNeedsKey,
+ }: PickerProps & { onPicked: () => void; onNeedsKey?: (m: ModelDef, p: CloudProvider) => void }) {
const [q, setQ] = useState("");
const status = useStatus().data;
+ const badges = useGpuBadges().data;
const mode = useEngineMode();
const mobile = useIsMobile();
const [recent] = useStoredList(RECENT_MODELS);
const [starred, setStarred] = useStoredList(STARRED_MODELS);
+ const today = useToday();
const engines = useMemo<Engine[]>(() => (mode === "both" ? ["cloud", "open"] : [mode]), [mode]);
- // "Best" ranks models that do what the studio's default does first (its main operation), not single-purpose tools.
+ // "Best" ranks models that do what the studio is for, not single-purpose tools.
+ // A preset's recipe leads, when it runs on this engine.
const best = useMemo(() => {
- const id = defaultModels?.[engine];
- const op = models.find((m) => m.id === id)?.routes[0]?.op;
- return bestForStudio(models, engine, id, 4, op).map((m) => m.id);
- }, [models, engine, defaultModels]);
- const { groups, count } = useMemo(() => groupModels({ models, engine, engines, query: q, recent, starred, best, boxes }), [models, engine, engines, q, recent, starred, best, boxes]);
- const ready = (m: ModelDef) => m.routes.some((r) => status?.providers[r.provider]?.configured);
- const shown = groups.flatMap((g) => g.models);
- const demo = status && status.demoMode !== "off" && shown.some((m) => !ready(m));
+ const ranked = studioBest(models, engine, defaultModels?.[engine], ops);
+ return recipe && models.some((m) => m.id === recipe && m.engine === engine) ? [recipe, ...ranked.filter((id) => id !== recipe)] : ranked;
+ }, [models, engine, defaultModels, ops, recipe]);
- const { groups, count } = useMemo(() => groupModels({ models, engine, engines, query: q, recent, starred, best, flat }), [models, engine, engines, q, recent, starred, best, flat]);
++ const { groups, count } = useMemo(
++ () => groupModels({ models, engine, engines, query: q, recent, starred, best, flat, boxes }),
++ [models, engine, engines, q, recent, starred, best, flat, boxes],
++ );
+ const demo = placeholdersOn(status?.demoMode);
const otherEngine = engine === "cloud" ? "open" : "cloud";
const noneForEngine = !q && !models.some((m) => m.engine === engine);
@@@ -249,9 -383,21 +397,22 @@@
value={`${g.id}:${m.id}`}
onSelect={() => pick(m)}
data-checked={value?.id === m.id}
+ aria-label={needsKey(m, status) ? `${m.name} needs your ${CLOUD_KEY[needsKey(m, status)![0]].label} key` : undefined}
className={cn("gap-2.5 rounded-lg px-2 py-1.5 [&>svg:last-child]:hidden", value?.id === m.id && "bg-brand-faint data-selected:bg-brand-faint-hover")}
>
- <ModelRow m={m} selected={value?.id === m.id} starred={starred.includes(m.id)} showEngine={!!q || m.engine !== engine} boxes={boxes} onStar={() => setStarred((s) => toggleIn(s, m.id))} />
+ <ModelRow
+ m={m}
+ selected={value?.id === m.id}
+ starred={starred.includes(m.id)}
+ showEngine={g.id !== "paid" && (!!q || m.engine !== engine)}
++ boxes={boxes}
+ today={today}
+ onStar={() => setStarred((s) => toggleIn(s, m.id))}
+ gpu={m.engine === "open" ? badgeFor(badges, { modelId: m.id }) : null}
+ gpuName={badges?.gpu}
+ needs={needsKey(m, status)}
+ made={m.id === madeWith}
+ />
</CommandItem>
))}
</CommandGroup>
diff --cc src/components/studio/studio-page.tsx
index 3d8a7334,d5aa0dab..3f7b81c1
--- a/src/components/studio/studio-page.tsx
+++ b/src/components/studio/studio-page.tsx
@@@ -8,12 -8,15 +8,29 @@@ import { memo, Suspense, useCallback, u
import { nanoid } from "nanoid";
import { toast } from "sonner";
import { SidebarTrigger } from "@/components/ui/sidebar";
+ import { HeaderPill } from "@/components/gpu/readiness-chip";
+ import { badgeFor, openGpuSetup, useGpuBadges } from "@/hooks/use-gpu";
import type { Generation, MediaKind, ModelDef, Preset } from "@/lib/catalog/types";
- import { useEngine, useGenerations } from "@/lib/api";
- import { claimStartToken, followEngineDefault, handoffKey, mergeHandoff, presetModel, promptShown, START_PARAM, withoutLayout, withoutStart } from "@/lib/composer";
+ import { GUEST_PROMPT_EVENT, useEngine, useGenerations, useIsGuest } from "@/lib/api";
-import { claimStartToken, followEngineDefault, handoffKey, mergeHandoff, presetModel, presetParams, promptShown, routeParams, START_PARAM, withoutStart, withPreset } from "@/lib/composer";
++import {
++ claimStartToken,
++ followEngineDefault,
++ handoffKey,
++ mergeHandoff,
++ presetModel,
++ presetParams,
++ promptShown,
++ routeParams,
++ START_PARAM,
++ withoutLayout,
++ withoutStart,
++ withPreset,
++} from "@/lib/composer";
+ import { presetGpuKey, presetRoutes } from "@/lib/catalog/preset-recipe-routes";
+import { editableLayout, EDIT_LAYOUT_PARAM, readEditLayoutParam } from "@/lib/output-actions";
import { positionsFrom } from "@/lib/catalog/keyframes";
import { reuseSignature, withSignatureWords } from "@/lib/catalog/palettes";
+ import { movedAppRequest } from "@/lib/catalog/plan";
import { currentModelId, migrateRequest } from "@/lib/catalog/replaced";
import { matchSpokenLanguage } from "@/lib/speech-languages";
import { SoulPresetCards } from "@/components/moodboards/soul-preset-cards";
@@@ -455,57 -583,34 +600,77 @@@ function HandoffSync(
);
}
+/**
+ * Edit layout (`/image?layout=<generation>[.<picture>]`, from a result's menu anywhere): the picture's boxes open in
+ * Layout mode with its words, model and seed: the request's own layout, or the one fal's MOSS-Image planned (decoded at
+ * the picture's size). The param isn't part of the hand-off key, so the draft on screen isn't reset first; it is taken
+ * out of the address once read, so a reload doesn't open it again.
+ */
+function LayoutHandoff() {
+ const sp = useSearchParams();
+ const value = sp.get(EDIT_LAYOUT_PARAM);
+ const { config, setDraft } = useStudioActions();
+ const catalog = useCatalog();
+ const [engine, setEngine] = useEngine();
+ const opened = useRef<string | null>(null);
+ const ref = config.layout ? readEditLayoutParam(value) : null;
+ useEffect(() => {
+ if (!ref || !value || opened.current === value || !catalog.ready) return;
+ opened.current = value;
+ void fetch(`/api/generations/${encodeURIComponent(ref.id)}`)
+ .then(async (res) => {
+ if (!res.ok) throw new Error("That picture isn't in your library any more");
+ const g = (await res.json()) as Generation;
+ const e = editableLayout(g, ref.index);
+ if (!e) throw new Error("This picture has no layout to open");
- const base = draftFromGeneration(g, config, catalog.getModel);
++ const base = draftFromGeneration(g, config, catalog.getModel, catalog.getPreset);
+ const params = { ...(base.params ?? {}), ...(e.seed !== undefined && { seed: e.seed }) };
+ setDraft({ ...base, prompt: e.caption, params, layout: { ...e.draft, summary: { ...e.draft.summary, caption: "" } } });
+ if (g.engine !== engine) setEngine(g.engine);
+ toast(e.seed !== undefined ? "Layout opened with the picture's seed: move a box or change a word, then generate" : "Layout opened: move a box or change a word, then generate", { id: "edit-layout" });
+ requestAnimationFrame(() => document.querySelector<HTMLTextAreaElement>("[data-composer] textarea")?.focus());
+ })
+ .catch((err: Error) => toast.error(err.message, { id: "edit-layout" }))
+ .finally(() => {
+ const u = new URL(window.location.href);
+ u.searchParams.delete(EDIT_LAYOUT_PARAM);
+ window.history.replaceState(null, "", `${u.pathname}${u.search}${u.hash}`);
+ });
+ }, [ref, value, catalog, config, engine, setDraft, setEngine]);
+ return null;
+}
+
- /** One draft's page: the studio and its hand-off. The start request resets with the draft (a new epoch). */
- function StudioSession({ header, tabs, sync }: { header?: React.ReactNode; tabs?: React.ReactNode; sync: Omit<React.ComponentProps<typeof HandoffSync>, "onStart"> }) {
+ /**
+ * One draft's page: the studio and its hand-off. The start request resets with the draft (a new epoch).
+ *
+ * A guest's Start from Home opens "Create a free account" here instead of sending a run that can only be refused. It
+ * 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,
+ examples,
+ sync,
+ }: {
+ header?: React.ReactNode;
+ tabs?: React.ReactNode;
+ examples?: StudioExampleRow;
+ sync: Omit<React.ComponentProps<typeof HandoffSync>, "onStart">;
+ }) {
const [startRequest, setStartRequest] = useState(0);
- const onStart = useCallback(() => setStartRequest((n) => n + 1), []);
+ const guest = useIsGuest();
+ const onStart = useCallback(() => {
+ if (guest) queueMicrotask(() => window.dispatchEvent(new CustomEvent(GUEST_PROMPT_EVENT, { detail: { action: "run" } })));
+ else setStartRequest((n) => n + 1);
+ }, [guest]);
return (
<StartRequestCtx.Provider value={startRequest}>
- <StudioBody header={header} tabs={tabs} />
+ <StudioBody header={header} tabs={tabs} examples={examples} />
<HandoffSync {...sync} onStart={onStart} />
+ <Suspense fallback={null}>
+ <LayoutHandoff />
+ </Suspense>
</StartRequestCtx.Provider>
);
}
diff --cc src/lib/catalog/plan.ts
index ddadfe21,3e6f67d3..77cf3cf0
--- a/src/lib/catalog/plan.ts
+++ b/src/lib/catalog/plan.ts
@@@ -17,8 -16,10 +16,12 @@@ import { cloudPath, fitLoras, gated, lo
import { anglesPrompt, anglesWords, ANGLES_ORIGINAL } from "./open-tools";
import { askedSize, numFramesValue, sizeValue } from "./payload";
import { characterScale, CINEMA_CROP, soulKind, soulMegapixels, soulRecipe, soulSize, type SoulOverlay } from "./soul";
+import { computeDimensions, fitCanvas } from "@/lib/comfy";
+import { carriesLayout, layoutCompilerFor, LAYOUT_MAX_SIDE, LAYOUT_MULTIPLE, LAYOUT_PARAM, readLayout, validateLayout, type LayoutDraft, type LayoutFormat } from "@/lib/layout-prompt";
+ import { pricingOn, type PriceClock } from "./promo";
+ import { presetRoutes } from "./preset-recipe-routes";
+
+ export { pricingAt } from "./promo";
/** Infer the operation from what the user attached. */
export function inferOperation(model: ModelDef, req: Pick<GenerationRequest, "op" | "inputs" | "params">): Operation {
@@@ -339,17 -390,11 +397,22 @@@ export function planGeneration
if (!routesFor(model, op).length) {
throw new Error(`${model.name} can't do ${op} — try another model`);
}
+ // A layout (the Image studio's Layout mode, Edit layout, an API caller's draft): compiled for this model at the size it
+ // renders, the prompt as its caption; nothing rewrites it afterwards (Fuobe's enhancer, the API's prompt expansion).
+ let layoutPlan: Plan["layout"];
+ if (carriesLayout(params.extra)) {
+ const drawn = readLayout(params.extra![LAYOUT_PARAM]);
+ if (!drawn) throw new Error("The layout couldn't be read: draw its boxes again");
+ const compiled = planLayout(model, op, prompt, drawn, params);
+ prompt = compiled.prompt;
+ params = compiled.params;
+ layoutPlan = compiled.layout;
+ }
+ // MiniMax H3's orbit of a still (its Orbit LoRA graph, src/lib/comfy-variants.ts) runs at the LoRA's own length, 3 s
+ // (73 frames), unless the run names a length.
+ if (model.options.promptFormat === "minimax-h3" && op === "i2v" && params.extra?.orbit === true && req.params?.duration === undefined && params.duration === model.defaults?.duration) {
+ params = { ...params, duration: 3 };
+ }
if (op === "finalize" && !params.draftId) throw new Error("Pick a draft to finish");
if (op === "dialogue" && !params.dialogue?.some((l) => l.text.trim())) throw new Error("Write at least one line");
if (op === "dub" && !params.targetLanguage) throw new Error("Pick a language to translate into");
diff --cc src/lib/composer.ts
index d65ae57d,22490cdf..b310ed49
--- a/src/lib/composer.ts
+++ b/src/lib/composer.ts
@@@ -10,10 -10,11 +10,12 @@@ import { wholeClipProblem, wholeClipToo
import { clipWindowProblem } from "./catalog/clip-windows";
import { addFrameAt, frameTimes, framesInputs, removeFrameAt, spread, type FrameSupport } from "./catalog/keyframes";
import { FACE_MOSAIC_MODELS } from "./catalog/open-tools";
+ import { pricingOn, type PriceClock } from "./catalog/promo";
import { soulPostStep } from "./catalog/soul";
- import { COLORMAPS, type Engine, type GenParams, type InputSlot, type MatteOutput, type MediaKind, type ModelDef, type Operation, type Preset, type VideoFormat } from "./catalog/types";
+ import { appModels, ownRoute, presetRoutes, type HasModel, type RecipePreset } from "./catalog/preset-recipe-routes";
+ import { COLORMAPS, type Engine, type GenParams, type InputSlot, type MatteOutput, type MediaKind, type ModelDef, type Operation, type Preset, type PresetRoute, type VideoFormat } from "./catalog/types";
import { spokenLanguageName } from "./speech-languages";
+import { LAYOUT_MAX_PIXELS, LAYOUT_MAX_SIDE, LAYOUT_PARAM, readLayout, readsBoxes, type LayoutDraft } from "./layout-prompt";
// ---------------------------------------------------------------------------
// Settings summary ("16:9 · 720p · 5s · ×1")
@@@ -960,8 -1023,23 +1092,23 @@@ export function bestForStudio(models: M
.map(([m]) => m);
}
+ /**
+ * A studio picker's "Best for this studio": the models that do what the default model does first, when the studio
+ * offers that (`ops`, its main operation first). A default that does something else first (Qwen-Image 2.1 makes
+ * pictures from words first, in the Edit and Inpaint studios) ranks the models that do the first of the studio's
+ * operations it does instead, leaving out the tools that take no words (a garment try-on) unless the default is one.
+ */
+ export function studioBest(models: ModelDef[], engine: Engine, defaultId: string | undefined, ops?: Operation[]): string[] {
+ const def = models.find((m) => m.id === defaultId);
+ const first = def?.routes[0]?.op;
+ if (!def || !first || !ops?.length || ops.includes(first)) return bestForStudio(models, engine, defaultId, 4, first).map((m) => m.id);
+ const op = ops.find((o) => def.routes.some((r) => r.op === o)) ?? ops[0];
+ const pool = models.filter((m) => m === def || !m.options.promptless || def.options.promptless);
+ return bestForStudio(pool, engine, defaultId, 4, op).map((m) => m.id);
+ }
+
export interface ModelGroup {
- id: "boxes" | "recent" | "starred" | "best" | "all" | "results";
- id: "recent" | "starred" | "best" | "all" | "results" | "paid";
++ id: "boxes" | "recent" | "starred" | "best" | "all" | "results" | "paid";
label: string;
models: ModelDef[];
}
@@@ -994,10 -1075,10 +1144,12 @@@ export function groupModels(input:
recent: string[];
starred: string[];
best: string[];
+ /** Layout mode: the models that place boxes by their coordinates come first ("Reads your boxes"). */
+ boxes?: boolean;
+ /** A short list in its own order (an app's models): one group. */
+ flat?: boolean;
}): { groups: ModelGroup[]; count: number } {
- const { models, engine, engines, query, recent, starred, best } = input;
+ const { models, engine, engines, query, recent, starred, best, boxes } = input;
const q = query.trim();
if (q) {
const hits = models
@@@ -1021,14 -1103,16 +1174,17 @@@
}
return out;
};
- const groups: ModelGroup[] = [
- ...(boxes ? [{ id: "boxes" as const, label: "Reads your boxes", models: take(pool.filter((m) => readsBoxes(m)).map((m) => m.id), 50) }] : []),
- { id: "recent", label: "Recent", models: take(recent, 3) },
- { id: "starred", label: "Starred", models: take(starred, 50) },
- { id: "best", label: "Best for this studio", models: take(best, 4) },
- { id: "all", label: "All models", models: pool },
- ];
- return { groups: groups.filter((g) => g.models.length), count: pool.length };
+ const top = (
+ [
++ ...(boxes ? [{ id: "boxes" as const, label: "Reads your boxes", models: take(pool.filter((m) => readsBoxes(m)).map((m) => m.id), 50) }] : []),
+ { id: "recent", label: "Recent", models: take(recent, 3) },
+ { id: "starred", label: "Starred", models: take(starred, 50) },
+ { id: "best", label: "Best for this studio", models: take(best, 4) },
+ ] satisfies ModelGroup[]
+ ).filter((g) => g.models.length);
+ const rest = pool.filter((m) => !used.has(m.id));
+ const groups: ModelGroup[] = [...top, ...(rest.length ? [{ id: "all" as const, label: top.length ? "More models" : "All models", models: rest }] : [])];
+ return { groups, count: pool.length };
}
/** Keep a most-recent-first id list without duplicates. */
diff --cc src/lib/studios.ts
index 22b5fb10,8fda4793..78f1a341
--- a/src/lib/studios.ts
+++ b/src/lib/studios.ts
@@@ -17,11 -17,12 +17,14 @@@ export const IMAGE_STUDIO: StudioConfi
feed: { kind: "image", features: ["image", "edit", "app:*", "character:*"] },
slots: [],
multiRef: { label: "Add ref", max: 8 },
- defaultModels: { cloud: "nano-banana-pro", open: "oss-z-image-turbo" },
+ defaultModels: { cloud: "nano-banana-pro", open: "oss-ideogram-4" },
+ // Ideogram 4 runs on a caption the install's local model writes: an account, a guest or an install with none opens on
+ // Qwen-Image 2.1, the next pick (plain words give Ideogram's grey safety card on about half the pictures of people).
+ uncaptioned: { open: "oss-qwen-image-21" },
// 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 and Ideogram 4.5.
+ layout: true,
// Color signature + Moodboard chips, and the models they can move a request to. Fuobe Soul's PixeletedFace look runs
// the face mosaic after the picture: its step's model is known here so the price counts it before the run.
signature: true,
diff --cc src/server/generations.ts
index 1f763bc4,8669cf96..7df373c0
--- a/src/server/generations.ts
+++ b/src/server/generations.ts
@@@ -42,17 -46,27 +46,28 @@@ import
type Preset,
type ProviderId,
} from "@/lib/catalog/types";
- import { asSystem, runAs, type Actor } from "./access/actor";
- import { AccountOffError, ownerActor, rowOwner, runAsOwner } from "./access/permissions";
import { db } from "./db";
import { listElements } from "./elements";
+ import { markStale } from "./gpu/snapshots";
+ import { BLOCKED_CARD_MESSAGE, looksBlocked } from "./safety-card";
import { pollTrainings } from "./training";
import { createExtendChain, createKeyframeFilm, createMosaicRun, createRelitClip, createShotFilm, createStillTo3d } from "./chains";
- import { enhancePrompt, enhanceSoulWords } from "./enhance";
+ import { enhancePrompt, enhanceSoulWords, ideogramCaption } from "./enhance";
+import { carriesLayout } from "@/lib/layout-prompt";
import { setResolver, watchGenerations, type LiveEvent } from "./live";
import { provider, PROVIDERS, RETIRED_PROVIDER_ERROR } from "./providers";
- import { comfyLoraFiles, probeComfy } from "./providers/comfyui";
+ import { comfyLoraFiles, computerScope, onOwnGpu, outputFetch, outsideOwnGpu, OWN_OUTPUT_LIMITS, ownGpu, probeComfy, relayFile, type OwnGpu } from "./providers/comfyui";
+ import { accountById, accountGpu, gpuLink, type AccountGpu } from "./auth";
+ import { accountEngineMode, accountKey, paidAllowed } from "./account-keys";
+ import { addKeyMessage, isCloudProvider, keyRemovedMessage, type CloudProvider } from "@/lib/your-keys";
+ import { CONNECT_GPU_MESSAGE, GUEST_RUN_MESSAGE, OWN_GPU_TOOL_MESSAGE } from "@/lib/guest-access";
+ import { outsideTenant, runAsTenant, tenant, tenantAccount } from "./tenant";
+ import { generationAccount } from "./account-library";
+ import { ACCOUNT_LIMITS, ACCOUNT_MESSAGES, accountTotalBytes, accountUsage, diskHasRoom, filesFullMessage } from "./account-files";
+ import { checkAccountLoras } from "./account-loras";
+ import { missingFilesMessage, type MissingFiles } from "@/lib/missing-files";
+ import { Readable } from "node:stream";
+ import { pipeline } from "node:stream/promises";
import { graphLoras } from "@/lib/catalog/character-swap";
import { ensureLorasOnComfy, prepareCloudLoras, withoutUnreachableCivitai } from "./loras";
import { ACCESS_PLACE } from "@/lib/model-access";
@@@ -1207,14 -1501,16 +1502,18 @@@ async function submitNow
};
const prepMask = async (ref?: string) => {
if (!ref) return undefined;
- const f = await readRef(ref);
- const fmt = route.map?.maskFormat;
- const data = fmt && fmt !== "white" && f.contentType === "image/png" ? convertMask(f.data, fmt) : f.data;
- return adapter.prepareFile(data, f.contentType, f.name, route);
+ return gate(async () => {
+ const f = await readRef(ref);
+ const fmt = route.map?.maskFormat;
+ const data = fmt && fmt !== "white" && f.contentType === "image/png" ? convertMask(f.data, fmt) : f.data;
+ return adapter.prepareFile(data, f.contentType, f.name, route);
+ });
};
let prompt = plan.prompt;
+ const captioned = plan.model.options.promptFormat === "ideogram4";
- if (req.params?.enhancePrompt && prompt && !captioned) {
+ // A layout's prompt is compiled boxes (plan.layout): the enhancer would rewrite them, so it never runs on one.
- if (req.params?.enhancePrompt && prompt && !plan.layout && !carriesLayout(req.params?.extra)) {
++ const laidOut = !!plan.layout || carriesLayout(req.params?.extra);
++ if (req.params?.enhancePrompt && prompt && !captioned && !laidOut) {
update(id, { message: "Enhancing prompt" });
const words = plan.soul?.words;
const at = words ? prompt.indexOf(words) : -1;
@@@ -1225,6 -1521,26 +1524,29 @@@
} else prompt = await enhancePrompt(prompt, plan.model.kind, plan.op).catch(() => prompt);
update(id, { prompt });
}
+ // Ideogram 4 reads a JSON caption (src/lib/ideogram-caption.ts): one given as the prompt (a reused run) is kept, plain
- // words get one written. It becomes the run's prompt, as Enhance's rewrite does, so Reuse makes the same picture.
++ // words get one written. It becomes the run's prompt, as Enhance's rewrite does, so Reuse makes the same picture. A
++ // layout's words are never rewritten by the helper: they get the fixed wrapper.
+ if (captioned && prompt) {
+ update(id, { message: "Writing the caption" });
+ const words = prompt;
- prompt = parseCaption(words) ?? (await ideogramCaption(words, computeDimensions(plan.params.aspectRatio, plan.params.resolution, {})).catch(() => captionFromWords(words)));
++ prompt =
++ parseCaption(words) ??
++ (laidOut ? captionFromWords(words) : await ideogramCaption(words, computeDimensions(plan.params.aspectRatio, plan.params.resolution, {})).catch(() => captionFromWords(words)));
+ update(id, { prompt });
+ }
+ // MiniMax H3 on your GPU reads its own layout (src/lib/h3-prompt.ts): the words (after any Enhance) go into it, with the
+ // start (and end) frame's alignment line for the clip's length on H3's frame grid. It becomes the run's prompt, so Reuse
+ // makes the same clip. An orbit keeps its words as they are: the Orbit LoRA reads its own caption style.
+ const h3Op = plan.op === "t2v" || plan.op === "i2v" || plan.op === "flf2v" ? plan.op : undefined;
+ const orbit = h3Op === "i2v" && plan.params.extra?.orbit === true;
+ if (plan.model.options.promptFormat === "minimax-h3" && h3Op && prompt && !orbit) {
+ const wrapped = h3Prompt(prompt, h3Op, h3Frames(plan.params.duration ?? plan.model.defaults?.duration ?? 5));
+ if (wrapped !== prompt) {
+ prompt = wrapped;
+ update(id, { prompt });
+ }
+ }
const input: GenInput = {
...plan.params,
prompt,