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
Engine switch: with hosted runs on, the owner's Open source runs free on the install's GPUs, said by name and picked first
Adarshd944a98c22ac
diff --git a/src/app/api/status/route.ts b/src/app/api/status/route.tsindex 9cc9338d..fc3cc2d5 100644--- a/src/app/api/status/route.ts+++ b/src/app/api/status/route.ts@@ -9,6 +9,7 @@ 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 { hostedRunsOn } from "@/server/hosted-switch";import { placeName } from "@/server/place-name";import { helperKnown, helperLive } from "@/server/text-helper";@@ -43,6 +44,9 @@ export async function GET(request?: Request) {// 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;+ // Hosted runs on, and the owner's open models run on those same workers: the name visitors read for them, so the+ // owner's engine switch says where Open source runs (free) and starts there.+ const ownerPlace = ownerPool && hostedRunsOn() ? placeName() : undefined;return Response.json({providers,demoMode: getSetting("demoMode"),@@ -51,6 +55,7 @@ export async function GET(request?: Request) {onboarded,...(ownerGpu && { ownerGpu }),...(ownerPool && { pool: ownerPool }),+ ...(ownerPlace && { ownerPlace }),// 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 1af0049e..c451b085 100644--- a/src/components/studio/composer.tsx+++ b/src/components/studio/composer.tsx@@ -1323,12 +1323,14 @@ export function Composer({ docked }: { docked: boolean }) {const demo = !!(model && placeholdersOn(status?.demoMode));// On the open engine every run is free on the GPU: said even before the run can be planned (no voice sample, no clip yet).// Said with "your GPU" only off a hosted studio: there the run may use the studio's GPUs, and the chip or hint says where.- const gpuRun = saysYourGpu(engine, hostedHere);+ // The owner while hosted runs are on: its open runs go to the same workers as everyone's, said with their name.+ const ownerSite = !status?.viewer && status?.ownerPlace && model?.engine === "open" ? placeOf(status.ownerPlace).label : undefined;+ const gpuRun = saysYourGpu(engine, hostedHere || !!ownerSite);// A cloud model that runs on a visitor's own key only (Mureka Extend on Audio → Extend & remix): never "Free · your GPU",// its key in the label's words.const keyOnly = setupViewer && !demo ? keyOnlySetup(model, engine) : null;const freeHere = engine === "open" && model && !keyOnly ? 0 : null;- const ownCostText = keyOnly && cost == null ? ownSetupLabel(keyOnly) : costLabel({ demo, cost: cost ?? freeHere, unknown: loraPriceUnknown, gpu: gpuRun }, formatCost);+ const ownCostText = keyOnly && cost == null ? ownSetupLabel(keyOnly) : costLabel({ demo, cost: cost ?? freeHere, unknown: loraPriceUnknown, gpu: gpuRun, place: ownerSite }, formatCost);// An account's paid run is billed to its own provider account (Your keys), or still needs that key.const payer = paidThrough(model, status);// Its provider account's balance ran out on a run: said before the next one, with Add credit.diff --git a/src/components/studio/engine-switch.tsx b/src/components/studio/engine-switch.tsxindex 34dc8fc3..391efead 100644--- a/src/components/studio/engine-switch.tsx+++ b/src/components/studio/engine-switch.tsx@@ -69,10 +69,13 @@ export function EngineSwitch({const account = accountEngine(hydrated ? status : undefined);const locked = account && "locked" in account ? account.locked : null;// Hosted runs: open models run free on this studio's GPUs, said with their place name (a guest's tip too).- const place = hydrated && status?.viewer?.hosted ? placeOf(status.viewer.placeName) : null;- // A guest or an account while hosted runs are on: both sides, always, with what each costs (the owner and a- // self-hosted install keep the switch below exactly as it was).- const visitor = hydrated && !owner && !selfHostedOnly ? visitorEngine(status) : null;+ // The owner, while hosted runs are on and its open models run on the same workers: the same place, free.+ const ownerPlace = owner && !selfHostedOnly && status?.ownerPlace ? placeOf(status.ownerPlace) : null;+ const place = hydrated && status?.viewer?.hosted ? placeOf(status.viewer.placeName) : ownerPlace;+ // A guest or an account while hosted runs are on: both sides, always, with what each costs. The owner gets the same+ // two sides there (its Cloud runs on the install's own keys); a self-hosted install keeps the switch below as it was.+ const ownerSides: VisitorEngine | null = ownerPlace && mode === "both" ? { place: ownerPlace, guest: false, keyless: false, keys: [] } : null;+ const visitor = (hydrated && !owner && !selfHostedOnly ? visitorEngine(status) : null) ?? ownerSides;if (visitor)return (<VisitorSwitch@@ -92,7 +95,8 @@ export function EngineSwitch({// One engine and nothing to change: only the owner (Settings) or an account that can add a key gets a badge.if (!hydrated || !viewer || (!owner && !(locked?.addKey && !selfHostedOnly))) return null;const o = OPTIONS.find((x) => x.value === (locked ? "open" : mode))!;- const text = locked?.text ?? (mode === "open" ? "Open source only" : "Cloud only");+ // Open source only, on the hosted workers: where it runs, and that it is free there.+ const text = locked?.text ?? (mode === "open" ? (ownerPlace ? `Open source · ${engineCaption.open(ownerPlace)}` : "Open source only") : "Cloud only");const cls = cn("inline-flex shrink-0 items-center gap-1.5 rounded-full bg-muted px-3 text-[13px] font-medium whitespace-nowrap text-muted-foreground transition-colors",size === "sm" ? "h-8" : "h-8 sm:h-9",diff --git a/src/lib/api.ts b/src/lib/api.tsindex 8dc9b0ce..fca2f442 100644--- a/src/lib/api.ts+++ b/src/lib/api.ts@@ -1077,6 +1077,11 @@ export interface StatusInfo {* and default as his runs go (src/lib/runnable-here.ts). Never with `viewer`.*/pool?: PoolRules;+ /**+ * Hosted runs are on and the owner's open models run on the same workers: their name (as visitors read it), so the+ * owner's engine switch says Open source runs free there, and starts on it. Never with `viewer`.+ */+ ownerPlace?: string;}/** The viewer's own GPU for the status strip and the header pill: an account's, or the owner's computer. */@@ -1328,7 +1333,7 @@ function useEngineSlot(): EngineSlot {const runOn = v?.runOn;const email = me?.account?.email;const cached = useSyncExternalStore(noopSubscribe, readCachedSlot, () => null);- const facts: SlotFacts = { known, viewer: kind ? { kind, hosted, runOn } : undefined, email, cached };+ const facts: SlotFacts = { known, viewer: kind ? { kind, hosted, runOn } : undefined, email, cached, ownerPlace: !v && !!status.data?.ownerPlace };const slot = engineSlot(facts);const remember = slotToCache(facts, slot);useEffect(() => {diff --git a/src/lib/composer.ts b/src/lib/composer.tsindex bee82a4d..abae41a2 100644--- a/src/lib/composer.ts+++ b/src/lib/composer.ts@@ -1319,9 +1319,10 @@ export function toggleIn(list: string[], id: string): string[] {* The price beside Generate. `gpu`: it runs on the person's own GPU, said with "Free" so a free run never reads as* free of anything (the run still takes their GPU's time).*/-export function costLabel(s: { demo: boolean; cost: number | null; compact?: boolean; unknown?: boolean; gpu?: boolean }, format: (usd: number) => string): string {+export function costLabel(s: { demo: boolean; cost: number | null; compact?: boolean; unknown?: boolean; gpu?: boolean; place?: string }, format: (usd: number) => string): string {if (s.demo) return s.compact ? "Placeholder" : "Placeholder · free";- if (s.cost === 0) return s.gpu ? (s.compact ? "Free · GPU" : "Free · your GPU") : "Free";+ // `place`: a free run on the install's own GPUs, said with their name ("Free · Fuobe Cloud").+ if (s.cost === 0) return s.place && !s.compact ? `Free · ${s.place}` : s.gpu ? (s.compact ? "Free · GPU" : "Free · your GPU") : "Free";if (s.cost != null) return `≈ ${format(s.cost)}`;// A price the provider hasn't published (fal's MOSS-Image with LoRAs): said, never shown as free.return s.unknown ? "Price unknown" : "";diff --git a/src/lib/connections.ts b/src/lib/connections.tsindex a47e7c4d..5513c896 100644--- a/src/lib/connections.ts+++ b/src/lib/connections.ts@@ -171,6 +171,8 @@ export interface ConnectionState {demoMode?: string;/** The owner's ComfyUI runs on the owner's computer: what its Fuobe tab last said (GET /api/status). */ownerGpu?: OwnerGpuView;+ /** Hosted runs are on and the owner's open models run on the same workers: their name (GET /api/status). */+ ownerPlace?: string;}/** The owner's computer, as its Fuobe tab last said (the same view as an account's "this computer"). */@@ -248,7 +250,7 @@ export function startLine(s: ConnectionState, quote: StartQuote | undefined, engconst otherEngine = engine === "open" ? "cloud" : "open";const other = s.engineMode === "both" && hosted(quote[otherEngine]) ? otherEngine : undefined;const then = mode === "edit" ? " after you add the photo" : "";- if (engine === "open" && quote.open && hosted(quote.open)) return { text: `Start runs ${quote.open.name} on your GPU${then} · Free` };+ if (engine === "open" && quote.open && hosted(quote.open)) return { text: `Start runs ${quote.open.name} on ${s.ownerPlace ?? "your GPU"}${then} · Free` };if (engine === "cloud" && quote.cloud && hosted(quote.cloud)) return { text: `Start runs ${quote.cloud.name}${then} · ${quote.cloud.price}` };const q = quote[engine];const connected = connectedEngines(s)[engine];diff --git a/src/lib/engine-pref.ts b/src/lib/engine-pref.tsindex 34f46b54..5180bbbf 100644--- a/src/lib/engine-pref.ts+++ b/src/lib/engine-pref.ts@@ -18,6 +18,8 @@ export const ENGINE_SLOT_KEY = "fuobe.engineSlot";export const ACCOUNT_ENGINE_PREFIX = "fuobe.engine.a.";/** A guest's switch while hosted runs are on. */export const GUEST_ENGINE_KEY = "fuobe.engine.guest";+/** The owner's switch while hosted runs are on and the owner's open models run on the same workers (status `ownerPlace`). */+export const OWNER_HOSTED_ENGINE_KEY = "fuobe.engine.owner";export interface EngineSlot {/** The storage key, or null when there is none yet (an account whose email hasn't answered): the pick then lasts for the page. */@@ -51,15 +53,19 @@ export interface SlotFacts {email?: string | null;/** ENGINE_SLOT_KEY as stored. */cached?: string | null;+ /** The owner, while its open models run free on the install's workers (status `ownerPlace`). */+ ownerPlace?: boolean;}const isAccountKey = (k: string | null | undefined): k is string => !!k && k.startsWith(ACCOUNT_ENGINE_PREFIX) && k.length > ACCOUNT_ENGINE_PREFIX.length;-const isHostedKey = (k: string | null | undefined): k is string => k === GUEST_ENGINE_KEY || isAccountKey(k);+const isHostedKey = (k: string | null | undefined): k is string => k === GUEST_ENGINE_KEY || k === OWNER_HOSTED_ENGINE_KEY || isAccountKey(k);/** Where this viewer's switch is kept, and what it starts on. */export function engineSlot(f: SlotFacts): EngineSlot {if (!f.known) return isHostedKey(f.cached) ? { key: f.cached, start: "open" } : SHARED_SLOT;const v = f.viewer;+ // The owner, while open models run free on the workers: a switch of its own, starting on Open source.+ if (!v && f.ownerPlace) return { key: OWNER_HOSTED_ENGINE_KEY, start: "open" };if (!v?.hosted) return SHARED_SLOT;if (v.kind !== "account") return { key: GUEST_ENGINE_KEY, start: "open" };const start: Engine = v.runOn === "key" ? "cloud" : "open";@@ -68,7 +74,7 @@ export function engineSlot(f: SlotFacts): EngineSlot {}/** The slot to remember for the next page (while hosted runs are on), null to forget it, undefined before the status answers. */-export const slotToCache = (f: SlotFacts, slot: EngineSlot): string | null | undefined => (!f.known ? undefined : f.viewer?.hosted && isHostedKey(slot.key) ? slot.key : null);+export const slotToCache = (f: SlotFacts, slot: EngineSlot): string | null | undefined => (!f.known ? undefined : (f.viewer?.hosted || (!f.viewer && f.ownerPlace)) && isHostedKey(slot.key) ? slot.key : null);/*** What a saved key does to the switch the studios start on: Cloud (the person just asked for paid models), except whilediff --git a/tests/composer.test.ts b/tests/composer.test.tsindex beee672b..54e16dcf 100644--- a/tests/composer.test.ts+++ b/tests/composer.test.ts@@ -308,6 +308,9 @@ describe("cost and mentions", () => {expect(costLabel({ demo: true, cost: 0.4 }, fmt)).toBe("Placeholder · free");expect(costLabel({ demo: true, cost: 0.4, compact: true }, fmt)).toBe("Placeholder");expect(costLabel({ demo: false, cost: 0 }, fmt)).toBe("Free");+ // A free run on the install's own GPUs (the owner while hosted runs are on): said with their name.+ expect(costLabel({ demo: false, cost: 0, gpu: false, place: "Our GPUs" }, fmt)).toBe("Free · Our GPUs");+ expect(costLabel({ demo: false, cost: 0, place: "Our GPUs", compact: true }, fmt)).toBe("Free");expect(costLabel({ demo: false, cost: 0, gpu: true }, fmt)).toBe("Free · your GPU");expect(costLabel({ demo: false, cost: 0, gpu: true, compact: true }, fmt)).toBe("Free · GPU");expect(costLabel({ demo: true, cost: 0, gpu: true }, fmt)).toBe("Placeholder · free");diff --git a/tests/engine-mode.test.ts b/tests/engine-mode.test.tsindex db021552..4a825e0b 100644--- a/tests/engine-mode.test.ts+++ b/tests/engine-mode.test.ts@@ -128,6 +128,23 @@ describe("the engine switch a studio starts on", () => {expect(api.readEngine()).toBe("cloud");});+ it("hosted, the owner whose open models run on the same workers: a switch of its own, starting on Open source", () => {+ const facts = { known: true, ownerPlace: true };+ const slot = pref.engineSlot(facts);+ expect(slot).toEqual({ key: "fuobe.engine.owner", start: "open" });+ expect(pref.slotToCache(facts, slot)).toBe("fuobe.engine.owner");+ // The next page opens on it before the status answers.+ expect(pref.engineSlot({ known: false, cached: "fuobe.engine.owner" })).toEqual({ key: "fuobe.engine.owner", start: "open" });+ const storage = memoryStorage({ "fuobe.engine": "cloud" });+ vi.stubGlobal("localStorage", storage);+ expect(api.readEngine(slot)).toBe("open");+ storage.setItem(slot.key!, "cloud");+ expect(api.readEngine(slot)).toBe("cloud");+ // Without it (hosted runs off, a self-hosted install): the browser's one switch, as always.+ expect(pref.engineSlot({ known: true, ownerPlace: false })).toEqual({ key: "fuobe.engine", start: "cloud" });+ expect(pref.slotToCache({ known: true }, pref.engineSlot({ known: true }))).toBeNull();+ });+it("hosted: an account whose remembered place is its key starts on Cloud", () => {expect(pref.engineSlot(known({ kind: "account", hosted: true, runOn: "key" }, "[email protected]")).start).toBe("cloud");for (const runOn of ["site", "gpu", undefined]) expect(pref.engineSlot(known({ kind: "account", hosted: true, runOn }, "[email protected]")).start).toBe("open");diff --git a/tests/home-start.test.ts b/tests/home-start.test.tsindex cae88484..f73955de 100644--- a/tests/home-start.test.ts+++ b/tests/home-start.test.ts@@ -100,6 +100,7 @@ describe("the line under Home's composer", () => {it("offers the other engine when that one would run it for real", () => {expect(startLine(state(["comfyui"]), q.image, "cloud", "image")).toEqual({ text: "No paid API is connected, so Start can't run it yet", other: "open" });expect(startLine(state(["comfyui"]), q.image, "open", "image")?.text).toMatch(/^Start runs .+ on your GPU · Free$/);+ expect(startLine({ ...state(["comfyui"]), ownerPlace: "Our GPUs" }, q.image, "open", "image")?.text).toMatch(/^Start runs .+ on Our GPUs · Free$/);expect(startLine(state(["fal"]), q.image, "open", "image")).toEqual({ text: "ComfyUI isn't connected, so Start can't run it yet", other: "cloud" });// A Replicate key doesn't run hosted MiniMax H3, so it isn't offered for Video.expect(startLine(state(["replicate"]), q.video, "open", "video")).toEqual({ text: "ComfyUI isn't connected, so Start can't run it yet" });