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.

N7-5 fixes: launch prices are read on the day they are shown or run, never while a page prerenders

Claude85aaf50596d4
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index 304a72b2..f58a63bf 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -66,7 +66,7 @@ Feed, Library, studios (React Query caches patched by id; polls every 10 s while
| `trainers.generated.ts` | Round 4 part 4. The fal trainers (`HOSTED_TRAINERS`: endpoint, fields, price per step, the output field the LoRA comes back in, licence). **Generated** by `scripts/gen-trainers.py` from `fuobe-originals-recipes-5.json`'s trainers; `training.ts` prices Soul ID from it |
| `studio-packs.generated.ts` | Round 4 part 5. The 14 Photodump / Instadump packs and the 6 Fashion Factory templates (name, photo or shot count, description). **Generated** by `scripts/gen-studio-packs.py` from the research in `higgsfield-image-studios.json`. It replaces `higgsfield-presets.generated.ts`, which went with `higgsfield-models.generated.ts` and their generators (see Retired models); the Soul preset fallback list and `presetPrompt` left `packs.ts` with it |
| `replaced.ts` | Round 4 part 5 (O7). What replaced each retired model, training target and lost operation, pure and browser-safe: `REPLACED_BY` (12 model ids → the model that does the job now, with `was`, the name it ran under, a `note`, and `original`, `ops`, `withReferences` and `director` where they apply), `TRAINING_REPLACED_BY`, `OPS_REPLACED_BY`, `replacedBy`, `currentModelId`, `replacementOf` and `migrateRequest` (see Retired models) |
-| `models.ts` | Open-source models (ComfyUI workflow ids), fal utility models (Join clips, and the hidden Extract frame, Crop to size, Mix voice and music, Level audio, Forced Alignment), the browser-only models (`local` provider: Color Grade, Ad compositor) + the generated cloud lists (whose hidden chain helpers include Trim video, Add soundtrack, Voice timeline and Extract soundtrack). A launch price (`Pricing.promo`) is applied when the list loads (`withCurrentPrice` → `pricingAt`). Since round 4 part 3 `MODELS` starts with the Fuobe Originals: `original()` joins each one's ComfyUI routes to its generated cloud half. Since round 4 part 5 the cloud list is `CLOUD_MODELS` and the cloud tools only (no Higgsfield models or routes are joined, and the hand-written `ai-influencer` is gone), and two hidden open models run Character Swap Studio's graphs: `oss-h3-swap-segment` (`video-swap` on `video-character-swap-h3-segment`) and `oss-h3-person-mask` (`bg-remove-video` on `video-mask-h3-relay`). Since round 5 part 1 `originals` holds the eight new Originals' GPU halves, `oss-video-depth-vda-large` joins the open list, the hidden `oss-face-mosaic` (`face-mosaic` on `image-face-mosaic-sam3`) is the face mosaic's GPU step, and `oss-tryon-klein` carries the try-on LoRA in `ModelOptions.loras`, so its switch governs it |
+| `models.ts` | Open-source models (ComfyUI workflow ids), fal utility models (Join clips, and the hidden Extract frame, Crop to size, Mix voice and music, Level audio, Forced Alignment), the browser-only models (`local` provider: Color Grade, Ad compositor) + the generated cloud lists (whose hidden chain helpers include Trim video, Add soundtrack, Voice timeline and Extract soundtrack). A launch price (`Pricing.promo`) stays beside the list price (see `promo.ts`): the catalog never reads the clock. Since round 4 part 3 `MODELS` starts with the Fuobe Originals: `original()` joins each one's ComfyUI routes to its generated cloud half. Since round 4 part 5 the cloud list is `CLOUD_MODELS` and the cloud tools only (no Higgsfield models or routes are joined, and the hand-written `ai-influencer` is gone), and two hidden open models run Character Swap Studio's graphs: `oss-h3-swap-segment` (`video-swap` on `video-character-swap-h3-segment`) and `oss-h3-person-mask` (`bg-remove-video` on `video-mask-h3-relay`). Since round 5 part 1 `originals` holds the eight new Originals' GPU halves, `oss-video-depth-vda-large` joins the open list, the hidden `oss-face-mosaic` (`face-mosaic` on `image-face-mosaic-sam3`) is the face mosaic's GPU step, and `oss-tryon-klein` carries the try-on LoRA in `ModelOptions.loras`, so its switch governs it |
| `llm-models.ts` | `text-llm` (cloud: Claude, else Ollama) and `oss-text-llm` (open: Ollama, never Claude; since round 4 its translations run on ComfyUI's Qwen3.5 4B, `oss-qwen35-translate`, when Ollama isn't running), kind `text`, ops `translate` and `write` |
| `elements.ts` | Elements (character / location / prop / style / voice), `@handle` parsing and `applyMentions`; since round 4 part 4 an element holds up to 80 photos (`MAX_ELEMENT_PHOTOS`) and a mention brings its trained LoRA to every model of the LoRA's family on either engine (`identityFor`); since round 4 part 5 an older Soul ID (Higgsfield's `referenceId`) goes to no model; the element shows "Older Soul ID" with "Retrain for Fuobe Soul" (nothing retrains by itself) |
| `sketch.ts` | `applySketch` (masks and drawings → the right operation and inputs) |
@@ -84,7 +84,8 @@ Feed, Library, studios (React Query caches patched by id; polls every 10 s while
| `lora-library.generated.ts` | 118 researched LoRAs (67 looks, 23 motions, 24 effects and, since round 5 part 1, 4 adapters), each with its pinned download, a unique local file name, SHA256, size and licence snapshot, plus the motion / effect preset → LoRA map (`MOTION_EFFECT_LORAS`). **Generated** by `scripts/gen-lora-library.py` from `fuobe-originals-recipes-5.json`. The downloader and Settings → LoRAs read it. Since round 4 part 3 Fuobe Soul's looks name its keys, and a DoP preset's LoRA that is a library file (47 of the map's 99) takes its pinned download and licence from it. Since round 5 part 1 the group `adapter` (the research's `adapterLoras`) holds the LoRAs an Original's recipe always loads: the try-on LoRA for FLUX.2 [klein] 4B, next-scene for Qwen-Image-Edit 2509, dx8152's Multiple-angles for 2509 and FusioniX for Wan 2.1 I2V 14B; and `MIXED_MEDIA_LOOK_LORAS` maps 14 of the 33 Mixed Media looks to a Z-Image LoRA (read by `mixed-media-looks.ts`' `mixedLoras`, kept apart so the studio page doesn't ship the library) |
| `influencer-options.generated.ts` | The AI Influencer builder's data: 19 categories (Character type first) and their options, the 6 creature types with species, Shuffle's weights and the two clash messages (`CONFLICT_MESSAGES`). **Generated** by `scripts/gen-influencer-options.py` from `docs/research/higgsfield-delta-4.json`; the rules and the prompt compiler are in `src/lib/influencer.ts` |
| `index.ts` | Lookup helpers; motions and effects through `dopPreset` (effects also `withPrestepPrice`: the relight step's price), round-1 Wan LoRAs on video apps (`withOssLoras`), the apps' dedicated open workflows (`APP_OPEN_OVERRIDES`: ReActor, the Qwen relight, the try-on); registers the LLM models. Since round 4 part 3 `modelsFor` lists an Original for an operation only on the engines whose routes run it; since round 5 part 1 `withPrestepPrice` prices a prestep on its model's cloud half (`onEngine(m, "cloud")`), so a prestep on an Original has a cloud price |
-| `plan.ts` | Pure planning logic (operation inference, prompt composition, batching, input validation, cost estimate, `pricingAt`, `routeLoras`); since round 4 part 3 the Soul plan (`Plan.soul`, `Plan.notes`), `mixLoras`, and per-megapixel prices for every picture made; since round 4 part 4 `withoutTriggers` (a LoRA left out takes its trigger word with it), a character's strength scaling its LoRA on every model, and video priced per megapixel (`videoMegapixels`: the tier's real size × frames, Fuobe Cinema's LTX-2.3); since round 5 part 1 a model's recipe LoRAs (`ModelOptions.loras`) go before the user's with their trigger words first, `defaultPrompt` fills an empty prompt, an app route's `look` runs `soulRecipe` on a model that isn't Soul (`routeLook`; a Soul model given an app's preset id reads it as the app, not a look), Fuobe Angles' camera fields become words on the GPU or are refused when the camera doesn't move, a talking avatar is priced on its voice (`avatarSeconds`, from `params.sourceDuration`), a clip edit that keeps the clip's length on the clip's seconds capped at the model's window (`clipEditSeconds`, fixes-5), and a megapixel model on the size sent as `params.extra.image_size` |
+| `plan.ts` | Pure planning logic (operation inference, prompt composition, batching, input validation, cost estimate (a launch price read at its `now`), `routeLoras`); since round 4 part 3 the Soul plan (`Plan.soul`, `Plan.notes`), `mixLoras`, and per-megapixel prices for every picture made; since round 4 part 4 `withoutTriggers` (a LoRA left out takes its trigger word with it), a character's strength scaling its LoRA on every model, and video priced per megapixel (`videoMegapixels`: the tier's real size × frames, Fuobe Cinema's LTX-2.3); since round 5 part 1 a model's recipe LoRAs (`ModelOptions.loras`) go before the user's with their trigger words first, `defaultPrompt` fills an empty prompt, an app route's `look` runs `soulRecipe` on a model that isn't Soul (`routeLook`; a Soul model given an app's preset id reads it as the app, not a look), Fuobe Angles' camera fields become words on the GPU or are refused when the camera doesn't move, a talking avatar is priced on its voice (`avatarSeconds`, from `params.sourceDuration`), a clip edit that keeps the clip's length on the clip's seconds capped at the model's window (`clipEditSeconds`, fixes-5), and a megapixel model on the size sent as `params.extra.image_size` |
+| `promo.ts` | Launch prices (`Pricing.promo`, N7-5): `pricingAt` / `pricingOn` give the price that holds at a time, to the end of the launch's last day (UTC). Whoever prices reads the clock: the server when it plans a run (a run is priced at the rate of the day it runs, even on a server started before), the browser when it shows a price (`useToday` in `src/hooks/use-today.ts`: the composer, the model picker, the Models page's `rowPrice`). A page prerendered at build time reads none (`now` null: a launch-priced model shows its price once the browser knows the day) |
| `payload.ts` | `buildPayload(FieldMap, GenInput)`, `extractMedia(response)`, `extractOutputs(response, op)` (structured outputs), `keepMatte` and `noOutputsError`; `sizeValue` takes an exact size table per tier and writes one `{width, height}` field when the map names a `key` (round 4 part 3: Fuobe Soul, fal's `image_size`); since round 4 part 5 `pointsValue` adds `frame_index` to a SAM point clicked on a later frame (`PixelPoint.frame`); since round 5 part 1 `numFrames.multiple` (fal's Wan 2.2 S2V takes 4n frames) and `faceMaskOutputs` (fal SAM 3.1's masks for the face mosaic, as `meta.role` `mask` outputs) |
| `palettes.ts` | `applySignature` (Color signature / Moodboard picks → native palette, style id, or words) and `withSignatureWords`; since round 4 part 3 curated moodboards are Fuobe Soul looks, and `locksByDefault` turns the palette lock on for Soul models; since round 4 part 4 a moodboard trained as a style LoRA runs as Fuobe Soul's `own-style` look on the Z-Image family, on either engine |
| `keyframes.ts` | Frames mode: which models take keyframes and how (`frameSupport`, `FRAMES_MODELS`), the strip's blockers and notes, gap checks (`chainGapProblem`) and the open film's clip plan (`planKeyframeClips`) |
diff --git a/src/app/(studio)/layers/[id]/page.tsx b/src/app/(studio)/layers/[id]/page.tsx
index 98051b3e..1efd6296 100644
--- a/src/app/(studio)/layers/[id]/page.tsx
+++ b/src/app/(studio)/layers/[id]/page.tsx
@@ -20,7 +20,10 @@ function toolModels(): Record<string, LayerModelInfo> {
name: m.name,
engine: m.engine,
tagline: m.tagline,
- ...(m.pricing ? { pricing: { unit: m.pricing.unit, usd: m.pricing.usd, ...(m.pricing.note ? { note: m.pricing.note } : {}) } } : {}),
+ // A launch price goes too: the editor shows the one of the day it is (costLabel), never one read here.
+ ...(m.pricing
+ ? { pricing: { unit: m.pricing.unit, usd: m.pricing.usd, ...(m.pricing.note ? { note: m.pricing.note } : {}), ...(m.pricing.promo ? { promo: m.pricing.promo } : {}) } }
+ : {}),
providers: [...new Set(m.routes.map((r) => r.provider))],
};
}
diff --git a/src/app/api/models/route.ts b/src/app/api/models/route.ts
index a512bc7b..4b108e3a 100644
--- a/src/app/api/models/route.ts
+++ b/src/app/api/models/route.ts
@@ -4,6 +4,7 @@ import { onEngine, runsOn } from "@/lib/catalog/engines";
import { ENGINE_MODELS } from "@/lib/catalog/faceless";
import { OPERATION_LABELS, type Engine, type MediaKind, type ModelDef, type Operation } from "@/lib/catalog/types";
import { findModels, MODEL_KINDS, toModelInfo } from "@/lib/model-list";
+import { rowPrice } from "@/lib/model-rows";
import { AUDIO_STUDIO, DIALOGUE_STUDIO, EDIT_STUDIO, IMAGE_STUDIO, VIDEO_STUDIO } from "@/lib/studios";
import { provider } from "@/server/providers";
import { llmBackends } from "@/server/providers/llm";
@@ -75,5 +76,11 @@ export const GET = handler({ access: "signed-in" }, async (request: Request) =>
Object.entries(DEFAULTS).map(([k, ids]) => [k, { ...(mode !== "open" && ids.cloud && { cloud: pick(ids.cloud, "cloud") }), ...(mode !== "cloud" && ids.open && { open: pick(ids.open, "open") }) }]),
);
const demoMode = getSetting("demoMode");
- return Response.json({ engineMode: mode, demoMode, defaults, items: list.map((m) => ({ ...toModelInfo(m), connected: connected(m), runs: runsAs(m, demoMode) })) });
+ // The price of the day asked (a launch price while it lasts); the row keeps the launch price and its last day too.
+ const now = Date.now();
+ const items = list.map((m) => {
+ const info = toModelInfo(m);
+ return { ...info, price: rowPrice(info, now), connected: connected(m), runs: runsAs(m, demoMode) };
+ });
+ return Response.json({ engineMode: mode, demoMode, defaults, items });
});
diff --git a/src/components/layers/editor-context.tsx b/src/components/layers/editor-context.tsx
index 4a6bc5ce..b2c490d8 100644
--- a/src/components/layers/editor-context.tsx
+++ b/src/components/layers/editor-context.tsx
@@ -1,6 +1,7 @@
"use client";
import { createContext, useContext } from "react";
+import { pricingAt } from "@/lib/catalog/promo";
import type { Engine } from "@/lib/catalog/types";
import { formatCost } from "@/lib/format";
import type { Box, LayerDoc, LayerJob, LayerJobInput, LayerModelInfo, LayerNode, LayerProject, LayerTool, LayerVersion } from "@/lib/layers";
@@ -132,12 +133,16 @@ export function useEditor(): EditorCtx {
return c;
}
-/** "Demo · free", "Free · your GPU", "≈ $0.27" or "Price unknown". */
+/**
+ * "Demo · free", "Free · your GPU", "≈ $0.27" or "Price unknown". A launch price is read on the browser's clock, the day
+ * the editor shows it (the editor renders once its project has loaded in the browser, never while a page prerenders).
+ */
export function costLabel(m: LayerModelInfo | undefined, demo: boolean, usd?: number | null): string {
if (!m) return "";
if (demo) return "Demo · free";
if (m.engine === "open") return "Free · your GPU";
- const v = usd !== undefined ? usd : m.pricing && ["image", "request", "megapixel"].includes(m.pricing.unit) ? m.pricing.usd : null;
+ const p = m.pricing && pricingAt(m.pricing);
+ const v = usd !== undefined ? usd : p && ["image", "request", "megapixel"].includes(p.unit) ? p.usd : null;
return v == null ? "Price unknown" : v === 0 ? "Free" : `≈ ${formatCost(v)}`;
}
diff --git a/src/components/models-table.tsx b/src/components/models-table.tsx
index 31456a76..a7f6fcf1 100644
--- a/src/components/models-table.tsx
+++ b/src/components/models-table.tsx
@@ -4,12 +4,13 @@ import { Cloud, Cpu, Info, Search } from "lucide-react";
import { useSearchParams } from "next/navigation";
import { memo, Suspense, useDeferredValue, useEffect, useMemo, useRef, useState } from "react";
import { useProgressive } from "@/components/use-progressive";
+import { useToday } from "@/hooks/use-today";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import Link from "next/link";
import { useEngine, useModelAccess } from "@/lib/api";
import { offered } from "@/lib/model-access";
import type { Engine, MediaKind } from "@/lib/catalog/types";
-import { enginesLabel, modelSearchText, type ModelRow } from "@/lib/model-rows";
+import { enginesLabel, modelSearchText, rowPrice, type ModelRow } from "@/lib/model-rows";
import { cn } from "@/lib/utils";
const KIND_LABEL: Partial<Record<MediaKind, string>> = { image: "Image", video: "Video", audio: "Audio", text: "Text", model3d: "3D" };
@@ -52,7 +53,9 @@ function RouteDetails({ row }: { row: ModelRow }) {
);
}
-const Row = memo(function Row({ m }: { m: ModelRow }) {
+/** One model; `today` (the browser's day, null while the page prerenders) picks a launch price or the list price. */
+const Row = memo(function Row({ m, today }: { m: ModelRow; today: number | null }) {
+ const price = rowPrice(m, today);
return (
<tr className="align-top hover:bg-accent/50">
<td className="px-3 py-3 sm:px-4">
@@ -78,7 +81,7 @@ const Row = memo(function Row({ m }: { m: ModelRow }) {
</div>
{m.note && <div className="mt-0.5 text-[11px] text-muted-foreground">{m.note}</div>}
<div className="mt-1 text-[11px] text-muted-foreground md:hidden">
- <span className="font-mono text-muted-foreground sm:hidden">{m.price} · </span>
+ {price && <span className="font-mono text-muted-foreground sm:hidden">{price} · </span>}
{m.ops.join(" · ")}
</div>
</td>
@@ -90,7 +93,7 @@ const Row = memo(function Row({ m }: { m: ModelRow }) {
</span>
</td>
<td className="hidden px-4 py-3 text-[12px] text-muted-foreground md:table-cell">{m.ops.join(" · ")}</td>
- <td className="hidden px-4 py-3 font-mono text-[12px] whitespace-nowrap sm:table-cell">{m.price}</td>
+ <td className="hidden px-4 py-3 font-mono text-[12px] whitespace-nowrap sm:table-cell">{price}</td>
<td className="px-2 py-2.5 text-right">
<RouteDetails row={m} />
</td>
@@ -117,6 +120,7 @@ export function ModelsTable({ models }: { models: ModelRow[] }) {
const [kind, setKind] = useState<MediaKind | "all">("all");
const [q, setQ] = useState("");
const term = useDeferredValue(q.trim().toLowerCase());
+ const today = useToday();
// Settings → Models & licences: what is switched off leaves the list (an Original stays for the engine still on).
const access = useModelAccess();
const on = useMemo(() => (access ? models.filter((m) => offered(access, m.id)) : models), [models, access]);
@@ -199,7 +203,7 @@ export function ModelsTable({ models }: { models: ModelRow[] }) {
</thead>
<tbody ref={rows} className="divide-y">
{list.slice(0, shown).map((m) => (
- <Row key={m.id} m={m} />
+ <Row key={m.id} m={m} today={today} />
))}
</tbody>
</table>
diff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsx
index 611ec13c..8dc8ae23 100644
--- a/src/components/studio/composer.tsx
+++ b/src/components/studio/composer.tsx
@@ -9,6 +9,7 @@ import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Kbd } from "@/components/ui/kbd";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
+import { useToday } from "@/hooks/use-today";
import { estimateCost, planGeneration, routesFor } from "@/lib/catalog/plan";
import type { Engine, GenerationRequest, MediaKind, ModelDef, Operation, Preset, VideoFormat } from "@/lib/catalog/types";
import { dualEngine } from "@/lib/catalog/engines";
@@ -220,6 +221,8 @@ export function Composer({ docked }: { docked: boolean }) {
const hydrated = useHydrated();
const liveStatus = useStatus().data;
const status = hydrated ? liveStatus : undefined;
+ // The day a launch price is read on: the browser's, once hydrated (none while the page prerenders: no price shown then).
+ const today = useToday();
// Upscale hub: the attached clip's header (length, size, frame rate). Its length prices per-second tools and
// travels with the request (params.sourceDuration); a clip swapped since a Reuse never keeps the old one's.
const facts = useClipFacts(config.clipFacts && !typed.slots.video?.uploading ? typed.slots.video?.ref : undefined).data;
@@ -435,12 +438,12 @@ export function Composer({ docked }: { docked: boolean }) {
op = plan.op;
// 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);
// PixeletedFace pixelates each picture's faces afterwards ($0.01 a picture in the cloud, free on the GPU).
- if (cost !== null) cost += postStepCost(plan.model.id, planned.presetId, engine, planned.params?.numOutputs ?? 1, catalog.getModel);
+ if (cost !== null) cost += postStepCost(plan.model.id, planned.presetId, engine, planned.params?.numOutputs ?? 1, catalog.getModel, today);
} catch (e) {
planError = (e as Error).message;
}
diff --git a/src/components/studio/model-picker.tsx b/src/components/studio/model-picker.tsx
index 749e1c55..b6cdccda 100644
--- a/src/components/studio/model-picker.tsx
+++ b/src/components/studio/model-picker.tsx
@@ -7,11 +7,11 @@ import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Command, CommandGroup, CommandInput, CommandItem, CommandList } from "@/components/ui/command";
import { useIsMobile } from "@/hooks/use-mobile";
+import { useToday } from "@/hooks/use-today";
import { type Engine, type ModelDef } from "@/lib/catalog/types";
import { useEngineMode, useStatus } from "@/lib/api";
import { bestForStudio, groupModels, toggleIn } from "@/lib/composer";
-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 { EngineSwitch } from "./engine-switch";
import { ResponsivePanel } from "./responsive-panel";
@@ -53,13 +53,6 @@ export function ModelBadges({ model, max }: { model: ModelDef; max?: number }) {
);
}
-function priceHint(m: ModelDef): string {
- if (m.engine === "open") return "Free";
- if (!m.pricing) return "";
- const unit = { image: "/image", second: "/sec", video: "/video", request: "/run", megapixel: "/MP", minute: "/min" }[m.pricing.unit];
- return `${formatCost(m.pricing.usd)}${unit}`;
-}
-
const STAR_KEY_HINT = "Alt+S";
/**
@@ -80,12 +73,15 @@ function ModelRow({
selected,
starred,
showEngine,
+ today,
onStar,
}: {
m: ModelDef;
selected: boolean;
starred: boolean;
showEngine: 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;
}) {
return (
@@ -115,7 +111,7 @@ function ModelRow({
</span>
)}
</span>
- <span className="shrink-0 text-right text-[11px] text-muted-foreground tabular-nums">{priceHint(m)}</span>
+ <span className="shrink-0 text-right text-[11px] text-muted-foreground tabular-nums">{pickerPrice(m, today)}</span>
{/* Pointer only: inside an option it would be a nested control. Keyboard: Alt+S on the highlighted row (starKey). */}
<button
type="button"
@@ -184,6 +180,7 @@ function PickerList({ models, value, onChange, engine, onEngineChange, defaultMo
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.
const best = useMemo(() => {
@@ -239,7 +236,7 @@ function PickerList({ models, value, onChange, engine, onEngineChange, defaultMo
data-checked={value?.id === m.id}
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} onStar={() => setStarred((s) => toggleIn(s, m.id))} />
+ <ModelRow m={m} selected={value?.id === m.id} starred={starred.includes(m.id)} showEngine={!!q || m.engine !== engine} today={today} onStar={() => setStarred((s) => toggleIn(s, m.id))} />
</CommandItem>
))}
</CommandGroup>
diff --git a/src/hooks/use-today.ts b/src/hooks/use-today.ts
new file mode 100644
index 00000000..dcd39a9f
--- /dev/null
+++ b/src/hooks/use-today.ts
@@ -0,0 +1,45 @@
+"use client";
+
+import { useSyncExternalStore } from "react";
+
+const DAY = 86_400_000;
+
+/** The start of today in UTC (ms). A launch price holds to the end of its last day (UTC), so the day is all a price needs. */
+export const startOfDayUtc = (now: number) => now - (now % DAY);
+
+const listeners = new Set<() => void>();
+let timer: ReturnType<typeof setTimeout> | null = null;
+const tell = () => listeners.forEach((l) => l());
+
+/** Just after the next UTC midnight, the day changes (one timer for every price on the page). */
+function arm() {
+ timer = setTimeout(() => {
+ tell();
+ arm();
+ }, DAY - (Date.now() % DAY) + 1000);
+}
+
+function subscribe(cb: () => void) {
+ listeners.add(cb);
+ if (listeners.size === 1) {
+ arm();
+ // A laptop that slept through midnight: the day is read again when the page is seen.
+ document.addEventListener("visibilitychange", tell);
+ }
+ return () => {
+ listeners.delete(cb);
+ if (listeners.size) return;
+ if (timer) clearTimeout(timer);
+ timer = null;
+ document.removeEventListener("visibilitychange", tell);
+ };
+}
+
+/**
+ * The day it is (its UTC midnight, in ms) for a price with a launch promo (src/lib/catalog/promo.ts): null on the server
+ * and while the page hydrates, so a page prerendered at build time never reads the clock and shows no launch-priced
+ * model's price until the browser knows the day; then the price of the day the person looks, changing at UTC midnight.
+ */
+export function useToday(): number | null {
+ return useSyncExternalStore(subscribe, () => startOfDayUtc(Date.now()), () => null);
+}
diff --git a/src/lib/catalog/faceless.ts b/src/lib/catalog/faceless.ts
index 34d8e8d4..a479a21c 100644
--- a/src/lib/catalog/faceless.ts
+++ b/src/lib/catalog/faceless.ts
@@ -1,5 +1,6 @@
import { describeMove, KEN_BURNS_FPS, sceneMoves } from "@/lib/av/ken-burns";
import { estimateCost } from "./plan";
+import { pricingAt } from "./promo";
import type { ChainSlot, Engine, Generation, GenerationRequest, ModelDef } from "./types";
/*
@@ -1469,7 +1470,8 @@ export const CAMERA_WORDS: Record<Engine, { placeholder: string; hint: string; s
export function stepCostUsd(model: ModelDef | undefined, request: GenerationRequest, seconds?: number): number | null {
if (!model) return null;
if (model.engine === "open") return 0;
- const p = model.pricing;
+ // A launch price while it lasts (./promo): read when the episode is priced.
+ const p = model.pricing && pricingAt(model.pricing);
if (!p) return null;
const params = { ...model.defaults, ...request.params, ...(seconds !== undefined && (p.unit === "second" || p.unit === "minute") && { duration: seconds }) };
if (p.unit === "request" && /per 1k char/i.test(p.note ?? "")) {
diff --git a/src/lib/catalog/models.ts b/src/lib/catalog/models.ts
index 31b72ecb..7db51089 100644
--- a/src/lib/catalog/models.ts
+++ b/src/lib/catalog/models.ts
@@ -1,5 +1,4 @@
import { CLOUD_MODELS, ORIGINAL_CLOUD } from "./cloud-models.generated";
-import { pricingAt } from "./plan";
import { DEFAULT_FPS_TARGET, FPS_TARGETS, SLOW_MOTION } from "@/lib/av/fps";
import { ASR_LANGUAGES, WHISPER_LANGUAGES } from "../speech-languages";
import { loraEntry, loraRef } from "./loras";
@@ -1623,19 +1622,11 @@ function withLastFrameExtend(m: ModelDef): ModelDef {
}
/**
- * A launch price while it lasts, the list price after (FLUX 3 Max, H3 Max camera controls): read each time the price is,
- * so a run is priced at the rate of the day it runs, even on a server started before the launch price ended.
+ * Cloud models (fal and Replicate) and the cloud tools. A launch price (FLUX 3 Max, H3 Max camera controls) stays in
+ * Pricing.promo beside the list price: whoever prices reads the clock (./promo), never the catalog, so the studios'
+ * slices and the pages prerendered at build time carry both and the browser shows the one of the day it is.
*/
-const withCurrentPrice = (m: ModelDef): ModelDef => {
- const raw = m.pricing;
- if (!raw?.promo) return m;
- const out = { ...m };
- Object.defineProperty(out, "pricing", { get: () => pricingAt(raw), enumerable: true, configurable: true });
- return out;
-};
-
-/** Cloud models (fal and Replicate) and the cloud tools. */
-const cloud: ModelDef[] = [...CLOUD_MODELS.map(withLastFrameExtend).map(withCurrentPrice), ...cloudTools];
+const cloud: ModelDef[] = [...CLOUD_MODELS.map(withLastFrameExtend), ...cloudTools];
// ---------------------------------------------------------------------------
// Fuobe Originals: one model on both engines
diff --git a/src/lib/catalog/plan.ts b/src/lib/catalog/plan.ts
index cc2e6361..f0f84312 100644
--- a/src/lib/catalog/plan.ts
+++ b/src/lib/catalog/plan.ts
@@ -9,7 +9,6 @@ import type {
Operation,
Preset,
PresetRoute,
- Pricing,
} from "./types";
import { sourceSeconds } from "./clip-windows";
import { chainGapProblem, chainTiming, FIRST_AT_ZERO, frameTimes, keyframeChain, MAX_KEYFRAMES, spread } from "./keyframes";
@@ -17,6 +16,9 @@ import { cloudPath, fitLoras, gated, localOnly, loraCapacity, needsToken, routeL
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 { pricingOn, type PriceClock } from "./promo";
+
+export { pricingAt } from "./promo";
/** Infer the operation from what the user attached. */
export function inferOperation(model: ModelDef, req: Pick<GenerationRequest, "op" | "inputs" | "params">): Operation {
@@ -613,14 +615,6 @@ function missingImages(model: ModelDef, req: Pick<GenerationRequest, "inputs">):
return labels?.length === min ? `Add the ${labels.join(" and the ")}` : `${model.name} needs ${min} images`;
}
-/** The price that holds at `now`: a launch promo to the end of its last day (UTC), then the list price. */
-export function pricingAt(p: Pricing, now = Date.now()): Pricing {
- if (!p.promo) return p;
- const { promo, ...list } = p;
- if (!(now <= Date.parse(`${promo.until}T23:59:59.999Z`))) return list;
- return { ...list, usd: promo.usd, ...(promo.byResolution ? { byResolution: promo.byResolution } : {}) };
-}
-
/**
* Operations whose result is as long as the clip they're given (upscale, FPS Boost, HDR, export): a per-second
* price counts the clip's seconds (params.sourceDuration) when the caller knows them, and slow motion bills
@@ -723,10 +717,15 @@ function routeMegapixels(model: ModelDef, params: GenParams, op?: Operation): nu
return (width * height) / (1024 * 1024);
}
-/** Rough USD estimate for a plan (BYO-key cloud runs). Open-source runs are free. */
-export function estimateCost(model: ModelDef, params: GenParams, jobs = 1, op?: Operation, withLoras = false): number | null {
+/**
+ * Rough USD estimate for a plan (BYO-key cloud runs). Open-source runs are free. A launch price (Pricing.promo) is read
+ * at `now` (./promo): the clock when not given (the server planning a run, the browser after it hydrates); with null (a
+ * page prerendering, the browser before it hydrates) a launch-priced model's price isn't known yet (null).
+ */
+export function estimateCost(model: ModelDef, params: GenParams, jobs = 1, op?: Operation, withLoras = false, now?: PriceClock): number | null {
if (model.engine === "open" || !model.pricing) return model.engine === "open" ? 0 : null;
- const p = model.pricing;
+ const p = pricingOn(model.pricing, now);
+ if (!p) return null;
// A LoRA endpoint with no published price (fal's MOSS-Image /lora): unknown, never free.
if (withLoras && p.lorasUnknown) return null;
const n = params.numOutputs ?? 1;
diff --git a/src/lib/catalog/promo.ts b/src/lib/catalog/promo.ts
new file mode 100644
index 00000000..11b677d7
--- /dev/null
+++ b/src/lib/catalog/promo.ts
@@ -0,0 +1,47 @@
+import type { Pricing } from "./types";
+
+/*
+ * Launch prices (Pricing.promo: FLUX 3 Max, H3 Max camera controls). The catalog keeps the list price and the launch
+ * price side by side and never reads the clock: whoever prices a run reads its own. The server reads it when it plans
+ * a run, so a run is priced at the rate of the day it runs, even on a server started before the launch price ended;
+ * the browser reads it when it shows a price (useToday), so the price a person sees is the one of the day they look.
+ * A page prerendered at build time reads none: it carries the launch price for the browser to pick.
+ */
+
+/** A price with a launch promo or not: the catalog's Pricing, or a slim copy of it sent to a page. */
+export interface PromoPrice {
+ usd: number;
+ byResolution?: Record<string, number>;
+ promo?: Pricing["promo"];
+}
+
+/**
+ * The time a price is read at: a time in ms; undefined, the clock now (the server planning a run, the browser after it
+ * hydrates); null where no clock may be read (a page prerendering at build time, the browser before it hydrates).
+ */
+export type PriceClock = number | null | undefined;
+
+/** Whether a launch price whose last day (UTC, YYYY-MM-DD) is `until` holds at `now`: to the end of that day. */
+export function launchHolds(until: string, now: number): boolean {
+ return now <= Date.parse(`${until}T23:59:59.999Z`);
+}
+
+/**
+ * The price that holds at `now`: a launch promo to the end of its last day (UTC), then the list price, either way without
+ * the promo record. The clock is read only for a price with a promo when no `now` is given.
+ */
+export function pricingAt<P extends PromoPrice>(p: P, now?: number): P {
+ if (!p.promo) return p;
+ const { promo, ...list } = p;
+ if (!launchHolds(promo.until, now ?? Date.now())) return list as P;
+ return { ...list, usd: promo.usd, ...(promo.byResolution ? { byResolution: promo.byResolution } : {}) } as P;
+}
+
+/**
+ * pricingAt for a caller that may have no clock: with `now` null, a price with a launch promo is undefined (which of the
+ * two holds isn't known yet) and one without is itself; otherwise the price that holds at `now`.
+ */
+export function pricingOn<P extends PromoPrice>(p: P, now: PriceClock): P | undefined {
+ if (p.promo && now === null) return undefined;
+ return pricingAt(p, now ?? undefined);
+}
diff --git a/src/lib/catalog/shorts-models.ts b/src/lib/catalog/shorts-models.ts
index 1213b5ee..a1994554 100644
--- a/src/lib/catalog/shorts-models.ts
+++ b/src/lib/catalog/shorts-models.ts
@@ -8,6 +8,7 @@ import { sourceSeconds } from "./clip-windows";
import { onEngine } from "./engines";
import { getModel } from "./index";
import { routesFor } from "./plan";
+import { pricingOn } from "./promo";
import { SHORTS, SHORTS_ORIGINAL } from "./shorts";
import type { Engine, ModelDef } from "./types";
@@ -75,10 +76,11 @@ export interface RestyleModelInfo {
/**
* What one unit costs at the resolution the studios ask for. Fuobe Shorts in the cloud bills frames ÷ 16 as seconds:
- * a second of a 30 fps clip, the common case, is shown.
+ * a second of a 30 fps clip, the common case, is shown. Read for the studio pages, prerendered at build time, so the
+ * clock isn't (`now` null by default): a launch-priced model's unit price is unknown there (./promo).
*/
-export function unitPrice(m: ModelDef): number | null {
- const p = m.pricing;
+export function unitPrice(m: ModelDef, now: number | null = null): number | null {
+ const p = m.pricing && pricingOn(m.pricing, now);
if (!p) return null;
const res = resolutionFor(m.id, m.engine) ?? m.defaults?.resolution;
const usd = (res && p.byResolution?.[res]) || p.usd;
diff --git a/src/lib/catalog/types.ts b/src/lib/catalog/types.ts
index d1f39740..90550e5c 100644
--- a/src/lib/catalog/types.ts
+++ b/src/lib/catalog/types.ts
@@ -630,7 +630,8 @@ export interface Pricing {
byResolution?: Record<string, number>;
/**
* A launch price that runs to the end of `until` (UTC, YYYY-MM-DD); `usd` / `byResolution` are the list
- * prices after it. The catalog applies whichever holds when it loads (FLUX 3 Max: $0.0425/s until 2026-11-07, then $0.17/s).
+ * prices after it (FLUX 3 Max: $0.0425/s until 2026-11-07, then $0.17/s). The catalog keeps both: whoever prices picks
+ * the one that holds when it reads its clock (./promo: the server when it plans a run, the browser when it shows one).
*/
promo?: { until: string; usd: number; byResolution?: Record<string, number> };
/**
diff --git a/src/lib/composer.ts b/src/lib/composer.ts
index 25c1c0f0..05fd3b8b 100644
--- a/src/lib/composer.ts
+++ b/src/lib/composer.ts
@@ -10,6 +10,7 @@ import { wholeClipProblem, wholeClipTool } from "./av/video-finish";
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 { spokenLanguageName } from "./speech-languages";
@@ -749,10 +750,18 @@ export function followEngineParams(params: GenParams, from: GenParams, to: GenPa
* A step after the run that costs on its own: Fuobe Soul's PixeletedFace look pixelates each picture's faces (SAM 3.1:
* free on the GPU, fal's per-request price in the cloud), one step per picture.
*/
-export function postStepCost(modelId: string | undefined, look: string | undefined, engine: Engine, pictures: number, getModel: (id: string) => ModelDef | undefined): number {
+export function postStepCost(
+ modelId: string | undefined,
+ look: string | undefined,
+ engine: Engine,
+ pictures: number,
+ getModel: (id: string) => ModelDef | undefined,
+ now?: PriceClock,
+): number {
if (!modelId || soulPostStep(modelId, look) !== "face-mosaic") return 0;
const step = getModel(FACE_MOSAIC_MODELS[engine]);
- return step?.engine === "cloud" && step.pricing?.unit === "request" ? step.pricing.usd * Math.max(1, pictures) : 0;
+ const price = step?.engine === "cloud" && step.pricing ? pricingOn(step.pricing, now) : undefined;
+ return price?.unit === "request" ? price.usd * Math.max(1, pictures) : 0;
}
/**
diff --git a/src/lib/layers.ts b/src/lib/layers.ts
index 022f5f8b..1b8f638d 100644
--- a/src/lib/layers.ts
+++ b/src/lib/layers.ts
@@ -9,6 +9,7 @@
* Full-canvas RGBA layers (Qwen-Image-Layered) are cropped to their alpha box, so selection handles
* hug what you see.
*/
+import type { Pricing } from "./catalog/types";
export type Box = [x: number, y: number, w: number, h: number];
@@ -341,7 +342,8 @@ export interface LayerModelInfo {
name: string;
engine: "cloud" | "open";
tagline: string;
- pricing?: { unit: string; usd: number; note?: string };
+ /** Its price; a launch price (Pricing.promo) holds through its last day (costLabel reads the browser's clock). */
+ pricing?: { unit: string; usd: number; note?: string; promo?: Pricing["promo"] };
/** Providers its routes run on (demo detection: none of them connected). */
providers: string[];
}
diff --git a/src/lib/model-rows.ts b/src/lib/model-rows.ts
index f8e2a8cc..ebb340f4 100644
--- a/src/lib/model-rows.ts
+++ b/src/lib/model-rows.ts
@@ -1,6 +1,7 @@
/** Slim rows for the Models page: what the table shows, computed on the server from the catalog. */
import { formatCost } from "./format";
import { enginesOf, providerEngine } from "./catalog/engines";
+import { launchHolds, pricingOn, type PriceClock } from "./catalog/promo";
import { OPERATION_LABELS, type Engine, type MediaKind, type ModelDef } from "./catalog/types";
export interface ModelRow {
@@ -19,7 +20,13 @@ export interface ModelRow {
ops: string[];
/** Provider routes ("fal: fal-ai/flux/dev"), shown in the row's details popover. */
routes: string[];
+ /** The list price ("$0.17 / second", "Free · …" for a Fuobe Original, "Free"). */
price: string;
+ /**
+ * A launch price and its last day (UTC): the price through the end of that day, `price` after (rowPrice). The row
+ * carries both, so the Models page, prerendered at build time, shows the one of the day it is looked at.
+ */
+ launch?: { until: string; price: string };
/** Where it runs when that's not the obvious place ("Runs on the isolated ComfyUI worker"). */
note?: string;
}
@@ -42,7 +49,9 @@ const BADGE_LABEL: Record<string, string> = {
export function toModelRow(m: ModelDef): ModelRow {
// A Fuobe Original's view on one engine (onEngine) keeps only that engine's routes: it lists that engine alone.
const engines = enginesOf(m).filter((e) => e === m.engine || m.routes.some((r) => providerEngine(r.provider) === e));
- const cloudPrice = m.pricing ? `${formatCost(m.pricing.usd)} / ${m.pricing.unit}` : "—";
+ // A Fuobe Original is free on your GPU and priced on the cloud.
+ const shown = (cloud: string) => (engines.length > 1 ? `Free · ${cloud}` : m.engine === "open" ? "Free" : cloud);
+ const p = m.pricing;
return {
id: m.id,
name: m.name,
@@ -54,12 +63,35 @@ export function toModelRow(m: ModelDef): ModelRow {
badges: (m.badges ?? []).filter((b) => b !== "open").map((b) => BADGE_LABEL[b] ?? b),
ops: [...new Set(m.routes.map((r) => OPERATION_LABELS[r.op] ?? r.op))],
routes: [...new Set(m.routes.map((r) => `${r.provider}: ${r.endpoint}`))],
- // A Fuobe Original is free on your GPU and priced on the cloud.
- price: engines.length > 1 ? `Free · ${cloudPrice}` : m.engine === "open" ? "Free" : cloudPrice,
+ price: shown(p ? `${formatCost(p.usd)} / ${p.unit}` : "—"),
+ // A launch price on the cloud (FLUX 3 Max): the browser picks it or the list price by the day (rowPrice).
+ ...(p?.promo && engines.includes("cloud") && { launch: { until: p.promo.until, price: shown(`${formatCost(p.promo.usd)} / ${p.unit}`) } }),
...(m.worker === "isolated" && { note: ISOLATED_NOTE }),
};
}
+/**
+ * The price a row shows at `now`: its launch price through the end of the launch's last day (UTC), then the list price.
+ * Nothing for a row with a launch price while `now` is null (the page prerendering or hydrating: the day isn't known).
+ */
+export function rowPrice(r: Pick<ModelRow, "price" | "launch">, now: number | null): string {
+ if (!r.launch) return r.price;
+ if (now === null) return "";
+ return launchHolds(r.launch.until, now) ? r.launch.price : r.price;
+}
+
+const PICKER_UNIT = { image: "/image", second: "/sec", video: "/video", request: "/run", megapixel: "/MP", minute: "/min" } as const;
+
+/**
+ * The model picker's short price ("$0.05/sec", "Free"), at `now` (./catalog/promo): the launch price while it holds,
+ * nothing for a launch-priced model while no clock may be read (null).
+ */
+export function pickerPrice(m: ModelDef, now: PriceClock): string {
+ if (m.engine === "open") return "Free";
+ const p = m.pricing && pricingOn(m.pricing, now);
+ return p ? `${formatCost(p.usd)}${PICKER_UNIT[p.unit]}` : "";
+}
+
/** "Open source", "Cloud", or both for a Fuobe Original. */
export const enginesLabel = (engines: Engine[]): string =>
engines.length > 1 ? "Open source + cloud" : engines[0] === "open" ? "Open source" : "Cloud";
diff --git a/src/lib/starter-prices.ts b/src/lib/starter-prices.ts
index ee36ef4d..2a2f9c2c 100644
--- a/src/lib/starter-prices.ts
+++ b/src/lib/starter-prices.ts
@@ -8,11 +8,16 @@ import { EDIT_STUDIO, IMAGE_STUDIO, VIDEO_STUDIO } from "@/lib/studios";
* What a first image and a first clip cost on the default paid models, for the first-run guide
* ("Nano Banana Pro ≈ $0.15 an image · Seedance 2.5 ≈ $0.60 a 5 s clip"). Server side: it reads
* the catalog, which stays out of the browser. Empty when no price is known.
+ *
+ * Home and Settings are prerendered at build time, so these never read the clock (PRERENDER): a default model with a
+ * launch price (./catalog/promo) is quoted without a price rather than at the build day's; its studio shows the day's.
*/
+const PRERENDER = null;
+
export function starterPriceLine(): string {
const quote = (id: string, what: (d?: number) => string) => {
const m = getModel(id);
- const usd = m ? estimateCost(m, { ...m.defaults }) : null;
+ const usd = m ? estimateCost(m, { ...m.defaults }, 1, undefined, false, PRERENDER) : null;
return m && usd ? `${m.name} ≈ ${formatCost(usd)} ${what(m.defaults?.duration)}` : "";
};
return [quote(IMAGE_STUDIO.defaultModels.cloud, () => "an image"), quote(VIDEO_STUDIO.defaultModels.cloud, (d) => (d ? `a ${d} s clip` : "a clip"))].filter(Boolean).join(" · ");
@@ -25,7 +30,7 @@ export function startQuotes(): Record<"image" | "video" | "edit", StartQuote> {
const quote = (d: { cloud: string; open: string }, what: (duration?: number) => string): StartQuote => {
const cloud = getModel(d.cloud);
const open = getModel(d.open);
- const usd = cloud ? estimateCost(cloud, { ...cloud.defaults }) : null;
+ const usd = cloud ? estimateCost(cloud, { ...cloud.defaults }, 1, undefined, false, PRERENDER) : null;
// The providers that host each model: a key for another one runs it as a demo.
const providers = (m: NonNullable<typeof cloud>) => [...new Set(m.routes.map((r) => r.provider))];
return {
diff --git a/src/lib/studio-catalog.ts b/src/lib/studio-catalog.ts
index 02c5b42b..a3bbe09e 100644
--- a/src/lib/studio-catalog.ts
+++ b/src/lib/studio-catalog.ts
@@ -15,7 +15,11 @@ export interface StudioCatalog {
lookup?: ModelDef[];
}
-/** A model without its provider field maps (server-only detail), keeping what the composer previews results with. */
+/**
+ * A model without its provider field maps (server-only detail), keeping what the composer previews results with. Its
+ * pricing goes as it is, a launch price (Pricing.promo) and all: the page is prerendered at build time, so the browser
+ * picks the price of the day it is (useToday), and nothing here reads the clock.
+ */
export function slimModel(m: ModelDef): ModelDef {
return {
...m,
diff --git a/src/server/assist/tools.ts b/src/server/assist/tools.ts
index bcee7d98..9544a7f1 100644
--- a/src/server/assist/tools.ts
+++ b/src/server/assist/tools.ts
@@ -5,6 +5,7 @@ import { z } from "zod";
import { getModel, modelsFor } from "@/lib/catalog";
import { offeredModels } from "../model-access";
import { dualEngine, runsOn } from "@/lib/catalog/engines";
+import { pricingAt } from "@/lib/catalog/promo";
import { currentModelId } from "@/lib/catalog/replaced";
import { OPERATION_LABELS, type ChainSlot, type GenerationRequest, type MediaKind, type ModelDef, type Operation } from "@/lib/catalog/types";
import { type PlannedJob, totalCost } from "@/lib/assist";
@@ -38,6 +39,8 @@ const KINDS = ["image", "video", "audio", "text", "model3d"] as const;
function summarize(m: ModelDef) {
const o = m.options;
+ // The price of the day asked: a launch price while it lasts (the note says when it ends).
+ const p = m.pricing && pricingAt(m.pricing);
const local = m.routes.some((r) => r.provider === "llm");
const configured = m.routes.some((r) => (r.provider === "llm" ? llmBackends(r).length > 0 : provider(r.provider).isConfigured()));
return {
@@ -56,13 +59,13 @@ function summarize(m: ModelDef) {
about: m.tagline,
does: [...new Set(m.routes.map((r) => r.op))].map((op) => `${op} (${OPERATION_LABELS[op]})`),
price: dualEngine(m)
- ? `free on your GPU; in the cloud ${m.pricing ? `$${m.pricing.usd} per ${m.pricing.unit}${m.pricing.withLoras ? ` ($${m.pricing.withLoras} with LoRAs)` : ""}` : "priced per run"}`
+ ? `free on your GPU; in the cloud ${p ? `$${p.usd} per ${p.unit}${p.withLoras ? ` ($${p.withLoras} with LoRAs)` : ""}` : "priced per run"}`
: m.engine === "open"
? local
? "free (your machine)"
: "free (your GPU)"
- : m.pricing
- ? `$${m.pricing.usd} per ${m.pricing.unit}${m.pricing.note ? ` — ${m.pricing.note}` : ""}${m.pricing.lorasUnknown ? "; with LoRAs the price is unknown (not published yet)" : ""}`
+ : p
+ ? `$${p.usd} per ${p.unit}${p.note ? ` — ${p.note}` : ""}${p.lorasUnknown ? "; with LoRAs the price is unknown (not published yet)" : ""}`
: "unknown",
connected: configured,
...(o.aspectRatios && { aspectRatios: o.aspectRatios }),
diff --git a/src/server/faceless.ts b/src/server/faceless.ts
index 23a5f68f..79bf7dd3 100644
--- a/src/server/faceless.ts
+++ b/src/server/faceless.ts
@@ -75,6 +75,7 @@ import {
type TopicIdea,
} from "@/lib/catalog/faceless";
import { routesFor } from "@/lib/catalog/plan";
+import { pricingAt } from "@/lib/catalog/promo";
import type { Engine, Generation, GenerationRequest } from "@/lib/catalog/types";
import { DocxError, docxText } from "./assist/docx";
import { PdfError, pdfText } from "./assist/pdf";
@@ -1067,7 +1068,7 @@ function upscaleOffer(ep: FacelessEpisode, seconds: number): EpisodeView["upscal
const model = modelId ? getModel(modelId) : undefined;
if (!model) return null;
const demo = runsAsDemo(model.id, "upscale-video");
- const p = model.pricing;
+ const p = model.pricing && pricingAt(model.pricing);
const costUsd = demo || model.engine === "open" ? 0 : p?.unit === "megapixel" ? Math.round(p.usd * UPSCALE_MP * UPSCALE_FPS * seconds * 100) / 100 : p?.unit === "second" ? Math.round(p.usd * seconds * 100) / 100 : null;
return { costUsd, demo };
}
diff --git a/tests/cloud-catalog-4.test.ts b/tests/cloud-catalog-4.test.ts
index 3e38d497..e7d96083 100644
--- a/tests/cloud-catalog-4.test.ts
+++ b/tests/cloud-catalog-4.test.ts
@@ -173,11 +173,11 @@ describe("round-4 cloud models", () => {
const after = pricingAt(raw, Date.parse("2026-11-08T00:00:01Z"));
expect(after).toMatchObject({ usd: 0.17, byResolution: { "720p": 0.17, "1080p": 0.29 } });
expect(after.promo).toBeUndefined();
- // The catalog holds the price that applies today, without the promo record.
+ // The catalog keeps both prices (no clock read when it loads or is copied); estimateCost picks the one of `now`.
const live = getModel("flux-3-max")!;
- expect(live.pricing!.promo).toBeUndefined();
- expect(live.pricing!.usd).toBe(pricingAt(raw).usd);
- expect(estimateCost({ ...live, pricing: pricingAt(raw, Date.parse("2026-10-22T00:00:00Z")) }, { duration: 10, resolution: "1080p" })).toBe(0.725);
+ expect(live.pricing).toEqual(raw);
+ expect(estimateCost(live, { duration: 10, resolution: "1080p" }, 1, undefined, false, Date.parse("2026-10-22T00:00:00Z"))).toBe(0.725);
+ expect(estimateCost(live, { duration: 10, resolution: "1080p" }, 1, undefined, false, Date.parse("2026-11-08T00:00:01Z"))).toBe(2.9);
expect(estimateCost({ ...live, pricing: after }, { duration: 10, resolution: "1080p" })).toBe(2.9);
});
diff --git a/tests/launch-prices.test.ts b/tests/launch-prices.test.ts
new file mode 100644
index 00000000..f1c24537
--- /dev/null
+++ b/tests/launch-prices.test.ts
@@ -0,0 +1,198 @@
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { createElement } from "react";
+import { renderToString } from "react-dom/server";
+import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from "vitest";
+import type { GenerationRequest, ModelDef } from "@/lib/catalog/types";
+import type { StudioConfig } from "@/components/studio/studio-context";
+
+/**
+ * Launch prices (Pricing.promo): H3 Max camera controls at $0.052/s (768P) through 2026-10-31, then $0.08/s; FLUX 3 Max
+ * at $0.0425/s (720p) through 2026-11-07, then $0.17/s. The catalog keeps both prices. The server prices a run on the
+ * day it runs, even when it started before a launch price ended; the browser shows the price of the day it is looked at;
+ * nothing a page prerenders at build time reads the clock (Next.js stops the build on Date.now() while prerendering).
+ */
+
+// The server starts on 2026-10-30, the day before H3 Max's launch price ends, and loads the catalog then.
+vi.useFakeTimers({ now: Date.parse("2026-10-30T10:00:00Z"), toFake: ["Date"] });
+
+const dir = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-launch-prices-"));
+process.env.FUOBE_DATA_DIR = dir;
+process.env.COMFYUI_URL = "http://127.0.0.1:9";
+process.env.OLLAMA_URL = "http://127.0.0.1:9";
+
+const { setSetting } = await import("@/server/settings");
+const { previewGeneration } = await import("@/server/generations");
+const { APPS, getModel, MODELS } = await import("@/lib/catalog");
+const { estimateCost } = await import("@/lib/catalog/plan");
+const { launchHolds, pricingOn } = await import("@/lib/catalog/promo");
+const { slimModel, studioCatalog } = await import("@/lib/studio-catalog");
+const studios = await import("@/lib/studios");
+const { pickerPrice, rowPrice, toModelRow } = await import("@/lib/model-rows");
+const { toModelInfo } = await import("@/lib/model-list");
+const { startQuotes, starterPriceLine } = await import("@/lib/starter-prices");
+const { modelInfos } = await import("@/lib/catalog/shorts-models");
+const { SHORTS_MODELS } = await import("@/lib/catalog/shorts");
+const { startOfDayUtc, useToday } = await import("@/hooks/use-today");
+
+const H3 = "minimax-h3-max-camera";
+const FLUX = "flux-3-max";
+const at = (iso: string) => vi.setSystemTime(Date.parse(iso));
+/** The day the browser's useToday gives at that moment. */
+const day = (iso: string) => startOfDayUtc(Date.parse(iso));
+
+/** Calls to Date.now() while `fn` runs (the fake clock's Date is the global one, so it is the one spied on). */
+function clockReads(fn: () => void): number {
+ const spy = vi.spyOn(Date, "now");
+ try {
+ fn();
+ return spy.mock.calls.length;
+ } finally {
+ spy.mockRestore();
+ }
+}
+
+beforeAll(() => {
+ setSetting("demoMode", "auto");
+ setSetting("enhanceProvider", "none");
+ // A fal key: runs are real (priced), not demo (free).
+ setSetting("falKey", "fal_test_key_123456");
+});
+afterEach(() => at("2026-10-30T10:00:00Z"));
+afterAll(() => {
+ vi.useRealTimers();
+ fs.rmSync(dir, { recursive: true, force: true });
+});
+
+describe("the catalog keeps both prices", () => {
+ it("H3 Max camera controls and FLUX 3 Max carry the list price and the launch price, as plain data", () => {
+ const h3 = getModel(H3)!.pricing!;
+ expect(h3).toMatchObject({ unit: "second", usd: 0.08, byResolution: { "768P": 0.08 }, promo: { until: "2026-10-31", usd: 0.052, byResolution: { "768P": 0.052 } } });
+ expect(Object.getOwnPropertyDescriptor(getModel(H3)!, "pricing")).toMatchObject({ writable: true });
+ expect(getModel(FLUX)!.pricing).toMatchObject({ usd: 0.17, promo: { until: "2026-11-07", usd: 0.0425 } });
+ expect(launchHolds("2026-10-31", Date.parse("2026-10-31T23:59:59.999Z"))).toBe(true);
+ expect(launchHolds("2026-10-31", Date.parse("2026-11-01T00:00:00Z"))).toBe(false);
+ });
+});
+
+describe("the server prices a run on the day it runs", () => {
+ it("H3 Max camera controls (Cinema's fly path): the launch rate today and through 2026-10-31 (UTC), the list rate from November", () => {
+ const m = getModel(H3)!;
+ const cost = () => estimateCost(m, { duration: 5, resolution: "768P" }, 1, "camera-path");
+ expect(cost()).toBe(0.26);
+ at("2026-10-31T23:59:59Z");
+ expect(cost()).toBe(0.26);
+ // Same process, same catalog: the run after midnight is priced at the list rate.
+ at("2026-11-01T00:00:00Z");
+ expect(cost()).toBe(0.4);
+ });
+
+ it("FLUX 3 Max through previewGeneration (the price POST /api/generations quotes and records): $0.0425/s through 2026-11-07, $0.17/s after", () => {
+ const req: GenerationRequest = { feature: "video", modelId: FLUX, engine: "cloud", prompt: "a paper boat drifts across a pond", params: { duration: 10, resolution: "720p" } };
+ const quote = () => {
+ const p = previewGeneration(req);
+ expect(p.demo).toBe(false);
+ return p.costUsd;
+ };
+ expect(quote()).toBe(0.425);
+ at("2026-11-07T23:59:00Z");
+ expect(quote()).toBe(0.425);
+ at("2026-11-08T00:00:01Z");
+ expect(quote()).toBe(1.7);
+ });
+});
+
+describe("the browser shows the price of the day it is", () => {
+ it("a studio's slice keeps both prices, for the composer to pick from", () => {
+ const flux = studioCatalog(studios.VIDEO_STUDIO).models.find((m) => m.id === FLUX)!;
+ expect(flux.pricing).toEqual(getModel(FLUX)!.pricing);
+ // What the page passes to the browser (an RSC prop) is data: a JSON round trip keeps the launch price.
+ expect(JSON.parse(JSON.stringify(flux)).pricing.promo).toEqual(getModel(FLUX)!.pricing!.promo);
+ });
+
+ it("the composer's price: the launch rate through the last day, the list rate after, none while the page prerenders", () => {
+ const flux = slimModel(getModel(FLUX)!);
+ const price = (today: number | null) => estimateCost(flux, { duration: 10, resolution: "1080p" }, 1, "t2v", false, today);
+ expect(price(day("2026-10-30T10:00:00Z"))).toBe(0.725);
+ expect(price(day("2026-11-07T23:59:59Z"))).toBe(0.725);
+ expect(price(day("2026-11-08T00:00:00Z"))).toBe(2.9);
+ // While the page prerenders or hydrates (useToday's null) no clock is read and the launch-priced model shows no price.
+ let unknown: number | null = 0;
+ expect(clockReads(() => (unknown = price(null)))).toBe(0);
+ expect(unknown).toBeNull();
+ // A model without a launch price is priced as ever, without the clock.
+ const plain = slimModel(getModel(studios.VIDEO_STUDIO.defaultModels.cloud)!);
+ let usd: number | null = null;
+ expect(clockReads(() => (usd = estimateCost(plain, { ...plain.defaults }, 1, undefined, false, null)))).toBe(0);
+ expect(usd).toBe(estimateCost(plain, { ...plain.defaults }));
+ expect(usd).toBeGreaterThan(0);
+ });
+
+ it("the fly path's price in the browser: H3 Max at $0.052/s on 2026-10-31, $0.08/s on 2026-11-01", () => {
+ const h3 = slimModel(getModel(H3)!);
+ expect(estimateCost(h3, { duration: 5, resolution: "1080P" }, 1, "camera-path", false, day("2026-10-31T12:00:00Z"))).toBe(0.52);
+ expect(estimateCost(h3, { duration: 5, resolution: "1080P" }, 1, "camera-path", false, day("2026-11-01T12:00:00Z"))).toBe(0.8);
+ });
+
+ it("the model picker's price", () => {
+ const flux = slimModel(getModel(FLUX)!);
+ expect(pickerPrice(flux, day("2026-11-07T08:00:00Z"))).toBe("$0.043/sec");
+ expect(pickerPrice(flux, day("2026-11-08T08:00:00Z"))).toBe("$0.17/sec");
+ expect(pickerPrice(flux, null)).toBe("");
+ expect(pickerPrice(slimModel(getModel(H3)!), day("2026-10-30T08:00:00Z"))).toBe("$0.052/sec");
+ expect(pickerPrice(slimModel(getModel(H3)!), day("2026-11-01T08:00:00Z"))).toBe("$0.08/sec");
+ });
+
+ it("the Models page: each row carries the launch price, and the browser picks it or the list price by the day", () => {
+ const row = toModelRow(getModel(FLUX)!);
+ expect(row).toMatchObject({ price: "$0.17 / second", launch: { until: "2026-11-07", price: "$0.043 / second" } });
+ expect(rowPrice(row, day("2026-11-07T22:00:00Z"))).toBe("$0.043 / second");
+ expect(rowPrice(row, day("2026-11-08T00:00:00Z"))).toBe("$0.17 / second");
+ expect(rowPrice(row, null)).toBe("");
+ const plain = toModelRow(getModel(studios.VIDEO_STUDIO.defaultModels.cloud)!);
+ expect(plain.launch).toBeUndefined();
+ expect(rowPrice(plain, null)).toBe(plain.price);
+ // GET /api/models (a request, so it may read the clock) says the price of the day asked.
+ const info = toModelInfo(getModel(H3)!);
+ expect(rowPrice(info, Date.parse("2026-10-30T10:00:00Z"))).toBe("$0.052 / second");
+ expect(rowPrice(info, Date.parse("2026-11-01T00:00:00Z"))).toBe("$0.08 / second");
+ });
+
+ it("useToday: no clock and no day while a page renders on the server (prerender, SSR); the day once the browser hydrates", () => {
+ const Probe = () => String(useToday());
+ let html = "";
+ expect(clockReads(() => (html = renderToString(createElement(Probe))))).toBe(0);
+ expect(html).toBe("null");
+ expect(startOfDayUtc(Date.parse("2026-10-31T23:59:59.999Z"))).toBe(Date.parse("2026-10-31T00:00:00Z"));
+ // The day's midnight is inside the launch's last day: the launch price holds all of it.
+ expect(pricingOn(getModel(H3)!.pricing!, day("2026-10-31T23:59:59Z"))!.usd).toBe(0.052);
+ expect(pricingOn(getModel(H3)!.pricing!, day("2026-11-01T00:00:00Z"))!.usd).toBe(0.08);
+ });
+});
+
+describe("what pages prerender at build time reads no clock", () => {
+ it("every studio's slice (the studio pages, /apps/[id], the Audio, Upscale and Video tools hubs)", () => {
+ const configs = [
+ ...Object.values(studios).filter((v): v is StudioConfig => typeof v === "object" && v !== null && "defaultModels" in v && "kind" in v),
+ ...APPS.map((a) => studios.appStudio(a)),
+ ];
+ expect(configs.length).toBeGreaterThan(APPS.length + 20);
+ let slices: ReturnType<typeof studioCatalog>[] = [];
+ expect(clockReads(() => (slices = configs.map((c) => studioCatalog(c))))).toBe(0);
+ // The launch-priced models are in them (FLUX 3 Max is in the video studios' pickers).
+ expect(slices.some((s) => s.models.some((m: ModelDef) => m.id === FLUX && m.pricing?.promo))).toBe(true);
+ });
+
+ it("the Models page rows, Home's and Settings' first-run quotes, and the Shorts and Mixed Media model rows", () => {
+ expect(
+ clockReads(() => {
+ MODELS.map(toModelRow);
+ starterPriceLine();
+ startQuotes();
+ modelInfos(SHORTS_MODELS.cloud, "cloud");
+ modelInfos(SHORTS_MODELS.open, "open");
+ }),
+ ).toBe(0);
+ });
+});