The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Runs on this install's GPUs: labels instead of refusals on every surface
Adarsheb37e9f27f1b
diff --git a/docs/public-signup.md b/docs/public-signup.mdindex e4411e4c..8a4b16ab 100644--- a/docs/public-signup.md+++ b/docs/public-signup.md@@ -681,16 +681,38 @@ With it on:one run on the key, and a note's link to a tool's cloud version opens that page on Cloud for that visit: neithermoves the switch. (With hosted runs off, the browser keeps one switch, starting on Cloud, and saving a key moves itthere, as before.)-- A model, mode or option that runs only on a person's own GPU or key keeps its label there ("Runs on your own GPU ·- 48 GB", `src/lib/own-setup.ts`), and Run opens that setup. So does a run that no worker can take (none holds its- files or may run its lane). Extra LoRAs added to a request stay on the account's own GPU.-- A 3D model (Image to 3D, and Refine detail on its model) runs there only while a worker's CPU slot finishes it, and- only when the billing service's policy allows 3D (`kinds.model3d`). Every other 3D model stays on the account's- own GPU or key.-- A choice that needs an NVIDIA RTX card (RTX Video's upscale, frame generation and HDR) doesn't go to the studio's- GPUs when their last GPU check says the card can't run it, or that their ComfyUI lacks the RTX Video nodes. The run- goes to the account's own GPU when it has one, or answers 403 `not-offered` ("This one needs an NVIDIA RTX card, and- this studio's GPUs can't run it right now…").+- What this install's GPUs can't run is a label, never a refusal, the same for a guest and an account. The price+ slot says where it runs and its tooltip what to do; Run opens the way there (Connect your GPU, Add your key, or a+ guest's sign-up card for that label), and with the GPU or key already there, the first press runs on it:+ - a model, mode or option that runs only on a person's own GPU or key ("Runs on your own GPU · 48 GB",+ `src/lib/own-setup.ts`), and a run that no worker can take (none holds its files or may run its lane): "Runs on+ your own GPU";+ - extra LoRAs added to a request: "LoRAs run on your own GPU", with "Run without LoRAs";+ - a kind of file the policy keeps off: "This file runs on your own GPU";+ - a choice that needs an NVIDIA RTX card (RTX Video's upscale, frame generation and HDR) when the GPUs' last check+ says their card can't run it, or that their ComfyUI lacks the RTX Video nodes: "Runs on your own RTX GPU";+ - a size bigger than every GPU here makes (each worker's PC ceiling: megapixels, seconds, results at once), said+ before Run: "This size runs on your own GPU", tooltip "Up to 8 megapixels on our GPUs. Pick a smaller size, or+ run it on your own GPU." The run's own size check stays as the last guard;+ - a 3D model no worker finishes (Image to 3D, and Refine detail on its model run there only while a worker's CPU+ slot finishes them, and only when the policy allows 3D, `kinds.model3d`; Any Angle's 3D view runs there like a+ picture): "Runs on your own GPU · 24 GB".++ The answer to such a run is 403 with `code: "connect-gpu"` (or `"add-key"`), the label as `error`, `ownSetup` and+ the `x-fuobe-connect-gpu` and `x-fuobe-own-setup` headers, so the card that opens says what it needs: "This one runs+ on your own GPU" / "It needs a GPU with 48 GB of memory. Connect yours, and this runs there. Everything else runs on+ our GPUs." with **Connect your GPU** and **Pick another model** (never a dead end on a phone). A guest's card says+ "Sign up free, then connect yours in a few steps." instead, never that the run starts once signed in; after sign-up+ the draft is back and that setup opens on the same page, and nothing runs by itself. Only a run past the outputs a+ run here makes is still words (`not-offered`: "Makes up to 4 at a time on our GPUs…"; the tools cut the count).+- Relight and Any Angle run there like the studios (the price check says where, or the label). Canvas board runs and+ the Ads Studio, Ad Multiplier, Click to Ad and Marketing Studio don't run for accounts yet: a board's Run points at+ the studio that makes it ("Make this in the Video studio", on our GPUs), and those tools' place chip says "Coming+ soon" with the studios to use now. A tool no account's own GPU or key runs yet answers "This one isn't open to+ accounts yet. Try the Image, Video or Audio studio, or an app, effect or camera motion."+- A run on this install's GPUs that failed on the person's own files ("A clip or sound in this run couldn't be read.",+ "This run couldn't finish with these files or settings.") offers **Reuse** first (the draft comes back to change),+ and Retry second.- When a billing service names the models that may run on the studio's GPUs, that applies to every model a run uses,not only its main one.- An account can upload pictures for these runs. Clips and sound go to the workers only when the install allows them@@ -754,7 +776,7 @@ Two optional services can go with it:The code is `src/server/hosted.ts` (the switch, the place, the line), `src/server/hosted-run.ts` (the run route's sideand the gate), `src/server/account-tool-run.ts` (a tool's run), `src/server/run-stamp.ts` (what every row of a runcarries), `src/server/run-on.ts` (the account's pick of where its runs go) and `src/lib/hosted.ts` (the browser's-side). The tests are `tests/hosted-runs.test.ts`, `tests/run-on.test.ts`,+side). The tests are `tests/hosted-runs.test.ts`, `tests/run-on.test.ts`, `tests/hosted-surface-labels.test.ts`,`tests/hosted-tool-runs.test.ts`, `tests/pool-account-runs.test.ts`, `tests/billing-hook.test.ts`,`tests/billing-release.test.ts` and `tests/moderation-hook.test.ts`.diff --git a/src/app/api/generations/route.ts b/src/app/api/generations/route.tsindex db5f6266..d5339584 100644--- a/src/app/api/generations/route.ts+++ b/src/app/api/generations/route.ts@@ -26,7 +26,7 @@ import { connectNeeds } from "@/server/connect-refusal";import { BILLING_HEADER, BILLING_WAIT, holdsOn } from "@/server/billing";import { queueRelease } from "@/server/billing-outbox";import { runOnPool } from "@/server/hosted";-import { decidePlace, moderateRun, policyWait, poolQuote, readWishes, reservePool, stepsProblem, type PlaceDecision, type Refusal, type ReserveFacts, type ReserveWait } from "@/server/hosted-run";+import { decidePlace, lateRefusal, moderateRun, policyWait, poolQuote, readWishes, reservePool, stepsProblem, type PlaceDecision, type Refusal, type ReserveFacts, type ReserveWait } from "@/server/hosted-run";import { withRunStamp, type RunStamp } from "@/server/run-stamp";import { hostedRunsOn } from "@/server/hosted-switch";import { endTry, notePressRun, pressPrior, pressRun, pressTries, pressTry, readPressId } from "@/server/run-requests";@@ -67,12 +67,17 @@ const accountRunAnswer = (r: AccountRunRefusal): Answer => ({headers: r.code === "connect-gpu" ? { [CONNECT_GPU_HEADER]: "1" } : r.code === "add-key" && r.provider ? { [ADD_KEY_HEADER]: r.provider } : {},});-/** The answer to a run the limits refuse as it is made (admitRun), or one with a step this install's GPUs don't take. */-const limitAnswer = (r: AdmitRefused["refusal"]): Answer => ({- status: r.status,- body: { error: r.error, code: r.code },- headers: r.code === "not-offered" ? { [BILLING_HEADER]: "not-offered" } : { "Retry-After": String(r.retryAfterS ?? 30) },-});+/**+ * The answer to a run the limits refuse as it is made (admitRun), or one with a step this install's GPUs don't take (its+ * label, which opens Connect your GPU: lateRefusal).+ */+function limitAnswer(r: AdmitRefused["refusal"]): Answer {+ if (r.code === "not-offered") {+ const late = lateRefusal(r.error);+ return { status: late.status, body: late.body as Answer["body"], headers: late.headers };+ }+ return { status: r.status, body: { error: r.error, code: r.code }, headers: { "Retry-After": String(r.retryAfterS ?? 30) } };+}/** Start a generation; `?preview=1` only says what it would run as (model, operation, jobs, outputs, cost). */export async function POST(request: Request) {diff --git a/src/components/any-angle/any-angle-tool.tsx b/src/components/any-angle/any-angle-tool.tsxindex e94b579c..5b85e12c 100644--- a/src/components/any-angle/any-angle-tool.tsx+++ b/src/components/any-angle/any-angle-tool.tsx@@ -13,6 +13,7 @@ import { ACCEPT, LibraryGrid } from "@/components/studio/media-slot";import { RunPlaceChip, useOpenRunPlace } from "@/components/studio/run-place-chip";import { getModel } from "@/lib/catalog";import { loadModelViewer } from "@/components/model3d/model-viewer";+import { PLACEHOLDER } from "@/lib/composer";import { askToSignUp, uploadFile, useAskBeforeUpload, useCreateGeneration, useEngine, useGenerations, useIsGuest, useIsOwner, usePlaceName, useStatus } from "@/lib/api";import { ACTIVE_RUNS_CODE } from "@/lib/guest-access";import {@@ -539,14 +540,20 @@ export function AnyAngleTool({ app }: { app?: { name: string } }) {const cloudOnly = mode === "cloud";// Where the angles are made and their price, as the studios say it (the 3D view, then one picture per angle). The 3D- // view is built on the viewer's own GPU only (this studio's GPUs refuse it), so an account connects its own.- const place = useOpenRunPlace([getModel(ANY_ANGLE.buildModel)?.name, getModel(ANY_ANGLE.shotModel)?.name].filter((x): x is string => !!x), null, { ownGpuOnly: true });+ // view is built on the viewer's own GPU, so an account connects its own; with hosted runs on, where the server's price+ // check for the build says (this studio's GPUs where one of them builds it, else its label, which Run opens).+ const hosted = !!useStatus().data?.viewer?.hosted;+ const buildQuote = useMemo<GenerationRequest | null>(+ () => (hosted ? { feature: ANY_ANGLE.stepFeature, modelId: ANY_ANGLE.buildModel, op: "splat", engine: "open", inputs: { images: [ref || PLACEHOLDER.image] } } : null),+ [hosted, ref],+ );+ const place = useOpenRunPlace([getModel(ANY_ANGLE.buildModel)?.name, getModel(ANY_ANGLE.shotModel)?.name].filter((x): x is string => !!x), buildQuote, { ownGpuOnly: !hosted });const ready = !!view && !!ref;// A build that failed takes the angles waiting for it with it.const waiting = build?.status === "failed" || build?.status === "canceled" ? null : asked;const buildView = () => {- if (guest) return askToSignUp("run");+ if (guest) return askToSignUp("run", place?.setup ? { setup: place.setup } : {});if (!ref) return;create.mutate({ feature: ANY_ANGLE.stepFeature, modelId: ANY_ANGLE.buildModel, op: "splat", engine: "open", inputs: { images: [ref] } },@@ -592,7 +599,7 @@ export function AnyAngleTool({ app }: { app?: { name: string } }) {};const make = async (list: AnglePick[], all = false) => {- if (guest) return askToSignUp("run");+ if (guest) return askToSignUp("run", place?.setup ? { setup: place.setup } : {});if (!view || !ref || !list.length) return;const reqs = list.flatMap((p) => {const cam = cameraOf(p);@@ -624,7 +631,7 @@ export function AnyAngleTool({ app }: { app?: { name: string } }) {}, [waiting, ready]);const again = (g: Generation) => {- if (guest) return askToSignUp("run");+ if (guest) return askToSignUp("run", place?.setup ? { setup: place.setup } : {});void send([{ ...g.request, account: undefined, params: { ...g.request.params, seed: newSeed() } } as GenerationRequest]);};@@ -644,7 +651,7 @@ export function AnyAngleTool({ app }: { app?: { name: string } }) {const building = busy(build);/** Make now, or (while the view builds) as soon as it is ready. */const start = (what: "picked" | "all") => {- if (guest) return askToSignUp("run");+ if (guest) return askToSignUp("run", place?.setup ? { setup: place.setup } : {});if (ready) return void make(what === "all" ? options.filter((o) => !isCustom(o)) : picked, what === "all");if (building) setWaiting(what);};diff --git a/src/components/canvas/visitor-canvas.tsx b/src/components/canvas/visitor-canvas.tsxindex 22a4c4cf..9ca92071 100644--- a/src/components/canvas/visitor-canvas.tsx+++ b/src/components/canvas/visitor-canvas.tsx@@ -10,7 +10,8 @@ import { NotFoundState } from "@/components/empty-state";import { Button } from "@/components/ui/button";import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";import { useIsMobile } from "@/hooks/use-mobile";-import { signInHref, useEngine, useHydrated, useViewer } from "@/lib/api";+import { signInHref, useEngine, useHydrated, usePlaceName, useViewer } from "@/lib/api";+import { boardRunWords } from "@/lib/board-run-words";import type { Canvas } from "@/lib/catalog/canvas";import type { CanvasPage } from "@/lib/catalog/canvas-board";import type { Generation } from "@/lib/catalog/types";@@ -94,15 +95,14 @@ const asCanvas = (b: { id: string; name: string; templateId: string | null; pagefunction RunNeeds({ open, onOpenChange, who, oneStep }: { open: boolean; onOpenChange: (o: boolean) => void; who: Who; oneStep?: VisitorBoardData["oneStep"] }) {const here = usePathname();+ // Hosted runs on: where the studio runs it, by its place name (null while they are off: today's words).+ const words = boardRunWords(!!oneStep, usePlaceName());return (<Dialog open={open} onOpenChange={onOpenChange}><DialogContent className="sm:max-w-md"><DialogHeader>- <DialogTitle>Running a board isn't available here</DialogTitle>- <DialogDescription>- You can build, change and keep boards here.{" "}- {oneStep ? "To make this result now, use the same effect in the Video studio: it runs every step at once." : "To make something now, use the Image, Video or Audio studio, or an app, effect or camera motion."}- </DialogDescription>+ <DialogTitle>{words.title}</DialogTitle>+ <DialogDescription>{words.body}</DialogDescription></DialogHeader><DialogFooter className="gap-2 sm:justify-start"><Button asChild className="rounded-full">diff --git a/src/components/cinema/hooks.ts b/src/components/cinema/hooks.tsindex 2eb86288..cbd27bf7 100644--- a/src/components/cinema/hooks.ts+++ b/src/components/cinema/hooks.ts@@ -265,6 +265,27 @@ export function useItemActions(projectId: string) {export type GenerateBody = { input: Omit<CinemaGenerateInput, "brief">; folderId: string | null; requestId?: string };export type GenerateResult = { items: Generation[]; folderId: string | null; plan: { notes: string[]; costUsd: number | null; outputs: number; modelId: string } };+/**+ * A take's price check (hosted runs on, an account: `body` set): `{ place: "pool", quote, line }` when it goes to this+ * studio's GPUs (their price and wait, or the label of what runs on the account's own GPU), `{ place: "own" }` otherwise.+ * Asked once the draft stops changing; nothing is made. Read with usePoolRun.+ */+export function useCinemaPriceCheck(projectId: string, body: GenerateBody | null) {+ const key = body ? JSON.stringify(body) : null;+ const [settled, setSettled] = useState(key);+ useEffect(() => {+ const t = setTimeout(() => setSettled(key), 400);+ return () => clearTimeout(t);+ }, [key]);+ return useQuery({+ queryKey: ["cinema", projectId, "price-check", settled],+ enabled: !!settled,+ retry: false,+ staleTime: 30_000,+ queryFn: () => send<unknown>(`/api/cinema/projects/${projectId}/generate?preview=1`, "POST", JSON.parse(settled!)),+ });+}+export function useCinemaGenerate(projectId: string) {const qc = useQueryClient();return useMutation({diff --git a/src/components/cinema/prompt-bar.tsx b/src/components/cinema/prompt-bar.tsxindex 3d18e341..6ac80584 100644--- a/src/components/cinema/prompt-bar.tsx+++ b/src/components/cinema/prompt-bar.tsx@@ -47,7 +47,9 @@ import { ExactOrbitControls } from "@/components/exact-orbit-controls";import { exactDefaults, takesExact } from "@/lib/exact-orbit";import { CameraChip, EmotionChip, FilmSetupChip, LightingChip, PaletteChip } from "./director-panel";import { directorPicks, draftToInput, withMoves, type BarAction, type CinemaDraft, type RefItem } from "./draft";-import { useCinemaGenerate } from "./hooks";+import { useCinemaGenerate, useCinemaPriceCheck } from "./hooks";+import { usePoolRun } from "@/components/studio/pool-price";+import { useRunViewer } from "@/components/studio/run-place-chip";import { firstFrame, mediaDuration } from "./media";import { formatUsd } from "./money";import { placeholdersOn } from "@/lib/demo-mode";@@ -352,9 +354,19 @@ export function PromptBar(props: PromptBarProps) {const cost = demo ? 0 : plan.costUsd;const overCap = costCapUsd != null && cost != null && cost > 0 && spentUsd + cost > costCapUsd + 1e-9;const uploading = draft.refs.some((r) => r.uploading);+ // Hosted runs on (an account, open models): where the take goes and its price, from its own price check. This studio's+ // GPUs say their price and wait; what runs on the account's own GPU says its label, and Generate opens that setup.+ const runViewer = useRunViewer();+ const checksPlace = !!runViewer?.hosted && runViewer.audience === "account" && engine === "open" && !demo;+ const priceCheck = useCinemaPriceCheck(projectId, checksPlace && !plan.blocker ? { input, folderId } : null);+ const poolRun = usePoolRun(checksPlace ? priceCheck.data : null);+ const pool = poolRun.pool;const blocker = uploading? "Uploading…"- : refCheck ?? plan.blocker ?? (overCap ? `Over the project's ${formatUsd(costCapUsd)} limit (≈ ${formatUsd(spentUsd)} spent) — raise it in project settings` : undefined);+ : (refCheck ??+ plan.blocker ??+ (overCap ? `Over the project's ${formatUsd(costCapUsd)} limit (≈ ${formatUsd(spentUsd)} spent) — raise it in project settings` : undefined) ??+ (poolRun.off ? pool?.text : undefined));// An empty bar needs no warning line (the placeholder says it); everything else is spelled out under the bar.const quietBlocker = !draft.prompt.trim() && !draft.refs.length && blocker === plan.blocker && /^Describe/.test(blocker ?? "");const blockerId = useId();@@ -376,6 +388,12 @@ export function PromptBar(props: PromptBarProps) {toast.error(blocker);return;}+ // A take that runs on the account's own GPU (its label): Generate opens that setup, or goes on where it already is.+ if (pool?.setup) {+ let goOn = false;+ poolRun.go(() => (goOn = true));+ if (!goOn) return;+ }let frame: string | undefined;const src = draft.source;if (src?.kind === "video" && (action === "extend-backward" || (action === "edit" && engine === "open"))) {@@ -529,9 +547,20 @@ export function PromptBar(props: PromptBarProps) {].filter(Boolean).join(" · ");- // The live cost sits next to Generate at every width (short on narrow bars).- const costShort = demo ? "Placeholder" : cost === 0 ? (engine === "open" ? "Free · GPU" : "Free") : cost != null ? `≈ ${formatCost(cost)}` : "≈ ?";- const costLong = demo ? "Placeholder · free" : cost === 0 ? (engine === "open" ? "Free · your GPU" : "Free") : cost != null ? `≈ ${formatCost(cost)}` : "Price unknown";+ // The live cost sits next to Generate at every width (short on narrow bars). On this studio's GPUs: the price check's+ // words ("Free · ready in about 2 min"), or the label of what runs on the account's own GPU.+ const onSite = !!pool && !pool.refused;+ const costShort = pool ? (onSite ? (pool.text.split(" · ")[0] ?? pool.text) : "Your GPU") : demo ? "Placeholder" : cost === 0 ? (engine === "open" ? "Free · GPU" : "Free") : cost != null ? `≈ ${formatCost(cost)}` : "≈ ?";+ const costLong = pool ? pool.text : demo ? "Placeholder · free" : cost === 0 ? (engine === "open" ? "Free · your GPU" : "Free") : cost != null ? `≈ ${formatCost(cost)}` : "Price unknown";+ const costTip = pool+ ? onSite+ ? `Runs on ${runViewer!.place.text}`+ : pool.text+ : demo+ ? "Placeholder results are on (Settings), so takes are free stand-ins"+ : cost === 0+ ? "Runs on your own GPU"+ : "Estimated cost of this run, billed by the provider to your key";// The Director's Panel chips: their own row from sm up; on phones one "Director" chip opens them in a sheet.const directorChips = (@@ -879,7 +908,7 @@ export function PromptBar(props: PromptBarProps) {</span></TooltipTrigger><TooltipContent>- {demo ? "Placeholder results are on (Settings), so takes are free stand-ins" : cost === 0 ? "Runs on your own GPU" : "Estimated cost of this run, billed by the provider to your key"}+ {costTip}</TooltipContent></Tooltip><Tooltip>@@ -918,7 +947,7 @@ export function PromptBar(props: PromptBarProps) {</p>)}<span className="sr-only" aria-live="polite">- {cost != null ? `Estimated cost ${demo ? "free: placeholder results" : cost === 0 && engine === "open" ? "free, on your GPU" : formatCost(cost)}` : ""}+ {pool ? costLong : cost != null ? `Estimated cost ${demo ? "free: placeholder results" : cost === 0 && engine === "open" ? "free, on your GPU" : formatCost(cost)}` : ""}</span></div>);diff --git a/src/components/guest-prompt.tsx b/src/components/guest-prompt.tsxindex 5872e900..34edc65d 100644--- a/src/components/guest-prompt.tsx+++ b/src/components/guest-prompt.tsx@@ -1,7 +1,7 @@"use client";import { useQueryClient } from "@tanstack/react-query";-import { Cpu, ExternalLink, KeyRound, LogIn, Sparkles } from "lucide-react";+import { Cpu, ExternalLink, KeyRound, LogIn, Shuffle, Sparkles } from "lucide-react";import Link from "next/link";import { usePathname } from "next/navigation";import { Suspense, useCallback, useEffect, useRef, useState } from "react";@@ -30,6 +30,9 @@ import { FAL_KEYS_URL } from "@/lib/connections";import { CLOUD_KEY } from "@/lib/your-keys";import { RUNS_CHANGED_EVENT } from "@/lib/guest-access";import { refreshPriceChecks } from "@/lib/hosted";+import { ownSetupLabel, type OwnSetup } from "@/lib/own-setup";+import { KEPT_RUN_WORDS, setupCardWords } from "@/lib/own-setup-card";+import { canPickModel, pickAnotherModel } from "@/lib/pick-model";/*** The cards a public studio shows when something is refused (watchGuestRefusals): "Create a free@@ -59,6 +62,11 @@ export function GuestPrompt() {// Opened by a tool only a GPU runs: no key offers on this card.const [gpuOnly, setGpuOnly] = useState(false);const [requirement, setRequirement] = useState<string | undefined>(undefined);+ // Hosted runs: the press was on an item that runs on one's own GPU or key (its label), and the page has a model picker+ // to pick another one from; or a guest's run a studio keeps through sign-up.+ const [setup, setSetup] = useState<OwnSetup | null>(null);+ const [canPick, setCanPick] = useState(false);+ const [kept, setKept] = useState(false);const close = useCallback(() => {setOpen(false);setRetry(null);@@ -80,6 +88,13 @@ export function GuestPrompt() {// Hosted runs: opened from an item that runs on one's own GPU only (its label's requirement), while everything else// runs on this studio's GPUs (said with their place name).const ownOnly = viewer?.hosted && !!requirement && needs !== "key" && !keyOnly ? placeOf(viewer.placeName) : null;+ // Its words, when the label's setup is known: what it needs, and that everything else runs on this studio's GPUs.+ const ownWords = ownOnly && setup ? setupCardWords(setup, ownOnly, "account") : null;+ const guestWords = viewer?.hosted && setup ? setupCardWords(setup, placeOf(viewer.placeName), "guest") : null;+ const pick = () => {+ close();+ pickAnotherModel();+ };const start = () => {const r = retry;close();@@ -100,8 +115,12 @@ export function GuestPrompt() {// Signed in a moment ago: not an offer to sign up, but to log in again; and the page asks who is looking.const out = was.current;if (show("guest")) {+ const d = detail(e);setSignedOut(out);- setAction(detail(e).action ?? "run");+ setAction(d.action ?? "run");+ setSetup(d.setup ?? null);+ setKept(!!d.kept);+ setCanPick(canPickModel());}if (out) {was.current = null;@@ -121,7 +140,9 @@ export function GuestPrompt() {setLook(!!d.look);setNeeds(d.needs ?? "gpu");setGpuOnly(!!d.gpuOnly);- setRequirement(typeof d.requirement === "string" && d.requirement ? d.requirement : undefined);+ setSetup(d.setup ?? null);+ setCanPick(canPickModel());+ setRequirement(typeof d.requirement === "string" && d.requirement ? d.requirement : d.setup ? ownSetupLabel(d.setup) : undefined);};window.addEventListener(GUEST_PROMPT_EVENT, guest);// A run started from a toast (not a page's own button): the lists show it.@@ -159,7 +180,15 @@ export function GuestPrompt() {{keyOnly ? <KeyRound className="size-5" /> : <Cpu className="size-5" />}</div><DialogTitle>- {reason ? TITLES[reason] : keyOnly ? "Add an API key to run this" : ownOnly ? "This one runs on your own GPU" : action === "upload" && !keysAllowed ? "Connect your GPU to add your own files" : TITLES[action]}+ {reason+ ? TITLES[reason]+ : keyOnly+ ? "Add an API key to run this"+ : ownOnly+ ? (ownWords?.title ?? "This one runs on your own GPU")+ : action === "upload" && !keysAllowed+ ? "Connect your GPU to add your own files"+ : TITLES[action]}</DialogTitle><DialogDescription>{keyOnly ? (@@ -171,13 +200,21 @@ export function GuestPrompt() {"Your files are kept for your own runs on your own ComfyUI.")) : ownOnly && !reason ? (- `Connect yours, and this runs there. Everything else runs on ${ownOnly.text}.`+ (ownWords?.body ?? `Connect yours, and this runs there. Everything else runs on ${ownOnly.text}.`)) : (<>{action === "connect" && !reason ? "Your runs go to the ComfyUI on your computer. It's free and private." : "Fuobe runs this on the ComfyUI on your computer. It's free and private."}</>)}</DialogDescription>{/* What the item asked for needs (its own-setup label). */}{requirement && <p className="text-[13px] font-medium text-brand-text">{requirement}</p>}+ {/* Never a dead end (a phone rarely has a 48 GB card to connect): another model is one press away. */}+ {ownOnly && !reason && canPick && (+ <div>+ <Button variant="secondary" size="sm" className="rounded-full" onClick={pick}>+ <Shuffle /> Pick another model+ </Button>+ </div>+ )}{/* Paid models run on the account's own key instead (Your keys), when the studio allows them. */}{viewer?.kind === "account" && keysAllowed && !!viewer.keys?.length && (<p className="text-[13px] text-muted-foreground">{`Or switch to Cloud to use your ${viewer.keys.map((k) => CLOUD_KEY[k].label).join(" or ")} key.`}</p>@@ -212,16 +249,28 @@ export function GuestPrompt() {<div className="mb-1 grid size-10 place-items-center rounded-xl bg-primary text-primary-foreground"><Sparkles className="size-5" /></div>- <DialogTitle>{action === "upload" ? "Create a free account to add your own files" : "Create a free account to run this"}</DialogTitle>- <DialogDescription>You're browsing as a guest. Sign up with an email and a password to generate, upload and keep your work.</DialogDescription>+ <DialogTitle>{guestWords && action === "run" ? guestWords.title : action === "upload" ? "Create a free account to add your own files" : "Create a free account to run this"}</DialogTitle>+ <DialogDescription>+ {guestWords && action === "run"+ ? guestWords.body+ : viewer?.hosted && kept && action === "run"+ ? KEPT_RUN_WORDS+ : "You're browsing as a guest. Sign up with an email and a password to generate, upload and keep your work."}+ </DialogDescription></DialogHeader>- <DialogFooter className="gap-2 sm:justify-start">+ <DialogFooter className={guestWords ? "flex-wrap gap-2 sm:justify-start" : "gap-2 sm:justify-start"}><Button asChild><Link href={signInHref("signup", card?.here)} onClick={close}>Sign up free</Link></Button>- <Button asChild variant="secondary">+ {/* An item that runs on one's own GPU or key: another model is the way on right now. */}+ {guestWords && action === "run" && canPick && (+ <Button variant="secondary" onClick={pick}>+ <Shuffle /> Pick another model+ </Button>+ )}+ <Button asChild variant={guestWords && action === "run" && canPick ? "ghost" : "secondary"}><Link href={signInHref("login", card?.here)} onClick={close}>Log in</Link>diff --git a/src/components/model3d/model3d-studio.tsx b/src/components/model3d/model3d-studio.tsxindex 32f750ea..5dc842d6 100644--- a/src/components/model3d/model3d-studio.tsx+++ b/src/components/model3d/model3d-studio.tsx@@ -53,6 +53,7 @@ import { keepOffered, offered } from "@/lib/model-access";import type { ExampleRowData } from "@/lib/examples/types";import { cn } from "@/lib/utils";import { OwnSetupChip, useOwnSetupPress } from "@/components/own-setup";+import { RunPlaceChip, useOpenRunPlace } from "@/components/studio/run-place-chip";import { Model3dSetupsProvider, useModel3dSetup, type Model3dSetups } from "./own-setups";import { toastError } from "@/lib/refusals";import { priceLine, useCreate3d, useRunPreview } from "./hooks";@@ -370,6 +371,10 @@ function Model3dStudioBody({ info, examples }: { info: Record<string, Model3dInf: null;const preview = useRunPreview(engineKnown ? priced : null);const price = priceLine(preview.data);+ // Hosted runs on: where an open run goes and its price, from the price check every studio reads (this studio's GPUs and+ // the wait, or the label of what runs on the visitor's own GPU, which the button opens). Otherwise the line above.+ const openPlace = useOpenRunPlace(preview.data?.modelName ? [preview.data.modelName] : [], engine === "open" && engineKnown ? priced : null);+ const site = openPlace && (openPlace.where === "pool" || openPlace.setup) ? openPlace : null;const cloudAllowed = engineMode !== "open";// A guest, or an account without a key, on open models only: the cloud models run with its own fal.ai key, labelled,// and a press opens the step that sets it up (own-setup.ts).@@ -384,7 +389,7 @@ function Model3dStudioBody({ info, examples }: { info: Record<string, Model3dInfconst finalAllowed = engineMode !== "cloud" && offered(access, FINAL_3D.model, "open");const refining = refineAllowed && engine === "open" && (mode === "image" || mode === "multi") && refine !== null ? refine : null;// A run with a step on the visitor's own GPU: a guest gets the sign-up card, an account without a GPU "Connect your GPU".- const needs = refining !== null ? refineSetup : idolSplat && engine === "open" && idolTrim ? cleanSetup : null;+ const needs = refining !== null ? refineSetup : idolSplat && engine === "open" && idolTrim ? cleanSetup : (site?.setup ?? null);const go = () => {if (blocker) return void toast(blocker, { id: "3d-blocker" });if (needs) return void press(needs, start);@@ -584,14 +589,22 @@ function Model3dStudioBody({ info, examples }: { info: Record<string, Model3dInf<Button size="lg" className={cn("mt-4 w-full rounded-full", blocker && "bg-muted text-muted-foreground hover:bg-muted")} onClick={go} disabled={create.isPending}>{create.isPending ? <Loader2 className="size-4 animate-spin" /> : <Box className="size-4" />} {mode === "splat" ? "Make the splat" : "Make it 3D"}</Button>- <p className="mt-2 text-[12px] text-muted-foreground" aria-live="polite">- {blocker ? `${blocker} · ` : ""}- {preview.isError ? (preview.error as Error).message : (price ?? "Working out the price…")}- </p>+ {site ? (+ // Hosted runs: the same place chip as the studios (its panel says the place, the wait, or the setup).+ <div className="mt-2 flex flex-wrap items-center gap-2 text-[12px] text-muted-foreground" aria-live="polite">+ {blocker && <span>{blocker}</span>}+ <RunPlaceChip place={site} runLabel={mode === "splat" ? "Make the splat" : "Make it 3D"} />+ </div>+ ) : (+ <p className="mt-2 text-[12px] text-muted-foreground" aria-live="polite">+ {blocker ? `${blocker} · ` : ""}+ {preview.isError ? (preview.error as Error).message : (price ?? "Working out the price…")}+ </p>+ )}<p className="mt-1 text-[12px] text-muted-foreground">{idolSplat? engine === "open"- ? "Idol cuts the object out, builds the splat and renders an orbit video on your GPU. One object per picture."+ ? `Idol cuts the object out, builds the splat and renders an orbit video${site?.where === "pool" ? "" : " on your GPU"}. One object per picture.`: "Idol cuts the object out and builds the splat, ready to download. One object per picture.": mode === "splat"? engine === "open"diff --git a/src/components/own-setup.tsx b/src/components/own-setup.tsxindex 0df13736..71ceeeda 100644--- a/src/components/own-setup.tsx+++ b/src/components/own-setup.tsx@@ -105,19 +105,22 @@ export function useOwnSetupViewer(): OwnSetupViewer | null {/*** Opens what a step asks for. True when it opened something (the run waits); false for `run`. `requirement`: the- * item's label, said on "Connect your GPU".+ * item's label, said on "Connect your GPU"; `setup`: what it needs, so the card (a guest's sign-up too, while hosted runs+ * are on) says it and offers another model.*/-export function openOwnSetupStep(step: OwnSetupStep, requirement?: string): boolean {+export function openOwnSetupStep(step: OwnSetupStep, requirement?: string, setup?: OwnSetup): boolean {switch (step.kind) {case "sign-up":- askToSignUp("run");+ askToSignUp("run", setup ? { setup } : {});return true;case "add-key":openAddKey(step.provider);return true;case "connect-gpu":window.dispatchEvent(- new CustomEvent<ConnectGpuDetail>(CONNECT_GPU_EVENT, { detail: { action: "run", ...(step.gpuOnly ? { gpuOnly: true, needs: "gpu" } : { needs: "any" }), ...(requirement && { requirement }) } }),+ new CustomEvent<ConnectGpuDetail>(CONNECT_GPU_EVENT, {+ detail: { action: "run", ...(step.gpuOnly ? { gpuOnly: true, needs: "gpu" } : { needs: "any" }), ...(requirement && { requirement }), ...(setup && { setup }) },+ }),);return true;default:@@ -134,7 +137,7 @@ export function useOwnSetupPress(): (item: OwnSetup | string | null | undefined,return useCallback((item, run) => {const o = typeof item === "string" ? ownSetupOnly(item) : (item ?? null);- if (openOwnSetupStep(ownSetupStep(o, viewer), o ? ownSetupLabel(o) : undefined)) return false;+ if (openOwnSetupStep(ownSetupStep(o, viewer), o ? ownSetupLabel(o) : undefined, o ?? undefined)) return false;run?.();return true;},diff --git a/src/components/relight/relight-tool.tsx b/src/components/relight/relight-tool.tsxindex a14f6a86..42f43ef6 100644--- a/src/components/relight/relight-tool.tsx+++ b/src/components/relight/relight-tool.tsx@@ -15,6 +15,7 @@ import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popoverimport { Slider } from "@/components/ui/slider";import { Switch } from "@/components/ui/switch";import { Textarea } from "@/components/ui/textarea";+import { PLACEHOLDER } from "@/lib/composer";import { askToSignUp, uploadFile, useCreateGeneration, useGenerations, useHydrated, useIsAccount, useIsGuest, useIsOwner, useStatus } from "@/lib/api";import { RunPlaceChip, useOpenRunPlace } from "@/components/studio/run-place-chip";import { getModel, getPreset } from "@/lib/catalog";@@ -144,7 +145,9 @@ export function RelightTool({ app }: { app?: { name: string; description: stringconst account = useIsAccount();const status = useStatus().data;const gpu = !!status?.viewer?.gpu?.connected;- const canRun = owner || (account && gpu);+ // Hosted runs on: an account with no GPU of its own lights its photo on this studio's GPUs (the server says where).+ const hosted = !!status?.viewer?.hosted;+ const canRun = owner || (account && (gpu || hosted));const fine = useFinePointer();const create = useCreateGeneration();// The scene read goes through its own mutation, so a Generate sent at the same moment keeps its callbacks.@@ -485,7 +488,7 @@ export function RelightTool({ app }: { app?: { name: string; description: stringsetHint(GUEST_LINE);return void askToSignUp("run");}- if (account && !gpu) {+ if (account && !gpu && !hosted) {setHint(NO_GPU_LINE);return void openConnect();}@@ -507,7 +510,7 @@ export function RelightTool({ app }: { app?: { name: string; description: string}// The values it reads are listed; the helpers read the same state.// eslint-disable-next-line react-hooks/exhaustive-deps- }, [lights, guest, account, gpu, current, look, override, seed, photo, img, scene]);+ }, [lights, guest, account, gpu, hosted, current, look, override, seed, photo, img, scene]);/*** The blend at the photo's size, as a PNG: as large as this browser can draw and read back (phones cap a canvas at@@ -615,9 +618,14 @@ export function RelightTool({ app }: { app?: { name: string; description: stringconst busy = !!runId || create.isPending;const sceneBusy = !!sceneId && sceneRun.data?.status !== "succeeded" && sceneRun.data?.status !== "failed";const line = busy ? "Lighting your photo…" : aligning ? "Lining it up…" : sceneBusy ? "Reading the scene…" : photo.uploading ? "Uploading…" : null;- const keeper = owner || (account && gpu);- // Where the lighting is made and its price, as the studios say it: on your GPU, free (an account connects its own).- const place = useOpenRunPlace([getModel(RELIGHT_MODEL)?.name ?? "Qwen Image 2.1"], null, { ownGpuOnly: true });+ const keeper = owner || (account && (gpu || hosted));+ // Where the lighting is made and its price, as the studios say it: on your GPU, free (an account connects its own);+ // with hosted runs on, where the server's price check says (this studio's GPUs, or the label of what runs elsewhere).+ const quoteReq = useMemo(+ () => (hosted && !owner ? relightRequest({ photo: photo.serverUrl ?? PLACEHOLDER.image, lights, seed }) : null),+ [hosted, owner, photo.serverUrl, lights, seed],+ );+ const place = useOpenRunPlace([getModel(RELIGHT_MODEL)?.name ?? "Qwen Image 2.1"], quoteReq, { ownGpuOnly: !hosted });const changed = anyResult && !current;// "Again" only once this viewer has generated on this photo.const again = made ? "Generate again" : "Generate";diff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsxindex f0232e7a..905f8d63 100644--- a/src/components/studio/composer.tsx+++ b/src/components/studio/composer.tsx@@ -936,6 +936,8 @@ export function Composer({ docked }: { docked: boolean }) {if (runOnPicked === "key") return submitRef.current(skip, withKeyAction(keyTwin.provider, keyTwin.modelId, keyTwin.op, keyPrice));return void setKeyChoice(true);}+ // A guest (hosted runs on): the draft waits for the sign-up, and this setup opens once signed up (never a run).+ if (guestHold) guestDraft.keepRun(null, poolSetup);if (pressSetup(poolSetup)) return submitRef.current(skip, undefined, "own");return;}@@ -958,8 +960,10 @@ export function Composer({ docked }: { docked: boolean }) {// A guest (hosted runs on): the draft, its kept files and this run wait for the sign-up, with the price shown; back// here as an account, the run starts by itself when the price is unchanged.if (guestHold) {- guestDraft.keepRun(poolPrice && hostedQuote?.allowed ? { amount: hostedQuote.amount, priceVersion: hostedQuote.priceVersion, text: hostedQuote.text } : null);- return askToSignUp("run");+ const keptRun = poolPrice && hostedQuote?.allowed ? { amount: hostedQuote.amount, priceVersion: hostedQuote.priceVersion, text: hostedQuote.text } : null;+ guestDraft.keepRun(keptRun);+ // A run on this studio's GPUs starts by itself once the guest is in: the card says so.+ return askToSignUp("run", keptRun ? { kept: true } : {});}setRecent((r) => pushRecent(r, draft.modelId));// The server resolves @mentions and drawings itself; only pin the operation when there are none.@@ -1220,14 +1224,29 @@ export function Composer({ docked }: { docked: boolean }) {const keptLost = guestDraft.lost;useEffect(() => {if (!pendingRun) return;- const next = pendingStep({ settled: !settling && priceSettled, blocked: !!blocker, pool: poolPrice, shown: pendingRun.shown, quote: hostedQuote, lost: keptLost, same: pendingRun.same });+ const next = pendingStep({+ settled: !settling && priceSettled,+ blocked: !!blocker,+ pool: poolPrice,+ shown: pendingRun.shown,+ quote: hostedQuote,+ lost: keptLost,+ same: pendingRun.same,+ setup: !!poolSetup,+ labelled: !!pendingRun.setup,+ });if (next === "wait") return;clearPending();if (next === "start") submitRef.current(undefined, undefined, undefined, true);+ // Pressed on an item that runs on one's own GPU or key: its setup opens on this page (Connect your GPU, Add your key),+ // with the draft back; nothing runs. One the account has already: Run waits for a click.+ else if (next === "setup" && poolSetup) {+ if (pressSetup(poolSetup)) setPriceNote(PENDING_WORDS.ask);+ }else if (next === "lost") setPriceNote(PENDING_WORDS.lost);else if (next === "ask") setPriceNote(PENDING_WORDS.ask);else if (next === "note" && hostedQuote) setPriceNote(PENDING_WORDS.note(hostedQuote.text));- }, [pendingRun, clearPending, settling, priceSettled, blocker, poolPrice, hostedQuote, keptLost]);+ }, [pendingRun, clearPending, settling, priceSettled, blocker, poolPrice, hostedQuote, keptLost, poolSetup, pressSetup]);const blockedSlot = blocker?.slot;useEffect(() => {if (step === "wait" || startRequest <= startedFor.current) return;@@ -1801,6 +1820,7 @@ export function Composer({ docked }: { docked: boolean }) {madeWith={madeWith}boxes={layoutOn}ownSetup={modelSetup}+ answersPick/>) : (<Chip icon={Loader2} disabled className="[&>svg]:animate-spin">diff --git a/src/components/studio/feed.tsx b/src/components/studio/feed.tsxindex dd20b8eb..dd03a046 100644--- a/src/components/studio/feed.tsx+++ b/src/components/studio/feed.tsx@@ -6,7 +6,7 @@ import { lineWords } from "@/lib/pool-line";import { refreshPriceChecks } from "@/lib/hosted";import { openGpuSetup } from "@/hooks/use-gpu";import { useLocalJob } from "@/components/gpu/computer-runner";-import { jobFraction, jobWords, POOL_WORDS } from "@/lib/relay";+import { FILE_TROUBLE_WORDS, jobFraction, jobWords, POOL_WORDS } from "@/lib/relay";import { createContext, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";import { toast } from "sonner";import {@@ -169,7 +169,14 @@ export function PendingTile({ g, ratio }: { g: Generation; ratio: number }) {);}-export function FailedTile({ g, ratio, onRetry }: { g: Generation; ratio: number; onRetry: () => void }) {+/** The sentences about the person's own files: the same run would only fail again, so changing the draft comes first. */+const FILE_TROUBLE: readonly string[] = Object.values(FILE_TROUBLE_WORDS);++/**+ * A run that didn't make anything. `onReuse` (the feed's Reuse: the draft comes back to change): for a run on this+ * studio's GPUs that failed on the person's own files, Reuse is the main button and Retry the quiet second.+ */+export function FailedTile({ g, ratio, onRetry, onReuse }: { g: Generation; ratio: number; onRetry: () => void; onReuse?: () => void }) {const create = useCreateGeneration();const trouble = g.status === "failed" ? g.trouble : undefined;// Hosted runs: a run that failed on the person's own GPU can run once on this studio's GPUs instead.@@ -177,6 +184,7 @@ export function FailedTile({ g, ratio, onRetry }: { g: Generation; ratio: numberconst onSite = !!trouble && offersRunOnSite(g, !!site);// A run on this studio's GPUs that couldn't finish: one plain sentence (the server's), nothing technical.const poolFailed = g.place === "pool" && g.status === "failed";+ const reuseFirst = poolFailed && !!onReuse && FILE_TROUBLE.includes(g.error ?? "");return (<div className="flex h-full max-w-full flex-col justify-between rounded-xl border border-dashed bg-background p-3" style={{ aspectRatio: Math.max(ratio, 0.8) }}><div className="min-h-0 space-y-1 overflow-hidden">@@ -204,6 +212,18 @@ export function FailedTile({ g, ratio, onRetry }: { g: Generation; ratio: number/>)}<div className="mt-2 flex flex-wrap gap-1.5">+ {reuseFirst && (+ <button+ onClick={(e) => {+ e.stopPropagation();+ onReuse?.();+ }}+ title="Load prompt, model and settings into the composer"+ className="inline-flex h-7 w-fit items-center gap-1.5 rounded-full bg-highlight px-2.5 text-[12px] font-medium text-highlight-foreground hover:opacity-90"+ >+ <RotateCcw className="size-3" /> Reuse+ </button>+ )}{g.status === "failed" && g.fix && (// Something was missing on the GPU: the guided fix shows what, and how to add it.<button@@ -221,7 +241,12 @@ export function FailedTile({ g, ratio, onRetry }: { g: Generation; ratio: numbere.stopPropagation();onRetry();}}- className="inline-flex h-7 w-fit items-center gap-1.5 rounded-full bg-secondary px-2.5 text-[12px] font-medium hover:bg-accent"+ className={+ reuseFirst+ ? // After Reuse, the quiet second: the same files would only fail again.+ "inline-flex h-7 w-fit items-center gap-1.5 rounded-full px-2.5 text-[12px] font-medium text-muted-foreground hover:bg-accent hover:text-foreground"+ : "inline-flex h-7 w-fit items-center gap-1.5 rounded-full bg-secondary px-2.5 text-[12px] font-medium hover:bg-accent"+ }><RotateCcw className="size-3" /> Retry</button>@@ -470,7 +495,7 @@ export const GenerationGroup = memo(function GenerationGroup({ g, newest, first))}{(g.status === "failed" || g.status === "canceled") && (<div className="h-56 max-w-full sm:h-64">- <FailedTile g={g} ratio={ratio} onRetry={() => feed.retry(g)} />+ <FailedTile g={g} ratio={ratio} onRetry={() => feed.retry(g)} onReuse={feed.reuse ? () => feed.reuse?.(g) : undefined} /></div>)}{g.status === "succeeded" &&diff --git a/src/components/studio/guest-draft.ts b/src/components/studio/guest-draft.tsindex b13288b5..22420513 100644--- a/src/components/studio/guest-draft.ts+++ b/src/components/studio/guest-draft.ts@@ -2,6 +2,7 @@import { useCallback, useEffect, useRef, useState } from "react";import { clearDraft, readDraft, restoredDraft, restoredPrompt, sameDraft, saveDraft, savePendingRun, takePendingRun, type PendingRun, type ShownPrice } from "@/lib/guest-draft";+import type { OwnSetup } from "@/lib/own-setup";import { replaceAttachment } from "@/lib/composer";import { readHeld } from "@/lib/held-files";import { uploadHeld, type SlotValue } from "./media-slot";@@ -73,13 +74,16 @@ export function useGuestDraft({ hold, viewer, draft, setDraft }: { hold: booleanif (hold && restored.current && path.current) saveDraft(path.current, draft as unknown as Parameters<typeof saveDraft>[1]);}, [hold, draft]);- /** A guest pressed Run: the draft and the run (with the price it showed, and the draft it was pressed on) wait for the sign-up. */+ /**+ * A guest pressed Run: the draft and the run (with the price it showed, and the draft it was pressed on) wait for the+ * sign-up. `setup`: pressed on an item that runs on one's own GPU or key, whose setup opens then instead.+ */const keepRun = useCallback(- (shown: ShownPrice) => {+ (shown: ShownPrice, setup?: OwnSetup) => {if (!path.current) return;const kept = draft as unknown as Parameters<typeof saveDraft>[1];saveDraft(path.current, kept);- savePendingRun(path.current, shown, kept);+ savePendingRun(path.current, shown, kept, setup);},[draft],);diff --git a/src/components/studio/model-picker.tsx b/src/components/studio/model-picker.tsxindex 275b2667..8419f3f6 100644--- a/src/components/studio/model-picker.tsx+++ b/src/components/studio/model-picker.tsx@@ -21,6 +21,7 @@ import { readsBoxes } from "@/lib/layout-prompt";import { pickerPrice } from "@/lib/model-rows";import { cn } from "@/lib/utils";import { ownSetupLabel } from "@/lib/own-setup";+import { answerPickModel } from "@/lib/pick-model";import { addKeyLabel, billedTo, CLOUD_KEY, CLOUD_PROVIDERS, needsKey, type CloudProvider } from "@/lib/your-keys";import { EngineSwitch } from "./engine-switch";import { ResponsivePanel } from "./responsive-panel";@@ -213,6 +214,8 @@ interface PickerProps {* with that label in place of its price, never left out.*/ownSetup?: (m: ModelDef) => OwnSetup | null;+ /** This picker opens for "Pick another model" on a card (src/lib/pick-model.ts): the studio composer's own. */+ answersPick?: boolean;}/**@@ -231,7 +234,8 @@ export function phoneName(name: string): string {export function ModelPicker(props: PickerProps) {const [open, setOpen] = useState(false);- const { value, models, onChange } = props;+ const { value, models, onChange, answersPick } = props;+ useEffect(() => (answersPick ? answerPickModel(() => setOpen(true)) : undefined), [answersPick]);const made = !!value && value.id === props.madeWith;// The model a dimmed row was chosen for (by this picker only): picked once its key is saved and the studio knows it// (the status has the key, so the engine switch is on Cloud and nothing swaps the model back to an open one).diff --git a/src/lib/api.ts b/src/lib/api.tsindex c7b96f68..b9524d9a 100644--- a/src/lib/api.ts+++ b/src/lib/api.ts@@ -28,7 +28,7 @@ import {import { fetchWithin, READ_LIMIT_MS } from "./fetch-within";import { cursorAfter, filterToSearch, type AssetUse, type FeedFilter, type Folder } from "./library";import { markRefusalShown, refusalShown, responseError } from "./refusals";-import { PLACE_ASK_HEADER, RUN_PLACE_HEADER, RUN_SHOWN_HEADER, RUNS_CHANGED_EVENT, shownHeader } from "./guest-access";+import { OWN_SETUP_HEADER, PLACE_ASK_HEADER, RUN_PLACE_HEADER, RUN_SHOWN_HEADER, RUNS_CHANGED_EVENT, shownHeader } from "./guest-access";import type { PoolRules } from "./pool-rules";import { HoldFilesCtx } from "./held-files";import { postFile } from "./upload";@@ -36,6 +36,7 @@ import type { ShareCreated, ShareInfo, ShareListItem, SharePatch, ShareRequest }import type { AccessSummary } from "./model-access";import { ADD_KEY_HEADER, isCloudProvider, type CloudProvider } from "./your-keys";import type { Diagnosis } from "./diagnose";+import type { OwnSetup } from "./own-setup";import { BILLING_EVENT, BILLING_HEADER, refreshPriceChecks, type BillingAction, type BillingRefusalDetail, type HostedBalance } from "./hosted";import { knownPlace, notePlaceName, placeOf, type Place } from "./place-name";import { ENGINE_KEY, ENGINE_SLOT_KEY, engineSlot, SHARED_SLOT, slotToCache, storedEngine, type EngineSlot, type SlotFacts } from "./engine-pref";@@ -1548,9 +1549,15 @@ export type RefusalCard = { kind: "guest"; here: string } | { kind: "gpu" };/** What a refusal card is about, for its words: a run (or any other change), or adding a file of one's own. */export type RefusalAction = "run" | "upload";-/** What the cards' events may say (GUEST_PROMPT_EVENT, CONNECT_GPU_EVENT). Without it, a card is about a run. */+/**+ * What the cards' events may say (GUEST_PROMPT_EVENT, CONNECT_GPU_EVENT). Without it, a card is about a run. `setup`: the+ * press was on an item that runs on one's own GPU or key (its label), so the card says what it needs and how to get+ * there; `kept`: a guest's run a studio keeps through sign-up, which starts once the guest is in.+ */export interface RefusalDetail {action?: RefusalAction;+ setup?: OwnSetup;+ kept?: boolean;}/** The requests that add a file of the visitor's own: their refusal's card says "add your own files", not "run this". */@@ -1565,9 +1572,12 @@ function requestPath(input: RequestInfo | URL): string {}}-/** Opens "Create a free account" on its own (GuestPrompt), e.g. before a guest's file chooser: it could only be refused. */-export function askToSignUp(action: RefusalAction = "upload"): void {- window.dispatchEvent(new CustomEvent<RefusalDetail>(GUEST_PROMPT_EVENT, { detail: { action } }));+/**+ * Opens "Create a free account" on its own (GuestPrompt), e.g. before a guest's file chooser: it could only be refused.+ * `more`: the label of the item pressed (`setup`), or a run kept through sign-up (`kept`).+ */+export function askToSignUp(action: RefusalAction = "upload", more: Pick<RefusalDetail, "setup" | "kept"> = {}): void {+ window.dispatchEvent(new CustomEvent<RefusalDetail>(GUEST_PROMPT_EVENT, { detail: { action, ...more } }));}/**@@ -1653,6 +1663,17 @@ export async function sendRunAgain(input: RequestInfo | URL, init: RequestInit |/** A body a run can be sent again with (a string: a form or a stream is read once). */const resendable = (input: RequestInfo | URL, init: RequestInit | undefined): boolean => !(input instanceof Request) && (init?.body === undefined || typeof init.body === "string");+/** The own GPU a refused run's label names (OWN_SETUP_HEADER), or null. */+function readSetupHeader(v: string | null): OwnSetup | null {+ if (!v || v.length > 300) return null;+ try {+ const o = JSON.parse(decodeURIComponent(v)) as OwnSetup;+ return o && typeof o === "object" && o.need === "gpu" ? o : null;+ } catch {+ return null;+ }+}+export function watchGuestRefusals(): void {const w = window as typeof window & { __fuobeGuestFetch?: boolean };if (w.__fuobeGuestFetch) return;@@ -1663,7 +1684,9 @@ export function watchGuestRefusals(): void {markRefusalShown(res);const needs = asNeeds(res.headers.get("x-fuobe-connect-needs"));const detail: ConnectGpuDetail = { action: UPLOAD_PATHS.has(path) ? "upload" : "run", ...(needs && { needs }) };- window.dispatchEvent(new CustomEvent(kind === "guest" ? GUEST_PROMPT_EVENT : CONNECT_GPU_EVENT, { detail }));+ // A run refused for what runs on the visitor's own GPU (a label, hosted runs on): the card says what it needs.+ const setup = kind === "gpu" ? readSetupHeader(res.headers.get(OWN_SETUP_HEADER)) : null;+ window.dispatchEvent(new CustomEvent(kind === "guest" ? GUEST_PROMPT_EVENT : CONNECT_GPU_EVENT, { detail: { ...detail, ...(setup && { setup }) } }));};window.fetch = async (input: RequestInfo | URL, init?: RequestInit) => {const res = await original(input, init);diff --git a/src/lib/board-run-words.ts b/src/lib/board-run-words.tsnew file mode 100644index 00000000..aefc1e36--- /dev/null+++ b/src/lib/board-run-words.ts@@ -0,0 +1,22 @@+import type { Place } from "./place-name";++/**+ * What a visitor's Run on a canvas board opens (src/components/canvas/visitor-canvas.tsx): a board is built, changed and+ * kept here, and made in a studio, which runs every step at once. `oneStep`: the board is one effect of the Video studio.+ * `place` (hosted runs on): the name visitors read for this install's GPUs, said as where the studio runs it, never+ * "isn't available here". Null: today's words. Pure: tests/hosted-surface-labels.test.ts.+ */+export function boardRunWords(oneStep: boolean, place: Place | null): { title: string; body: string } {+ if (!place) {+ return {+ title: "Running a board isn't available here",+ body: `You can build, change and keep boards here. ${oneStep ? "To make this result now, use the same effect in the Video studio: it runs every step at once." : "To make something now, use the Image, Video or Audio studio, or an app, effect or camera motion."}`,+ };+ }+ return oneStep+ ? { title: "Make this in the Video studio", body: `You can build, change and keep boards here. The same effect in the Video studio runs every step at once, on ${place.text}.` }+ : {+ title: "Make it in a studio",+ body: `You can build, change and keep boards here. To make something now, use the Image, Video or Audio studio, or an app, effect or camera motion. They run on ${place.text}.`,+ };+}diff --git a/src/lib/guest-access.ts b/src/lib/guest-access.tsindex 87b1ed78..72afb908 100644--- a/src/lib/guest-access.ts+++ b/src/lib/guest-access.ts@@ -426,12 +426,27 @@ export const ACTIVE_RUNS_CODE = "active-runs";export const OWN_GPU_TOOL_MESSAGE = "This tool isn't available here. Try the Image, Video or Audio studio, or an app, effect or camera motion.";+/**+ * The same answer while hosted runs are on (a tool that runs for the studio's owner only: no GPU or key of a visitor's+ * own runs it yet, so no setup is offered), with the way on: the studios.+ */+export const OWN_GPU_TOOL_HOSTED = "This one isn't open to accounts yet. Try the Image, Video or Audio studio, or an app, effect or camera motion.";++/** A tool no visitor's own GPU or key runs yet, in the words for this install (hosted runs on or off). */+export const ownGpuToolMessage = (hosted: boolean): string => (hosted ? OWN_GPU_TOOL_HOSTED : OWN_GPU_TOOL_MESSAGE);+/*** The header of an account's run the server asks about instead of moving (409): its own GPU didn't answer, and the run* named no place. The page offers to run it on this studio's GPUs (watchGuestRefusals).*/export const PLACE_ASK_HEADER = "x-fuobe-place-ask";+/**+ * The own GPU a refused run's label names (hosted runs on: an item this install's GPUs don't run), as URI-encoded JSON+ * (an OwnSetup), beside x-fuobe-connect-gpu: the card that opens says what it needs.+ */+export const OWN_SETUP_HEADER = "x-fuobe-own-setup";+/** Fired when a run started from a toast or a card (not from a page's own button), so the lists show it. */export const RUNS_CHANGED_EVENT = "fuobe:runs-changed";diff --git a/src/lib/guest-draft.ts b/src/lib/guest-draft.tsindex f9d59cb4..5ffd4ea1 100644--- a/src/lib/guest-draft.ts+++ b/src/lib/guest-draft.ts@@ -1,4 +1,5 @@import type { MediaKind } from "./catalog/types";+import type { OwnSetup } from "./own-setup";/*** A guest's whole studio draft through sign-up (hosted runs on): the words, the model and its settings, the preset and@@ -139,12 +140,14 @@ export interface PendingRun {at: number;/** The draft Run was pressed on (draftPrint). */draft?: string;+ /** Run was pressed on an item that runs on one's own GPU or key (its label): its setup opens once signed up. */+ setup?: OwnSetup;}-/** A guest pressed Run here on this draft: kept for this tab, to start once signed up. */-export function savePendingRun(path: string, shown: ShownPrice, draft?: DraftLike): void {+/** A guest pressed Run here on this draft: kept for this tab, to start (or open its setup: `setup`) once signed up. */+export function savePendingRun(path: string, shown: ShownPrice, draft?: DraftLike, setup?: OwnSetup): void {try {- store()?.setItem(PENDING_KEY, JSON.stringify({ path, shown, at: Date.now(), ...(draft && { draft: draftPrint(draft) }) } satisfies PendingRun));+ store()?.setItem(PENDING_KEY, JSON.stringify({ path, shown, at: Date.now(), ...(draft && { draft: draftPrint(draft) }), ...(setup && { setup }) } satisfies PendingRun));} catch {}}@@ -213,8 +216,12 @@ export const PENDING_WORDS = {* other runs, until the day's GPU time renews: the server takes it all the same); or the price can't be known now* (the billing service doesn't answer: the run waits for it, and is priced against the price the guest saw);* - note: a new price, shown, and Run waits for a click;+ * - setup: it runs on one's own GPU or key (the price check says its label, `setup`): that setup opens (Connect your GPU,+ * Add your key) with the draft back, and nothing starts;* - none: something is missing (the blocker says what), it would run elsewhere, it is refused now, or no price was shown* to compare.+ * A run pressed on such an item (`labelled`) never starts by itself: when it runs here now, the draft is back and Run+ * waits for a click (`ask`).*/export function pendingStep(o: {settled: boolean;@@ -224,10 +231,15 @@ export function pendingStep(o: {quote?: { allowed: boolean; amount: number; text: string };lost: boolean;same: boolean;-}): "wait" | "start" | "note" | "ask" | "lost" | "none" {+ setup?: boolean;+ labelled?: boolean;+}): "wait" | "start" | "note" | "ask" | "lost" | "setup" | "none" {if (o.lost) return "lost";if (!o.settled) return "wait";- if (o.blocked || !o.pool) return "none";+ if (o.blocked) return "none";+ if (o.setup) return "setup";+ if (o.labelled) return o.pool && o.quote?.allowed ? "ask" : "none";+ if (!o.pool) return "none";if (!o.same) return o.quote?.allowed ? "ask" : "none";if (priceUnchanged(o.shown, o.quote)) return "start";// Allowed with no price said: the service doesn't answer now (the run is taken and waits for it).diff --git a/src/lib/own-setup-card.ts b/src/lib/own-setup-card.tsnew file mode 100644index 00000000..1a1900fa--- /dev/null+++ b/src/lib/own-setup-card.ts@@ -0,0 +1,36 @@+import { keyName, type OwnSetup } from "./own-setup";+import type { Place } from "./place-name";++/**+ * The card a press on a labelled item opens while hosted runs are on (an item this install's GPUs don't run: "Runs on+ * your own GPU · 48 GB", "Use your own fal.ai key"): what it needs, and the way there. A guest reads how signing up+ * leads there, never that the run starts once signed in (nothing can start before the GPU or key exists); an account+ * reads how connecting its GPU runs it. Both read that everything else runs on the place (`place`: the name visitors+ * read for this install's GPUs). Pure: tests/own-setup-card.test.ts.+ */++/** What a GPU item needs, as a sentence's object: "a GPU with 48 GB of memory", "a Linux computer with …". */+function gpuNeed(o: Extract<OwnSetup, { need: "gpu" }>): string {+ const card = o.vramGb ? `a GPU with ${o.vramGb} GB of memory` : "a GPU of your own";+ return o.linux ? `a Linux computer with ${card}` : card;+}++export function setupCardWords(o: OwnSetup, place: Place | null, who: "guest" | "account"): { title: string; body: string } {+ const rest = place ? ` Everything else runs on ${place.text}.` : "";+ if (o.need === "key") {+ const name = keyName(o.provider);+ return who === "guest"+ ? { title: `This one runs with your own ${name} key`, body: `Sign up free, then add your key. ${name} bills your runs to your account with them.${rest}` }+ : { title: `This one runs with your own ${name} key`, body: `Add your key, and this runs with it. ${name} bills your runs to your account with them.${rest}` };+ }+ const orKey = o.orKey ? ` Or use your own ${keyName(o.orKey)} key.` : "";+ return who === "guest"+ ? { title: "This one runs on your own GPU", body: `It needs ${gpuNeed(o)}. Sign up free, then connect yours in a few steps.${rest}${orKey}` }+ : { title: "This one runs on your own GPU", body: `It needs ${gpuNeed(o)}. Connect yours, and this runs there.${rest}${orKey}` };+}++/**+ * The guest card's words for a run a studio kept through sign-up (an item this install's GPUs run): it starts as soon as+ * the guest is in. Said only for such a run.+ */+export const KEPT_RUN_WORDS = "Sign up with an email and a password. Your run starts as soon as you're in.";diff --git a/src/lib/own-setup.ts b/src/lib/own-setup.tsindex 142560bc..b51946bf 100644--- a/src/lib/own-setup.ts+++ b/src/lib/own-setup.ts@@ -158,7 +158,11 @@ export function ownSetupGraphs(id: string): readonly string[] {export const OWN_SETUP_IDS: readonly string[] = Object.keys(ITEMS);const KEY_NAME: Record<string, string> = { fal: "fal.ai", replicate: "Replicate" };-const keyName = (p: string) => KEY_NAME[p] ?? p;+/** A key provider's name as people read it: "fal.ai", "Replicate". */+export const keyName = (p: string): string => KEY_NAME[p] ?? p;++/** The own GPU a 3D model runs on when its workflow's index names no memory (hosted runs: one no worker finishes). */+export const MODEL3D_SETUP: OwnSetup = { need: "gpu", vramGb: 24 };/*** The label next to an item: "Runs on your own GPU · 48 GB", "Set up on your computer", "Use your owndiff --git a/src/lib/pick-model.ts b/src/lib/pick-model.tsnew file mode 100644index 00000000..55635d30--- /dev/null+++ b/src/lib/pick-model.ts@@ -0,0 +1,25 @@+/**+ * "Pick another model" from a card (an item that runs on one's own GPU or key): the page's model picker opens. The studio+ * composer's picker answers it (the last one shown, when a page has more); a page with none doesn't offer the button.+ */++const openers: (() => void)[] = [];++/** A picker answers "Pick another model" while it is shown: returns what stops it. */+export function answerPickModel(open: () => void): () => void {+ openers.push(open);+ return () => {+ const i = openers.lastIndexOf(open);+ if (i >= 0) openers.splice(i, 1);+ };+}++/** Is there a picker on this page to open? */+export const canPickModel = (): boolean => openers.length > 0;++/** Open the page's model picker. False when there is none. */+export function pickAnotherModel(): boolean {+ const open = openers[openers.length - 1];+ open?.();+ return !!open;+}diff --git a/src/lib/run-place.ts b/src/lib/run-place.tsindex 3fd5a09e..d11fceb9 100644--- a/src/lib/run-place.ts+++ b/src/lib/run-place.ts@@ -82,6 +82,13 @@ const list = (names: readonly string[]) => (names.length < 2 ? (names[0] ?? "")/** Unique names, in order. */const uniq = (names: readonly string[] | undefined) => [...new Set((names ?? []).filter(Boolean))];+/**+ * A tool that runs for the studio's owner only, as anyone else reads it while hosted runs are on: what is coming, and the+ * studios to use now (never "Not available here").+ */+const OWNER_ONLY_HOSTED: Omit<RunPlace, "tip"> = { where: "unavailable", label: "Coming soon", price: "", title: "Coming soon", send: "" };+export const ownerOnlyTip = (tool: string): string => `${tool} isn't open to accounts yet. Try the Image, Video or Audio studio.`;+/** The price's words (the studio composer's costLabel, without the place: the chip says that). */export function placePrice(s: { demo?: boolean; costUsd?: number | null; open: boolean }, format: (usd: number) => string): string {if (s.demo) return "Placeholder · free";@@ -105,6 +112,8 @@ export function runPlace(input: RunPlaceInput): RunPlace {};}if (input.ownerOnly && audience !== "owner") {+ // Hosted runs on: said as what is coming, with the way on now (no visitor's own GPU or key runs it yet, so no setup).+ if (input.hosted) return { ...OWNER_ONLY_HOSTED, tip: ownerOnlyTip(input.ownerOnly) };return {where: "unavailable",label: "Not available here",diff --git a/src/proxy.ts b/src/proxy.tsindex 28b46f29..fb6f21c5 100644--- a/src/proxy.ts+++ b/src/proxy.ts@@ -24,7 +24,7 @@ import {isLibraryChange,isPriceCheck,LIBRARY_MESSAGE,- OWN_GPU_TOOL_MESSAGE,+ ownGpuToolMessage,ownerOnly,ownGpuRun,poolToolRun,@@ -224,8 +224,11 @@ function guest(request: NextRequest): NextResponse {return NextResponse.json({ error: GUEST_RUN_MESSAGE }, { status: 401, headers: guestHeaders });}-/** A tool that doesn't run on an account's own GPU or key yet, for a guest or an account: one answer (no sign-up card). */-const ownGpuTool = () => NextResponse.json({ error: OWN_GPU_TOOL_MESSAGE, code: "own-gpu-tool" }, { status: 403, headers: { "Cache-Control": "no-store" } });+/**+ * A tool that doesn't run on an account's own GPU or key yet, for a guest or an account: one answer (no sign-up card), in+ * the words for this install (hosted runs on: no "isn't available here").+ */+const ownGpuTool = () => NextResponse.json({ error: ownGpuToolMessage(hostedRunsOn()), code: "own-gpu-tool" }, { status: 403, headers: { "Cache-Control": "no-store" } });/** Any change to Assist by a visitor (a guest, or an account with or without a GPU): one answer, which the Assist pages also show. */const assistOwner = () => NextResponse.json({ error: ASSIST_OWNER_MESSAGE, code: "assist-owner" }, { status: 403, headers: { "Cache-Control": "no-store" } });diff --git a/src/server/account-tool-run.ts b/src/server/account-tool-run.tsindex 9454eba0..1a863544 100644--- a/src/server/account-tool-run.ts+++ b/src/server/account-tool-run.ts@@ -1,6 +1,6 @@import "server-only";import { AsyncLocalStorage } from "node:async_hooks";-import { ACTIVE_RUNS_CODE, CONNECT_GPU_HEADER, GUEST_HEADER, GUEST_RUN_MESSAGE, OWN_GPU_TOOL_MESSAGE } from "@/lib/guest-access";+import { ACTIVE_RUNS_CODE, CONNECT_GPU_HEADER, GUEST_HEADER, GUEST_RUN_MESSAGE, ownGpuToolMessage } from "@/lib/guest-access";import { ANY_ANGLE } from "@/lib/catalog/any-angle";import { graphLoras as h3GraphLoras } from "@/lib/catalog/character-swap";import { pikaFlexGraphLoras } from "@/lib/catalog/pika-flex";@@ -14,12 +14,12 @@ import { accountInputProblem } from "./account-inputs";import { checkAccountLoras } from "./account-loras";import { requestViewer, type Account } from "./auth";import { accountRun, AccountRunError, asAccount, asVisitor, outputKind, previewChained, type AccountRunRefusal } from "./generations";-import { BILLING_HEADER, type Quote } from "./billing";+import type { Quote } from "./billing";import { queueRelease } from "./billing-outbox";import { gateGeneration, GPU_SETUP_HEADER } from "./gpu/gate";import { gpuTargetFor } from "./gpu/target";import { runOnPool } from "./hosted";-import { decideToolPlace, GUEST_PLAN, madeRunProblem, moderateRun, policyWait, poolMayTake, poolOutputsCap, readWishes, reservePool, toolPoolQuote, type PlaceWish, type PoolLine, type Refusal, type ReserveFacts, type ReserveWait, type ToolPoolRun } from "./hosted-run";+import { decideToolPlace, GUEST_PLAN, lateRefusal, madeRunProblem, moderateRun, policyWait, poolMayTake, poolOutputsCap, readWishes, reservePool, toolPoolQuote, type PlaceWish, type PoolLine, type Refusal, type ReserveFacts, type ReserveWait, type ToolPoolRun } from "./hosted-run";import { cancelGeneration, captureRun } from "./generations";import { AdmitRefused, admitRun, clientAddress, closeAdmission, forgetAdmission, openAdmission, ownActiveRuns, poolLimitPlan, type AdmitPlan } from "./pool-limits";import { heldGuessMs, holdRun, holdShape } from "./pool-holds";@@ -67,7 +67,7 @@ const NO_STORE = { "Cache-Control": "no-store" };export const guestRun = () => Response.json({ error: GUEST_RUN_MESSAGE }, { status: 401, headers: { [GUEST_HEADER]: "1", ...NO_STORE } });/** A tool (or a step of one) that doesn't run on an account's own GPU or key: one answer, no sign-up card. */-export const ownGpuTool = () => Response.json({ error: OWN_GPU_TOOL_MESSAGE, code: "own-gpu-tool" }, { status: 403, headers: NO_STORE });+export const ownGpuTool = () => Response.json({ error: ownGpuToolMessage(hostedRunsOn()), code: "own-gpu-tool" }, { status: 403, headers: NO_STORE });/*** Run `fn` as the viewer's work: the owner's as it is; an account's inside asAccount (its files, its runs, its GPU, its@@ -605,7 +605,11 @@ async function startOnPool<T>(};/** Refused from here on: after its hold was made, when one was (it goes back). */const refused = (response: Response): AccountToolResult<T> => ({ ...back(response), ...(stamp.hold && { held: true }) });- const notOffered = (error: string) => refuse(403, error, { code: "not-offered" }, { [BILLING_HEADER]: "not-offered" });+ // A step of the run as made that these GPUs don't take: its label, which opens Connect your GPU (lateRefusal).+ const notOffered = (error: string) => {+ const late = lateRefusal(error);+ return refuse(late.status, late.body.error, late.body, late.headers);+ };/*** What the start made: its capture (its value, and its rows, which keep coming while an awaiting start runs), its open* admission, and what the policy's limits decided (whether it waits to enter the line).diff --git a/src/server/computer/pool.ts b/src/server/computer/pool.tsindex 86b04a36..7634d322 100644--- a/src/server/computer/pool.ts+++ b/src/server/computer/pool.ts@@ -954,6 +954,24 @@ export function workersCanRun(workflowId: string | null, o: { size?: Needs["sizereturn ableWorkers(workflowId, o).length > 0;}+/**+ * The largest job of a workflow any worker that may and can run it makes (its PC's ceiling), each limit apart: undefined+ * where one of them has no limit, and for a workflow none of them runs. Said before Run with a size they don't make.+ */+export function workersMost(workflowId: string): { maxMegapixels?: number; maxSeconds?: number; maxOutputs?: number } {+ const ceilings = ableWorkers(workflowId).map(ceilingOf);+ const most = (k: "maxMegapixels" | "maxSeconds" | "maxOutputs"): number | undefined => {+ if (!ceilings.length || ceilings.some((c) => !c?.[k])) return undefined;+ return Math.max(...ceilings.map((c) => c![k]!));+ };+ const out: { maxMegapixels?: number; maxSeconds?: number; maxOutputs?: number } = {};+ for (const k of ["maxMegapixels", "maxSeconds", "maxOutputs"] as const) {+ const v = most(k);+ if (v !== undefined) out[k] = v;+ }+ return out;+}+/** The workers that may and can run this workflow (any workflow: null), whatever their state now (workersCanRun). */function ableWorkers(workflowId: string | null, o: { size?: Needs["size"]; tickets?: boolean } = {}): WorkerRow[] {const needs = workflowId ? needsOf(loadIndex(), workflowId) : null;diff --git a/src/server/generations.ts b/src/server/generations.tsindex f002415d..11225b4e 100644--- a/src/server/generations.ts+++ b/src/server/generations.ts@@ -96,6 +96,7 @@ import {type TroubleAction,} from "@/lib/diagnose";import { CONNECT_GPU_MESSAGE, GUEST_RUN_MESSAGE, OWN_GPU_TOOL_MESSAGE } from "@/lib/guest-access";+import { MODEL3D_SETUP, ownSetupLabel } from "@/lib/own-setup";import { outsideTenant, runAsTenant, tenant, tenantAccount } from "./tenant";import { generationAccount } from "./account-library";import { ACCOUNT_LIMITS, ACCOUNT_MESSAGES, accountTotalBytes, accountUsage, diskHasRoom, filesFullMessage } from "./account-files";@@ -1209,7 +1210,8 @@ export function createGenerations(sent: GenerationRequest, opts: CreateOptions =// worker runs it (poolFinishes3d). Any Angle's 3D view is the exception: a splat and its turntable, nothing to finish.if (original.account && original.place === "pool" && shotModel?.kind === "model3d" && shotModel.id !== ANY_ANGLE.buildModel) {const ops = original.op ? [original.op] : shotModel.routes.filter((r) => r.provider === "comfyui").map((r) => r.op);- if (!ops.length || !ops.every((op) => poolFinishes3d({ provider: "comfyui", op }))) throw new Error(OWN_GPU_TOOL_MESSAGE);+ // (The gate says this before Run as a label: hosted-run.ts poolGate. This is its last guard, in the same words.)+ if (!ops.length || !ops.every((op) => poolFinishes3d({ provider: "comfyui", op }))) throw new Error(ownSetupLabel(MODEL3D_SETUP));}if (!opts.dependsOn && shotModel?.options.multiShot?.mode === "concat" && (original.params?.shots?.filter((x) => x.prompt.trim()).length ?? 0) > 1) {return createShotFilm(original, shotModel);diff --git a/src/server/hosted-run.ts b/src/server/hosted-run.tsindex 0ab0f8f4..4502846f 100644--- a/src/server/hosted-run.ts+++ b/src/server/hosted-run.ts@@ -1,9 +1,10 @@import "server-only";import crypto from "node:crypto";import { nanoid } from "nanoid";+import { ANY_ANGLE } from "@/lib/catalog/any-angle";import type { GenerationRequest } from "@/lib/catalog/types";-import { CONNECT_GPU_HEADER, OWN_GPU_TOOL_MESSAGE } from "@/lib/guest-access";-import { ownSetupLabel, type OwnSetup } from "@/lib/own-setup";+import { CONNECT_GPU_HEADER, OWN_SETUP_HEADER } from "@/lib/guest-access";+import { MODEL3D_SETUP, ownSetupDetail, ownSetupLabel, type OwnSetup } from "@/lib/own-setup";import { gpuState } from "./account-gpu";import { accountGpu, type Account } from "./auth";import {@@ -42,7 +43,7 @@ import { loadIndex } from "./gpu/index-file";import { attemptLimitMs, MAX_ATTEMPTS, poolLane } from "./computer/pool";import { poolFinishes3d } from "./computer/finish";import { holdTiming } from "./queue-settings";-import { hostedGuestWords, hostedWords, inputCounts, outputsWords, poolAllows, poolAllowsRun, poolAway, poolOnWorkers, poolReady, poolRunsProvider, poolTakes, poolTicketsReady, poolUploads, POOL_LANE, queueFacts, runFacts, runOnPool, workflowPicks } from "./hosted";+import { hostedDetails, hostedGuestWords, hostedWords, inputCounts, isOutputsWords, outputsWords, poolAllows, poolAllowsRun, poolAway, poolFitsSize, poolMostWords, poolOnWorkers, poolReady, poolRunsProvider, poolTakes, poolTicketsReady, poolUploads, POOL_LANE, queueFacts, runFacts, runOnPool, workflowPicks, type JobSize } from "./hosted";import { withRunStamp } from "./run-stamp";import { hostedRunsOn } from "./hosted-switch";import { checkRun, moderationConfigured } from "./moderation";@@ -151,20 +152,34 @@ const ownSetupRefusal = (setup: OwnSetup): { kind: "refuse"; refusal: Refusal }refusal: {status: 403,body: { error: ownSetupLabel(setup), code: setup.need === "key" ? "add-key" : "connect-gpu", ownSetup: setup, ...(setup.need === "key" && { provider: setup.provider }) },- headers: setup.need === "key" ? { [ADD_KEY_HEADER]: setup.provider } : { [CONNECT_GPU_HEADER]: "1" },+ headers: setup.need === "key" ? { [ADD_KEY_HEADER]: setup.provider } : { [CONNECT_GPU_HEADER]: "1", [OWN_SETUP_HEADER]: encodeURIComponent(JSON.stringify(setup)) },},});-/** A gate's refusal as the run's answer: its words, with the own setup that would run it. */+/**+ * A gate's refusal as the run's answer: its label (gateText), with the own setup that runs it, so the page opens that+ * setup ("Connect your GPU", "Add your key") instead of saying no. A run past the outputs a run here makes says so in+ * words (the person picks fewer).+ */function gateRefusal(gate: GateRefusal, place: Place): { kind: "refuse"; refusal: Refusal } {- if (gate.reason === "ownSetup") return ownSetupRefusal(gate.setup ?? needsGpu());- const error = gateText(gate, false, place);- if (gate.reason === "model3d") return { kind: "refuse", refusal: { status: 403, body: { error, code: "own-gpu-tool" }, headers: {} } };- const r = notOffered(error);- if (gate.setup) r.refusal.body.ownSetup = gate.setup;+ if (gate.reason === "outputs") return notOffered(gateText(gate, false, place));+ const r = ownSetupRefusal(gate.setup ?? needsGpu());+ if (gate.reason === "ownSetup") return r;+ r.refusal.body.error = gateText(gate, false, place);return r;}+/**+ * A late guard's answer (stepsProblem, madeRunProblem: a step of the run as made that this install's GPUs don't take,+ * after the gate took its plan): its label, which opens Connect your GPU as the gate's does. A run past the outputs a run+ * here makes stays words (the person picks fewer).+ */+export function lateRefusal(problem: string): Refusal {+ if (isOutputsWords(problem)) return notOffered(problem).refusal;+ const r = ownSetupRefusal(needsGpu()).refusal;+ return { ...r, body: { ...r.body, error: problem } };+}+/** The question for a run whose own GPU didn't answer, with the place name its "Run on …" button says. */const askPlace = (place: Place): Refusal => ({ status: 409, body: { error: ownGpuQuiet(place), code: "own-gpu-offline", placeName: place.label }, headers: { [PLACE_ASK_HEADER]: "1" } });@@ -248,13 +263,20 @@ export function stepsProblem(p: Policy, steps: PlannedStep[]): string | null {if (s.provider === "comfyui" && !poolTakes(stepEndpoint(s))) return words.notOffered;continue;}- if (s.provider !== "comfyui" || (s.kind === "model3d" && !poolFinishes3d(s))) return words.notOffered;+ if (s.provider !== "comfyui") return words.notOffered;+ if (s.kind === "model3d" && !madeHere3d(s)) return ownSetupLabel(MODEL3D_SETUP);if (!poolAllows(p, s.modelId, s.presetId) || !kindAllowed(p, s.kind as RunFacts["kind"])) return words.notOffered;if (!poolTakes(stepEndpoint(s))) return words.notOffered;}return null;}+/**+ * Is this 3D step made on this install's GPUs: a model a worker's CPU slot finishes (poolFinishes3d), or Any Angle's 3D+ * view (a splat and its turntable, nothing to finish: generations.ts lets it there too).+ */+const madeHere3d = (s: { provider: string; op: string; modelId: string }): boolean => s.modelId === ANY_ANGLE.buildModel || poolFinishes3d(s);+/** How many outputs each row asks for (its request's numOutputs: a run split into one job per output keeps it on each). */function rowOutputs(ids: string[]): number[] {const q = db().prepare("SELECT request_json FROM generations WHERE id = ?");@@ -333,24 +355,41 @@ export function pricedSteps(steps: PlannedStep[]): NonNullable<RunFacts["steps"]* Run, with the setup that runs it. A run these GPUs take but can't start right now (every one that could is away, or* being updated) is no reason: it waits in line (runWaits).*/-export type GateReason = "model3d" | "notOffered" | "rtxCard" | "loras" | "inputs" | "outputs" | "ownSetup";+export type GateReason = "model3d" | "notOffered" | "rtxCard" | "loras" | "inputs" | "size" | "outputs" | "ownSetup";/**- * A gate's refusal: its reason, and the visitor's own setup that would run it (`setup`: always with "ownSetup"; with the- * others, a GPU of its own, which runs what this install's GPUs don't take). `cap`: with "outputs", the most a run there- * makes at once.+ * A gate's refusal: its reason, and the visitor's own setup that would run it (`setup`: always with "ownSetup" and+ * "model3d"; with the others, a GPU of its own, which runs what this install's GPUs don't take). `cap`: with "outputs",+ * the most a run there makes at once. `most`: with "size", the largest those GPUs make, in words ("8 megapixels").*/-export type GateRefusal = { ok: false; reason: GateReason; setup?: OwnSetup; cap?: number };+export type GateRefusal = { ok: false; reason: GateReason; setup?: OwnSetup; cap?: number; most?: string };++/** The own GPU a 3D model no worker here finishes runs on: the memory its workflow needs, else MODEL3D_SETUP's. */+const model3dSetup = (endpoint?: string): OwnSetup => {+ const gpu = needsGpu(endpoint);+ return gpu.need === "gpu" && gpu.vramGb ? gpu : MODEL3D_SETUP;+};-/** The words for a gate's reason: an account may connect its own GPU in Settings, a guest has nowhere to do that yet. */+/** A gate's label for a reason (the same for a guest and an account: Run opens the sign-up for a guest). */export function gateWords(reason: Exclude<GateReason, "ownSetup" | "outputs">, guest: boolean, place: Place): string {- if (reason === "model3d") return OWN_GPU_TOOL_MESSAGE;+ if (reason === "model3d") return ownSetupLabel(model3dSetup());return (guest ? hostedGuestWords() : hostedWords(place))[reason];}-/** A gate's refusal in words: the own setup's label (the same for a guest and an account), or the reason's words. */+/** A gate's refusal in words: the own setup's label (the same for a guest and an account), or the reason's label. */export const gateText = (gate: GateRefusal, guest: boolean, place: Place): string =>- gate.reason === "ownSetup" ? ownSetupLabel(gate.setup ?? needsGpu()) : gate.reason === "outputs" ? outputsWords(gate.cap ?? 1, guest, place) : gateWords(gate.reason, guest, place);+ gate.reason === "ownSetup" || gate.reason === "model3d"+ ? ownSetupLabel(gate.setup ?? (gate.reason === "model3d" ? model3dSetup() : needsGpu()))+ : gate.reason === "outputs"+ ? outputsWords(gate.cap ?? 1, guest, place)+ : gateWords(gate.reason, guest, place);++/** A label's one sentence (the price slot's tooltip): what to do, or what the own setup is. None for "outputs". */+export function gateDetail(gate: GateRefusal, place: Place): string | undefined {+ if (gate.reason === "ownSetup" || gate.reason === "model3d") return ownSetupDetail(gate.setup ?? model3dSetup());+ if (gate.reason === "outputs") return undefined;+ return hostedDetails(place, gate.most)[gate.reason];+}/*** The one check of whether this install's GPUs take a run, shared by the run itself (decidePlace) and the price check@@ -368,14 +407,15 @@ export function poolGate(planned: Planned,req: GenerationRequest,planSteps: () => PlannedStep[] | null,+ sizeOf?: () => JobSize | null,): { ok: true; steps: PlannedStep[] | null } | GateRefusal {const own = requestOwnSetup({ ...req, modelId: planned.model.id, engine: "open" });if (own) return { ok: false, reason: "ownSetup", setup: own };const gpu = needsGpu(planned.route.endpoint);const kind = outputKind(planned.op, planned.model);// A 3D model only where a worker finishes it (its GLB checked, made for the web and given a turntable there): then the- // policy's kinds say, as for any other kind.- if (kind === "model3d" && !poolFinishes3d({ provider: planned.route.provider, op: planned.op })) return { ok: false, reason: "model3d" };+ // policy's kinds say, as for any other kind. Elsewhere it runs on the visitor's own GPU (a label, with that setup).+ if (kind === "model3d" && !madeHere3d({ provider: planned.route.provider, op: planned.op, modelId: planned.model.id })) return { ok: false, reason: "model3d", setup: model3dSetup(planned.route.endpoint) };if (p && (!poolAllowsRun(p, planned, req.presetId) || !kindAllowed(p, kind))) return { ok: false, reason: "notOffered", setup: gpu };// Nothing of this install's runs it right now (no worker holds its files, is allowed its lane, or has the memory it// needs): a run that would wait for nothing, so it runs on the visitor's own GPU instead.@@ -387,6 +427,13 @@ export function poolGate(const takes = poolUploads(p);if ((inputs.image && !takes.image) || (inputs.video && !takes.video) || (inputs.audio && !takes.audio)) return { ok: false, reason: "inputs", setup: gpu };}+ // A size bigger than every GPU here that runs it makes (their PCs' ceilings): said before Run as a label, never a run+ // that fails once pressed (the run's own check stays the last guard: comfyui.ts POOL_TOO_BIG).+ const size = sizeOf ? safeSize(sizeOf) : null;+ if (size && !poolFitsSize(planned.route.endpoint, size)) {+ const most = poolMostWords(planned.route.endpoint, size);+ return { ok: false, reason: "size", setup: gpu, ...(most && { most }) };+ }// Every step of a chain, not only its first: each one the policy must allow, and the run is priced for all of them.const steps = planSteps();for (const s of steps ?? []) {@@ -398,6 +445,24 @@ export function poolGate(return { ok: true, steps };}+/** A size worked out, or null when it can't be (an input that can't be read): the run's own check says then. */+function safeSize(sizeOf: () => JobSize | null): JobSize | null {+ try {+ return sizeOf();+ } catch {+ return null;+ }+}++/**+ * The size of each job a run makes on this install's GPUs, about, as a PC's ceiling reads it (its pictures' or frames'+ * megapixels, a clip's seconds, its results at once), read as `viewer` (its own files only).+ */+export function jobSize(viewer: string | null, req: GenerationRequest, planned: Planned): JobSize {+ const f = runOnPool(viewer, () => runFacts(req, planned, outputKind(planned.op, planned.model)));+ return { megapixels: f.megapixels ?? 0, seconds: Number(f.seconds) || 0, outputs: f.outputsPerJob };+}+/*** Does a run these GPUs take wait for one of them to be free: every GPU that could run some GPU step of it is away now* (paused, silent, outside its hours: runAway), or built from the catalog before this studio's update (it takes the run@@ -511,7 +576,7 @@ export async function decidePlace(account: Account, asked: GenerationRequest, wi// reads before Run) goes to the account's own GPU when it has one and didn't ask for this install's; otherwise it is// refused in the same words. A run they take is taken even while every GPU that could run it is away or being updated:// it waits in line in its place until one is free, never moved to the account's own GPU for that.- const gate = poolGate(p, planned, req, () => stepsFor(account, req));+ const gate = poolGate(p, planned, req, () => stepsFor(account, req), () => jobSize(account.id, req, planned));if (!gate.ok) {if (ownFallback) return OWN;return gateRefusal(gate, placeFor(p));@@ -793,11 +858,22 @@ function poolLine(facts: Pick<QueueFacts, "ahead" | "etaS" | "nextOpenAt">, o: {* A price check refused for what this install's GPUs don't take: its words, and (`ownSetup`) the visitor's own setup* that runs it, so Run opens that setup (Connect your GPU, Add your key, or a guest's sign-up) instead of staying off.*/-const notOfferedQuote = (text: string, setup?: OwnSetup): Quote & { ownSetup?: OwnSetup } => ({ allowed: false, amount: 0, priceVersion: "", text, code: "not-offered", ...(setup && { ownSetup: setup }) });+const notOfferedQuote = (text: string, setup?: OwnSetup, sub?: string): Quote & { ownSetup?: OwnSetup } => ({+ allowed: false,+ amount: 0,+ priceVersion: "",+ text,+ code: "not-offered",+ ...(sub && { sub }),+ ...(setup && { ownSetup: setup }),+});-/** A gate's refusal as the price check's quote (gateText: the label's words for an own setup), with that setup. */+/**+ * A gate's refusal as the price check's quote: its label (gateText), the sentence under it (`sub`: the tooltip), and the+ * own setup Run opens. A run past the outputs a run here makes has no setup: the person picks fewer.+ */const gateQuote = (gate: GateRefusal, guest: boolean, place: Place): Quote & { ownSetup?: OwnSetup } =>- notOfferedQuote(gateText(gate, guest, place), gate.reason === "model3d" ? undefined : gate.setup);+ notOfferedQuote(gateText(gate, guest, place), gate.reason === "outputs" ? undefined : (gate.setup ?? needsGpu()), gateDetail(gate, place));/*** A price check on this install's GPUs (hosted runs on): the plan there, the billing service's quote (no service: free,@@ -841,7 +917,7 @@ export async function poolQuote(if (p && !p.hosted) return null;// What this install's GPUs won't take goes to the viewer's own GPU when it has one (as the run would); otherwise the// price check says its label, and Run opens the setup that runs it.- const gate = poolGate(p, planned, req, () => stepsFor(account, req));+ const gate = poolGate(p, planned, req, () => stepsFor(account, req), () => jobSize(account?.id ?? null, req, planned));if (!gate.ok) {if (hasGpu && wish !== "pool") return null;return { planned, quote: gateQuote(gate, !account, placeFor(p)), line: poolLine(queueFacts(account?.id ?? null, planned.route.endpoint), { light: false, waits: false, p }) };@@ -929,7 +1005,7 @@ export function toolGate(continue;}if (planned.route.provider !== "comfyui") return "unplanned";- const gate = poolGate(p, planned, req, () => (deps ? [asPlannedStep(req, planned, true)] : poolSteps(viewer ?? GUEST_PLAN, req)));+ const gate = poolGate(p, planned, req, () => (deps ? [asPlannedStep(req, planned, true)] : poolSteps(viewer ?? GUEST_PLAN, req)), deps ? undefined : () => jobSize(viewer, req, planned));// A tool adds its LoRAs itself (a person adds none to it): said as a step that runs on an own GPU, not as extra LoRAs.if (!gate.ok) return gate.reason === "loras" ? { ok: false, reason: "notOffered", setup: gate.setup } : gate;if ((req.params?.numOutputs ?? 1) > cap) return { ok: false, reason: "outputs", cap };diff --git a/src/server/hosted.ts b/src/server/hosted.tsindex a5a93d2f..f2bf01bf 100644--- a/src/server/hosted.ts+++ b/src/server/hosted.ts@@ -6,7 +6,7 @@ import { imageSize } from "@/lib/image-size";import type { GenerationRequest } from "@/lib/catalog/types";import type { Place } from "@/lib/place-name";import { billingConfigured, type Policy, type QueueFacts, type RunFacts } from "./billing";-import { lineFacts, poolLane, queueOfGeneration, workersAway, workersCanRun, type LinePlace } from "./computer/pool";+import { lineFacts, poolLane, queueOfGeneration, workersAway, workersCanRun, workersMost, type LinePlace } from "./computer/pool";import { db } from "./db";import { loadIndex } from "./gpu/index-file";import { hostedRunsOn } from "./hosted-switch";@@ -86,6 +86,35 @@ export function poolTakes(endpoint: string | undefined): boolean {return picks.length > 0 && picks.every((id) => workersCanRun(id));}+/** The size of one job, as a PC's ceiling reads it: its pictures' or frames' megapixels, a clip's seconds, its results. */+export interface JobSize {+ megapixels: number;+ seconds: number;+ outputs: number;+}++/**+ * Does a job of this size fit a GPU here that runs its workflow (on the workers: one whose PC's ceiling holds it)? Yes+ * for a workflow none of them runs (another check speaks for it), one that picks its graph at run time, and off the+ * workers (this install's own ComfyUI has no ceiling).+ */+export function poolFitsSize(endpoint: string | undefined, size: JobSize): boolean {+ if (!endpoint || endpoint.includes("{") || !poolOnWorkers() || !workersCanRun(endpoint)) return true;+ return workersCanRun(endpoint, { size });+}++const tenth = (n: number) => Math.round(n * 10) / 10;++/** The largest size the GPUs here make of the limit a job passes, in words ("8 megapixels", "10 s clips"), or null. */+export function poolMostWords(endpoint: string | undefined, size: JobSize): string | null {+ if (!endpoint || endpoint.includes("{")) return null;+ const most = workersMost(endpoint);+ if (most.maxMegapixels !== undefined && size.megapixels > most.maxMegapixels) return `${tenth(most.maxMegapixels)} megapixels`;+ if (most.maxSeconds !== undefined && size.seconds > most.maxSeconds) return `${tenth(most.maxSeconds)} s clips`;+ if (most.maxOutputs !== undefined && size.outputs > most.maxOutputs) return `${most.maxOutputs} results at a time`;+ return null;+}+/*** Are this install's GPUs all away for this endpoint now (on the workers: every worker that could run it paused, silent or* outside its hours)? A run made then waits in line until one is back: the price check says it starts when a GPU is@@ -146,13 +175,18 @@ export function runOnPool<T>(accountId: string | null, fn: () => T): T {/*** Words for runs on this install's GPUs, with the name visitors read for them (`place`, src/server/place-name.ts). Every* sentence fits any name: no verb agrees with it.+ *+ * What these GPUs don't run is a label, never a refusal: the price slot says where it runs ("Runs on your own GPU"), its+ * tooltip says what to do (hostedDetails), and Run opens the way there (Connect your GPU, or a guest's sign-up). The+ * same labels for a guest and an account.*/export function hostedWords(place: Place) {return {- notOffered: "This one runs on your own GPU. Connect one in Settings, or pick another model.",- loras: "Extra LoRAs run on your own GPU. Connect one in Settings, or run without them.",- inputs: "This kind of file runs on your own GPU. Connect one in Settings, or use a picture.",- rtxCard: "This one needs an NVIDIA RTX card. Connect your own RTX GPU in Settings, or pick another choice.",+ notOffered: "Runs on your own GPU",+ loras: "LoRAs run on your own GPU",+ inputs: "This file runs on your own GPU",+ rtxCard: "Runs on your own RTX GPU",+ size: "This size runs on your own GPU",notHosted: `Your account can't run on ${place.text} right now. Your own GPU or key still works.`,};}@@ -160,16 +194,23 @@ export function hostedWords(place: Place) {/** The reasons a run on this install's GPUs is refused, by name (the same for every place name). */export type HostedReason = keyof ReturnType<typeof hostedWords>;-/** The same refusals for a guest, who has no Settings to connect a GPU in yet (no place name in them). */-export function hostedGuestWords() {+/** A label's one sentence (the price slot's tooltip, the line under the toolbar on a phone). `most`: the largest size here. */+export function hostedDetails(place: Place, most?: string | null) {return {- notOffered: "This one isn't offered here. Pick another model.",- rtxCard: "This one isn't offered here right now. Pick another choice.",- loras: "Extra LoRAs aren't offered here. Run without them.",- inputs: "This kind of file can't be used here. Use a picture instead.",+ notOffered: "Connect your GPU to run this one, or pick another model.",+ loras: "Connect your GPU to use them, or run without them.",+ inputs: "Connect your GPU to use it, or use a picture.",+ rtxCard: "This one needs an NVIDIA RTX card.",+ size: `${most ? `Up to ${most} on ${place.text}. ` : ""}Pick a smaller size, or run it on your own GPU.`,};}+/** The labels for a guest: the same as an account's (Run opens the sign-up for that label). */+export function hostedGuestWords() {+ const { notOffered, rtxCard, loras, inputs, size } = hostedWords({ label: "", text: "" });+ return { notOffered, rtxCard, loras, inputs, size };+}+/*** A tool's run that asks for more pictures or clips at once than a run on this install's GPUs makes (the policy's cap per* run): pick fewer. An account may also connect its own GPU, which has no such cap.@@ -180,6 +221,9 @@ export function outputsWords(cap: number, guest: boolean, place: Place): stringreturn guest ? `Makes ${most}. ${pick}.` : `Makes ${most} on ${place.text}. ${pick}, or connect your own GPU in Settings.`;}+/** Are these words outputsWords (a run past the outputs a run here makes: the person picks fewer), not a label? */+export const isOutputsWords = (words: string): boolean => /^Makes (one|up to \d+) at a time\b/.test(words);+/** May this model (and app) run on this install's GPUs under this policy? */export function poolAllows(p: Pick<Policy, "pool">, modelId: string, presetId?: string | null): boolean {const m = p.pool ?? {};diff --git a/tests/account-3d-apps.test.ts b/tests/account-3d-apps.test.tsindex 115bad4b..1cbab4c6 100644--- a/tests/account-3d-apps.test.ts+++ b/tests/account-3d-apps.test.ts@@ -179,7 +179,7 @@ describe("an account's 3D app runs on its own ComfyUI", () => {it("the same run stamped for this install's GPUs is refused when it is made", () => {const req = imageTo3dApp(photo) as Parameters<typeof createGenerations>[0];- expect(() => asAccount(a, () => withRunStamp({ place: "pool" }, () => createGenerations(req)))).toThrow(access.OWN_GPU_TOOL_MESSAGE);+ expect(() => asAccount(a, () => withRunStamp({ place: "pool" }, () => createGenerations(req)))).toThrow("Runs on your own GPU · 24 GB");// A place in the request itself is dropped: only the stamp in scope sets it.const own = asAccount(a, () => createGenerations({ ...req, place: "pool" } as never));expect(own[0].request.place).toBeUndefined();diff --git a/tests/account-image-to-3d.test.ts b/tests/account-image-to-3d.test.tsindex 6a5c5c05..83edb7f2 100644--- a/tests/account-image-to-3d.test.ts+++ b/tests/account-image-to-3d.test.ts@@ -326,7 +326,7 @@ describe("3D is allowed on the account's own GPU or key, and refused on this insit("a run stamped for this install's GPUs is refused when it is made; the account's own is made", () => {const photo = runAsTenant({ kind: "account", id: a }, () => saveFile({ data: TINY_PNG, contentType: "image/png", source: "upload", name: "p.png" }).url);const req = fromImage(photo);- expect(() => asAccount(a, () => withRunStamp({ place: "pool" }, () => createGenerations(req)))).toThrow(access.OWN_GPU_TOOL_MESSAGE);+ expect(() => asAccount(a, () => withRunStamp({ place: "pool" }, () => createGenerations(req)))).toThrow("Runs on your own GPU · 24 GB");const made = asAccount(a, () => createGenerations(req));expect(made[0].kind).toBe("model3d");expect(made[0].request.account).toBe(a);diff --git a/tests/any-angle-route.test.ts b/tests/any-angle-route.test.tsindex 964e0896..90370e0b 100644--- a/tests/any-angle-route.test.ts+++ b/tests/any-angle-route.test.ts@@ -20,7 +20,9 @@ const { asAccount, createGenerations } = await import("@/server/generations");const { withRunStamp } = await import("@/server/run-stamp");const { viewKeyOf } = await import("@/server/any-angle");const { ANY_ANGLE } = await import("@/lib/catalog/any-angle");-const { OWN_GPU_TOOL_MESSAGE } = await import("@/lib/guest-access");+const { MODEL3D_SETUP, ownSetupLabel } = await import("@/lib/own-setup");+/** The words a 3D run on this install's GPUs that no worker finishes is turned away in: its label. */+const MODEL3D_LABEL = ownSetupLabel(MODEL3D_SETUP);const { ACCOUNT_LIMITS } = await import("@/server/account-files");const { db } = await import("@/server/db");const { hit, peek, resetRates } = await import("@/server/rate");@@ -92,8 +94,8 @@ describe("Any Angle's 3D view through the route", () => {refused = e;}// Whatever else stops it here (no GPU connected in this test), it isn't the 3D finish that keeps accounts out.- expect((refused as Error | null)?.message ?? "").not.toBe(OWN_GPU_TOOL_MESSAGE);- expect(() => asAccount(a, () => withRunStamp({ place: "pool" }, () => createGenerations({ feature: "image-to-3d", modelId: "oss-triposplat", op: "splat", engine: "open", inputs: { images: [photo] } } as never)))).toThrow(OWN_GPU_TOOL_MESSAGE);+ expect((refused as Error | null)?.message ?? "").not.toBe(MODEL3D_LABEL);+ expect(() => asAccount(a, () => withRunStamp({ place: "pool" }, () => createGenerations({ feature: "image-to-3d", modelId: "oss-triposplat", op: "splat", engine: "open", inputs: { images: [photo] } } as never)))).toThrow(MODEL3D_LABEL);});});diff --git a/tests/glb-finish-safety.test.ts b/tests/glb-finish-safety.test.tsindex d4c2fe8d..500b1e53 100644--- a/tests/glb-finish-safety.test.ts+++ b/tests/glb-finish-safety.test.ts@@ -12,7 +12,7 @@ const { saveFile } = await import("@/server/storage");const { asAccount, createGenerations } = await import("@/server/generations");const { db } = await import("@/server/db");const { withRunStamp } = await import("@/server/run-stamp");-const { OWN_GPU_TOOL_MESSAGE } = await import("@/lib/guest-access");+const MODEL3D_LABEL = "Runs on your own GPU · 24 GB";afterAll(() => {delete process.env.FUOBE_TEST_SECRET;});@@ -143,7 +143,7 @@ describe("an account's 3D model runs on its own GPU or key, never on this instalit("refuses the same run on this install's GPUs (the pool's stamp) before anything is queued", () => {const rows = () => (db().prepare("SELECT COUNT(*) AS n FROM generations").get() as { n: number }).n;const before = rows();- expect(() => asAccount("acct-1", () => withRunStamp({ place: "pool" }, () => createGenerations(request())))).toThrow(OWN_GPU_TOOL_MESSAGE);+ expect(() => asAccount("acct-1", () => withRunStamp({ place: "pool" }, () => createGenerations(request())))).toThrow(MODEL3D_LABEL);expect(rows()).toBe(before);});@@ -152,6 +152,6 @@ describe("an account's 3D model runs on its own GPU or key, never on this instalconst made = asAccount("acct-1", () => createGenerations(request({ place })));expect(made[0].request.place, place).toBeUndefined();}- expect(() => asAccount("acct-1", () => withRunStamp({ place: "pool" }, () => createGenerations(request({ place: "own" }))))).toThrow(OWN_GPU_TOOL_MESSAGE);+ expect(() => asAccount("acct-1", () => withRunStamp({ place: "pool" }, () => createGenerations(request({ place: "own" }))))).toThrow(MODEL3D_LABEL);});});diff --git a/tests/hi3d-refine.test.ts b/tests/hi3d-refine.test.tsindex 40801013..751946ea 100644--- a/tests/hi3d-refine.test.ts+++ b/tests/hi3d-refine.test.ts@@ -23,7 +23,7 @@ const { getModel, getPreset, MODELS } = await import("@/lib/catalog");const { inferOperation, planGeneration } = await import("@/lib/catalog/plan");const { OPERATION_OUTPUT } = await import("@/lib/catalog/types");const { buildLicenceList, licenceInfo, licenceTerms, NODE_PACKS } = await import("@/lib/licences");-const { OWN_GPU_TOOL_MESSAGE } = await import("@/lib/guest-access");+const MODEL3D_LABEL = "Runs on your own GPU · 24 GB";const { withRunStamp } = await import("@/server/run-stamp");const hi3d = await import("@/lib/av/hi3d");const m3d = await import("@/lib/av/model3d");@@ -186,8 +186,8 @@ describe("the chain per engine", () => {it("accounts: on this install's GPUs refused like every 3D model, before anything is queued", () => {const onPool = <T,>(fn: () => T) => gens.asAccount("acct-1", () => withRunStamp({ place: "pool" }, fn));- expect(() => onPool(() => gens.createGenerations(hi3d.refineRequest({ glb: "/api/files/placeholder.glb", photo })))).toThrow(OWN_GPU_TOOL_MESSAGE);- expect(() => onPool(() => gens.createGenerations(hi3d.withRefine(m3d.model3dRequest({ engine: "open", mode: "image", photo }), "open", 1024)))).toThrow(OWN_GPU_TOOL_MESSAGE);+ expect(() => onPool(() => gens.createGenerations(hi3d.refineRequest({ glb: "/api/files/placeholder.glb", photo })))).toThrow(MODEL3D_LABEL);+ expect(() => onPool(() => gens.createGenerations(hi3d.withRefine(m3d.model3dRequest({ engine: "open", mode: "image", photo }), "open", 1024)))).toThrow(MODEL3D_LABEL);});it("is free on the open engine, and the refined GLB gets the server's finish", () => {diff --git a/tests/hosted-app-runs.test.ts b/tests/hosted-app-runs.test.tsindex a6783717..8f55c4b5 100644--- a/tests/hosted-app-runs.test.ts+++ b/tests/hosted-app-runs.test.ts@@ -42,7 +42,6 @@ const billing = await import("@/server/billing");const { clearAccountLoras } = await import("@/server/account-loras");const { hostedWords } = await import("@/server/hosted");const HOSTED_WORDS = hostedWords((await import("@/lib/place-name")).placeOf(null));-const { OWN_GPU_TOOL_MESSAGE } = await import("@/lib/guest-access");let fake: FakeBilling;const ids: Record<string, string> = {};@@ -118,7 +117,7 @@ type Case = {url: string;body: (pic: string) => Record<string, unknown>;/** Refused on this install's GPUs before Run, in these words (a step that runs only on an own GPU for now). */- ownOnly?: string;+ ownOnly?: string | RegExp;};const CASES: Case[] = [{ name: "Photodump", route: routes.photodump, url: "/api/photodump", body: (pic) => ({ packId: "winter-special", engine: "open", selfie: pic, aspectRatio: "3:4" }) },@@ -127,7 +126,7 @@ const CASES: Case[] = [{ name: "Character Sheet", route: routes.character, url: "/api/photodump/character", body: () => ({ mode: "describe", engine: "open", prompt: "a surfer from Lisbon" }) },// The turnaround's angle LoRA isn't one this install's GPUs carry yet, and Fly around's path is drawn from a 3D step.{ name: "Turnaround", route: routes.turnaround, url: "/api/turnaround", body: (pic) => ({ engine: "open", views: { front: pic, back: pic } }), ownOnly: HOSTED_WORDS.notOffered },- { name: "Fly around", route: routes.flyAround, url: "/api/fly-around", body: (pic) => ({ engine: "open", image: pic, orbit: { degrees: 90, direction: "cw" } }), ownOnly: OWN_GPU_TOOL_MESSAGE },+ { name: "Fly around", route: routes.flyAround, url: "/api/fly-around", body: (pic) => ({ engine: "open", image: pic, orbit: { degrees: 90, direction: "cw" } }), ownOnly: /^Runs on your own GPU · \d+ GB$/ },];describe("hosted runs off: an account's app runs as any tool run, on its own GPU", () => {@@ -156,12 +155,15 @@ describe("hosted runs on: an account with no GPU of its own runs the apps on thiexpect(priced.place, JSON.stringify(priced)).toBe("pool");if (c.ownOnly) {// Run stays off and says why; pressed anyway, nothing is held or made.- expect(priced.quote).toMatchObject({ allowed: false, text: c.ownOnly });+ // A label (never a refusal): Run opens the own setup it names.+ expect(priced.quote).toMatchObject({ allowed: false, text: typeof c.ownOnly === "string" ? c.ownOnly : expect.stringMatching(c.ownOnly), ownSetup: expect.objectContaining({ need: "gpu" }) });const before = reserves();const since = Date.now();const r = await c.route.POST(json(c.url, "POST", c.body(pic), "none"));expect(r.status).toBe(403);- expect(((await r.json()) as { error: string }).error).toBe(c.ownOnly);+ const refusedWith = (await r.json()) as { error: string; code: string; ownSetup?: unknown };+ expect(refusedWith.error).toMatch(typeof c.ownOnly === "string" ? new RegExp(`^${c.ownOnly}$`) : c.ownOnly);+ expect(refusedWith).toMatchObject({ code: "connect-gpu", ownSetup: expect.objectContaining({ need: "gpu" }) });expect(reserves()).toBe(before);expect(places("none", since)).toEqual([]);return;diff --git a/tests/hosted-guest-draft.test.ts b/tests/hosted-guest-draft.test.tsindex 82703e0e..b012489b 100644--- a/tests/hosted-guest-draft.test.ts+++ b/tests/hosted-guest-draft.test.ts@@ -151,6 +151,24 @@ describe("the run a guest pressed", () => {expect(composer).toMatch(/onSuccess: \(\) => \{[^}]*signedUp && viewerInfo\?\.hosted\) setPriceNote\(PENDING_WORDS\.made\)/);});+ it("pressed on an item that runs on one's own GPU or key: never starts by itself; its setup opens once signed up", () => {+ const setup = { need: "gpu" as const, vramGb: 48 };+ draftLib.savePendingRun("/video", null, undefined, setup);+ expect(draftLib.takePendingRun("/video")).toMatchObject({ path: "/video", shown: null, setup });+ // Still labelled after sign-up: its setup opens (Connect your GPU, Add your key) with the draft back; nothing runs.+ expect(step({ shown: null, setup: true, labelled: true })).toBe("setup");+ // A kept run whose item is labelled now: its setup too, never a start.+ expect(step({ setup: true })).toBe("setup");+ // It runs here now: the draft is back and Run waits for a click.+ expect(step({ shown: null, labelled: true })).toBe("ask");+ expect(step({ labelled: true })).toBe("ask");+ expect(step({ shown: null, labelled: true, quote: { allowed: false, amount: 0, text: "" } })).toBe("none");+ expect(step({ shown: null, labelled: true, pool: false })).toBe("none");+ // A missing file says so first, and a lost one is asked for again.+ expect(step({ setup: true, blocked: true })).toBe("none");+ expect(step({ setup: true, lost: true })).toBe("lost");+ });+it("never starts without a kept file that didn't come back, even in a slot the run could do without", () => {// When every run costs the same ("Free") and a reference photo or start frame is optional, only the lost file// stops it, and the person is asked to add it again.diff --git a/tests/hosted-runs-kandinsky6.test.ts b/tests/hosted-runs-kandinsky6.test.tsindex f7b2aa5f..60b54d4c 100644--- a/tests/hosted-runs-kandinsky6.test.ts+++ b/tests/hosted-runs-kandinsky6.test.ts@@ -70,7 +70,8 @@ describe("Kandinsky 6.0 on this install's GPUs", () => {billing.resetBillingCache();const refused = await decidePlace(account, req, undefined);expect(refused.kind, req.modelId).toBe("refuse");- if (refused.kind === "refuse") expect(refused.refusal.body.code).toBe("not-offered");+ // A label, never a refusal: the run's answer opens Connect your GPU.+ if (refused.kind === "refuse") expect(refused.refusal.body).toMatchObject({ code: "connect-gpu", error: "This file runs on your own GPU", ownSetup: { need: "gpu" } });fake.policy = { ...FAKE_POLICY, uploads: { ...FAKE_POLICY.uploads, [kind]: true } };billing.resetBillingCache();expect((await decidePlace(account, req, undefined)).kind, req.modelId).toBe("pool");diff --git a/tests/hosted-runs-voice-design.test.ts b/tests/hosted-runs-voice-design.test.tsindex b0336dc8..8be01d99 100644--- a/tests/hosted-runs-voice-design.test.ts+++ b/tests/hosted-runs-voice-design.test.ts@@ -69,7 +69,7 @@ describe("Design a voice on this install's GPUs", () => {it("a clone reads a voice sample: offered only when the policy takes audio uploads", async () => {const refused = await decidePlace(account, clone, undefined);expect(refused.kind).toBe("refuse");- if (refused.kind === "refuse") expect(refused.refusal.body.code).toBe("not-offered");+ if (refused.kind === "refuse") expect(refused.refusal.body).toMatchObject({ code: "connect-gpu", error: "This file runs on your own GPU" });fake.policy = { ...FAKE_POLICY, uploads: { ...FAKE_POLICY.uploads, audio: true } };billing.resetBillingCache();expect((await decidePlace(account, clone, undefined)).kind).toBe("pool");diff --git a/tests/hosted-runs.test.ts b/tests/hosted-runs.test.tsindex 340048fe..670aef9b 100644--- a/tests/hosted-runs.test.ts+++ b/tests/hosted-runs.test.ts@@ -118,13 +118,19 @@ describe("hosted runs on", () => {it("refuses here what runs only on an account's own GPU: extra LoRAs, a model the policy leaves out", async () => {const loras = await post({ feature: "image", modelId: "oss-z-image-turbo", prompt: "a fox", loras: [{ file: "x.safetensors", url: "https://huggingface.co/x/x.safetensors" }] });expect(loras.status).toBe(403);- expect(((await loras.json()) as { code: string }).code).toBe("not-offered");+ // A label, never a refusal: the answer opens Connect your GPU, with what it needs in a header.+ expect(loras.headers.get("x-fuobe-connect-gpu")).toBe("1");+ expect(JSON.parse(decodeURIComponent(loras.headers.get("x-fuobe-own-setup") ?? "null"))).toMatchObject({ need: "gpu" });+ expect((await loras.json()) as { code: string; error: string }).toMatchObject({ code: "connect-gpu", error: "LoRAs run on your own GPU" });process.env.FUOBE_BILLING_URL = fake.url;process.env.FUOBE_BILLING_TOKEN = "test-billing-token";fake.policy = { ...fake.policy, pool: { deny: ["oss-z-image-turbo"] } };const denied = await post({ feature: "image", modelId: "oss-z-image-turbo", prompt: "a fox" });expect(denied.status).toBe(403);- expect(denied.headers.get("x-fuobe-billing")).toBe("not-offered");+ // The same: its label, and the answer opens Connect your GPU (never the billing card).+ expect(denied.headers.get("x-fuobe-billing")).toBeNull();+ expect(denied.headers.get("x-fuobe-connect-gpu")).toBe("1");+ expect((await denied.json()) as { code: string; error: string }).toMatchObject({ code: "connect-gpu", error: "Runs on your own GPU" });});it("an account the policy keeps off this install's GPUs gets today's answer", async () => {@@ -197,8 +203,8 @@ describe("hosted runs on", () => {check(device, [...missing]);const { r, body, reached } = await runs(rtx);expect(r.status).toBe(403);- expect(body.code).toBe("not-offered");- expect(body.error).toContain("NVIDIA RTX card");+ expect(body.code).toBe("connect-gpu");+ expect(body.error).toBe("Runs on your own RTX GPU");// Visitor words: no script, switch or file names.expect(body.error).not.toMatch(/install-comfyui|RTX_VIDEO|scripts\/|\.sh\b/);expect(reached).not.toContain("/v1/quote");@@ -214,12 +220,12 @@ describe("hosted runs on", () => {// Frame generation needs an RTX 40 series card or newer: an RTX 3090 is refused, an RTX 4070 isn't.check({ name: "cuda:0 NVIDIA GeForce RTX 3090 : cudaMallocAsync", type: "cuda" });const fg = { feature: "fps-boost", modelId: "oss-rtx-frame-generation", op: "interpolate", inputs: { video: url }, params: { targetFps: 60 } };- expect((await runs(fg)).body.code).toBe("not-offered");+ expect((await runs(fg)).body).toMatchObject({ code: "connect-gpu", error: "Runs on your own RTX GPU" });check({ name: "cuda:0 NVIDIA GeForce RTX 4070 : cudaMallocAsync", type: "cuda" });- expect((await runs(fg)).body.code).not.toBe("not-offered");+ expect((await runs(fg)).body.code).not.toBe("connect-gpu");// A card the name doesn't tell (a data-centre card) is never refused for its name.check({ name: "cuda:0 NVIDIA H100 80GB HBM3 : cudaMallocAsync", type: "cuda" });- expect((await runs(rtx)).body.code).not.toBe("not-offered");+ expect((await runs(rtx)).body.code).not.toBe("connect-gpu");} finally {check({ name: "cuda:0 NVIDIA GeForce RTX 4090 : cudaMallocAsync", type: "cuda" });}diff --git a/tests/hosted-surface-labels.test.ts b/tests/hosted-surface-labels.test.tsnew file mode 100644index 00000000..85781771--- /dev/null+++ b/tests/hosted-surface-labels.test.ts@@ -0,0 +1,89 @@+import { describe, expect, it } from "vitest";+import { boardRunWords } from "@/lib/board-run-words";+import { OWN_GPU_TOOL_HOSTED, OWN_GPU_TOOL_MESSAGE, ownGpuToolMessage } from "@/lib/guest-access";+import { KEPT_RUN_WORDS, setupCardWords } from "@/lib/own-setup-card";+import { answerPickModel, canPickModel, pickAnotherModel } from "@/lib/pick-model";+import { placeOf } from "@/lib/place-name";+import { runPlace } from "@/lib/run-place";++/*+ * What the site's GPUs can't run is a label, never a refusal (hosted runs on): the card a press on a labelled item opens+ * says what it needs and the way there, for a guest and an account, with "Pick another model" one press away; the+ * surfaces that don't run here yet point at the studios. With hosted runs off every word stays as it was.+ */++const PLACE = placeOf("Studio North GPUs");++describe("the card a labelled item opens", () => {+ const gpu48 = { need: "gpu" as const, vramGb: 48 };++ it("a guest reads how signing up leads there, never that the run starts once in", () => {+ const g = setupCardWords(gpu48, PLACE, "guest");+ expect(g).toEqual({+ title: "This one runs on your own GPU",+ body: "It needs a GPU with 48 GB of memory. Sign up free, then connect yours in a few steps. Everything else runs on Studio North GPUs.",+ });+ expect(g.body).not.toContain("as soon as you're in");+ const key = setupCardWords({ need: "key", provider: "fal" }, PLACE, "guest");+ expect(key.title).toBe("This one runs with your own fal.ai key");+ expect(key.body).toBe("Sign up free, then add your key. fal.ai bills your runs to your account with them. Everything else runs on Studio North GPUs.");+ });++ it("an account reads how connecting its GPU runs it; a Linux card and a key that runs it too are said", () => {+ expect(setupCardWords(gpu48, PLACE, "account").body).toBe("It needs a GPU with 48 GB of memory. Connect yours, and this runs there. Everything else runs on Studio North GPUs.");+ expect(setupCardWords({ need: "gpu", vramGb: 24, linux: true, orKey: "fal" }, PLACE, "account").body).toBe(+ "It needs a Linux computer with a GPU with 24 GB of memory. Connect yours, and this runs there. Everything else runs on Studio North GPUs. Or use your own fal.ai key.",+ );+ // No place known: nothing said about where everything else runs.+ expect(setupCardWords({ need: "gpu" }, null, "account").body).toBe("It needs a GPU of your own. Connect yours, and this runs there.");+ });++ it("the promise that a run starts once signed in is its own words, for a run the site takes", () => {+ expect(KEPT_RUN_WORDS).toBe("Sign up with an email and a password. Your run starts as soon as you're in.");+ });+});++describe("Pick another model", () => {+ it("opens the last model picker shown, and is offered only while one is", () => {+ expect(canPickModel()).toBe(false);+ expect(pickAnotherModel()).toBe(false);+ const opened: string[] = [];+ const stopA = answerPickModel(() => opened.push("a"));+ const stopB = answerPickModel(() => opened.push("b"));+ expect(canPickModel()).toBe(true);+ expect(pickAnotherModel()).toBe(true);+ expect(opened).toEqual(["b"]);+ stopB();+ expect(pickAnotherModel()).toBe(true);+ expect(opened).toEqual(["b", "a"]);+ stopA();+ expect(canPickModel()).toBe(false);+ });+});++describe("the surfaces that don't run here yet", () => {+ it("a board's Run points at the studio that makes it, by the place name; with hosted runs off, today's words", () => {+ expect(boardRunWords(true, PLACE)).toEqual({+ title: "Make this in the Video studio",+ body: "You can build, change and keep boards here. The same effect in the Video studio runs every step at once, on Studio North GPUs.",+ });+ expect(boardRunWords(false, PLACE).title).toBe("Make it in a studio");+ expect(boardRunWords(true, null).title).toBe("Running a board isn't available here");+ expect(boardRunWords(false, null).body).toBe("You can build, change and keep boards here. To make something now, use the Image, Video or Audio studio, or an app, effect or camera motion.");+ });++ it("a tool for the studio's owner only: coming soon, with the studios to use now; with hosted runs off, as before", () => {+ const hosted = runPlace({ audience: "account", engine: "cloud", hosted: true, ownerOnly: "Ad Multiplier", format: String });+ expect(hosted).toMatchObject({ where: "unavailable", label: "Coming soon", title: "Coming soon", price: "", send: "", tip: "Ad Multiplier isn't open to accounts yet. Try the Image, Video or Audio studio." });+ const off = runPlace({ audience: "guest", engine: "cloud", ownerOnly: "Ad Multiplier", format: String });+ expect(off).toMatchObject({ label: "Not available here", tip: "Ad Multiplier isn't available here. Try the Image, Video or Audio studio." });+ // The owner runs it as always.+ expect(runPlace({ audience: "owner", engine: "cloud", hosted: true, ownerOnly: "Ad Multiplier", format: String }).where).toBe("cloud");+ });++ it("a tool no visitor's own GPU or key runs yet: no 'isn't available here' while hosted runs are on", () => {+ expect(ownGpuToolMessage(false)).toBe(OWN_GPU_TOOL_MESSAGE);+ expect(ownGpuToolMessage(true)).toBe(OWN_GPU_TOOL_HOSTED);+ expect(OWN_GPU_TOOL_HOSTED).not.toMatch(/isn't available here/);+ });+});diff --git a/tests/hosted-tool-runs.test.ts b/tests/hosted-tool-runs.test.tsindex 164d67a0..8443ca77 100644--- a/tests/hosted-tool-runs.test.ts+++ b/tests/hosted-tool-runs.test.ts@@ -191,12 +191,16 @@ describe("hosted runs on", () => {const steps = [{ request: { feature: "image", modelId: "oss-z-image-turbo", prompt: "a fox" } }];const place = await toolRun.placeOf(auth.accountById(ids.none)!, steps);expect(place.kind).toBe("refuse");- if (place.kind === "refuse") expect(place.refusal.body.code).toBe("not-offered");+ if (place.kind === "refuse") expect(place.refusal.body).toMatchObject({ code: "connect-gpu", error: "Runs on your own GPU", ownSetup: { need: "gpu" } });const before = reserves();const rows = stored("none").length;const r = await toolRun.runAccountTool(json("/api/x", "POST", {}, "none"), auth.accountById(ids.none)!, { tool: "test", files: [], plan: () => steps, start: () => createGenerations(steps[0].request) });expect(r.ok).toBe(false);- if (!r.ok) expect(((await r.response.json()) as { code: string }).code).toBe("not-offered");+ // Its label, and the answer opens Connect your GPU.+ if (!r.ok) {+ expect(r.response.headers.get("x-fuobe-connect-gpu")).toBe("1");+ expect((await r.response.json()) as { code: string; error: string }).toMatchObject({ code: "connect-gpu", error: "Runs on your own GPU" });+ }expect(reserves()).toBe(before);expect(stored("none").length).toBe(rows);});@@ -238,7 +242,9 @@ describe("hosted runs on", () => {expect(r.ok).toBe(false);if (!r.ok) {expect(r.response.status).toBe(403);- expect(((await r.response.json()) as { code: string }).code).toBe("not-offered");+ // Said as its label, which opens Connect your GPU (lateRefusal), as the gate says it before Run.+ expect(((await r.response.json()) as { code: string }).code).toBe("connect-gpu");+ expect(r.response.headers.get("x-fuobe-connect-gpu")).toBe("1");}expect(reserves() - before).toBe(1);expect((fake.calls_of("/v1/reserve").at(-1)!.body as { run: { steps: { jobs: number }[] } }).run.steps).toEqual([expect.objectContaining({ jobs: 1 })]);@@ -500,13 +506,15 @@ describe("hosted runs on", () => {expect(fake.calls_of("/v1/refund").filter((c) => (c.body as { holdId: string }).holdId === hold[0])).toHaveLength(1);});- it("a 3D model stays on an account's own GPU: refused here in the tools' words", async () => {+ it("a 3D model stays on an account's own GPU: its label, and the answer opens Connect your GPU", async () => {const steps = [{ request: { feature: "3d", modelId: "oss-pixal3d", op: "image-to-3d" as const, prompt: "", inputs: { images: ["/api/files/x.png"] } } }];const place = await toolRun.placeOf(auth.accountById(ids.none)!, steps);expect(place.kind).toBe("refuse");if (place.kind === "refuse") {- expect(place.refusal.body.code).toBe("own-gpu-tool");- expect(place.refusal.body.error).toBe(OWN_GPU_TOOL_MESSAGE);+ expect(place.refusal.body.code).toBe("connect-gpu");+ expect(place.refusal.body.error).toMatch(/^Runs on your own GPU · \d+ GB$/);+ expect(place.refusal.body.ownSetup).toMatchObject({ need: "gpu" });+ expect(place.refusal.body.error).not.toBe(OWN_GPU_TOOL_MESSAGE);}});diff --git a/tests/hosted-words.test.ts b/tests/hosted-words.test.tsindex 345d1b11..094a41db 100644--- a/tests/hosted-words.test.ts+++ b/tests/hosted-words.test.ts@@ -32,9 +32,12 @@ vi.mock("@/lib/api", async (load) => ({useEngineMode: () => "both",}));-const { hostedGuestWords, hostedWords, outputsWords } = await import("@/server/hosted");-const { gateText, ownGpuQuiet } = await import("@/server/hosted-run");+const { hostedDetails, hostedGuestWords, hostedWords, outputsWords } = await import("@/server/hosted");+const { gateDetail, gateText, ownGpuQuiet } = await import("@/server/hosted-run");const { needsGpu } = await import("@/server/pool-own-setup");+const { KEPT_RUN_WORDS, setupCardWords } = await import("@/lib/own-setup-card");+const { boardRunWords } = await import("@/lib/board-run-words");+const { OWN_GPU_TOOL_HOSTED } = await import("@/lib/guest-access");const { SITE_HIDDEN_WORDS } = await import("@/server/output-checks");const { SITE_FAILED_WORDS } = await import("@/lib/comfy-compose");const { FILE_TROUBLE_WORDS, POOL_WORDS } = await import("@/lib/relay");@@ -109,13 +112,21 @@ afterEach(() => notePlaceName(null));/** Every sentence a visitor reads from the server's word tables, for a place. */function serverWords(place: ReturnType<typeof placeOf>): string[] {- const reasons = ["notOffered", "rtxCard", "loras", "inputs"] as const;+ const reasons = ["notOffered", "rtxCard", "loras", "inputs", "size", "model3d"] as const;+ const setups = [needsGpu(), { need: "gpu" as const, vramGb: 48 }, { need: "gpu" as const, vramGb: 24, orKey: "fal" as const }, { need: "key" as const, provider: "fal" }];return [...Object.values(hostedWords(place)),...Object.values(hostedGuestWords()),+ ...Object.values(hostedDetails(place, "8 megapixels")),+ ...Object.values(hostedDetails(place)),...[1, 3].flatMap((cap) => [outputsWords(cap, false, place), outputsWords(cap, true, place)]),- ...reasons.flatMap((reason) => [gateText({ ok: false, reason }, false, place), gateText({ ok: false, reason }, true, place)]),+ ...reasons.flatMap((reason) => [gateText({ ok: false, reason }, false, place), gateText({ ok: false, reason }, true, place), gateDetail({ ok: false, reason, most: "10 s clips" }, place) ?? ""]),gateText({ ok: false, reason: "ownSetup", setup: needsGpu() }, false, place),+ // The cards a labelled item opens (a guest's sign-up, an account's setup), and the other surfaces' labels.+ ...setups.flatMap((s) => (["guest", "account"] as const).flatMap((who) => Object.values(setupCardWords(s, place, who)))),+ KEPT_RUN_WORDS,+ ...[true, false].flatMap((one) => Object.values(boardRunWords(one, place))),+ OWN_GPU_TOOL_HOSTED,gateText({ ok: false, reason: "outputs", cap: 2 }, false, place),ownGpuQuiet(place),...Object.values(POOL_WORDS),@@ -131,6 +142,12 @@ function chipWords(place: ReturnType<typeof placeOf>): string[] {for (const audience of ["account", "guest"] as const)for (const pool of [undefined, { text: "" }, { text: "1 generation", wait: "ready in about 40 s" }, { text: "Free", wait: "starts when a GPU is free" }, { text: "You have 2 runs going.", refused: true }])for (const p of [runPlace({ audience, engine: "open", hosted: true, models: ["Z-Image Turbo"], pool, place, format: String })]) out.push(p.label, p.price, p.title, p.tip, p.send);+ // A label (what runs on one's own GPU), and a tool for the studio's owner only.+ for (const audience of ["account", "guest"] as const) {+ const labelled = runPlace({ audience, engine: "open", hosted: true, pool: { text: "Runs on your own GPU · 48 GB", refused: true, setup: { need: "gpu", vramGb: 48 } }, place, format: String });+ const ownerOnly = runPlace({ audience, engine: "cloud", hosted: true, ownerOnly: "Ads Studio", place, format: String });+ for (const p of [labelled, ownerOnly]) out.push(p.label, p.price, p.title, p.tip, p.send);+ }return out.filter(Boolean);}diff --git a/tests/pool-limits.test.ts b/tests/pool-limits.test.tsindex bbb5947e..b0a5af96 100644--- a/tests/pool-limits.test.ts+++ b/tests/pool-limits.test.ts@@ -51,7 +51,7 @@ const { loadManifest } = await import("@/server/providers/comfyui");const { loadIndex } = await import("@/server/gpu/index-file");const { allLanes } = await import("@/lib/lanes");const { getModel } = await import("@/lib/catalog");-const { CONNECT_GPU_HEADER, OWN_GPU_TOOL_MESSAGE, PLACE_ASK_HEADER } = await import("@/lib/guest-access");+const { CONNECT_GPU_HEADER, PLACE_ASK_HEADER } = await import("@/lib/guest-access");const hosted = await import("@/server/hosted");const { getGeneration } = await import("@/server/generations");const { ACCOUNT_MESSAGES } = await import("@/server/account-files");@@ -482,10 +482,10 @@ describe("where a run goes", () => {const r = await post(IMAGE, a.cookie);expect(r.status, JSON.stringify(r.body)).toBe(201);expect(r.body.items![0].place).toBeUndefined();- // Named, it is a refusal (the person asked for that place).+ // Named, it is its label, which opens the setup that runs it (the person asked for that place).const named = await post({ ...IMAGE, place: "pool", ...SHOWN }, a.cookie);expect(named.status).toBe(403);- expect(named.body.code).toBe("not-offered");+ expect(named.body.code).toBe("connect-gpu");});it("with this install's GPUs first, the price check of a run that names no place answers for where it really goes", async () => {@@ -661,12 +661,12 @@ describe("where a run goes", () => {const a = account();const r = await post({ ...IMAGE, ...SHOWN }, a.cookie);expect(r.status).toBe(403);- expect(r.body.code).toBe("not-offered");+ expect(r.body.code).toBe("connect-gpu");expect(hostedRun.kindAllowed({ kinds: { image: false } }, "video")).toBe(true);expect(hostedRun.kindAllowed({}, "model3d")).toBe(true);});- it("3D isn't offered on this install's GPUs yet, even with kinds.model3d on: an account with no GPU of its own is told the tool isn't available here", async () => {+ it("3D no worker finishes, even with kinds.model3d on: an account with no GPU of its own reads its label, and the answer opens Connect your GPU", async () => {withBilling({ kinds: { model3d: true }, limits: { activeRuns: 0, waiting: 0, runsPerHour: 0 } });const a = account();const uploadsRoute = await import("@/app/api/uploads/route");@@ -679,9 +679,9 @@ describe("where a run goes", () => {const holds = fake.holds.size;const r = await post({ feature: "image-to-3d", modelId: "oss-pixal3d", op: "image-to-3d", inputs: { images: [url] }, ...SHOWN }, a.cookie);expect(r.status, JSON.stringify(r.body)).toBe(403);- expect(r.body.code).toBe("own-gpu-tool");- expect(r.body.error).toBe(OWN_GPU_TOOL_MESSAGE);- expect(r.headers.get(CONNECT_GPU_HEADER)).toBeNull();+ expect(r.body.code).toBe("connect-gpu");+ expect(r.body.error).toMatch(/^Runs on your own GPU · \d+ GB$/);+ expect(r.headers.get(CONNECT_GPU_HEADER)).toBe("1");expect(poolRuns(a.id)).toBe(0);expect(fake.holds.size).toBe(holds);});@@ -852,7 +852,7 @@ describe("a run's price facts", () => {const holds = fake.holds.size;const r = await post(film, a.cookie);expect(r.status, JSON.stringify(r.body)).toBe(403);- expect(r.body.code).toBe("not-offered");+ expect(r.body.code).toBe("connect-gpu");expect(poolRuns(a.id)).toBe(0);expect(fake.holds.size).toBe(holds);// Its price check says the same before Run: not offered here, so Run stays off.@@ -880,7 +880,6 @@ describe("the price check before Run and the run itself", async () => {const { hostedGuestWords, hostedWords } = await import("@/server/hosted");const HOSTED_GUEST_WORDS = hostedGuestWords();const HOSTED_WORDS = hostedWords(placeOf(null));- const { OWN_GPU_TOOL_MESSAGE } = await import("@/lib/guest-access");/** A Fuobe DoP effect: its start frame is made first on another model, then animated. */const EFFECT = { feature: "video", presetId: "effect-acid", modelId: "fuobe-dop", op: "i2v", prompt: "a dancer", inputs: { images: [PLACEHOLDER.image] } };const LORAS = { ...IMAGE, loras: [{ file: "x.safetensors", url: "https://huggingface.co/x/x.safetensors" }] };@@ -896,7 +895,7 @@ describe("the price check before Run and the run itself", async () => {{ name: "extra LoRAs", req: LORAS, refused: HOSTED_WORDS.loras },{ name: "a kind of file the policy keeps off", req: EFFECT, policy: { uploads: { image: false, video: false, audio: false } }, refused: HOSTED_WORDS.inputs },{ name: "a chain whose later step the policy denies", req: EFFECT, policy: { pool: { deny: ["fuobe-mixed-media"] } }, refused: HOSTED_WORDS.notOffered },- { name: "a 3D model", req: THREE_D, refused: OWN_GPU_TOOL_MESSAGE },+ { name: "a 3D model", req: THREE_D, refused: "3d" },];const a = account();const acct = auth.accountById(a.id)!;@@ -911,8 +910,45 @@ describe("the price check before Run and the run itself", async () => {continue;}expect(run.kind, c.name).toBe("refuse");- expect(run.kind === "refuse" && run.refusal.body.error, c.name).toBe(c.refused);- expect(check?.quote, c.name).toMatchObject({ allowed: false, text: c.refused });+ const words = c.refused === "3d" ? expect.stringMatching(/^Runs on your own GPU · \d+ GB$/) : c.refused;+ expect(run.kind === "refuse" && run.refusal.body.error, c.name).toEqual(words);+ expect(check?.quote, c.name).toMatchObject({ allowed: false, text: words, ownSetup: { need: "gpu" } });+ }+ });++ it("a size bigger than every GPU here makes is its label before Run, the press opens Connect your GPU, and an own GPU runs it at once", async () => {+ withBilling({ limits: NO_LIMITS });+ const a = account();+ const acct = auth.accountById(a.id)!;+ const req = { ...IMAGE, account: a.id } as never;+ expect((await hostedRun.decidePlace(acct, req, undefined)).kind).toBe("pool");+ // The only GPU here makes pictures up to a tenth of a megapixel (its PC's ceiling).+ db().prepare("UPDATE relay_workers SET ceiling_json = ? WHERE id = ?").run(JSON.stringify({ maxMegapixels: 0.1 }), worker.id);+ try {+ const check = await hostedRun.poolQuote(acct, req, undefined);+ expect(check?.quote).toMatchObject({ allowed: false, code: "not-offered", text: HOSTED_WORDS.size, ownSetup: { need: "gpu" } });+ expect((check?.quote as { sub?: string }).sub).toBe("Up to 0.1 megapixels on our GPUs. Pick a smaller size, or run it on your own GPU.");+ const run = await hostedRun.decidePlace(acct, req, undefined);+ expect(run.kind).toBe("refuse");+ if (run.kind === "refuse") {+ expect(run.refusal.body).toMatchObject({ code: "connect-gpu", error: "This size runs on your own GPU", ownSetup: { need: "gpu" } });+ expect(run.refusal.headers[CONNECT_GPU_HEADER]).toBe("1");+ }+ // Pressed anyway: nothing is held or made.+ const holds = fake.holds.size;+ const r = await post({ ...IMAGE, place: "pool", ...SHOWN }, a.cookie);+ expect(r.status, JSON.stringify(r.body)).toBe(403);+ expect(r.body.code).toBe("connect-gpu");+ expect(poolRuns(a.id)).toBe(0);+ expect(fake.holds.size).toBe(holds);+ // An account whose own GPU answers: the run goes there on the first press, no question.+ const g = account({ gpu: "online" });+ expect((await hostedRun.decidePlace(auth.accountById(g.id)!, { ...IMAGE, account: g.id } as never, undefined)).kind).toBe("own");+ // A size within the ceiling runs here again.+ db().prepare("UPDATE relay_workers SET ceiling_json = ? WHERE id = ?").run(JSON.stringify({ maxMegapixels: 64 }), worker.id);+ expect((await hostedRun.decidePlace(acct, req, undefined)).kind).toBe("pool");+ } finally {+ db().prepare("UPDATE relay_workers SET ceiling_json = NULL WHERE id = ?").run(worker.id);}});@@ -925,7 +961,7 @@ describe("the price check before Run and the run itself", async () => {const run = await hostedRun.decidePlace(acct, { ...r, account: a.id } as never, undefined);return run.kind === "refuse" ? run.refusal.body.error : run.kind;};- expect(await refused(THREE_D)).toBe(OWN_GPU_TOOL_MESSAGE);+ expect(await refused(THREE_D)).toMatch(/^Runs on your own GPU · \d+ GB$/);// A worker whose CPU slot runs the 3D finish: the model's GLB is checked, made for the web and given its turntable there.db().prepare("UPDATE relay_workers SET cpu_slot_json = ? WHERE id = ?").run(JSON.stringify({ finishes: ["model3d"] }), worker.id);try {@@ -936,14 +972,14 @@ describe("the price check before Run and the run itself", async () => {expect(await refused(THREE_D)).toBe(HOSTED_WORDS.notOffered);withBilling({ limits: NO_LIMITS });// A splat or a scene gets no finish there: it stays on a visitor's own setup.- expect(await refused({ ...THREE_D, modelId: "oss-triposplat", op: "splat" })).toBe(OWN_GPU_TOOL_MESSAGE);- expect(await refused({ ...THREE_D, modelId: "oss-scene-moge", op: "scene-3d" })).toBe(OWN_GPU_TOOL_MESSAGE);+ expect(await refused({ ...THREE_D, modelId: "oss-triposplat", op: "splat" })).toMatch(/^Runs on your own GPU · \d+ GB$/);+ expect(await refused({ ...THREE_D, modelId: "oss-scene-moge", op: "scene-3d" })).toMatch(/^Runs on your own GPU · \d+ GB$/);} finally {db().prepare("UPDATE relay_workers SET cpu_slot_json = NULL WHERE id = ?").run(worker.id);}// No CPU slot that finishes it any more: refused again, before Run and at the run alike.- expect(await refused(THREE_D)).toBe(OWN_GPU_TOOL_MESSAGE);- expect((await hostedRun.poolQuote(acct, req, undefined))?.quote).toMatchObject({ allowed: false, text: OWN_GPU_TOOL_MESSAGE });+ expect(await refused(THREE_D)).toMatch(/^Runs on your own GPU · \d+ GB$/);+ expect((await hostedRun.poolQuote(acct, req, undefined))?.quote).toMatchObject({ allowed: false, text: expect.stringMatching(/^Runs on your own GPU · \d+ GB$/), ownSetup: { need: "gpu" } });});it("while every worker that could run it is built from the catalog before the studio's update, the run is taken and waits in line until one is updated; Run stays on", async () => {@@ -1000,7 +1036,7 @@ describe("the price check before Run and the run itself", async () => {expect(hostedRun.runAway(planned as never, chain)).toBe(false);});- it("a guest's price check plans every step of a chain too, and words its refusals for someone with no Settings yet", async () => {+ it("a guest's price check plans every step of a chain too, and says the same labels as an account's", async () => {withBilling({ limits: NO_LIMITS });expect((await hostedRun.poolQuote(null, EFFECT as never, undefined))?.quote.allowed).toBe(true);// A later step this install's GPUs don't take: refused before Run, never only once the run starts after sign-up.@@ -1008,8 +1044,8 @@ describe("the price check before Run and the run itself", async () => {expect((await hostedRun.poolQuote(null, EFFECT as never, undefined))?.quote).toMatchObject({ allowed: false, code: "not-offered", text: HOSTED_GUEST_WORDS.notOffered });withBilling({ limits: NO_LIMITS, pool: { deny: ["oss-z-image-turbo"] } });const denied = await hostedRun.poolQuote(null, IMAGE as never, undefined);- expect(denied?.quote).toMatchObject({ allowed: false, text: HOSTED_GUEST_WORDS.notOffered });- expect(denied?.quote.text).not.toMatch(/Settings|your own GPU/);+ expect(denied?.quote).toMatchObject({ allowed: false, text: HOSTED_GUEST_WORDS.notOffered, ownSetup: { need: "gpu" } });+ expect(denied?.quote.text).toBe(HOSTED_WORDS.notOffered);withBilling({ limits: NO_LIMITS });expect((await hostedRun.poolQuote(null, LORAS as never, undefined))?.quote.text).toBe(HOSTED_GUEST_WORDS.loras);// Planned as nobody's: nothing of the plan is kept.@@ -1037,9 +1073,10 @@ describe("the price check before Run and the run itself", async () => {expect(hostedRun.stepsProblem(billing.OPEN_POLICY, chain)).toBe(HOSTED_WORDS.rtxCard);setSetting("comfyWhere", "workers");expect(hostedRun.stepsProblem(billing.OPEN_POLICY, chain)).not.toBe(HOSTED_WORDS.rtxCard);- // A guest is told it isn't offered, with nowhere to connect a GPU named.+ // A guest reads the same label as an account (Run opens the sign-up for it), with no Settings named.expect(hostedRun.gateWords("rtxCard", true, placeOf(null))).toBe(HOSTED_GUEST_WORDS.rtxCard);- expect(hostedRun.gateWords("rtxCard", true, placeOf(null))).not.toMatch(/Settings|your own GPU|NVIDIA/);+ expect(hostedRun.gateWords("rtxCard", true, placeOf(null))).toBe("Runs on your own RTX GPU");+ expect(hostedRun.gateWords("rtxCard", true, placeOf(null))).not.toMatch(/Settings/);expect(hostedRun.gateWords("rtxCard", false, placeOf(null))).toBe(HOSTED_WORDS.rtxCard);});