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
Model pickers: what runs on Fuobe Cloud first, and a free run with the closest model
Adarsh3f09d0e7ee45
diff --git a/src/app/api/status/route.ts b/src/app/api/status/route.tsindex d1306a44..9cc9338d 100644--- a/src/app/api/status/route.ts+++ b/src/app/api/status/route.ts@@ -8,6 +8,7 @@ import { llmBackends } from "@/server/providers/llm";import { nothingConnected, type EngineModeName } from "@/lib/connections";import { getSetting, setSetting } from "@/server/settings";import { offeredSummary } from "@/server/model-access";+import { poolOwnModels } from "@/server/pool-own-setup";import { placeName } from "@/server/place-name";import { helperKnown, helperLive } from "@/server/text-helper";@@ -39,6 +40,9 @@ export async function GET(request?: Request) {// ComfyUI runs on the owner's computer: what the owner's Fuobe tab there last said (ComfyUI stays "configured", so runs// wait for that tab instead of turning into demos).const ownerGpu = getSetting("comfyWhere") === "computer" ? computerView("owner") : undefined;+ // ComfyUI runs on the workers: the open models none of them can run now (the same set a visitor's pickers read), so+ // the owner's pickers order, tag and default as his runs will go (src/lib/runnable-here.ts).+ const ownerPool = getSetting("comfyWhere") === "workers" ? { own: poolOwnModels() } : undefined;return Response.json({providers,demoMode: getSetting("demoMode"),@@ -46,6 +50,7 @@ export async function GET(request?: Request) {cloudProvider: getSetting("cloudProvider"),onboarded,...(ownerGpu && { ownerGpu }),+ ...(ownerPool && { pool: ownerPool }),// Settings → Models & licences: the models switched off, so pickers leave them out (absent while everything is on)....(access && { access }),// The text LLM: the AI helper setting, whether Claude takes text steps, the local server (no keys), and the freediff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsxindex 77950900..7c406d1b 100644--- a/src/components/studio/composer.tsx+++ b/src/components/studio/composer.tsx@@ -37,7 +37,9 @@ import { RunOnChip } from "./run-on";import { PlaceIntro } from "./place-intro";import { PoolNote } from "./pool-note";import { EndFrameNote } from "./end-frame-note";-import { modelOwnSetup, pickerRules, poolRunsModel } from "@/lib/pool-rules";+import { modelOwnSetup, pickerRules } from "@/lib/pool-rules";+import { carryParams, closestHere, hereDefault, hereOwnLink, hereReason, hereRunLabel, hereSetup, runsHere } from "@/lib/runnable-here";+import { useHere } from "@/hooks/use-pool-rules";import { controlSetup, keyOnlySetup } from "@/lib/own-setup-controls";import { ownSetupDetail, ownSetupLabel, ownSetupShort } from "@/lib/own-setup";import { OwnSetupChip, useOwnSetupPress, useOwnSetupViewer } from "@/components/own-setup";@@ -381,7 +383,9 @@ export function Composer({ docked }: { docked: boolean }) {// what runs them (their own-setup label, src/lib/pool-rules.ts), as the models that run on a visitor's own setup only// do: Run then opens that setup, or runs it on the viewer's own GPU at once. Only a viewer with no GPU of its own is// moved off an untouched default they keep off (poolOff, below).- const poolRules = status?.viewer?.hosted && !status.viewer.gpu.connected ? status.viewer.pool : undefined;+ // Where this viewer's open runs go to this install's GPUs, and what they run now (runnable-here.ts): the same check as+ // the run's (poolGate), for the default, the picker's order and the free alternative below.+ const here = useHere();const labelRules = pickerRules(status?.viewer);const models = useMemo(() => filterModels(catalog.models, { kind: config.kind, ops: pickerOps }), [catalog.models, config.kind, pickerOps]);const setupViewer = useOwnSetupViewer();@@ -531,13 +535,11 @@ export function Composer({ docked }: { docked: boolean }) {// moves to the first model of its list they run. A model the person picked (or a link, a Reuse) stays, with its label,// and Run opens the setup that runs it.const untouched = !!model && (model.id === config.defaultModels[engine] || model.id === defaults[engine]);- const poolOff = model && untouched && !lockedModel && !presetFallback && !offModel && !poolRunsModel(poolRules, model) ? model : undefined;- const poolTo = poolOff- ? [defaults[engine], ...models.filter((m) => m.engine === engine).map((m) => m.id)].find((id) => {- const m = id && id !== poolOff.id ? models.find((x) => x.id === id) : undefined;- return !!m && poolRunsModel(poolRules, m) && !modelSetup(m);- })- : undefined;+ // The studio's untouched default that doesn't run here now (runnable-here.ts: a visitor whose runs go to this install's+ // GPUs, or the owner's on the workers): the default is always one that runs, so it moves to the studio's other default+ // when that runs, else to the closest model that does (the free alternative's pick).+ const poolOff = model && untouched && !lockedModel && !presetFallback && !offModel && !runsHere(here, model) ? model : undefined;+ const poolTo = poolOff ? hereDefault(poolOff, defaults[engine], models, here, { params: draft.params })?.id : undefined;useEffect(() => {const m = poolOff && poolTo ? catalog.getModel(poolTo) : undefined;// A link that names the model keeps it.@@ -1079,6 +1081,8 @@ export function Composer({ docked }: { docked: boolean }) {pressSetup(owner ? null : "fly-around:exact-orbit", () => fly.run.mutate({ engine: withKey ? "cloud" : engine, image: exactImage, orbit: exact, prompt: draft.prompt.trim() || undefined, feature: config.feature }));return;}+ // A model that doesn't run here now: the press runs the free alternative (its own setup is the link under it).+ if (hereAlt && !withKey && !once && !skipGpu && !signedUp && !create.isPending) return runHereAlt();if (keyToAdd && model && !create.isPending) return openAddKey(keyToAdd, model.id);if (!blocker && gpuSetup && !skipGpu && !withKey && once !== "pool" && !create.isPending) return openGpuFix();// It runs on the visitor's own setup: Run opens it (Connect your GPU, Add your key, a guest's sign-up), and nothing@@ -1455,6 +1459,50 @@ export function Composer({ docked }: { docked: boolean }) {if (m.engine !== engine) setEngine(m.engine);};+ // A model picked that doesn't run on this install's GPUs now (runnable-here.ts, the run's own check): Run becomes a+ // one-press free run on the closest model that does, with the same prompt, files and settings, and a link opens what+ // runs the one picked (Connect your GPU, Add your key, a guest's sign-up; the owner's workers).+ const hereNeed = model && !demo && !exact ? hereSetup(here, model) : null;+ const altPool = lockedModel ? appPickerModels : models;+ const hereImages = draft.refs.length + slots.filter((s) => s.accept === "image" && draft.slots[s.key]?.ref).length;+ const hereAlt = useMemo(+ () => (hereNeed && model ? closestHere(model, altPool, here, { op: effectiveOp, params: draft.params, images: hereImages, endFrame: !!draft.slots.endImage?.ref }) : undefined),+ [hereNeed, model, altPool, here, effectiveOp, draft.params, hereImages, draft.slots.endImage?.ref],+ );+ const [altRun, setAltRun] = useState<string | null>(null);+ const runHereAlt = () => {+ if (!hereAlt || !model) return;+ const keep = { aspectRatio: draft.params.aspectRatio, resolution: draft.params.resolution, duration: draft.params.duration, numOutputs: draft.params.numOutputs, generateAudio: draft.params.generateAudio, seed: draft.params.seed, enhancePrompt: draft.params.enhancePrompt };+ const kept = Object.fromEntries(Object.entries(carryParams(keep, hereAlt)).filter(([, v]) => v !== undefined));+ setDraft((d) => (d.modelId !== model.id ? {} : { modelId: hereAlt.id, params: { ...hereAlt.defaults, ...kept }, ...lookCleared(model, hereAlt) }));+ if (hereAlt.engine !== engine) setEngine(hereAlt.engine);+ setAltRun(hereAlt.id);+ };+ // Once the draft is on the stand-in and its files and price check have settled, it runs (as a press of Run would).+ useEffect(() => {+ if (!altRun) return;+ if (model?.id !== altRun) {+ if (model && draft.modelId !== altRun) setAltRun(null);+ return;+ }+ if (settling || !priceSettled) return;+ setAltRun(null);+ submitRef.current();+ }, [altRun, model, draft.modelId, settling, priceSettled]);+ const hereOwn = () => {+ const setup = poolSetup ?? hereNeed;+ if (!setup || !model) return;+ // As Run did before: the setup that runs it (an account with its GPU runs it there with this press; one whose key+ // runs its cloud version picks, at the key's price).+ if (viewerInfo?.gpu.connected && setup.need === "gpu") return submitRef.current(undefined, undefined, "own");+ if (keyTwin && keyPrice && !viewerInfo?.gpu.connected) {+ if (runOnPicked === "key") return submitRef.current(undefined, withKeyAction(keyTwin.provider, keyTwin.modelId, keyTwin.op, keyPrice));+ return void setKeyChoice(true);+ }+ if (guestHold) guestDraft.keepRun(null, setup);+ if (pressSetup(setup)) submitRef.current(undefined, undefined, "own");+ };+// Frames on: the start and end frames already attached become the first frames. Off: the first and last frames// go back to start and end (the ones in between can come back with Undo).const framesLength = framesCtx?.duration ?? (model ? framesDuration(model, p.duration) : p.duration);@@ -1983,7 +2031,8 @@ export function Composer({ docked }: { docked: boolean }) {) : null}{/* Toolbar: one row on phones (it scrolls, with faded edges, when it does not fit); from sm up it wraps, so every chip shows. */}- <div className="flex items-center gap-2">+ {/* The free alternative's button takes its own line on a phone, so the model chip keeps its name. */}+ <div className={cn("flex items-center gap-2", hereAlt && "max-sm:flex-wrap")}>{/* Phones (below sm): "+", Settings (icon), the model (it shrinks to fit) and @; the other chips are in the settings sheet. */}<div ref={chipRow} style={fade} data-composer-toolbar className="scrollbar-none -my-1 flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto py-1 sm:flex-wrap sm:overflow-x-visible">{kinds.length > 0 && <AttachMenu kinds={kinds} onFiles={attach.attachFiles} onPick={attach.attach} />}@@ -2126,7 +2175,7 @@ export function Composer({ docked }: { docked: boolean }) {className={cn(poolRefused && runOnRows.on === "site" && "max-w-48")}/>)}- {!runOnRows && costText && (+ {!runOnRows && costText && !hereAlt && (<Tooltip><TooltipTrigger asChild><span@@ -2166,6 +2215,18 @@ export function Composer({ docked }: { docked: boolean }) {</TooltipContent></Tooltip>)}+ {hereAlt && model ? (+ <Button+ onClick={() => submit()}+ disabled={create.isPending || signature.lock.isPending || !!altRun}+ aria-busy={!!altRun || create.isPending || undefined}+ data-slot="run-free-alt"+ className="h-10 min-w-0 shrink gap-1.5 rounded-full px-4 text-[13px] font-medium max-sm:w-full"+ >+ {altRun || create.isPending ? <Loader2 className="motion-spinner size-4 shrink-0" /> : <ArrowUp className="size-4 shrink-0" />}+ <span className="truncate">{hereRunLabel(hereAlt, here?.owner)}</span>+ </Button>+ ) : (<Tooltip><TooltipTrigger asChild><Button@@ -2197,8 +2258,29 @@ export function Composer({ docked }: { docked: boolean }) {)}</TooltipContent></Tooltip>+ )}</div><div aria-live="polite">+ {hereAlt && hereNeed && model && (+ <p data-here-alt className="flex flex-wrap items-center gap-x-2 px-2 text-[12px] text-muted-foreground">+ <span className="inline-flex min-h-6 items-center">{hereReason(model, here?.owner ? "a worker" : sitePlace.text)}</span>+ {here?.owner ? (+ <Link href="/settings/workers" className="inline-flex min-h-6 items-center font-medium text-brand-text underline-offset-2 hover:underline">+ {hereOwnLink(model.name, hereNeed, true)} →+ </Link>+ ) : (+ <button+ type="button"+ onMouseDown={(e) => e.preventDefault()}+ disabled={create.isPending}+ onClick={hereOwn}+ className="inline-flex min-h-6 items-center text-left font-medium text-brand-text underline-offset-2 hover:underline"+ >+ {hereOwnLink(model.name, hereNeed)} →+ </button>+ )}+ </p>+ )}{line && blocker && (// Focused from the keyboard, it stays (the composer unfolding must not hide what has the focus).<p className={cn("px-2 text-[12px] text-muted-foreground", line === "touch" && "[@media(hover:hover)]:hidden [@media(hover:hover)]:focus-within:block")}>@@ -2218,7 +2300,7 @@ export function Composer({ docked }: { docked: boolean }) {</p>)}{/* Folded (docked, not focused), the composer stays one line: the wait shows again once it opens. */}- {!blocker && !gpuSetup && !ownKeyHere && poolState && (poolState.refused || !collapsed) && <PoolNote state={poolState} offer={waitOffer} alt={withoutLoras} />}+ {!blocker && !gpuSetup && !ownKeyHere && !hereAlt && poolState && (poolState.refused || !collapsed) && <PoolNote state={poolState} offer={waitOffer} alt={withoutLoras} />}{!blocker && turnedDown && (<p data-key-turned-down className="flex flex-wrap items-center gap-x-2 px-2 text-[12px] text-muted-foreground"><span>{keyTurnedDownWords(turnedDown.provider)}</span>diff --git a/src/components/studio/model-picker.tsx b/src/components/studio/model-picker.tsxindex 655b430b..ac786b58 100644--- a/src/components/studio/model-picker.tsx+++ b/src/components/studio/model-picker.tsx@@ -1,6 +1,6 @@"use client";-import { ChevronDown, Cloud, Cpu, SearchX, Sparkles, Star } from "lucide-react";+import { ChevronDown, Cloud, Cpu, KeyRound, SearchX, Sparkles, Star } from "lucide-react";import Link from "next/link";import { useEffect, useMemo, useRef, useState } from "react";import { KEY_ADDED_EVENT, openAddKey } from "@/components/keys/your-keys";@@ -21,7 +21,9 @@ import { groupModels, studioBest, toggleIn } from "@/lib/composer";import { readsBoxes } from "@/lib/layout-prompt";import { pickerPrice } from "@/lib/model-rows";import { cn } from "@/lib/utils";-import { ownSetupLabel } from "@/lib/own-setup";+import { ownSetupDetail, ownSetupLabel } from "@/lib/own-setup";+import { useHere } from "@/hooks/use-pool-rules";+import { hereSetup, hereTag, runsHere } from "@/lib/runnable-here";import { answerPickModel } from "@/lib/pick-model";import { addKeyLabel, billedTo, CLOUD_KEY, CLOUD_PROVIDERS, needsKey, type CloudProvider } from "@/lib/your-keys";import { CLOUD_PICKER_NOTE, CLOUD_SECTION_LABEL, cloudModelAsk, openCloudPanel, visitorEngine } from "@/lib/engine-ux";@@ -98,6 +100,7 @@ export function ModelRow({edits,setup,guest,+ here,}: {m: ModelDef;selected: boolean;@@ -121,6 +124,11 @@ export function ModelRow({edits?: boolean;/** It runs on the visitor's own GPU or key (own-setup.ts): its label in place of the price; Run then opens that setup. */setup?: OwnSetup | null;+ /**+ * A "More models" row (runnable-here.ts): what runs it instead of this install's GPUs, as a short positive tag ("With+ * your GPU · 24 GB", "With your fal.ai key"; the owner's "Add to a worker") in place of the price.+ */+ here?: { setup: OwnSetup; owner: boolean } | null;}) {return (<>@@ -161,7 +169,16 @@ export function ModelRow({</span>)}</span>- {setup && !needs ? (+ {here && !needs ? (+ <span+ data-slot="here-tag"+ title={here.owner ? "No worker has its files yet: add them on the Workers page." : ownSetupDetail(here.setup)}+ className="inline-flex h-auto min-h-4 max-w-[45%] shrink-0 items-center gap-1 overflow-hidden rounded-[4px] bg-muted px-1 text-[10px] leading-4 font-medium whitespace-nowrap text-muted-foreground"+ >+ {here.setup.need === "key" ? <KeyRound className="size-2.5! shrink-0" aria-hidden /> : <Cpu className="size-2.5! shrink-0" aria-hidden />}+ <span className="truncate">{hereTag(here.setup, here.owner)}</span>+ </span>+ ) : setup && !needs ? (<OwnSetupChip setup={setup} className="h-auto min-h-4 max-w-[45%]" />) : needs ? (// On a phone the short words, so the model's name keeps its room.@@ -333,6 +350,9 @@ export function PickerList({const [recent] = useStoredList(RECENT_MODELS);const [starred, setStarred] = useStoredList(STARRED_MODELS);const today = useToday();+ // What runs on this install's GPUs now comes first; the rest follows as "More models", each tagged with what runs it.+ const here = useHere();+ const runs = useMemo(() => (here ? (m: ModelDef) => runsHere(here, m) : undefined), [here]);// A studio for clip edits (Edit video: its first operation edits a clip) prices models as an edit bills.const editsClips = ops?.[0] === "v2v" || ops?.[0] === "video-swap" || ops?.[0] === "video-insert";const engines = useMemo<Engine[]>(() => (mode === "both" ? ["cloud", "open"] : [mode]), [mode]);@@ -343,8 +363,8 @@ export function PickerList({return recipe && models.some((m) => m.id === recipe && m.engine === engine) ? [recipe, ...ranked.filter((id) => id !== recipe)] : ranked;}, [models, engine, defaultModels, ops, recipe]);const { groups, count } = useMemo(- () => groupModels({ models, engine, engines, query: q, recent, starred, best, flat, boxes }),- [models, engine, engines, q, recent, starred, best, flat, boxes],+ () => groupModels({ models, engine, engines, query: q, recent, starred, best, flat, boxes, runs }),+ [models, engine, engines, q, recent, starred, best, flat, boxes, runs],);const demo = placeholdersOn(status?.demoMode);const otherEngine = engine === "cloud" ? "open" : "cloud";@@ -384,6 +404,10 @@ export function PickerList({onChange(m);onPicked();};+ const hereRow = (m: ModelDef) => {+ const setup = hereSetup(here, m);+ return setup && here ? { setup, owner: here.owner } : null;+ };const addKey = () => {onPicked();openAddKey("fal");@@ -480,6 +504,7 @@ export function PickerList({made={m.id === madeWith}edits={editsClips}setup={ownSetup?.(m)}+ here={hereRow(m)}/></CommandItem>))}diff --git a/src/hooks/use-pool-rules.ts b/src/hooks/use-pool-rules.tsindex 9162f626..7cd17958 100644--- a/src/hooks/use-pool-rules.ts+++ b/src/hooks/use-pool-rules.ts@@ -1,7 +1,9 @@"use client";import { useEngineMode, useHydrated, useStatus } from "@/lib/api";+import { useMemo } from "react";import { tryFreeFor, type PoolRules } from "@/lib/pool-rules";+import { hereOf, type Here } from "@/lib/runnable-here";/*** What this studio's GPUs keep off for this viewer (hosted runs on, no GPU of its own): pickers show it with its@@ -19,3 +21,14 @@ export function useTryFree(): ReturnType<typeof tryFreeFor> {const mode = useEngineMode();return hydrated ? tryFreeFor(v, mode) : null;}++/**+ * Where this viewer's open runs go to this install's GPUs, with what they run now (src/lib/runnable-here.ts hereOf): the+ * pickers order, tag and default by it. The owner's status has no viewer, and carries `pool` only while his ComfyUI runs+ * on the workers. Null until the page has hydrated, and where nothing here has a say.+ */+export function useHere(): Here | null {+ const hydrated = useHydrated();+ const s = useStatus().data;+ return useMemo(() => (hydrated ? hereOf(s, !!s && !s.viewer) : null), [hydrated, s]);+}diff --git a/src/lib/api.ts b/src/lib/api.tsindex b64056eb..faf558b0 100644--- a/src/lib/api.ts+++ b/src/lib/api.ts@@ -1020,6 +1020,11 @@ export interface StatusInfo {* `viewer` (that is a visitor's view of the studio).*/ownerGpu?: OwnerGpuView;+ /**+ * The owner's ComfyUI runs on the workers: the open models none of them can run now (`own`), so his pickers order, tag+ * and default as his runs go (src/lib/runnable-here.ts). Never with `viewer`.+ */+ pool?: PoolRules;}/** The viewer's own GPU for the status strip and the header pill: an account's, or the owner's computer. */diff --git a/src/lib/composer.ts b/src/lib/composer.tsindex 00c78731..27d09d04 100644--- a/src/lib/composer.ts+++ b/src/lib/composer.ts@@ -1205,7 +1205,7 @@ export function studioBest(models: ModelDef[], engine: Engine, defaultId: string}export interface ModelGroup {- id: "boxes" | "recent" | "starred" | "best" | "all" | "results" | "paid";+ id: "boxes" | "recent" | "starred" | "best" | "all" | "results" | "paid" | "more";label: string;models: ModelDef[];}@@ -1231,6 +1231,10 @@ export function matchScore(m: Pick<ModelDef, "name" | "vendor" | "tagline" | "fa* models" under them, "All models" when it is the only one). `count` is still every model of* the engine. With a query: one list across every allowed engine, best* matches first.+ *+ * `runs` (src/lib/runnable-here.ts runsHere): the models that run on this install's GPUs now come first everywhere: the+ * sections above hold only those, the rest of them follow as "Ready to run", and the others go last as "More models",+ * each with what runs it. A search lists them first among equal matches.*/export function groupModels(input: {models: ModelDef[];@@ -1245,21 +1249,27 @@ export function groupModels(input: {boxes?: boolean;/** A short list in its own order (an app's models): one group. */flat?: boolean;+ /** Does it run here now (runnable-here.ts)? Absent: every model does. */+ runs?: (m: ModelDef) => boolean;}): { groups: ModelGroup[]; count: number } {- const { models, engine, engines, query, recent, starred, best, boxes } = input;+ const { models, engine, engines, query, recent, starred, best, boxes, runs } = input;+ const later = (m: ModelDef) => (runs && !runs(m) ? 1 : 0);const q = query.trim();if (q) {const hits = models.filter((m) => engines.includes(m.engine)).map((m, i) => ({ m, s: matchScore(m, q), i })).filter((x) => x.s >= 0)- .sort((a, b) => a.s - b.s || (boxes ? Number(!readsBoxes(a.m)) - Number(!readsBoxes(b.m)) : 0) || Number(a.m.engine !== engine) - Number(b.m.engine !== engine) || a.i - b.i)+ .sort((a, b) => a.s - b.s || later(a.m) - later(b.m) || (boxes ? Number(!readsBoxes(a.m)) - Number(!readsBoxes(b.m)) : 0) || Number(a.m.engine !== engine) - Number(b.m.engine !== engine) || a.i - b.i).map((x) => x.m);return { groups: hits.length ? [{ id: "results", label: "Results", models: hits }] : [], count: hits.length };}const pool = models.filter((m) => m.engine === engine);- if (input.flat) return { groups: pool.length ? [{ id: "all", label: "Models", models: pool }] : [], count: pool.length };- const byId = new Map(pool.map((m) => [m.id, m]));+ const more = runs ? pool.filter((m) => !runs(m)) : [];+ const moreGroup: ModelGroup[] = more.length ? [{ id: "more", label: "More models", models: more }] : [];+ const now = more.length ? pool.filter((m) => !more.includes(m)) : pool;+ if (input.flat) return { groups: [...(now.length ? [{ id: "all" as const, label: "Models", models: now }] : []), ...moreGroup], count: pool.length };+ const byId = new Map(now.map((m) => [m.id, m]));const used = new Set<string>();const take = (ids: string[], max: number) => {const out: ModelDef[] = [];@@ -1273,14 +1283,15 @@ export function groupModels(input: {};const top = ([- ...(boxes ? [{ id: "boxes" as const, label: "Reads your boxes", models: take(pool.filter((m) => readsBoxes(m)).map((m) => m.id), 50) }] : []),+ ...(boxes ? [{ id: "boxes" as const, label: "Reads your boxes", models: take(now.filter((m) => readsBoxes(m)).map((m) => m.id), 50) }] : []),{ id: "recent", label: "Recent", models: take(recent, 3) },{ id: "starred", label: "Starred", models: take(starred, 50) },{ id: "best", label: "Best for this studio", models: take(best, 4) },] satisfies ModelGroup[]).filter((g) => g.models.length);- const rest = pool.filter((m) => !used.has(m.id));- const groups: ModelGroup[] = [...top, ...(rest.length ? [{ id: "all" as const, label: top.length ? "More models" : "All models", models: rest }] : [])];+ const rest = now.filter((m) => !used.has(m.id));+ const restLabel = more.length ? "Ready to run" : top.length ? "More models" : "All models";+ const groups: ModelGroup[] = [...top, ...(rest.length ? [{ id: "all" as const, label: restLabel, models: rest }] : []), ...moreGroup];return { groups, count: pool.length };}diff --git a/src/lib/pool-rules.ts b/src/lib/pool-rules.tsindex 897efdc2..95b2d1fe 100644--- a/src/lib/pool-rules.ts+++ b/src/lib/pool-rules.ts@@ -162,7 +162,14 @@ export function tryFreeFor(* hosted runs are off, or with nothing kept off.*/export function pickerRules(v: { hosted?: boolean; prefer?: "pool"; runOn?: string; gpu: { connected: boolean }; pool?: PoolRules } | undefined): PoolRules | undefined {- if (!v?.hosted || !v.pool) return undefined;- const here = !v.gpu.connected || v.runOn === "site" || v.runOn === "key" || (!v.runOn && v.prefer === "pool");- return here ? v.pool : undefined;+ return v?.pool && runsGoHere(v) ? v.pool : undefined;+}++/**+ * Do a visitor's open runs go to this studio's GPUs (hosted runs on, and no GPU of its own, or its pick or the install's+ * puts them there first)? The place src/lib/runnable-here.ts orders and tags the pickers for.+ */+export function runsGoHere(v: { hosted?: boolean; prefer?: "pool"; runOn?: string; gpu: { connected: boolean } }): boolean {+ if (!v.hosted) return false;+ return !v.gpu.connected || v.runOn === "site" || v.runOn === "key" || (!v.runOn && v.prefer === "pool");}diff --git a/src/lib/runnable-here.ts b/src/lib/runnable-here.tsnew file mode 100644index 00000000..58ea0df3--- /dev/null+++ b/src/lib/runnable-here.ts@@ -0,0 +1,159 @@+import type { GenParams, ModelDef, Operation } from "./catalog/types";+import { keyName, type OwnSetup } from "./own-setup";+import { modelOwnSetup, runsGoHere, type PoolRules } from "./pool-rules";++/**+ * "Runs here": the models a viewer's open runs on this install's GPUs (Fuobe Cloud) take right now, from the same+ * sources the run's own check reads (src/server/hosted-run.ts poolGate): the static own-setup items (own-setup.ts), the+ * policy's model lists and kinds, and the open models no worker can run now (src/server/pool-own-setup.ts+ * poolOwnModels: poolTakes, poolCardRefuses). GET /api/status sends those rules (visitors: `viewer.pool`; the owner, while+ * his ComfyUI runs on the workers: `pool`), so a picker's order, its default, its tags and Run all agree with the run.+ *+ * Pure (client and server). One shared check for every surface that asks "does this run here?" (pickers, the composer's+ * default and free alternative, Assist's plans): import it from here rather than writing a second one.+ */++/** Where a viewer's open runs go to this install's GPUs, with the rules that say what they take now. */+export interface Here {+ rules: PoolRules | undefined;+ /** The pool's owner: his runs go to the workers; what they lack now is a worker's files, never his own GPU or key. */+ owner: boolean;+}++/** The parts of GET /api/status this reads. */+export interface HereStatus {+ viewer?: { hosted?: boolean; prefer?: "pool"; runOn?: string; gpu: { connected: boolean }; pool?: PoolRules };+ /** The owner's view of the workers (sent only while his ComfyUI runs on them): the open models they can't run now. */+ pool?: PoolRules;+}++/**+ * The place a viewer's open runs go to this install's GPUs, or null when they don't (hosted runs off, a visitor whose+ * runs go to its own GPU, the owner's ComfyUI on his server or computer): then nothing is reordered or tagged here.+ */+export function hereOf(s: HereStatus | undefined, owner: boolean): Here | null {+ if (!s) return null;+ if (owner) return s.pool ? { rules: s.pool, owner: true } : null;+ const v = s.viewer;+ return v && runsGoHere(v) ? { rules: v.pool, owner: false } : null;+}++/**+ * What a model needs instead of this install's GPUs (a visitor: its own GPU or key; the owner: a worker with its files),+ * or null when it runs here now. Cloud models are the keys' business (their own rows say), never the pool's.+ */+export function hereSetup(here: Here | null | undefined, m: Pick<ModelDef, "id" | "kind" | "engine">): OwnSetup | null {+ if (!here || m.engine !== "open") return null;+ if (here.owner) return here.rules?.own?.[m.id] ?? null;+ return modelOwnSetup(here.rules, m);+}++/** Does this install's GPUs run this model for the viewer now (no place: yes, nothing here has a say)? */+export const runsHere = (here: Here | null | undefined, m: Pick<ModelDef, "id" | "kind" | "engine">): boolean => !hereSetup(here, m);++/**+ * The short positive tag on a "More models" row: "With your GPU · 24 GB", "With your fal.ai key", "With your GPU or+ * fal.ai key"; the owner's "Add to a worker".+ */+export function hereTag(o: OwnSetup, owner = false): string {+ if (owner) return "Add to a worker";+ if (o.need === "key") return `With your ${keyName(o.provider)} key`;+ if (o.orKey) return `With your GPU or ${keyName(o.orKey)} key`;+ return `With your GPU${o.vramGb ? ` · ${o.vramGb} GB` : ""}`;+}++/** The link under the free alternative, to the model's own setup: "Use LTX-2.5 with your own GPU" (the owner: a worker). */+export function hereOwnLink(name: string, o: OwnSetup, owner = false): string {+ if (owner) return `Add ${name} to a worker`;+ if (o.need === "key") return `Use ${name} with your ${keyName(o.provider)} key`;+ if (o.orKey) return `Use ${name} with your own GPU or key`;+ return `Use ${name} with your own GPU`;+}++/** The primary button's words for the free alternative: "Run free with LTX-2.3" (the owner's runs are his: "Run with"). */+export const hereRunLabel = (alt: Pick<ModelDef, "name">, owner = false): string => `${owner ? "Run with" : "Run free with"} ${alt.name}`;++/** The one-line reason beside it: "LTX-2.5 isn't on Fuobe Cloud yet". */+export const hereReason = (m: Pick<ModelDef, "name">, place: string): string => `${m.name} isn't on ${place} yet`;++/** What the draft asks for that a stand-in should keep: its operation, settings and how many pictures it sends. */+export interface HereAsk {+ op?: Operation;+ params?: Partial<GenParams>;+ /** Reference pictures sent (a start frame counts). */+ images?: number;+ /** An end frame is set. */+ endFrame?: boolean;+}++/**+ * How many of the draft's key settings a model can't keep (lower is closer): its aspect, length, sound, references and end+ * frame. A size it doesn't make is never a reason to pass over a better model (carryParams picks its own).+ */+function misses(m: ModelDef, ask: HereAsk): number {+ const o = m.options;+ const p = ask.params ?? {};+ let n = 0;+ if (p.aspectRatio && o.aspectRatios?.length && !o.aspectRatios.includes(p.aspectRatio)) n++;+ if (p.duration && o.durations?.length && !o.durations.includes(p.duration)) n++;+ if (p.generateAudio && !o.audio) n++;+ if ((ask.images ?? 0) > (o.maxImages ?? 1)) n++;+ if (ask.endFrame && !o.endFrame) n++;+ return n;+}++/** The catalog's own quality order: its top picks, then what's new, then the rest (in catalog order after). */+const rank = (m: ModelDef): number => (m.badges?.includes("top") ? 0 : m.badges?.includes("pro") ? 1 : m.badges?.includes("new") ? 2 : 3);++/**+ * The closest model that runs here now for one that doesn't (the free alternative): the same kind and operation (the+ * draft's, else the model's first), open, then the one that keeps most of the draft's settings (aspect, length,+ * sound, references, end frame), the catalog's top picks first (then its newest), its own family, and the+ * catalog's order.+ * Undefined when none runs here.+ */+export function closestHere(from: ModelDef, models: readonly ModelDef[], here: Here | null | undefined, ask: HereAsk = {}): ModelDef | undefined {+ const op = ask.op && from.routes.some((r) => r.op === ask.op) ? ask.op : from.routes[0]?.op;+ const fits = models+ .map((m, i) => ({ m, i }))+ .filter(({ m }) => m.id !== from.id && !m.hidden && m.engine === "open" && m.kind === from.kind && (!op || m.routes.some((r) => r.op === op)) && runsHere(here, m));+ fits.sort((a, b) => misses(a.m, ask) - misses(b.m, ask) || rank(a.m) - rank(b.m) || Number(b.m.family === from.family) - Number(a.m.family === from.family) || a.i - b.i);+ return fits[0]?.m;+}++/**+ * The draft's settings as the stand-in takes them: every setting it keeps, and its own default (else its nearest+ * length) for one it can't, so the prompt, inputs and choices carry over to the one press.+ */+export function carryParams<P extends Partial<GenParams>>(params: P, to: ModelDef): P {+ const o = to.options;+ const out: Partial<GenParams> = { ...params };+ const d = to.defaults ?? {};+ if (out.aspectRatio && o.aspectRatios?.length && !o.aspectRatios.includes(out.aspectRatio)) out.aspectRatio = d.aspectRatio ?? o.aspectRatios[0];+ if (out.resolution && o.resolutions?.length && !o.resolutions.includes(out.resolution)) out.resolution = d.resolution ?? o.resolutions[0];+ if (out.duration && o.durations?.length && !o.durations.includes(out.duration)) {+ const want = out.duration;+ out.duration = o.durations.reduce((a, b) => (Math.abs(b - want) < Math.abs(a - want) ? b : a));+ }+ if (out.generateAudio && !o.audio) out.generateAudio = false;+ if (out.numOutputs && o.maxOutputs && out.numOutputs > o.maxOutputs) out.numOutputs = o.maxOutputs;+ return out as P;+}++/** A picker's two parts: what runs here now (first), and "More models" (each with what runs it). */+export function splitHere<M extends Pick<ModelDef, "id" | "kind" | "engine">>(models: readonly M[], here: Here | null | undefined): { now: M[]; more: M[] } {+ const now: M[] = [];+ const more: M[] = [];+ for (const m of models) (runsHere(here, m) ? now : more).push(m);+ return { now, more };+}++/**+ * Where a studio's untouched default moves when it doesn't run here now: the studio's other default (`defaultId`) when+ * that runs, else the closest model that does (closestHere). Undefined when it runs here, or nothing does.+ */+export function hereDefault(current: ModelDef, defaultId: string | undefined, models: readonly ModelDef[], here: Here | null | undefined, ask: HereAsk = {}): ModelDef | undefined {+ if (runsHere(here, current)) return undefined;+ const d = models.find((m) => m.id === defaultId);+ return d && d.id !== current.id && runsHere(here, d) ? d : closestHere(current, models, here, ask);+}diff --git a/tests/runnable-here.test.ts b/tests/runnable-here.test.tsnew file mode 100644index 00000000..8a68b037--- /dev/null+++ b/tests/runnable-here.test.ts@@ -0,0 +1,255 @@+import http from "node:http";+import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";+import { tempDir } from "./helpers/temp-dir";+import { FAKE_POLICY, listenOnFreePort, startFakeBilling, type FakeBilling } from "./helpers/fake-billing";+import { startFakeComfy, type FakeComfy } from "./helpers/fake-comfy-runner";+import type { ModelDef } from "@/lib/catalog/types";++/*+ * "Runs here" (src/lib/runnable-here.ts): pickers list what runs on this install's GPUs now first, the studio's default+ * is always one of them, a model that doesn't gets a one-press free alternative, and all of it agrees with the run's own+ * check (hosted-run.ts poolGate), as the server sends it in GET /api/status.+ */+vi.mock("next/server", async (importOriginal) => ({ ...(await importOriginal<typeof import("next/server")>()), connection: async () => {} }));+const dir = tempDir("fuobe-runnable-here-");+process.env.FUOBE_DATA_DIR = dir;+process.env.FUOBE_PUBLIC_SIGNUP = "1";+delete process.env.FUOBE_PASSWORD;+delete process.env.FUOBE_HOSTED_RUNS;+delete process.env.FUOBE_MODERATION_URL;+globalThis.__fuobeTestDiskFree = 1e13;++const probe = http.createServer();+const comfyPort = await listenOnFreePort(probe);+await new Promise<void>((r) => probe.close(() => r()));+const comfy: FakeComfy = await startFakeComfy({ output: "image", delayMs: 0 }, comfyPort);+process.env.COMFYUI_URL = comfy.url;++const { MODELS } = await import("@/lib/catalog/models");+const { groupModels } = await import("@/lib/composer");+const { carryParams, closestHere, hereDefault, hereOf, hereOwnLink, hereReason, hereRunLabel, hereSetup, hereTag, runsHere, splitHere } = await import("@/lib/runnable-here");+const { ownSetupOnly } = await import("@/lib/own-setup");++const byId = (id: string) => MODELS.find((m) => m.id === id)!;+const LTX25 = byId("oss-ltx25");+const H3 = byId("oss-minimax-h3");+const visitorHere = (own: Record<string, { need: "gpu"; vramGb?: number }>) => ({ rules: { own }, owner: false });++describe("where a viewer's open runs go here", () => {+ const gpu = { connected: false };+ it("a visitor whose runs go to this install's GPUs; never one whose runs go to its own GPU, nor with hosted runs off", () => {+ expect(hereOf({ viewer: { hosted: true, gpu, pool: { deny: ["x"] } } }, false)).toEqual({ rules: { deny: ["x"] }, owner: false });+ expect(hereOf({ viewer: { hosted: true, gpu } }, false)).toEqual({ rules: undefined, owner: false });+ expect(hereOf({ viewer: { hosted: true, runOn: "gpu", gpu: { connected: true } } }, false)).toBeNull();+ expect(hereOf({ viewer: { gpu } }, false)).toBeNull();+ expect(hereOf(undefined, false)).toBeNull();+ });+ it("the owner, while his ComfyUI runs on the workers (his status carries their `pool`)", () => {+ expect(hereOf({ pool: { own: { "oss-ltx25": { need: "gpu" } } } }, true)).toEqual({ rules: { own: { "oss-ltx25": { need: "gpu" } } }, owner: true });+ expect(hereOf({}, true)).toBeNull();+ });+});++describe("what runs here now", () => {+ it("a model no worker holds (the rules' `own`) runs on the visitor's own setup; the static items too; cloud models are the keys'", () => {+ const here = visitorHere({ "oss-ltx25": { need: "gpu", vramGb: 24 } });+ expect(hereSetup(here, LTX25)).toEqual({ need: "gpu", vramGb: 24 });+ expect(runsHere(here, LTX25)).toBe(false);+ expect(runsHere(here, H3)).toBe(true);+ expect(hereSetup(here, byId("oss-h3-regenerate"))).toEqual(ownSetupOnly("oss-h3-regenerate"));+ const cloud = MODELS.find((m) => m.engine === "cloud" && !m.hidden)!;+ expect(runsHere(here, cloud)).toBe(true);+ // No place: nothing here has a say.+ expect(runsHere(null, LTX25)).toBe(true);+ });+ it("the owner: only what the workers lack, never the visitors' own-setup items", () => {+ const owner = { rules: { own: { "oss-ltx25": { need: "gpu" as const } } }, owner: true };+ expect(runsHere(owner, LTX25)).toBe(false);+ expect(runsHere(owner, byId("oss-h3-regenerate"))).toBe(true);+ });+ it("splits a list into what runs now (first) and the rest", () => {+ const here = visitorHere({ "oss-ltx25": { need: "gpu" } });+ const { now, more } = splitHere([LTX25, H3], here);+ expect(now.map((m) => m.id)).toEqual(["oss-minimax-h3"]);+ expect(more.map((m) => m.id)).toEqual(["oss-ltx25"]);+ });+});++describe("the words", () => {+ const phrases = [+ hereTag({ need: "gpu", vramGb: 24 }),+ hereTag({ need: "key", provider: "fal" }),+ hereTag({ need: "gpu", orKey: "fal" }),+ hereTag({ need: "gpu" }, true),+ hereOwnLink("LTX-2.5", { need: "gpu", vramGb: 24 }),+ hereOwnLink("LTX-2.5", { need: "key", provider: "fal" }),+ hereRunLabel(H3),+ hereReason(LTX25, "Fuobe Cloud"),+ ];+ it("short and positive: what runs it, never a refusal", () => {+ expect(phrases).toEqual([+ "With your GPU · 24 GB",+ "With your fal.ai key",+ "With your GPU or fal.ai key",+ "Add to a worker",+ "Use LTX-2.5 with your own GPU",+ "Use LTX-2.5 with your fal.ai key",+ "Run free with MiniMax H3",+ "LTX-2.5 isn't on Fuobe Cloud yet",+ ]);+ for (const p of phrases) expect(p).not.toMatch(/can['’]t|cannot|not available|unavailable|unsupported/i);+ expect(hereRunLabel(H3, true)).toBe("Run with MiniMax H3");+ });+});++describe("the free alternative", () => {+ it("is the closest model that runs here: same kind and operation, open, premium first", () => {+ const here = visitorHere({ "oss-ltx25": { need: "gpu", vramGb: 24 } });+ const alt = closestHere(LTX25, MODELS, here, { op: "t2v", params: { aspectRatio: "16:9", duration: 5 } })!;+ expect(alt.id).toBe("oss-minimax-h3");+ expect(alt.kind).toBe("video");+ expect(alt.engine).toBe("open");+ expect(alt.routes.some((r) => r.op === "t2v")).toBe(true);+ });+ it("never one that doesn't run here, and none when nothing does", () => {+ const here = visitorHere({ "oss-ltx25": { need: "gpu" }, "oss-minimax-h3": { need: "gpu" } });+ const alt = closestHere(LTX25, MODELS, here, { op: "t2v" })!;+ expect(alt.id).not.toBe("oss-minimax-h3");+ expect(runsHere(here, alt)).toBe(true);+ const own = Object.fromEntries(MODELS.filter((m) => m.engine === "open").map((m) => [m.id, { need: "gpu" as const }]));+ expect(closestHere(LTX25, MODELS, visitorHere(own), { op: "t2v" })).toBeUndefined();+ });+ it("keeps the draft's settings where it can: a 4:3 clip goes to a model that makes 4:3", () => {+ const here = visitorHere({ "oss-ltx25": { need: "gpu" }, "oss-minimax-h3": { need: "gpu" } });+ const alt = closestHere(LTX25, MODELS, here, { op: "t2v", params: { aspectRatio: "4:3" } })!;+ expect(alt.options.aspectRatios).toContain("4:3");+ });+ it("follows the draft's operation: a start frame asks for one that animates a picture", () => {+ const here = visitorHere({ "oss-ltx25": { need: "gpu" } });+ const alt = closestHere(LTX25, MODELS, here, { op: "i2v", images: 1 })!;+ expect(alt.routes.some((r) => r.op === "i2v")).toBe(true);+ });+ it("an image model's stand-in is an image model", () => {+ const ideogram = byId("oss-ideogram-4");+ const alt = closestHere(ideogram, MODELS, visitorHere({ "oss-ideogram-4": { need: "gpu" } }), { op: "t2i" })!;+ expect(alt.kind).toBe("image");+ expect(alt.routes.some((r) => r.op === "t2i")).toBe(true);+ expect(alt.badges).toContain("top");+ });+ it("carries the settings it takes, and fits the ones it doesn't", () => {+ const to = { ...H3, options: { ...H3.options, aspectRatios: ["16:9", "9:16"], durations: [5, 10] }, defaults: { aspectRatio: "16:9" } } as ModelDef;+ expect(carryParams({ aspectRatio: "9:16", duration: 8, seed: 7 }, to)).toEqual({ aspectRatio: "9:16", duration: 10, seed: 7 });+ expect(carryParams({ aspectRatio: "21:9", duration: 6 }, to)).toEqual({ aspectRatio: "16:9", duration: 5 });+ });+});++describe("the studio's default", () => {+ it("is always one that runs here: an untouched default that doesn't moves, to the other default first", () => {+ const here = visitorHere({ "oss-ltx25": { need: "gpu" } });+ expect(hereDefault(H3, "oss-minimax-h3", MODELS, here)).toBeUndefined();+ expect(hereDefault(LTX25, "oss-minimax-h3", MODELS, here)?.id).toBe("oss-minimax-h3");+ const moved = hereDefault(LTX25, "oss-ltx25", MODELS, here, { op: "t2v" })!;+ expect(runsHere(here, moved)).toBe(true);+ expect(moved.kind).toBe("video");+ });+});++describe("the picker's order", () => {+ const video = MODELS.filter((m) => m.kind === "video" && m.engine === "open" && !m.hidden);+ const here = visitorHere({ "oss-ltx25": { need: "gpu", vramGb: 24 } });+ const runs = (m: ModelDef) => runsHere(here, m);+ it("what runs here first, in every section; the rest last as \"More models\"", () => {+ const { groups, count } = groupModels({ models: video, engine: "open", engines: ["open"], query: "", recent: ["oss-ltx25"], starred: ["oss-ltx25"], best: ["oss-ltx25", "oss-minimax-h3"], runs });+ expect(count).toBe(video.length);+ const last = groups.at(-1)!;+ expect(last).toMatchObject({ id: "more", label: "More models" });+ expect(last.models.map((m) => m.id)).toEqual(["oss-ltx25"]);+ for (const g of groups.slice(0, -1)) expect(g.models.every(runs), g.id).toBe(true);+ expect(groups.find((g) => g.id === "best")!.models[0].id).toBe("oss-minimax-h3");+ expect(groups.find((g) => g.id === "all")!.label).toBe("Ready to run");+ // Every model shows once.+ expect(groups.flatMap((g) => g.models).length).toBe(video.length);+ });+ it("an app's short list keeps its order, what runs first", () => {+ const { groups } = groupModels({ models: [LTX25, H3], engine: "open", engines: ["open"], query: "", recent: [], starred: [], best: [], flat: true, runs });+ expect(groups.map((g) => [g.id, g.models.map((m) => m.id)])).toEqual([+ ["all", ["oss-minimax-h3"]],+ ["more", ["oss-ltx25"]],+ ]);+ });+ it("a search lists what runs here first among equal matches", () => {+ const { groups } = groupModels({ models: video, engine: "open", engines: ["open"], query: "ltx", recent: [], starred: [], best: [], runs });+ const ids = groups[0].models.map((m) => m.id);+ expect(ids.indexOf("oss-ltx2")).toBeLessThan(ids.indexOf("oss-ltx25"));+ });+ it("with no place, as before", () => {+ const { groups } = groupModels({ models: video, engine: "open", engines: ["open"], query: "", recent: [], starred: [], best: [] });+ expect(groups.map((g) => g.id)).toEqual(["all"]);+ });+});++describe("the label and the run agree", () => {+ let fake: FakeBilling;+ let account: { id: string; email: string };+ let auth: typeof import("@/server/auth");+ let billing: typeof import("@/server/billing");+ beforeAll(async () => {+ auth = await import("@/server/auth");+ billing = await import("@/server/billing");+ fake = await startFakeBilling();+ auth.setPassword("install password");+ account = auth.accountById(auth.createAccount("[email protected]", "long enough").id)!;+ });+ afterAll(async () => {+ globalThis.__fuobeTestDiskFree = undefined;+ for (const k of ["FUOBE_HOSTED_RUNS", "FUOBE_BILLING_URL", "FUOBE_BILLING_TOKEN"]) delete process.env[k];+ await fake.close();+ await comfy.close();+ });+ beforeEach(() => {+ billing.resetBillingCache();+ process.env.FUOBE_HOSTED_RUNS = "1";+ process.env.FUOBE_BILLING_URL = fake.url;+ process.env.FUOBE_BILLING_TOKEN = "test-billing-token";+ fake.policy = { ...FAKE_POLICY, pool: { deny: ["oss-ltx25"] } };+ });++ it("a visitor: what the status says runs here is what the price check before Run takes, and the rest it refuses with the same setup", async () => {+ const { visitorStatus } = await import("@/server/account-gpu");+ const { poolQuote } = await import("@/server/hosted-run");+ const acct = auth.accountById(account.id)!;+ const status = await visitorStatus(acct);+ const here = hereOf(status, false);+ expect(here).not.toBeNull();+ const ids = ["oss-ltx25", "oss-minimax-h3", "oss-wan22-5b", "oss-z-image-turbo", "oss-flux1-schnell", "oss-h3-regenerate"];+ for (const id of ids) {+ const m = byId(id);+ const op = m.routes[0].op;+ const req = { feature: m.kind === "image" ? "image" : "video", modelId: id, engine: "open", op, prompt: "A model walks a runway", params: {} } as Parameters<typeof poolQuote>[1];+ const q = await poolQuote(acct, req, undefined);+ const setup = (q?.quote as { ownSetup?: unknown } | undefined)?.ownSetup;+ // Runs here: priced. Doesn't: refused with an own setup of the same kind (the run names the memory where its index does).+ if (runsHere(here, m)) expect(setup, id).toBeUndefined();+ else expect((setup as { need?: string } | undefined)?.need, id).toBe(hereSetup(here, m)!.need);+ }+ });++ it("the owner's status carries the workers' set only while his ComfyUI runs on them", async () => {+ const { setSetting } = await import("@/server/settings");+ const { poolOwnModels } = await import("@/server/pool-own-setup");+ const { GET } = await import("@/app/api/status/route");+ setSetting("comfyWhere", "workers");+ try {+ const s = await (await GET()).json();+ expect(s.viewer).toBeUndefined();+ expect(s.pool).toEqual({ own: poolOwnModels() });+ const here = hereOf(s, true)!;+ for (const [id, o] of Object.entries(s.pool.own)) expect(hereSetup(here, byId(id) ?? { id, kind: "image", engine: "open" })).toEqual(o);+ } finally {+ setSetting("comfyWhere", "server");+ }+ const s = await (await GET()).json();+ expect(s.pool).toBeUndefined();+ expect(hereOf(s, true)).toBeNull();+ });+});