Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Your GPU: the owner connects the ComfyUI on this computer from every place Fuobe asks

Adarshe2322729a6db
diff --git a/src/components/app-sidebar.tsx b/src/components/app-sidebar.tsx
index 9595054a..42de2cc8 100644
--- a/src/components/app-sidebar.tsx
+++ b/src/components/app-sidebar.tsx
@@ -40,7 +40,8 @@ import { IntentLink } from "@/components/intent-link";
import { JobNotifications } from "@/components/job-notifications";
import { NAV, type NavGroupDef } from "@/components/nav-items";
import { SkillBuilderProvider } from "@/components/skills/skill-builder-provider";
-import { CONNECT_GPU_EVENT, signInHref, signOut, useEngineMode, useHydrated, useStatus, useViewer, VIEWER_KEY, type StatusInfo } from "@/lib/api";
+import { usePagePlace } from "@/components/gpu/use-page-place";
+import { CONNECT_GPU_EVENT, ownGpuOf, signInHref, signOut, useEngineMode, useHydrated, useStatus, useViewer, VIEWER_KEY, type StatusInfo } from "@/lib/api";
import { deviceLabel } from "@/lib/gpu/readiness";
import { useModKey } from "@/lib/keys";
import { fullScreenStudio, groupId, NAV_CLOSED_KEY, navActive, NEW_CREATION_HREF, parseClosed, scrollFades, sidebarCookie, SIDEBAR_STATE_SCRIPT, sidebarOpenFromCookie } from "@/lib/nav";
@@ -428,12 +429,13 @@ function ViewerRow() {
}
/**
- * A visitor's status strip (public sign-up): its own GPU, never the install's. A guest is sent to sign
- * up first; an account without one opens "Connect your GPU"; a connected one says whether it answers.
+ * "Your GPU" in the status strip: a visitor's own (public sign-up), never the install's, or the owner's computer. A
+ * guest is sent to sign up first; anyone else without one opens "Connect your GPU"; a connected one says whether it
+ * answers.
*/
-function YourGpuChip({ viewer }: { viewer: NonNullable<StatusInfo["viewer"]> }) {
+function YourGpuChip({ gpu, guest }: { gpu: NonNullable<StatusInfo["viewer"]>["gpu"]; guest: boolean }) {
const cls = "flex w-full flex-col gap-1 rounded-md px-2 py-1.5 text-left text-[12px] text-muted-foreground transition-colors hover:bg-accent group-data-[collapsible=icon]:hidden";
- const g = viewer.gpu;
+ const g = gpu;
if (g.connected) {
const vram = g.vramBytes ? `${Math.round(g.vramBytes / 2 ** 30)} GB` : "";
return (
@@ -454,7 +456,7 @@ function YourGpuChip({ viewer }: { viewer: NonNullable<StatusInfo["viewer"]> })
<span className="ml-auto font-medium text-brand-text">Connect</span>
</span>
);
- return viewer.kind === "guest" ? (
+ return guest ? (
<a href={signInHref("signup", "/connect")} className={cls}>
{body}
</a>
@@ -542,6 +544,9 @@ export function AppSidebar() {
const cloud = status && (status.providers.fal?.configured || status.providers.replicate?.configured);
const comfy = status?.providers.comfyui?.configured;
const mode = useEngineMode();
+ // The owner's GPU as "Your GPU": on the owner's computer, or (a hosted studio with nothing connected) one to connect.
+ const place = usePagePlace();
+ const ownerGpu = status && !status.viewer && (status.ownerGpu || (place === "hosted" && !comfy && mode !== "cloud")) ? (ownGpuOf(status) ?? { connected: false }) : null;
const ready = mode === "open" ? comfy : mode === "cloud" ? cloud : cloud || comfy;
const [closed, setClosed] = useState(readClosed);
const toggle = useCallback((id: string) => {
@@ -616,7 +621,17 @@ export function AppSidebar() {
<SidebarFooter className="gap-1 border-t border-sidebar-border" onClick={closeOnLink}>
{computer && <ComputerNote />}
{status?.viewer ? (
- <YourGpuChip viewer={status.viewer} />
+ <YourGpuChip gpu={status.viewer.gpu} guest={status.viewer.kind === "guest"} />
+ ) : ownerGpu ? (
+ <>
+ {mode !== "open" && (
+ <IntentLink href="/settings" className="flex items-center gap-2 rounded-md px-2 py-1.5 text-[12px] text-muted-foreground transition-colors hover:bg-accent group-data-[collapsible=icon]:hidden">
+ <StatusDot ok={!!cloud} /> Cloud models
+ <span className="ml-auto">{cloud ? "connected" : "add key"}</span>
+ </IntentLink>
+ )}
+ <YourGpuChip gpu={ownerGpu} guest={false} />
+ </>
) : !status ? (
// Not known yet: no "add key / offline" the install may not have, for a visitor who never sees them.
<div aria-hidden className="flex h-[30px] items-center px-2 group-data-[collapsible=icon]:hidden">
diff --git a/src/components/assist/schedule-dialog.tsx b/src/components/assist/schedule-dialog.tsx
index 16b32e78..e5bf149e 100644
--- a/src/components/assist/schedule-dialog.tsx
+++ b/src/components/assist/schedule-dialog.tsx
@@ -13,7 +13,7 @@ import { Textarea } from "@/components/ui/textarea";
import { EngineSwitch } from "@/components/studio/engine-switch";
import { radioKeys, radioTab } from "@/components/studio/radio-keys";
import { useNow } from "@/components/studio/use-now";
-import { useEngine } from "@/lib/api";
+import { useEngine, useStatus } from "@/lib/api";
import { threadTitle, type AssistModeChoice } from "@/lib/assist";
import {
DEFAULT_SCHEDULE_CAP_USD,
@@ -160,6 +160,7 @@ function Form({ schedule, seed, onDone }: { schedule?: ScheduleView; seed?: Sche
};
const toggleDay = (d: number) => setDays((xs) => (xs.includes(d) ? xs.filter((x) => x !== d) : [...xs, d]));
+ const onComputer = !!useStatus().data?.ownerGpu;
return (
<form onSubmit={save} className="flex min-h-0 flex-col">
@@ -168,6 +169,8 @@ function Form({ schedule, seed, onDone }: { schedule?: ScheduleView; seed?: Sche
<CalendarClock className="size-5 text-muted-foreground" /> {schedule ? "Edit scheduled task" : "Schedule a task"}
</DialogTitle>
<DialogDescription>Each run is a new chat on this server — it runs even when Fuobe isn&apos;t open in a browser. What it makes lands in your Library.</DialogDescription>
+ {/* ComfyUI on the owner's computer: its open-source runs wait for a Fuobe tab there. */}
+ {onComputer && <p className="text-[13px] text-muted-foreground">Runs on your computer: keep Fuobe open there at that time.</p>}
</DialogHeader>
<div className="min-h-0 flex-1 space-y-6 overflow-y-auto px-5 py-5">
<div className="space-y-2">
diff --git a/src/components/connect-field.tsx b/src/components/connect-field.tsx
index aca083e9..fa839005 100644
--- a/src/components/connect-field.tsx
+++ b/src/components/connect-field.tsx
@@ -9,6 +9,7 @@ import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { saveSettings, testConnection, type ConnectionTest } from "@/lib/api";
import { settingProblem, type TestProvider } from "@/lib/connections";
+import { addressHost, addressKind, refusedLine, refusedOnHosted } from "@/lib/page-place";
import { cn } from "@/lib/utils";
import { toastError } from "@/lib/refusals";
@@ -20,13 +21,21 @@ export interface PublicSetting {
isSet: boolean;
}
+/** GET /api/settings: every setting, and whether the server may test a private address for a hosted page. */
+const settingsQuery = (enabled: boolean) => ({
+ queryKey: ["settings"],
+ queryFn: async () => (await (await fetch("/api/settings")).json()) as { settings: PublicSetting[]; allowPrivate?: boolean },
+ enabled,
+});
+
/** Every setting as the browser may see it (secrets masked). `enabled: false` waits (Home's guide, until the status says it's wanted). */
export function useSettings(enabled = true) {
- return useQuery({
- queryKey: ["settings"],
- queryFn: async () => ((await (await fetch("/api/settings")).json()) as { settings: PublicSetting[] }).settings,
- enabled,
- });
+ return useQuery({ ...settingsQuery(enabled), select: (d) => d.settings });
+}
+
+/** The server may call a private address (FUOBE_ALLOW_PRIVATE_URLS: a VPN such as Tailscale) for a hosted page. */
+export function useAllowPrivate(enabled = true): boolean {
+ return useQuery({ ...settingsQuery(enabled), select: (d) => d.allowPrivate === true }).data ?? false;
}
interface Result extends ConnectionTest {
@@ -35,6 +44,8 @@ interface Result extends ConnectionTest {
saved?: boolean;
}
+const ADDRESS_FIELDS = new Set(["comfyUrl", "comfyIsolatedUrl"]);
+
/**
* A key or address field with one button that does what it says: "Save & test" tests the typed value
* first and saves it once it connects (a value that doesn't connect is offered "Save anyway"); with
@@ -54,6 +65,11 @@ export function ConnectField({
options,
className,
saveOnly = false,
+ hideDefault = false,
+ extraValues,
+ place,
+ trustSaved = false,
+ refusal,
}: {
name: string;
setting?: PublicSetting;
@@ -72,6 +88,16 @@ export function ConnectField({
className?: string;
/** Save the typed value without a test (nothing to connect to). */
saveOnly?: boolean;
+ /** Show the field empty while only the built-in default is there (a hosted studio's ComfyUI address): Connect waits for one typed. */
+ hideDefault?: boolean;
+ /** Tested with the typed value and saved with it after a green test (comfyWhere "server": a server address while ComfyUI runs on a computer). */
+ extraValues?: Record<string, string>;
+ /** "hosted": the page isn't on the server's machine (lib/page-place.ts). A ComfyUI address there on the server's own machine or network is refused, never sent. */
+ place?: "hosted";
+ /** The saved address works for the server (it connected): only a typed one is refused. */
+ trustSaved?: boolean;
+ /** How a refused address is shown: its one line, and what to do instead. */
+ refusal?: (line: string) => React.ReactNode;
}) {
const qc = useQueryClient();
const inputId = useId();
@@ -79,11 +105,19 @@ export function ConnectField({
const [busy, setBusy] = useState(false);
const [result, setResult] = useState<Result | null>(null);
const secret = !!setting?.secret;
- const saved = secret ? "" : (setting?.value ?? "");
+ // Only the built-in default (127.0.0.1 on a hosted studio means its server): shown empty, nothing to test until typed.
+ const onlyDefault = hideDefault && !setting?.isSet && !setting?.fromEnv;
+ const saved = secret || onlyDefault ? "" : (setting?.value ?? "");
const typed = draft !== null && draft.trim() !== saved.trim() ? draft.trim() : null;
const shown = draft ?? saved;
const problem = typed ? settingProblem(name, typed) : null;
- const canTest = saveOnly ? typed !== null && !problem : typed !== null || !!setting?.isSet || !!setting?.value;
+ const canTest = saveOnly ? typed !== null && !problem : typed !== null || (!onlyDefault && (!!setting?.isSet || !!setting?.value));
+ // A hosted page: an address on the server's own machine or network is never sent to be tested (lib/page-place.ts).
+ const allowPrivate = useAllowPrivate(place === "hosted");
+ const checked = place === "hosted" && ADDRESS_FIELDS.has(name) && (typed !== null || !trustSaved) ? (typed ?? saved) : "";
+ const kind = checked ? addressKind(checked) : null;
+ const refusedHere = kind && refusedOnHosted(kind, allowPrivate) ? refusedLine(kind, addressHost(checked)) : null;
+ const hostedTest = place === "hosted" && (typed !== null || !trustSaved);
const refresh = () => {
void qc.invalidateQueries({ queryKey: ["settings"] });
@@ -104,8 +138,13 @@ export function ConnectField({
toast.success(`${label} saved`);
return;
}
- const values = typed !== null ? { [name]: typed } : undefined;
- const res = await testConnection(provider, values, name);
+ // Refused here, before any request: the line says why, and no "Save anyway".
+ if (refusedHere) {
+ setResult({ ok: false, detail: refusedHere, code: "on-your-computer" });
+ return;
+ }
+ const values = typed !== null ? { [name]: typed, ...extraValues } : extraValues;
+ const res = await testConnection(provider, values, name, { place: hostedTest ? "hosted" : undefined });
if (res.ok) {
// Connected: keep it. The first-run guide goes once the status sees a connection the engine
// mode generates with (the server remembers that), not for Ollama or an unused provider.
@@ -114,7 +153,7 @@ export function ConnectField({
refresh();
onConnected?.(res);
}
- setResult({ ...res, saved: res.ok && !!values, unsaved: !res.ok ? values : undefined });
+ setResult({ ...res, saved: res.ok && !!values, unsaved: !res.ok && res.code !== "on-your-computer" && typed !== null ? { [name]: typed } : undefined });
} catch (e) {
setResult({ ok: false, detail: (e as Error).message });
} finally {
@@ -193,13 +232,18 @@ export function ConnectField({
)}
</div>
</div>
- {problem && (
+ {/* An address refused here gets its own line instead (fixing its form wouldn't help). */}
+ {problem && !refusedHere && (
<p className="flex items-start gap-1.5 text-[12px] text-foreground">
<TriangleAlert className="mt-0.5 size-3.5 shrink-0 text-warning" /> {problem}
</p>
)}
<div id={`${inputId}-result`} role="status" aria-live="polite" className="empty:hidden">
- {result && (
+ {/* A saved address the server must not call from here: said at once. A refusal shows its own way. */}
+ {!result && typed === null && refusedHere && refusal?.(refusedHere)}
+ {result?.code === "on-your-computer" && refusal ? (
+ refusal(result.detail)
+ ) : result && (
<p className={cn("flex flex-wrap items-center gap-x-1.5 gap-y-1 text-[12px]", result.ok ? "text-success" : "text-destructive")}>
{result.ok ? <CheckCircle2 className="size-3.5 shrink-0" /> : <CircleAlert className="size-3.5 shrink-0" />}
<span className="min-w-0 break-words">
diff --git a/src/components/get-started.tsx b/src/components/get-started.tsx
index 66fb7056..a5618011 100644
--- a/src/components/get-started.tsx
+++ b/src/components/get-started.tsx
@@ -1,13 +1,16 @@
"use client";
import { useQueryClient } from "@tanstack/react-query";
-import { AudioLines, Bot, Clapperboard, Cloud, Copy, Cpu, ExternalLink, ImageIcon, Megaphone, Mic2, Sparkles, Video, Wand2, X } from "lucide-react";
+import { AudioLines, Bot, ChevronDown, Clapperboard, Cloud, Copy, Cpu, ExternalLink, ImageIcon, Megaphone, Mic2, Sparkles, Video, Wand2, X } from "lucide-react";
import Link from "next/link";
import { useId, useState } from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { ConnectField, useSettings } from "@/components/connect-field";
-import { saveSettings, useEngineMode, type StatusInfo } from "@/lib/api";
+import { OwnerComputerLine, OwnerServerComfy } from "@/components/gpu/connect-choice";
+import { usePagePlace } from "@/components/gpu/use-local-comfy";
+import { Skeleton } from "@/components/ui/skeleton";
+import { CONNECT_GPU_EVENT, saveSettings, useEngineMode, type StatusInfo } from "@/lib/api";
import { copyWithToast } from "@/lib/clipboard";
import { COMFY_INSTALL_COMMAND, COMFY_INSTALL_DOCS, FAL_KEYS_URL, nothingConnected } from "@/lib/connections";
import { cn } from "@/lib/utils";
@@ -31,6 +34,68 @@ const INTENTS = [
export type IntentMode = "image" | "video" | "edit";
+/** Models per workflow, how to install ComfyUI, and its install command: the GPU card's links. */
+function ComfyLinks() {
+ return (
+ <span className="flex flex-wrap items-center gap-x-3 gap-y-1">
+ <Link href="/workflows" className="text-brand-text underline-offset-2 hover:underline">
+ Models per workflow
+ </Link>
+ <a href={COMFY_INSTALL_DOCS} target="_blank" rel="noreferrer" className="inline-flex items-center gap-1 text-brand-text underline-offset-2 hover:underline">
+ Install ComfyUI <ExternalLink className="size-3" />
+ </a>
+ <button
+ type="button"
+ onClick={() => void copyWithToast(COMFY_INSTALL_COMMAND, "Install command copied")}
+ className="inline-flex max-w-full items-center gap-1 rounded-md bg-background px-1.5 py-0.5 font-mono text-[11px] text-foreground ring-1 ring-border hover:bg-accent"
+ aria-label={`Copy the install command: ${COMFY_INSTALL_COMMAND}`}
+ >
+ <span className="truncate">{COMFY_INSTALL_COMMAND}</span> <Copy className="size-3 shrink-0" />
+ </button>
+ </span>
+ );
+}
+
+/**
+ * "Use your GPU" on a hosted studio (the page isn't on the server's machine, so the server's 127.0.0.1 isn't the
+ * owner's): Fuobe finds the ComfyUI on this computer, in the connect dialog (it stays open through "connected" after
+ * this guide goes); a ComfyUI on a server or a cloud GPU is the quieter second way. Once ComfyUI runs on the owner's
+ * computer (a guide opened again), its state.
+ */
+function HostedGpuCard({ computer }: { computer: boolean }) {
+ const [server, setServer] = useState(false);
+ return (
+ <GuideCard icon={Cpu} title="Use your GPU" cost="Free: open-source models run on your own graphics card">
+ {computer ? (
+ <OwnerComputerLine />
+ ) : (
+ <>
+ <p className="text-[13px] leading-relaxed text-muted-foreground">Fuobe finds the ComfyUI running on this computer and sends your runs to it.</p>
+ <div className="space-y-1.5">
+ <Button className="h-11 w-full sm:h-9 sm:w-fit" onClick={() => window.dispatchEvent(new Event(CONNECT_GPU_EVENT))}>
+ <Cpu /> Use the ComfyUI on this computer
+ </Button>
+ <p className="text-[12px] text-muted-foreground">Runs while Fuobe is open in this browser.</p>
+ </div>
+ <div>
+ <button type="button" onClick={() => setServer((v) => !v)} aria-expanded={server} className="flex items-center gap-1 text-[12px] text-muted-foreground hover:text-foreground">
+ ComfyUI on a server or a cloud GPU? <ChevronDown className={cn("size-3.5 transition-transform", server && "rotate-180")} />
+ </button>
+ {server && (
+ <div className="mt-3">
+ <OwnerServerComfy hosted onlyAddress />
+ </div>
+ )}
+ </div>
+ </>
+ )}
+ <p className="text-[12px] text-muted-foreground">
+ <ComfyLinks />
+ </p>
+ </GuideCard>
+ );
+}
+
function GuideCard({ icon: Icon, title, cost, children }: { icon: typeof Cloud; title: string; cost: string; children: React.ReactNode }) {
return (
<section aria-label={title} className="flex min-w-0 flex-col gap-3 rounded-xl border bg-background p-4 text-left">
@@ -86,6 +151,8 @@ export function GetStarted({
const titleId = useId();
const cachedMode = useEngineMode();
const mode = status?.engineMode ?? cachedMode;
+ // Where this page is: unknown in the server's HTML (Home's static shell), so the GPU card waits for it there.
+ const place = usePagePlace();
const hide = async () => {
setHiding(true);
@@ -112,7 +179,9 @@ export function GetStarted({
</h2>
<p className="mt-1 text-[13px] text-muted-foreground">
{status && nothingConnected(status)
- ? "Nothing is connected yet, so every run is a free demo with placeholder results. Connect a model to make the real thing:"
+ ? status.demoMode === "off"
+ ? "Nothing is connected yet. Connect a model to make the real thing:"
+ : "Nothing is connected yet, so every run is a free demo with placeholder results. Connect a model to make the real thing:"
: "Three ways to make things with Fuobe. Connect another one, or check one you set up:"}
</p>
</div>
@@ -140,7 +209,13 @@ export function GetStarted({
/>
</GuideCard>
)}
- {mode !== "cloud" && (
+ {mode !== "cloud" && place === null ? (
+ <GuideCard icon={Cpu} title="Use your GPU" cost="Free: open-source models run on your own graphics card">
+ <Skeleton className="h-[116px] w-full rounded-lg" />
+ </GuideCard>
+ ) : mode !== "cloud" && place === "hosted" ? (
+ <HostedGpuCard computer={get("comfyWhere")?.value === "computer"} />
+ ) : mode !== "cloud" && (
<GuideCard icon={Cpu} title="Use your GPU" cost="Free: open-source models run on your machine">
<p className="text-[13px] leading-relaxed text-muted-foreground">Point Fuobe at a running ComfyUI. Each workflow lists the model files it needs.</p>
<ConnectField
diff --git a/src/components/gpu/connect-choice.tsx b/src/components/gpu/connect-choice.tsx
index 9b0a389e..937588e5 100644
--- a/src/components/gpu/connect-choice.tsx
+++ b/src/components/gpu/connect-choice.tsx
@@ -1,30 +1,34 @@
"use client";
-import { useQuery, useQueryClient } from "@tanstack/react-query";
-import { ChevronDown, Cpu, Globe, Loader2, TriangleAlert, Unplug } from "lucide-react";
-import { useState } from "react";
+import { useQuery, useQueryClient, type QueryClient } from "@tanstack/react-query";
+import { ChevronDown, Cpu, Globe, Info, Loader2, Search, TriangleAlert, Unplug } from "lucide-react";
+import { createContext, useContext, useState } from "react";
import { toast } from "sonner";
+import { ConnectField, useAllowPrivate, useSettings } from "@/components/connect-field";
import { gib } from "@/components/gpu/comfy-finder";
import { YourGpu } from "@/components/gpu/your-gpu";
import { Button } from "@/components/ui/button";
import { deviceLabel } from "@/lib/gpu/readiness";
-import { useViewer } from "@/lib/api";
+import { CONNECT_GPU_EVENT, useStatus, useViewer } from "@/lib/api";
+import type { OwnerGpuView } from "@/lib/connections";
+import { addressKind, refusedOnHosted } from "@/lib/page-place";
import { RELAY_WORDS } from "@/lib/relay";
import { cn } from "@/lib/utils";
import { restartComputerRunner, rememberComfy, rememberedComfy } from "./computer-runtime";
import { GuardFix, SettingFix, ThisComputer, unsupportedWords } from "./this-computer";
-import { lookOn, useComputerSupport } from "./use-local-comfy";
+import { lookOn, useComputerSupport, usePagePlace } from "./use-local-comfy";
import { openFinder, useComputerState, type FindReason } from "./computer-runner";
/**
- * "Connect your GPU" for an account: the ComfyUI on this computer first (the quickest way: nothing to install, runs
- * while Fuobe is open in this browser), a link (a tunnel) second, for runs that go on with the tab closed. On a phone,
- * in Safari, or on a page that can't ask for the permission, only the link, with why.
+ * "Connect your GPU": the ComfyUI on this computer first (the quickest way: nothing to install, runs while Fuobe is
+ * open in this browser). For an account, a link (a tunnel) second, for runs that go on with the tab closed; for the
+ * owner of a hosted studio, a ComfyUI at a server address (a cloud GPU, a tunnel). On a phone, in Safari, or on a page
+ * that can't ask for the permission, only the second way, with why.
*/
-export type AccountGpuView =
- | { mode: "computer"; online: boolean; comfy?: "down" | "no-setting"; device?: string; vramBytes?: number; version?: string; port?: number; cors?: "exact" | "any" | "other"; guard?: boolean }
- | { mode: "link"; url: string; hasToken: boolean };
+export type AccountGpuView = OwnerGpuView | { mode: "link"; url: string; hasToken: boolean };
+
+type ComputerView = Extract<AccountGpuView, { mode: "computer" }>;
async function gpuCall<T>(method: string, body?: unknown): Promise<T> {
const res = await fetch("/api/account/gpu", { method, headers: { "Content-Type": "application/json" }, body: body === undefined ? undefined : JSON.stringify(body) });
@@ -42,12 +46,25 @@ export async function connectThisComputer(): Promise<void> {
await gpuCall("PUT", { mode: "computer" });
}
-/** The owner's: ComfyUI runs on the computer the owner uses (Settings → Where ComfyUI runs). */
-async function connectOwnerComputer(): Promise<void> {
- const res = await fetch("/api/settings", { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ comfyWhere: "computer" }) });
+async function putWhere(where: "server" | "computer"): Promise<void> {
+ const res = await fetch("/api/settings", { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ comfyWhere: where }) });
if (!res.ok) throw new Error(((await res.json().catch(() => ({}))) as { error?: string }).error ?? `Request failed (${res.status})`);
}
+/** The owner's: ComfyUI runs on the computer the owner uses (Settings → Where ComfyUI runs). */
+export async function connectOwnerComputer(): Promise<void> {
+ await putWhere("computer");
+}
+
+/** The owner's ComfyUI goes back to the server's address (the runs still waiting for the computer stop, saying why). */
+export async function disconnectOwnerComputer(qc: QueryClient): Promise<void> {
+ await putWhere("server");
+ for (const key of ["viewer", "status", "settings"]) void qc.invalidateQueries({ queryKey: [key] });
+}
+
+/** The owner's last line once the computer is connected. */
+const OWNER_DONE = "Done. Your open-source runs now go to this computer. Keep a Fuobe tab open here while they run.";
+
const ABOUT =
"Fuobe's setting lets the Fuobe page use your ComfyUI. On its own, it would also let other websites send work to your ComfyUI if your browser lets them reach apps on this computer (Chrome, Edge and Firefox ask you first). Fuobe's guard, a small file in ComfyUI's custom_nodes folder, turns them away. To turn the setting off, start ComfyUI the usual way.";
@@ -119,9 +136,11 @@ function NoGuard({ port }: { port: number }) {
);
}
-/** "This computer · RTX 5090 · port 8188 · Ready", another port, a link instead, Disconnect. */
-function ComputerStatus({ gpu, onLink }: { gpu: Extract<AccountGpuView, { mode: "computer" }>; onLink: () => void }) {
- const qc = useQueryClient();
+/**
+ * "This computer · RTX 5090 · port 8188 · Ready", another port, the other way to connect, Disconnect. `look`: this
+ * browser can reach a ComfyUI on its computer (not a phone): the port can be changed from here.
+ */
+function ComputerStatus({ gpu, onDisconnect, other, look = true }: { gpu: ComputerView; onDisconnect: () => Promise<void>; other: { label: string; onClick: () => void }; look?: boolean }) {
const here = useHere();
const [busy, setBusy] = useState(false);
const [about, setAbout] = useState(false);
@@ -131,7 +150,7 @@ function ComputerStatus({ gpu, onLink }: { gpu: Extract<AccountGpuView, { mode:
// A tab of this browser runs the jobs: what it sees now. Elsewhere (a phone, another computer has them): the server.
const mine = here && !here.other ? here : null;
const online = mine ? mine.comfy === "ok" && !mine.access : gpu.online;
- const shownPort = mine?.port ?? rememberedComfy()?.port ?? gpu.port;
+ const shownPort = mine?.port ?? (look ? rememberedComfy()?.port : undefined) ?? gpu.port;
const facts = [gpu.device && deviceLabel(gpu.device), gib(gpu.vramBytes), shownPort && `port ${shownPort}`].filter(Boolean).join(" · ");
const guard = mine?.facts ? mine.facts.guard : gpu.guard;
const lookAt = async () => {
@@ -150,9 +169,7 @@ function ComputerStatus({ gpu, onLink }: { gpu: Extract<AccountGpuView, { mode:
const remove = async () => {
setBusy(true);
try {
- qc.setQueryData(["account-gpu"], await gpuCall("DELETE"));
- void qc.invalidateQueries({ queryKey: ["viewer"] });
- void qc.invalidateQueries({ queryKey: ["status"] });
+ await onDisconnect();
} catch (e) {
toast.error((e as Error).message);
} finally {
@@ -164,7 +181,10 @@ function ComputerStatus({ gpu, onLink }: { gpu: Extract<AccountGpuView, { mode:
<div className="flex items-start gap-2.5 rounded-xl bg-brand-faint px-3 py-2.5">
<Cpu className="mt-0.5 size-4 shrink-0 text-brand-text" />
<div className="min-w-0 flex-1">
- <p className="font-medium">This computer{online ? " · Ready" : ""}</p>
+ <p className="font-medium">
+ {look ? "This computer" : "Your computer"}
+ {online ? " · Ready" : ""}
+ </p>
{online ? <p className="truncate text-[12px] text-muted-foreground">{facts || "Your ComfyUI"}</p> : <ComputerProblem here={here} server={gpu.comfy} />}
</div>
<Button size="sm" variant="ghost" className="-my-1 h-7" onClick={() => void remove()} disabled={busy}>
@@ -172,19 +192,21 @@ function ComputerStatus({ gpu, onLink }: { gpu: Extract<AccountGpuView, { mode:
</Button>
</div>
{gpu.cors === "any" && <p className="text-[12px] text-amber-700 dark:text-amber-400">Your ComfyUI lets every website in. To keep it private, start it with --enable-cors-header {window.location.origin} instead.</p>}
- {online && guard === false && gpu.cors !== "any" && shownPort && <NoGuard port={shownPort} />}
- <div className="flex flex-wrap items-center gap-2">
- <span className="text-[12px] text-muted-foreground">ComfyUI on another port?</span>
- <input aria-label="ComfyUI's port" inputMode="numeric" className="h-8 w-20 rounded-md border bg-background px-2 text-[13px]" value={port} onChange={(e) => setPort(e.target.value)} onKeyDown={(e) => e.key === "Enter" && void lookAt()} />
- <Button size="sm" variant="secondary" className="h-8" onClick={() => void lookAt()}>
- Look
- </Button>
- </div>
+ {look && online && guard === false && gpu.cors !== "any" && shownPort && <NoGuard port={shownPort} />}
+ {look && (
+ <div className="flex flex-wrap items-center gap-2">
+ <span className="text-[12px] text-muted-foreground">ComfyUI on another port?</span>
+ <input aria-label="ComfyUI's port" inputMode="numeric" className="h-8 w-20 rounded-md border bg-background px-2 text-[13px]" value={port} onChange={(e) => setPort(e.target.value)} onKeyDown={(e) => e.key === "Enter" && void lookAt()} />
+ <Button size="sm" variant="secondary" className="h-8" onClick={() => void lookAt()}>
+ Look
+ </Button>
+ </div>
+ )}
{note && <p className="text-[12px] text-muted-foreground">{note}</p>}
{fixPort && <SettingFix key={fixPort} port={fixPort} back={false} />}
<div className="flex flex-wrap gap-x-4 gap-y-1 text-[12px]">
- <button type="button" className="text-muted-foreground underline-offset-4 hover:text-foreground hover:underline" onClick={onLink}>
- Use a link instead
+ <button type="button" className="text-muted-foreground underline-offset-4 hover:text-foreground hover:underline" onClick={other.onClick}>
+ {other.label}
</button>
<button type="button" className="flex items-center gap-1 text-muted-foreground hover:text-foreground" onClick={() => setAbout((v) => !v)}>
About this setting <ChevronDown className={cn("size-3.5 transition-transform", about && "rotate-180")} />
@@ -195,6 +217,146 @@ function ComputerStatus({ gpu, onLink }: { gpu: Extract<AccountGpuView, { mode:
);
}
+/** The two ways, as cards: this computer (primary), and the second way behind a disclosure. */
+function ChoiceCards({
+ instead,
+ computer,
+ title,
+ sub,
+ open,
+ onToggle,
+ children,
+ className,
+}: {
+ /** The second way is connected: this computer is offered "instead". */
+ instead: boolean;
+ computer: React.ReactNode;
+ title: string;
+ sub: string;
+ open: boolean;
+ onToggle: () => void;
+ children: React.ReactNode;
+ /** 36rem wide at most from sm up, unless a wider page lifts that (ConnectChoice's className). */
+ className?: string;
+}) {
+ return (
+ <div className={cn("w-full min-w-0 space-y-3 sm:max-w-[36rem]", className)}>
+ <div className={cn("space-y-3 rounded-2xl border bg-background p-4", !instead && "border-primary/40")}>
+ <div className="flex items-start gap-3">
+ <div className="grid size-9 shrink-0 place-items-center rounded-xl bg-primary text-primary-foreground">
+ <Cpu className="size-4" />
+ </div>
+ <div className="min-w-0">
+ <p className="text-[15px] font-medium">{instead ? "Use the ComfyUI on this computer instead" : "Use the ComfyUI on this computer"}</p>
+ <p className="text-[13px] text-muted-foreground">The quickest way. Runs while Fuobe is open in this browser.</p>
+ </div>
+ </div>
+ {computer}
+ </div>
+ <div className="rounded-2xl border border-dashed p-4">
+ <button type="button" className="flex w-full items-start gap-3 text-left" onClick={onToggle} aria-expanded={open}>
+ <Globe className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
+ <span className="min-w-0 flex-1">
+ <span className="block text-[13px] font-medium">{title}</span>
+ <span className="block text-[12px] text-muted-foreground">{sub}</span>
+ </span>
+ <ChevronDown className={cn("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform", open && "rotate-180")} />
+ </button>
+ {open && <div className="mt-3">{children}</div>}
+ </div>
+ </div>
+ );
+}
+
+/** "Use the ComfyUI on this computer" under a refused address, inside the choice: start this computer's finder there. */
+const FindHere = createContext<(() => void) | null>(null);
+
+/**
+ * A ComfyUI address the server must not call from a hosted page (127.0.0.1 is the server itself there): what that
+ * address means here, in one line, and the way that reaches the owner's own computer.
+ */
+export function HostedRefusal({ line }: { line: string }) {
+ const find = useContext(FindHere);
+ const support = useComputerSupport();
+ return (
+ <div className="mt-1 space-y-2 rounded-xl bg-brand-faint px-3 py-2.5 text-[13px]">
+ <p className="flex items-start gap-1.5">
+ <Info aria-hidden className="mt-0.5 size-3.5 shrink-0 text-brand-text" /> {line}
+ </p>
+ {support === "ok" && (
+ <Button size="sm" onClick={() => (find ? find() : window.dispatchEvent(new Event(CONNECT_GPU_EVENT)))}>
+ <Cpu /> Use the ComfyUI on this computer
+ </Button>
+ )}
+ </div>
+ );
+}
+
+/**
+ * The owner's ComfyUI at a server address: a cloud GPU, a tunnel to the owner's own, or (on the server's own machine)
+ * 127.0.0.1. On a hosted studio the built-in 127.0.0.1 isn't shown, and an address on the server's machine or network
+ * is refused before anything is sent. While ComfyUI runs on the owner's computer, a green test moves it to the server.
+ * `onlyAddress`: the address alone (the first-run guide).
+ */
+export function OwnerServerComfy({ hosted, computer = false, onlyAddress = false }: { hosted: boolean; computer?: boolean; onlyAddress?: boolean }) {
+ const qc = useQueryClient();
+ const settings = useSettings().data;
+ const status = useStatus().data;
+ const get = (n: string) => settings?.find((s) => s.name === n);
+ // A server ComfyUI that answers works for the server, wherever this page is: only a newly typed address is checked.
+ const trustSaved = !computer && !!status?.providers.comfyui?.configured;
+ const place = hosted ? ("hosted" as const) : undefined;
+ const refusal = hosted ? (line: string) => <HostedRefusal line={line} /> : undefined;
+ const connected = (r: { detail: string }) => {
+ toast.success("ComfyUI connected", { description: r.detail });
+ void qc.invalidateQueries({ queryKey: ["viewer"] });
+ };
+ return (
+ <div className="space-y-4">
+ <ConnectField
+ name="comfyUrl"
+ setting={get("comfyUrl")}
+ provider="comfyui"
+ label={hosted ? "Server address" : "ComfyUI server URL"}
+ idleLabel="Connect"
+ placeholder={hosted ? "https://…" : "http://127.0.0.1:8188"}
+ hint={hosted ? "An address Fuobe's server can reach: a cloud GPU, or a tunnel to your own." : "Where ComfyUI listens; a local install is http://127.0.0.1:8188."}
+ hideDefault={hosted}
+ extraValues={computer ? { comfyWhere: "server" } : undefined}
+ place={place}
+ trustSaved={trustSaved}
+ refusal={refusal}
+ onConnected={connected}
+ />
+ {!onlyAddress && (
+ <ConnectField
+ name="comfyToken"
+ setting={get("comfyToken")}
+ provider="comfyui"
+ label={hosted ? "Access token (optional)" : "Auth token (optional)"}
+ hint={hosted ? "For a ComfyUI behind a login or a proxy." : "Sent as a Bearer token, for ComfyUI behind a proxy."}
+ place={computer ? undefined : place}
+ trustSaved={trustSaved}
+ refusal={refusal}
+ />
+ )}
+ {!onlyAddress && !computer && (
+ <ConnectField
+ name="comfyIsolatedUrl"
+ setting={get("comfyIsolatedUrl")}
+ provider="comfyui"
+ label="Isolated worker URL (optional)"
+ placeholder={hosted ? "https://…" : "http://127.0.0.1:8189"}
+ hint="A second ComfyUI for LatentSync 1.6 and ThinkSound, whose node packs can't share the main install. scripts/comfy/README.md shows how to start one."
+ place={place}
+ refusal={refusal}
+ />
+ )}
+ {computer && <p className="text-[12px] text-muted-foreground">Connecting a server address stops the runs still going on your computer.</p>}
+ </div>
+ );
+}
+
export interface ConnectChoiceProps {
/** Opened from a run: once connected, the run starts by itself. */
fromRun?: boolean;
@@ -212,19 +374,20 @@ export interface ConnectChoiceProps {
className?: string;
}
-export function ConnectChoice({ fromRun, kind, reason, onStart, onNotNow, className }: ConnectChoiceProps) {
+export function ConnectChoice(props: ConnectChoiceProps) {
+ const viewer = useViewer().data;
+ if (!viewer) return <Loader2 className="size-5 animate-spin text-muted-foreground" />;
+ return viewer.owner ? <OwnerChoice {...props} /> : <AccountChoice {...props} />;
+}
+
+function AccountChoice({ fromRun, kind, reason, onStart, onNotNow, className }: ConnectChoiceProps) {
+ const qc = useQueryClient();
const support = useComputerSupport();
- // The owner (whose runs go to their own computer when Settings says so) has no account GPU: only the finder.
- const owner = useViewer().data?.owner === true;
- const q = useAccountGpu(!owner);
+ const q = useAccountGpu();
const gpu = q.data?.gpu ?? null;
// Once the person starts finding their ComfyUI, the flow stays on screen through to "connected".
const [flow, setFlow] = useState(!!reason);
const [link, setLink] = useState(false);
- if (owner) {
- if (support !== "ok") return <p className="text-[13px] text-muted-foreground">{unsupportedWords(support)}</p>;
- return <ThisComputer connect={connectOwnerComputer} fromRun={fromRun} kind={kind} onStart={onStart} onNotNow={onNotNow} autoLook={reason === "setting" || reason === "find"} again={reason === "setting"} />;
- }
if (q.isError) return <p className="text-[13px] text-muted-foreground">{q.error.message}</p>;
if (!q.data) return <Loader2 className="size-5 animate-spin text-muted-foreground" />;
if (support !== "ok") {
@@ -236,20 +399,28 @@ export function ConnectChoice({ fromRun, kind, reason, onStart, onNotNow, classN
</div>
);
}
- if (gpu?.mode === "computer" && !flow && !link) return <ComputerStatus gpu={gpu} onLink={() => setLink(true)} />;
+ if (gpu?.mode === "computer" && !flow && !link)
+ return (
+ <ComputerStatus
+ gpu={gpu}
+ onDisconnect={async () => {
+ qc.setQueryData(["account-gpu"], await gpuCall("DELETE"));
+ void qc.invalidateQueries({ queryKey: ["viewer"] });
+ void qc.invalidateQueries({ queryKey: ["status"] });
+ }}
+ other={{ label: "Use a link instead", onClick: () => setLink(true) }}
+ />
+ );
const linked = gpu?.mode === "link";
return (
- <div className={cn("w-full min-w-0 space-y-3 sm:max-w-[36rem]", className)}>
- <div className={cn("space-y-3 rounded-2xl border bg-background p-4", !linked && "border-primary/40")}>
- <div className="flex items-start gap-3">
- <div className="grid size-9 shrink-0 place-items-center rounded-xl bg-primary text-primary-foreground">
- <Cpu className="size-4" />
- </div>
- <div className="min-w-0">
- <p className="text-[15px] font-medium">{linked ? "Use the ComfyUI on this computer instead" : "Use the ComfyUI on this computer"}</p>
- <p className="text-[13px] text-muted-foreground">The quickest way. Runs while Fuobe is open in this browser.</p>
- </div>
- </div>
+ <ChoiceCards
+ className={className}
+ instead={linked}
+ title="Run from anywhere with a link"
+ sub="For runs that go on with this tab closed. You'll need a tunnel."
+ open={link || linked}
+ onToggle={() => setLink((v) => !v)}
+ computer={
<div onClickCapture={() => setFlow(true)}>
<ThisComputer
connect={async () => {
@@ -264,29 +435,142 @@ export function ConnectChoice({ fromRun, kind, reason, onStart, onNotNow, classN
again={reason === "setting"}
/>
</div>
+ }
+ >
+ <YourGpu className={className} onLinked={onStart} />
+ </ChoiceCards>
+ );
+}
+
+/**
+ * The owner's choice. On a hosted studio (the page isn't on the server's machine): the ComfyUI on this computer first,
+ * a ComfyUI at a server address second. On the server's own machine or network: the server address, as before (the
+ * computer is in Settings' "Where ComfyUI runs"). While ComfyUI runs on the owner's computer: its state, with
+ * Disconnect and the server address as the other way.
+ */
+function OwnerChoice({ fromRun, kind, reason, onStart, onNotNow, className }: ConnectChoiceProps) {
+ const qc = useQueryClient();
+ const support = useComputerSupport();
+ const place = usePagePlace();
+ const status = useStatus().data;
+ const settings = useSettings().data;
+ const allowPrivate = useAllowPrivate(place === "hosted");
+ // Once the person starts finding their ComfyUI, the flow stays on screen through to "connected".
+ const [flow, setFlow] = useState(!!reason);
+ // The server way, opened or closed by hand (until then: open when an address is saved or connected).
+ const [serverOpen, setServerOpen] = useState<boolean | null>(null);
+ const [lookNow, setLookNow] = useState(0);
+ // Just disconnected: this computer's finder waits for a tap (a browser that may reach ComfyUI would connect it again
+ // by itself), then looks at once.
+ const [armed, setArmed] = useState<"auto" | "tap" | "look">("auto");
+ const thisComputer = (
+ <ThisComputer
+ connect={async () => {
+ setFlow(true);
+ await connectOwnerComputer();
+ void qc.invalidateQueries({ queryKey: ["settings"] });
+ void qc.invalidateQueries({ queryKey: ["status"] });
+ }}
+ fromRun={fromRun}
+ kind={kind}
+ onStart={onStart}
+ onNotNow={onNotNow}
+ autoLook={reason === "setting" || reason === "find" || armed === "look"}
+ again={reason === "setting"}
+ doneWords={OWNER_DONE}
+ lookNow={lookNow}
+ />
+ );
+ const findButton = (
+ <Button className="h-11 sm:h-9" onClick={() => setArmed("look")}>
+ <Search /> Find my ComfyUI
+ </Button>
+ );
+ // Opened by the note of the tab that runs the jobs: straight to the finder, as before.
+ if (reason) return support !== "ok" ? <p className="text-[13px] text-muted-foreground">{unsupportedWords(support, true)}</p> : thisComputer;
+ if (!settings || !status || place === null) return <Loader2 className="size-5 animate-spin text-muted-foreground" />;
+ const computer = settings.find((s) => s.name === "comfyWhere")?.value === "computer";
+ const hosted = place === "hosted" && status.engineMode !== "cloud";
+ const serverConnected = !computer && !!status.providers.comfyui?.configured;
+ const address = settings.find((s) => s.name === "comfyUrl");
+ // Opens by itself for a server address of the owner's: connected, or saved and one the server may call from here.
+ const usable = !!address?.isSet && !(hosted && refusedOnHosted(addressKind(address.value), allowPrivate));
+ const open = serverOpen ?? (serverConnected || usable);
+ const serverForm = <OwnerServerComfy hosted={hosted} computer={computer} />;
+ const findHere = () => {
+ setServerOpen(false);
+ setFlow(true);
+ setArmed((a) => (a === "tap" ? "look" : a));
+ setLookNow((n) => n + 1);
+ };
+ const disconnect = async () => {
+ await disconnectOwnerComputer(qc);
+ setArmed("tap");
+ setFlow(false);
+ setServerOpen(null);
+ };
+ const state = computer ? (
+ <ComputerStatus
+ gpu={status.ownerGpu ?? { mode: "computer", online: false }}
+ look={support === "ok"}
+ onDisconnect={disconnect}
+ other={{ label: "Use a server address instead", onClick: () => setServerOpen((v) => !(v ?? false)) }}
+ />
+ ) : null;
+ const serverBox = (
+ <div className="rounded-2xl border border-dashed p-4">
+ <p className="mb-3 text-[13px] font-medium">Use a ComfyUI on a server</p>
+ {serverForm}
+ </div>
+ );
+
+ // A page on the server's own machine or its network: the server address, as before (the computer is in Settings'
+ // "Where ComfyUI runs").
+ if (!hosted)
+ return (
+ <div className={cn("w-full min-w-0 space-y-3 sm:max-w-[36rem]", className)}>
+ {state}
+ {computer ? serverOpen && serverBox : serverForm}
</div>
- <div className="rounded-2xl border border-dashed p-4">
- <button type="button" className="flex w-full items-start gap-3 text-left" onClick={() => setLink((v) => !v)} aria-expanded={link || linked}>
- <Globe className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
- <span className="min-w-0 flex-1">
- <span className="block text-[13px] font-medium">Run from anywhere with a link</span>
- <span className="block text-[12px] text-muted-foreground">For runs that go on with this tab closed. You&apos;ll need a tunnel.</span>
- </span>
- <ChevronDown className={cn("mt-0.5 size-4 shrink-0 text-muted-foreground transition-transform", (link || linked) && "rotate-180")} />
- </button>
- {(link || linked) && (
- <div className="mt-3">
- <YourGpu className={className} onLinked={onStart} />
- </div>
- )}
+ );
+ // A phone, Safari, a plain-http page: what the computer said last (if it runs there), why not here, and the server way.
+ if (support !== "ok")
+ return (
+ <div className={cn("w-full min-w-0 space-y-3 sm:max-w-[36rem]", className)}>
+ {state}
+ <p className="rounded-xl bg-muted px-3 py-2.5 text-[13px] text-muted-foreground">{unsupportedWords(support, true)}</p>
+ {serverBox}
</div>
- </div>
+ );
+ if (computer && !flow)
+ return (
+ <FindHere.Provider value={() => setServerOpen(false)}>
+ <div className={cn("w-full min-w-0 space-y-3 sm:max-w-[36rem]", className)}>
+ {state}
+ {serverOpen && serverBox}
+ </div>
+ </FindHere.Provider>
+ );
+ return (
+ <FindHere.Provider value={findHere}>
+ <ChoiceCards
+ className={className}
+ instead={serverConnected}
+ title="Use a ComfyUI on a server"
+ sub="A cloud GPU or a tunnel address. Runs go on with this tab closed."
+ open={open}
+ onToggle={() => setServerOpen(!open)}
+ computer={<div onClickCapture={() => setFlow(true)}>{armed === "tap" ? findButton : thisComputer}</div>}
+ >
+ {serverForm}
+ </ChoiceCards>
+ </FindHere.Provider>
);
}
/**
- * The owner's "Where ComfyUI runs" (Settings → Open-source engine · ComfyUI): on this server, at the address below, or
- * on the computer the owner uses, which the owner's own Fuobe tab runs (a studio on a server, a GPU at home).
+ * The owner's "Where ComfyUI runs" (Settings → Open-source engine · ComfyUI, on the server's own machine or network):
+ * on this server, at the address below, or on the computer the owner uses, which the owner's own Fuobe tab runs.
*/
export function OwnerComfyWhere({ value, onChange }: { value: string; onChange: (v: "server" | "computer") => Promise<unknown> }) {
const qc = useQueryClient();
@@ -339,7 +623,8 @@ export function OwnerComfyWhere({ value, onChange }: { value: string; onChange:
);
}
-function OwnerComputerLine() {
+/** "This computer · RTX 5090 · port 8188 · Ready" (or what's wrong), as this browser's tab sees it. */
+export function OwnerComputerLine() {
const here = useHere();
const mine = here && !here.other ? here : null;
const facts = mine?.facts;
diff --git a/src/components/gpu/connect-gpu.tsx b/src/components/gpu/connect-gpu.tsx
index 221f0f93..8c2c135b 100644
--- a/src/components/gpu/connect-gpu.tsx
+++ b/src/components/gpu/connect-gpu.tsx
@@ -8,11 +8,14 @@ import { useEffect, useRef } from "react";
import { PreflightChecklist } from "@/components/gpu/preflight-checklist";
import { ReadinessBoard } from "@/components/gpu/readiness-board";
import { ConnectChoice } from "@/components/gpu/connect-choice";
+import { useSettings } from "@/components/connect-field";
+import { usePagePlace } from "@/components/gpu/use-local-comfy";
import { KeyInstead } from "@/components/keys/your-keys";
import { Button } from "@/components/ui/button";
import { Skeleton } from "@/components/ui/skeleton";
import { useGpuCheck, useGpuReadiness } from "@/hooks/use-gpu";
import { signInHref, useStatus, useViewer } from "@/lib/api";
+import { ownerSteer } from "@/lib/page-place";
import { safeNext } from "@/lib/safe-redirect";
/**
@@ -45,6 +48,15 @@ export function ConnectGpu() {
});
const g = gpu.data?.gpu;
const url = g ? (g.mode === "computer" ? "this computer" : g.url) : null;
+ // The owner of a hosted studio with no ComfyUI connected: where it runs comes first (the server's own address would
+ // be the server itself, never the owner's computer), and nothing is checked until then.
+ const owner = !!viewer?.owner;
+ const place = usePagePlace();
+ const status = useStatus().data;
+ const ownerSettings = useSettings(owner).data;
+ const comfyWhere = ownerSettings?.find((s) => s.name === "comfyWhere")?.value;
+ const steer = owner ? ownerSteer(place, status, ownerSettings ? comfyWhere || "server" : undefined) : null;
+ const ownerSetup = steer === "hosted";
const lastUrl = useRef<string | null | undefined>(undefined);
useEffect(() => {
if (!isAccount || gpu.isLoading) return;
@@ -55,14 +67,14 @@ export function ConnectGpu() {
const view = r.data;
const auto = useRef<string | null>(null);
useEffect(() => {
- if (!view?.connected || check.running || (view.wait ?? 0) > 0) return;
+ if (!view?.connected || check.running || (view.wait ?? 0) > 0 || ownerSetup || (owner && steer === null)) return;
const old = view.checkedAt == null || view.stale || Date.now() - view.checkedAt > 60_000;
const key = `${url ?? "install"}`;
if (old && auto.current !== key) {
auto.current = key;
void check.start();
}
- }, [view, check, url]);
+ }, [view, check, url, ownerSetup, owner, steer]);
const title = welcome ? "Welcome! Connect your GPU" : "Connect your GPU";
const lead = "Make things on your own graphics card with ComfyUI. It's free, private and has no run limit. Fuobe checks what your ComfyUI has, and shows what each studio still needs.";
@@ -125,6 +137,18 @@ export function ConnectGpu() {
</div>
);
+ if (ownerSetup)
+ return (
+ <div className="space-y-6">
+ {header(1)}
+ <Card>
+ <h2 className="mb-3 text-[16px] font-semibold">Where is ComfyUI running?</h2>
+ <ConnectChoice className="sm:max-w-none" />
+ </Card>
+ {done(false)}
+ </div>
+ );
+
const reason = view && !view.connected ? view.reason : undefined;
if (reason === "off")
return (
@@ -170,7 +194,7 @@ export function ConnectGpu() {
</Link>
) : (
<Link href="/settings#comfyui" className="text-[13px] text-brand-text underline-offset-2 hover:underline">
- The studio&apos;s ComfyUI
+ {view?.target === "computer" ? "Change where it runs" : "The studio's ComfyUI"}
</Link>
)}
</div>
diff --git a/src/components/gpu/readiness-chip.tsx b/src/components/gpu/readiness-chip.tsx
index 0723d300..74f7c6d7 100644
--- a/src/components/gpu/readiness-chip.tsx
+++ b/src/components/gpu/readiness-chip.tsx
@@ -2,7 +2,7 @@
import { CheckCircle2, Cpu, Download, Layers } from "lucide-react";
import { badgeState, badgeText } from "@/hooks/use-gpu";
-import { useStatus } from "@/lib/api";
+import { ownGpuOf, useStatus } from "@/lib/api";
import type { Badge } from "@/lib/gpu/types";
import { cn } from "@/lib/utils";
@@ -55,7 +55,8 @@ export function CardChip({ badge, gpu }: { badge: Badge; gpu?: string }) {
* isn't there right now (ComfyUI closed, without Fuobe's setting, a link that doesn't answer) says that instead.
*/
export function HeaderPill({ badge, gpu, onOpen, compact }: { badge: Badge; gpu?: string; onOpen?: () => void; compact?: boolean }) {
- const own = useStatus().data?.viewer?.gpu;
+ // The viewer's own GPU: an account's, or the owner's computer (whose tab says whether ComfyUI is there now).
+ const own = ownGpuOf(useStatus().data);
const s = badgeState(badge);
const t = badgeText(badge, gpu);
const tenths = badge[2];
diff --git a/src/components/gpu/this-computer.tsx b/src/components/gpu/this-computer.tsx
index 131a4984..5b71372b 100644
--- a/src/components/gpu/this-computer.tsx
+++ b/src/components/gpu/this-computer.tsx
@@ -95,7 +95,14 @@ const UNSUPPORTED: Record<"safari" | "phone" | "http", string> = {
http: "Your browser only lets a secure page reach apps on this computer. Open the studio over https, or on the computer that runs ComfyUI, or run from anywhere with a link.",
};
-export const unsupportedWords = (why: "safari" | "phone" | "http") => UNSUPPORTED[why];
+/** The owner's second way is a ComfyUI at a server address (a cloud GPU, a tunnel), not an account's link. */
+const UNSUPPORTED_OWNER: Record<"safari" | "phone" | "http", string> = {
+ phone: "Your phone can't run ComfyUI. Open Fuobe on your computer to use its ComfyUI, or use a ComfyUI on a server below.",
+ safari: "Safari can't reach apps on this computer from a website. Open Fuobe in Chrome, Edge or Firefox to use your ComfyUI directly, or use a ComfyUI on a server below.",
+ http: "Your browser only lets a secure page reach apps on this computer. Open the studio over https, or on the computer that runs ComfyUI, or use a ComfyUI on a server below.",
+};
+
+export const unsupportedWords = (why: "safari" | "phone" | "http", owner = false) => (owner ? UNSUPPORTED_OWNER : UNSUPPORTED)[why];
/** Save a file the page made (the start file, the guard). */
function save(name: string, text: string) {
@@ -268,7 +275,7 @@ function readyLine(board: ReadinessView | null | undefined): string | null {
}
/** The connected screen: the GPU, what's ready, and the run starting (when it was opened from one). */
-function Celebration({ c, fromRun, kind, onStart, onNotNow }: { c: Connected; fromRun?: boolean; kind?: string; onStart?: () => void; onNotNow?: () => void }) {
+function Celebration({ c, fromRun, kind, onStart, onNotNow, doneWords }: { c: Connected; fromRun?: boolean; kind?: string; onStart?: () => void; onNotNow?: () => void; doneWords?: string }) {
const facts = statsFacts(c.stats, origin(), c.guard);
const gpu = [facts.device && deviceLabel(facts.device), gib(facts.vramBytes), facts.version && `ComfyUI ${facts.version}`].filter(Boolean).join(" · ");
const ready = readyLine(c.board);
@@ -357,7 +364,7 @@ function Celebration({ c, fromRun, kind, onStart, onNotNow }: { c: Connected; fr
</Button>
</div>
) : (
- !fromRun && <p className="text-[13px] text-muted-foreground">Done. Runs from the Image, Video and Audio studios now use your GPU. Keep a Fuobe tab open while they run.</p>
+ !fromRun && <p className="text-[13px] text-muted-foreground">{doneWords ?? "Done. Runs from the Image, Video and Audio studios now use your GPU. Keep a Fuobe tab open while they run."}</p>
)}
</div>
);
@@ -377,6 +384,10 @@ export interface ThisComputerProps {
autoLook?: boolean;
/** ComfyUI had Fuobe's setting before, and runs without it now (the fix says so). */
again?: boolean;
+ /** The last line once connected, when it wasn't opened from a run (the owner's own words). */
+ doneWords?: string;
+ /** Changes when something outside asks to look now ("Use the ComfyUI on this computer" under a refused address). */
+ lookNow?: number;
}
/** Is Fuobe's guard in this ComfyUI (it answers at /fuobe/guard)? */
@@ -387,7 +398,7 @@ const guardAt = (port: number, host: string) =>
);
/** The whole flow, from "Find my ComfyUI" to connected. */
-export function ThisComputer({ connect, fromRun, kind, onStart, onNotNow, autoLook, again }: ThisComputerProps) {
+export function ThisComputer({ connect, fromRun, kind, onStart, onNotNow, autoLook, again, doneWords, lookNow }: ThisComputerProps) {
const qc = useQueryClient();
const { state, look, choose } = useLocalComfy(true);
const [done, setDone] = useState<Connected | null>(null);
@@ -401,6 +412,14 @@ export function ThisComputer({ connect, fromRun, kind, onStart, onNotNow, autoLo
void look();
}, [autoLook, state.s, look]);
+ // Asked from outside: look now (from the start screen, or after nothing answered).
+ const looked = useRef(lookNow ?? 0);
+ useEffect(() => {
+ if (!lookNow || lookNow === looked.current) return;
+ looked.current = lookNow;
+ if (state.s === "start" || state.s === "none") void look();
+ }, [lookNow, state.s, look]);
+
// Found and readable: connect with no click, then check what it has.
useEffect(() => {
if (state.s !== "found") return;
@@ -440,7 +459,7 @@ export function ThisComputer({ connect, fromRun, kind, onStart, onNotNow, autoLo
})();
}, [state, connect, qc]);
- if (done) return <Celebration c={done} fromRun={fromRun} kind={kind} onStart={onStart} onNotNow={onNotNow} />;
+ if (done) return <Celebration c={done} fromRun={fromRun} kind={kind} onStart={onStart} onNotNow={onNotNow} doneWords={doneWords} />;
return (
<div className="space-y-3 text-[13px]">
<Screen state={state} look={look} choose={choose} again={again} />
diff --git a/src/components/guest-prompt.tsx b/src/components/guest-prompt.tsx
index 47443859..2f460730 100644
--- a/src/components/guest-prompt.tsx
+++ b/src/components/guest-prompt.tsx
@@ -33,7 +33,7 @@ export function GuestPrompt() {
// Opened by the runner's note: ComfyUI needs Fuobe's setting again, find ComfyUI, or let this browser reach it.
const [reason, setReason] = useState<FindReason | undefined>(undefined);
// What was refused: a run (or any other change), or a file of the visitor's own.
- const [action, setAction] = useState<RefusalAction>("run");
+ const [action, setAction] = useState<RefusalAction | "connect">("run");
const [retry, setRetry] = useState<{ retry: () => void; kind?: string } | null>(null);
const close = useCallback(() => {
setOpen(false);
@@ -112,7 +112,7 @@ export function GuestPrompt() {
"Your files are kept for your own runs on your own ComfyUI."
)
) : (
- <>Fuobe runs this on the ComfyUI on your computer. It&apos;s free and private.</>
+ <>{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>
{/* Paid models run on the account's own key instead (Your keys), when the studio allows them. */}
@@ -187,9 +187,11 @@ function logInAgain(who: "owner" | "account", here?: string): string {
return `${href}${href.includes("?") ? "&" : "?"}owner=1`;
}
-const TITLES: Record<FindReason | RefusalAction, string> = {
+const TITLES: Record<FindReason | RefusalAction | "connect", string> = {
run: "Connect your GPU to run this",
upload: "Connect your GPU or add a key to add your own files",
+ // Opened with no run waiting (the setup guide, the sidebar's Connect).
+ connect: "Connect your GPU",
setting: "Your ComfyUI needs Fuobe's setting again",
find: "Find your ComfyUI",
browser: "Run your GPU jobs from this browser",
diff --git a/src/components/home-view.tsx b/src/components/home-view.tsx
index 92f36ba1..4f659dc4 100644
--- a/src/components/home-view.tsx
+++ b/src/components/home-view.tsx
@@ -5,6 +5,7 @@ import { ArrowRight, CircleAlert, ImageIcon, Loader2, MessageCircle, Video, Wand
import { useRouter, useSearchParams } from "next/navigation";
import { lazy, Suspense, useCallback, useEffect, useRef, useState } from "react";
import { GetStarted } from "@/components/get-started";
+import { usePagePlace } from "@/components/gpu/use-page-place";
import { GitHubMark } from "@/components/github-mark";
import { PageShell } from "@/components/page-shell";
import { Skeleton } from "@/components/ui/skeleton";
@@ -170,6 +171,8 @@ export function HomeView({
const statusData = useStatus().data;
const status = hydrated ? statusData : undefined;
const nothingConnected = !!status && noConnection(status);
+ // A hosted studio: the owner's GPU is connected from here (the dialog), not by an address in Settings.
+ const hostedPage = usePagePlace() === "hosted";
// Until something is connected (or it's put away): three ways to start, under the composer. The
// static shell (no status yet) shows it only in a browser where it showed last time
// (FirstRunScript), so a visitor to a public studio, who never gets it, doesn't see it come and go.
@@ -400,9 +403,15 @@ export function HomeView({
) : nothingConnected && !status?.viewer && (
<p className="mt-4 text-[13px] text-muted-foreground">
You’re in <span className="font-medium text-foreground">demo mode</span> — outputs are placeholders.{" "}
- <Link href="/settings#get-started" className="text-brand-text underline underline-offset-2">
- {engineMode === "open" ? "Connect ComfyUI" : engineMode === "cloud" ? "Add a fal.ai or Replicate key" : "Add a fal.ai key or connect ComfyUI"}
- </Link>{" "}
+ {hostedPage && engineMode !== "cloud" ? (
+ <button type="button" onClick={() => window.dispatchEvent(new Event(CONNECT_GPU_EVENT))} className="text-brand-text underline underline-offset-2">
+ Connect your GPU
+ </button>
+ ) : (
+ <Link href="/settings#get-started" className="text-brand-text underline underline-offset-2">
+ {engineMode === "open" ? "Connect ComfyUI" : engineMode === "cloud" ? "Add a fal.ai or Replicate key" : "Add a fal.ai key or connect ComfyUI"}
+ </Link>
+ )}{" "}
to generate for real.
</p>
)}
diff --git a/src/components/settings-form.tsx b/src/components/settings-form.tsx
index ced4da15..805ce554 100644
--- a/src/components/settings-form.tsx
+++ b/src/components/settings-form.tsx
@@ -7,7 +7,8 @@ import { useRouter } from "next/navigation";
import { useEffect, useState, useSyncExternalStore } from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
-import { OwnerComfyWhere } from "@/components/gpu/connect-choice";
+import { ConnectChoice, OwnerComfyWhere } from "@/components/gpu/connect-choice";
+import { usePagePlace } from "@/components/gpu/use-local-comfy";
import { Label } from "@/components/ui/label";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Skeleton } from "@/components/ui/skeleton";
@@ -158,12 +159,13 @@ function ChoiceField({
* each a link to its field), the engine mode and, for the owner, the accounts. Also opens the setup guide again.
*/
function StatusStrip({ status, onGuide, guideOpen }: { status?: StatusInfo; onGuide: () => void; guideOpen: boolean }) {
+ const place = usePagePlace();
return (
<div className="sticky top-12 z-10 -mx-4 border-b bg-background/90 px-4 py-2.5 backdrop-blur sm:-mx-8 sm:px-8 md:top-0">
<nav aria-label="Connections" className="scrollbar-none -my-1 flex items-center gap-1.5 overflow-x-auto py-1">
{status ? (
<>
- {connectionSummary(status).map((c) => (
+ {connectionSummary(status, place).map((c) => (
<a
key={c.id}
href={c.href}
@@ -468,11 +470,31 @@ function LocalLlmSettings({ get, set }: { get: (n: string) => PublicSetting | un
);
}
+/** The studio's own ComfyUI on the server's machine or network: where it runs, then its address, token and isolated worker. */
+function LocalComfy({ get, onWhere }: { get: (n: string) => PublicSetting | undefined; onWhere: (v: "server" | "computer") => Promise<unknown> }) {
+ return (
+ <>
+ <OwnerComfyWhere value={get("comfyWhere")?.value || "server"} onChange={onWhere} />
+ <ConnectField name="comfyUrl" setting={get("comfyUrl")} provider="comfyui" label="ComfyUI server URL" placeholder="http://127.0.0.1:8188" hint="Where ComfyUI listens; a local install is http://127.0.0.1:8188." />
+ <ConnectField name="comfyToken" setting={get("comfyToken")} provider="comfyui" label="Auth token (optional)" hint="Sent as a Bearer token, for ComfyUI behind a proxy." />
+ <ConnectField
+ name="comfyIsolatedUrl"
+ setting={get("comfyIsolatedUrl")}
+ provider="comfyui"
+ label="Isolated worker URL (optional)"
+ placeholder="http://127.0.0.1:8189"
+ hint="A second ComfyUI for LatentSync 1.6 and ThinkSound, whose node packs can't share the main install. scripts/comfy/README.md shows how to start one."
+ />
+ </>
+ );
+}
+
export function SettingsForm({ prices }: { prices?: string }) {
const qc = useQueryClient();
const router = useRouter();
const settings = useSettings();
const status = useStatus().data;
+ const place = usePagePlace();
// The setup guide on request: the strip's "Setup guide", or a link to /settings#get-started (Home's demo line).
const [guide, setGuide] = useState<boolean | null>(null);
const askedByLink = useSyncExternalStore(subscribeHash, () => window.location.hash === "#get-started", () => false);
@@ -506,6 +528,9 @@ export function SettingsForm({ prices }: { prices?: string }) {
</div>
);
const mode = get("engineMode")?.value || "both";
+ // A hosted studio (this page isn't on the server's machine): the owner's GPU is first the ComfyUI on this computer.
+ const hosted = place === "hosted" && mode !== "cloud";
+ const onComputer = get("comfyWhere")?.value === "computer";
// The guide opens by itself on a first run, and on request ("Setup guide") after that.
const firstRun = showFirstRun(status);
const guideOpen = !!status && (firstRun || (guide ?? askedByLink));
@@ -586,27 +611,27 @@ export function SettingsForm({ prices }: { prices?: string }) {
id="comfyui"
title="Open-source engine · ComfyUI"
description={
- <>
- Run every open-source workflow on your own GPU (or a rented one). Fuobe talks to ComfyUI&apos;s HTTP API and uploads inputs for you. See{" "}
- <Link href="/workflows" className="text-brand-text underline-offset-2 hover:underline">
- ComfyUI workflows
- </Link>{" "}
- for the models each one needs.
- </>
+ hosted ? (
+ <>
+ Run every open-source workflow on your own graphics card. See{" "}
+ <Link href="/workflows" className="text-brand-text underline-offset-2 hover:underline">
+ ComfyUI workflows
+ </Link>{" "}
+ for the models each one needs.
+ </>
+ ) : (
+ <>
+ Run every open-source workflow on your own GPU (or a rented one). Fuobe talks to ComfyUI&apos;s HTTP API and uploads inputs for you. See{" "}
+ <Link href="/workflows" className="text-brand-text underline-offset-2 hover:underline">
+ ComfyUI workflows
+ </Link>{" "}
+ for the models each one needs.
+ </>
+ )
}
inactive={mode === "cloud" ? "Not used in Paid APIs only mode" : undefined}
>
- <OwnerComfyWhere value={get("comfyWhere")?.value || "server"} onChange={(v) => save.mutateAsync({ comfyWhere: v })} />
- <ConnectField name="comfyUrl" setting={get("comfyUrl")} provider="comfyui" label="ComfyUI server URL" placeholder="http://127.0.0.1:8188" hint="Where ComfyUI listens; a local install is http://127.0.0.1:8188." />
- <ConnectField name="comfyToken" setting={get("comfyToken")} provider="comfyui" label="Auth token (optional)" hint="Sent as a Bearer token, for ComfyUI behind a proxy." />
- <ConnectField
- name="comfyIsolatedUrl"
- setting={get("comfyIsolatedUrl")}
- provider="comfyui"
- label="Isolated worker URL (optional)"
- placeholder="http://127.0.0.1:8189"
- hint="A second ComfyUI for LatentSync 1.6 and ThinkSound, whose node packs can't share the main install. scripts/comfy/README.md shows how to start one."
- />
+ {hosted ? <ConnectChoice /> : <LocalComfy get={get} onWhere={(v) => save.mutateAsync({ comfyWhere: v })} />}
</Section>
<Section
@@ -614,6 +639,11 @@ export function SettingsForm({ prices }: { prices?: string }) {
title="LoRAs · looks, motions, effects and adapters"
description="Looks, camera moves and effects add LoRA files to open models, on your GPU and in the cloud; an adapter is the LoRA an Original always loads (Fuobe Try-On's). Fuobe fetches the pinned version a run needs and shows each file's licence; what may run where is your call in Models & licences."
>
+ {onComputer && (
+ <p className="flex items-start gap-1.5 text-[13px] text-muted-foreground">
+ <Info aria-hidden className="mt-0.5 size-3.5 shrink-0 text-brand-text" /> Your ComfyUI is on your computer: put LoRA files in its models/loras folder. Fuobe tells you which ones a run needs.
+ </p>
+ )}
<LoraSettings folder={get("comfyLorasDir")} civitaiKey={get("civitaiKey")} />
</Section>
diff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsx
index f27369b5..b6dcda91 100644
--- a/src/components/studio/composer.tsx
+++ b/src/components/studio/composer.tsx
@@ -17,7 +17,8 @@ import { dualEngine } from "@/lib/catalog/engines";
import { locksByDefault } from "@/lib/catalog/palettes";
import { DEFAULT_LOOK, lookCard } from "@/lib/catalog/soul-cards";
import { formatsOf } from "@/lib/av/formats";
-import { enhance, useClipFacts, useCreateGeneration, useElements, useEngine, useHydrated, useStatus } from "@/lib/api";
+import { CONNECT_GPU_EVENT, enhance, useClipFacts, useCreateGeneration, useElements, useEngine, useHydrated, useStatus } from "@/lib/api";
+import { usePagePlace } from "@/components/gpu/use-page-place";
import { applyMentions, type StudioElement } from "@/lib/catalog/elements";
import { applySketch, stripMotionPaths } from "@/lib/catalog/sketch";
import {
@@ -247,6 +248,8 @@ export function Composer({ docked }: { docked: boolean }) {
const hydrated = useHydrated();
const liveStatus = useStatus().data;
const status = hydrated ? liveStatus : undefined;
+ // A hosted studio: the owner connects a GPU from the dialog ("Connect your GPU"), not with an address in Settings.
+ const hostedPage = usePagePlace() === "hosted";
// The day a launch price is read on: the browser's, once hydrated (none while the page prerenders: no price shown then).
const today = useToday();
// Upscale hub: the attached clip's header (length, size, frame rate). Its length prices per-second tools and
@@ -1232,9 +1235,15 @@ export function Composer({ docked }: { docked: boolean }) {
{engineMode === "cloud"
? "This install runs paid cloud APIs only (Settings → Engine mode), and no cloud API re-encodes a finished clip: export formats are written by ComfyUI on your own machine."
: config.comfyOnly!.note}{" "}
- <Link href="/settings" className="font-medium text-brand-text underline-offset-2 hover:underline">
- Open Settings
- </Link>
+ {hostedPage && engineMode !== "cloud" && !status?.viewer ? (
+ <button type="button" onClick={() => window.dispatchEvent(new Event(CONNECT_GPU_EVENT))} className="font-medium text-brand-text underline-offset-2 hover:underline">
+ Connect your GPU
+ </button>
+ ) : (
+ <Link href="/settings" className="font-medium text-brand-text underline-offset-2 hover:underline">
+ Open Settings
+ </Link>
+ )}
</p>
{alternative && alternativeHref && engineMode !== "open" && (
<p>
diff --git a/src/components/workflows-view.tsx b/src/components/workflows-view.tsx
index 3eaadbfb..85a965b1 100644
--- a/src/components/workflows-view.tsx
+++ b/src/components/workflows-view.tsx
@@ -9,6 +9,9 @@ import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Skeleton } from "@/components/ui/skeleton";
import { useProgressive } from "@/components/use-progressive";
+import { usePagePlace } from "@/components/gpu/use-page-place";
+import { CONNECT_GPU_EVENT, useStatus } from "@/lib/api";
+import { timeAgo } from "@/lib/format";
import { copyText } from "@/lib/clipboard";
import type { ManifestWorkflow } from "@/lib/comfy";
import { installScript, workflowSource } from "@/lib/comfy-install";
@@ -21,6 +24,9 @@ type WF = Omit<ManifestWorkflow, "models"> & { models: (ManifestWorkflow["models
interface ComfyStatus {
/** null: a visitor, who isn't told about the studio's own ComfyUI (their own is on /connect). */
reachable: boolean | null;
+ /** "computer": the owner's ComfyUI runs on the owner's computer; the checkmarks are from its tab's last check (`checkedAt`). */
+ where?: "computer";
+ checkedAt?: number | null;
generatedAt: string;
comfyuiCommit?: string;
workflows: WF[];
@@ -30,7 +36,67 @@ async function fetchStatus(): Promise<ComfyStatus> {
const res = await fetch("/api/comfyui");
const body = (await res.json().catch(() => ({}))) as Partial<ComfyStatus> & { error?: string };
if (!res.ok) throw new Error(body.error ?? `Couldn’t load the workflow library (${res.status})`);
- return { reachable: body.reachable === null ? null : !!body.reachable, generatedAt: body.generatedAt ?? "", comfyuiCommit: body.comfyuiCommit, workflows: body.workflows ?? [] };
+ return {
+ reachable: body.reachable === null ? null : !!body.reachable,
+ ...(body.where === "computer" && { where: "computer" as const, checkedAt: body.checkedAt ?? null }),
+ generatedAt: body.generatedAt ?? "",
+ comfyuiCommit: body.comfyuiCommit,
+ workflows: body.workflows ?? [],
+ };
+}
+
+/** The owner's banner: where ComfyUI is, whether it answers, and what the checkmarks mean. */
+function OwnerBanner({ data }: { data: ComfyStatus }) {
+ const status = useStatus().data;
+ const place = usePagePlace();
+ const cls = (ok: boolean) => cn("flex flex-wrap items-center gap-3 rounded-xl border px-4 py-3 text-[13px]", ok ? "bg-background" : "bg-brand-faint");
+ const link = "text-brand-text underline underline-offset-2";
+ if (data.where === "computer") {
+ const checked = data.checkedAt ?? null;
+ return (
+ <div className={cls(!!checked)}>
+ {checked ? <CheckCircle2 className="size-4 shrink-0 text-success" /> : <CircleAlert className="size-4 shrink-0 text-brand-text" />}
+ <span className="min-w-0 flex-1 basis-56">
+ {checked ? `Checked on your computer ${timeAgo(checked)}. Checkmarks show the models it has.` : "Your GPU is the ComfyUI on your computer. Check it to see which models it has."}
+ </span>
+ <Link href="/connect" className={link}>
+ {checked ? "Check again" : "Check your GPU"}
+ </Link>
+ </div>
+ );
+ }
+ if (data.reachable)
+ return (
+ <div className={cls(true)}>
+ <CheckCircle2 className="size-4 shrink-0 text-success" />
+ <span className="min-w-0 flex-1 basis-56">Connected to ComfyUI — model checkmarks below reflect what’s installed.</span>
+ <Link href="/settings#comfyui" className={link}>
+ Server settings
+ </Link>
+ </div>
+ );
+ // Nothing answers. A hosted studio: the owner's GPU is to be connected (the server's own address isn't the owner's).
+ if (place === "hosted")
+ return (
+ <div className={cls(false)}>
+ <CircleAlert className="size-4 shrink-0 text-brand-text" />
+ <span className="min-w-0 flex-1 basis-56">ComfyUI isn&apos;t connected yet. Connect your GPU to run these on your own graphics card.</span>
+ <Button size="sm" onClick={() => window.dispatchEvent(new Event(CONNECT_GPU_EVENT))}>
+ Connect your GPU
+ </Button>
+ </div>
+ );
+ return (
+ <div className={cls(false)}>
+ <CircleAlert className="size-4 shrink-0 text-warning" />
+ <span className="min-w-0 flex-1 basis-56">
+ {status?.demoMode === "off" ? "ComfyUI is not reachable, so open-source runs can’t start." : "ComfyUI is not reachable, so open-source runs fall back to demo output."}
+ </span>
+ <Link href="/settings#comfyui" className={link}>
+ Server settings
+ </Link>
+ </div>
+ );
}
/**
@@ -229,15 +295,7 @@ export function WorkflowsView({ routes = [] }: { routes?: ComfyRoute[] }) {
</Link>
</div>
) : (
- <div className={cn("flex flex-wrap items-center gap-3 rounded-xl border px-4 py-3 text-[13px]", data.reachable ? "bg-background" : "bg-brand-faint")}>
- {data.reachable ? <CheckCircle2 className="size-4 shrink-0 text-success" /> : <CircleAlert className="size-4 shrink-0 text-warning" />}
- <span className="min-w-0 flex-1 basis-56">
- {data.reachable ? "Connected to ComfyUI — model checkmarks below reflect what’s installed." : "ComfyUI is not reachable, so open-source runs fall back to demo output."}
- </span>
- <Link href="/settings#comfyui" className="text-brand-text underline underline-offset-2">
- Server settings
- </Link>
- </div>
+ <OwnerBanner data={data} />
)}
{workflows.length > 0 && (
<div className="flex flex-col gap-2 sm:flex-row sm:items-center">
diff --git a/tests/e2e/_browser.mjs b/tests/e2e/_browser.mjs
index 951ec0c3..555c5363 100644
--- a/tests/e2e/_browser.mjs
+++ b/tests/e2e/_browser.mjs
@@ -34,9 +34,10 @@ export function chromiumPath() {
return exe && fs.existsSync(exe) ? exe : undefined;
}
-export async function launch() {
+/** `opts`: more launch options (`args`: Chromium flags, such as a host name mapped to this machine). */
+export async function launch(opts = {}) {
const { chromium } = loadPlaywright();
- return chromium.launch({ executablePath: chromiumPath() });
+ return chromium.launch({ executablePath: chromiumPath(), ...opts });
}
export const PHONE = { viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true };
diff --git a/tests/e2e/owner-computer.mjs b/tests/e2e/owner-computer.mjs
new file mode 100644
index 00000000..037b6d7d
--- /dev/null
+++ b/tests/e2e/owner-computer.mjs
@@ -0,0 +1,517 @@
+// The owner's "Use the ComfyUI on this computer" on a hosted studio, end to end in Chromium. A production server on
+// 3375 with a throwaway data folder; stand-in ComfyUIs (tests/helpers/fake-local-comfy.ts): the owner's computer on
+// 3376, the account's on 3378, and (E2E_MODE=local) the server's own on 3377. Nothing listens on 3399.
+//
+// Hosted (E2E_MODE=hosted, the default): the page is http://studio.test:3375, a name Chromium maps to this machine, so
+// the studio reads as hosted (lib/page-place.ts) while the browser still reaches only loopback. The browser treats it
+// as secure (as https would be), so it may ask to reach apps on this computer.
+// Local (E2E_MODE=local): the page is http://127.0.0.1:3375, the server's ComfyUI at 127.0.0.1:3377, as before.
+//
+// Every loopback request but the studio's and the stand-ins' is refused before it leaves the browser, so a real
+// ComfyUI on 8188 is never touched.
+//
+// pnpm build && node tests/e2e/owner-computer.mjs && E2E_MODE=local node tests/e2e/owner-computer.mjs
+import { spawn } from "node:child_process";
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { DatabaseSync } from "node:sqlite";
+import { launch, root } from "./_browser.mjs";
+
+const MODE = process.env.E2E_MODE === "local" ? "local" : "hosted";
+const HOSTED = MODE === "hosted";
+const APP_PORT = Number(process.env.E2E_APP_PORT ?? 3375);
+const PC_PORT = Number(process.env.E2E_PC_PORT ?? 3376);
+const SERVER_COMFY_PORT = Number(process.env.E2E_SERVER_COMFY_PORT ?? 3377);
+const ACCOUNT_PORT = Number(process.env.E2E_ACCOUNT_PORT ?? 3378);
+const DEAD_PORT = 3399;
+const SITE = HOSTED ? `http://studio.test:${APP_PORT}` : `http://127.0.0.1:${APP_PORT}`;
+const LOCAL = `http://127.0.0.1:${APP_PORT}`;
+const shots = process.env.E2E_SHOTS ?? fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-owner-computer-shots-"));
+fs.mkdirSync(shots, { recursive: true });
+const data = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-owner-computer-e2e-"));
+const PASSWORD = `e2e-${Math.random().toString(36).slice(2)}`;
+const results = [];
+const check = (name, ok, detail = "") => {
+ results.push({ name, ok: !!ok, detail });
+ console.log(`${ok ? "PASS" : "FAIL"} ${name}${detail ? ` — ${detail}` : ""}`);
+};
+const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
+async function until(fn, ms = 30_000, every = 250) {
+ const end = Date.now() + ms;
+ for (;;) {
+ try {
+ const v = await fn();
+ if (v) return v;
+ } catch {}
+ if (Date.now() > end) return null;
+ await sleep(every);
+ }
+}
+
+// --- Stand-in ComfyUIs, each its own process (a restart is a new process, as for the real one).
+const fakes = new Map();
+async function startFake(port, cors, o = {}) {
+ const args = ["--port", String(port), "--cors", cors, "--steps", "6", "--step-ms", "200", "--has", path.join(root, "workflows/comfyui/requirements.json"), ...(o.guard ? ["--guard", "1"] : [])];
+ const p = spawn(process.execPath, ["--disable-warning=MODULE_TYPELESS_PACKAGE_JSON", path.join(root, "tests/helpers/fake-local-comfy.ts"), ...args], { stdio: ["ignore", "ignore", "inherit"] });
+ fakes.set(port, p);
+ await until(() => fetch(`http://127.0.0.1:${port}/__fake/stats`).then((r) => r.ok), 15_000);
+}
+async function stopFake(port) {
+ const p = fakes.get(port);
+ if (!p) return;
+ fakes.delete(port);
+ p.kill();
+ await until(() => fetch(`http://127.0.0.1:${port}/__fake/stats`).then(() => false, () => true), 10_000);
+}
+const posts = async (port) => (await fetch(`http://127.0.0.1:${port}/__fake/stats`).then((r) => r.json()).catch(() => ({ posts: -1 }))).posts;
+
+// --- The studio.
+const server = spawn(process.execPath, [path.join(root, "node_modules/next/dist/bin/next"), "start", "-p", String(APP_PORT), "-H", "127.0.0.1"], {
+ cwd: root,
+ env: {
+ ...process.env,
+ FUOBE_DATA_DIR: data,
+ FUOBE_PASSWORD: PASSWORD,
+ FUOBE_PUBLIC_SIGNUP: "1",
+ FUOBE_ALLOWED_ORIGINS: SITE,
+ // Hosted: the server's own ComfyUI address answers nothing. Local: the server's stand-in.
+ COMFYUI_URL: HOSTED ? `http://127.0.0.1:${DEAD_PORT}` : `http://127.0.0.1:${SERVER_COMFY_PORT}`,
+ NODE_ENV: "production",
+ },
+ stdio: ["ignore", "pipe", "pipe"],
+});
+let serverLog = "";
+server.stdout.on("data", (d) => (serverLog += d));
+server.stderr.on("data", (d) => (serverLog += d));
+
+let browser;
+async function finish(code) {
+ await browser?.close().catch(() => {});
+ for (const port of [...fakes.keys()]) await stopFake(port).catch(() => {});
+ server.kill();
+ await sleep(800);
+ try {
+ fs.rmSync(data, { recursive: true, force: true });
+ } catch {}
+ const failed = results.filter((r) => !r.ok);
+ console.log(`\n[${MODE}] ${results.length - failed.length}/${results.length} passed. Screenshots: ${shots}`);
+ if (failed.length) console.log(serverLog.split("\n").slice(-30).join("\n"));
+ fs.writeFileSync(path.join(shots, `results-${MODE}.json`), JSON.stringify(results, null, 2));
+ process.exit(code ?? (failed.length ? 1 : 0));
+}
+
+/** Every request this browser sends to a loopback port other than the studio's, and every connection test it sends. */
+async function context(o = {}, allow = [APP_PORT, PC_PORT]) {
+ const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 }, colorScheme: "light", ...o });
+ // Every loopback request the page tried (the finder looks at ComfyUI's usual ports), and the ones let through.
+ ctx.loopback = [];
+ ctx.passed = [];
+ ctx.tests = [];
+ await ctx.route(/^(https?|wss?):\/\/(127\.0\.0\.1|localhost|\[::1\]):\d+/, (route) => {
+ const port = Number(new URL(route.request().url()).port);
+ if (port !== APP_PORT) ctx.loopback.push(`${route.request().method()} ${route.request().url()}`);
+ if (!allow.includes(port)) return route.abort("connectionrefused");
+ if (port !== APP_PORT) ctx.passed.push(port);
+ return route.continue();
+ });
+ ctx.on("request", (r) => {
+ if (r.method() === "POST" && new URL(r.url()).pathname === "/api/providers/test") ctx.tests.push(r.postData() ?? "");
+ });
+ return ctx;
+}
+
+const api = (page, url, init = {}) =>
+ page.evaluate(
+ async ({ url, init }) => {
+ const r = await fetch(url, init);
+ return { status: r.status, headers: Object.fromEntries(r.headers), body: await r.json().catch(() => null) };
+ },
+ { url, init },
+ );
+const send = (page, url, body, method = "POST") => api(page, url, { method, headers: { "content-type": "application/json" }, body: JSON.stringify(body) });
+const runs = async (page) => (await api(page, "/api/generations?limit=20")).body?.items ?? [];
+
+async function signIn(page, who) {
+ await page.goto(`${SITE}/status`, { waitUntil: "load" });
+ const r = who === "owner" ? await send(page, "/api/auth/login", { password: PASSWORD }) : await send(page, "/api/auth/signup", { email: who, password: "long enough password" });
+ if (r.status !== 200 && r.status !== 201) throw new Error(`sign-in answered ${r.status}`);
+}
+
+/** The screen at 1440 and 390, light and dark. */
+async function shoot(page, name, o = {}) {
+ for (const [w, h] of [
+ [1440, 900],
+ [390, 844],
+ ]) {
+ for (const scheme of ["light", "dark"]) {
+ await page.setViewportSize({ width: w, height: h });
+ await page.emulateMedia({ colorScheme: scheme });
+ await sleep(400);
+ if (o.scroll) await page.locator(o.scroll).first().scrollIntoViewIfNeeded().catch(() => {});
+ await page.screenshot({ path: path.join(shots, `${MODE}-${name}-${w}-${scheme}.png`) });
+ }
+ }
+ await page.setViewportSize({ width: 1440, height: 900 });
+ await page.emulateMedia({ colorScheme: "light" });
+ await sleep(200);
+}
+
+async function studio(page, url) {
+ await page.goto(SITE + url, { waitUntil: "load", timeout: 120_000 });
+ await page.waitForSelector("[data-composer-toolbar]", { timeout: 60_000 });
+ await page.waitForFunction(() => Object.keys(document.querySelector("[data-composer-toolbar]") ?? {}).some((k) => k.startsWith("__react")), null, { timeout: 60_000 });
+}
+
+async function generate(page, prompt) {
+ const known = new Set((await runs(page)).map((g) => g.id));
+ await page.locator("[data-composer] textarea").fill(prompt);
+ await page.getByRole("button", { name: "Generate", exact: true }).click();
+ return () => runs(page).then((list) => list.find((g) => !known.has(g.id)));
+}
+
+const ended = (g) => g && (g.status === "succeeded" || g.status === "failed" || g.status === "canceled");
+
+/** The relay task of a run, read from the studio's database (no API shows task ids). */
+function taskOf(generationId) {
+ const db = new DatabaseSync(path.join(data, "fuobe.db"), { readOnly: true });
+ try {
+ return db.prepare("SELECT id, principal, state FROM relay_tasks WHERE generation_id = ?").get(generationId);
+ } finally {
+ db.close();
+ }
+}
+
+try {
+ if (!(await until(() => fetch(`${LOCAL}/api/auth/me`).then((r) => r.ok), 90_000, 500))) throw new Error(`the studio didn't start:\n${serverLog}`);
+ // Hosted: Chromium itself (its new headless mode), which honours the flag that makes the page secure; the older
+ // headless shell ignores it.
+ browser = await launch({
+ ...(HOSTED && { channel: process.env.E2E_CHANNEL ?? "chromium" }),
+ args: HOSTED ? [`--host-resolver-rules=MAP studio.test 127.0.0.1`, `--unsafely-treat-insecure-origin-as-secure=${SITE}`, "--disable-gpu"] : ["--disable-gpu"],
+ });
+
+ if (HOSTED) await hosted();
+ else await local();
+} catch (e) {
+ check("the scenarios ran to the end", false, (e && e.stack) || String(e));
+}
+await finish();
+
+// ---------------------------------------------------------------------------------------------------------------------
+async function hosted() {
+ await startFake(PC_PORT, SITE, { guard: true });
+ const ctx = await context();
+ const page = await ctx.newPage();
+ await signIn(page, "owner");
+ await page.evaluate((port) => localStorage.setItem("fuobe.comfy.port", String(port)), PC_PORT);
+ // As on fuobe.com: open-source models only, no demo.
+ check("settings as on the live studio", (await send(page, "/api/settings", { engineMode: "open", demoMode: "off" }, "PUT")).status === 200);
+
+ // H1. Home's guide: the GPU card offers this computer, and nothing shows the server's 127.0.0.1:8188.
+ await page.goto(`${SITE}/`, { waitUntil: "load" });
+ const card = page.getByRole("region", { name: "Use your GPU" });
+ await card.getByRole("button", { name: "Use the ComfyUI on this computer" }).waitFor({ timeout: 30_000 });
+ check("Home's GPU card: Use the ComfyUI on this computer", true);
+ check("Home's GPU card: the server is the quieter second way", await card.getByRole("button", { name: /ComfyUI on a server or a cloud GPU\?/ }).isVisible());
+ const shown = await page.evaluate(() => document.body.innerText + [...document.querySelectorAll("input")].map((i) => i.value).join(" "));
+ check("no 127.0.0.1:8188 anywhere on Home", !shown.includes("127.0.0.1:8188"));
+ await shoot(page, "home-guide");
+
+ // The bug: the server address typed into the guide is never sent.
+ await card.getByRole("button", { name: /ComfyUI on a server or a cloud GPU\?/ }).click();
+ const field = card.getByRole("textbox", { name: "Server address" });
+ // Only the built-in address: the field is empty and Connect waits. (Here COMFYUI_URL names the server's own 127.0.0.1,
+ // so it shows, and what it means on this website is said at once.)
+ const preset = await field.inputValue();
+ check(
+ "the guide's server field: empty, or the server's own address with what it means here",
+ preset === "" ? await card.getByRole("button", { name: /Connect Server address/ }).isDisabled() : await card.getByText("On this website, 127.0.0.1 is Fuobe's server, not your computer.").isVisible(),
+ preset,
+ );
+ await field.fill("127.0.0.1:8188");
+ await card.getByRole("button", { name: /Save and test Server address/ }).click();
+ const line = await until(() => card.getByText("On this website, 127.0.0.1 is Fuobe's server, not your computer.").isVisible(), 10_000);
+ check("127.0.0.1:8188 in the guide: one line, and the server makes no call", !!line && ctx.tests.length === 0, `tests sent: ${ctx.tests.length}`);
+ check("the line offers this computer right there", await card.getByRole("button", { name: "Use the ComfyUI on this computer" }).nth(1).isVisible());
+ await shoot(page, "home-guide-refused", { scroll: '[aria-label="Use your GPU"]' });
+
+ // The guide's button opens the dialog: Find my ComfyUI → connected, with the owner's words.
+ await card.getByRole("button", { name: "Use the ComfyUI on this computer" }).first().click();
+ const dialog = page.getByRole("dialog");
+ await dialog.getByRole("heading", { name: "Connect your GPU", exact: true }).waitFor({ timeout: 15_000 });
+ check("the dialog says Connect your GPU (no run waiting)", true);
+ check("the dialog: this computer first", await dialog.getByText("Use the ComfyUI on this computer", { exact: true }).first().isVisible());
+ check("the dialog: a ComfyUI on a server second", await dialog.getByText("Use a ComfyUI on a server", { exact: true }).isVisible());
+ await shoot(page, "dialog-choose");
+ await dialog.getByRole("button", { name: "Find my ComfyUI" }).click();
+ await dialog.getByText("Your GPU is connected").waitFor({ timeout: 30_000 });
+ check("found and connected with one tap", true);
+ check("the owner's done line", await until(() => dialog.getByText("Done. Your open-source runs now go to this computer. Keep a Fuobe tab open here while they run.").isVisible(), 10_000));
+ await until(() => dialog.getByText(/Ready now:/).isVisible(), 20_000);
+ await shoot(page, "dialog-connected");
+ const settings = (await api(page, "/api/settings")).body;
+ check("Settings now say ComfyUI runs on the owner's computer", settings?.settings?.find((s) => s.name === "comfyWhere")?.value === "computer");
+ await page.keyboard.press("Escape");
+
+ // The sidebar and Settings' strip say where the GPU is.
+ const chip = await until(() => page.getByText(/^Your computer · NVIDIA GeForce RTX 5090/).first().isVisible(), 45_000, 500);
+ check("the sidebar: Your GPU · online · Your computer · RTX 5090", !!chip && (await page.locator('[data-sidebar="footer"]').getByText("online").isVisible()));
+ await shoot(page, "sidebar-online");
+ await page.goto(`${SITE}/settings`, { waitUntil: "load" });
+ const strip = page.getByRole("navigation", { name: "Connections" });
+ check("Settings' strip: Your GPU · Your computer · Online", !!(await until(() => strip.getByText("Your computer · Online").isVisible(), 30_000)));
+ const section = page.locator("#comfyui");
+ await section.getByText(/This computer/).first().waitFor({ timeout: 15_000 });
+ check("Settings' ComfyUI section: this computer, ready, with Disconnect", await section.getByRole("button", { name: "Disconnect" }).isVisible());
+ await shoot(page, "settings-computer", { scroll: "#comfyui" });
+
+ // A run from /image goes to the owner's computer, and its result is in the Library.
+ const before = await posts(PC_PORT);
+ await studio(page, "/image?model=oss-z-image-turbo");
+ const pending = await generate(page, "a lighthouse at dusk");
+ const done = await until(async () => {
+ const g = await pending();
+ return ended(g) && g;
+ }, 90_000, 500);
+ check("an open-source run ran on the owner's computer", done?.status === "succeeded" && (await posts(PC_PORT)) > before, done?.error ?? done?.status ?? "no run");
+ check("its task was the owner's", taskOf(done?.id)?.principal === "owner");
+ await page.goto(`${SITE}/library`, { waitUntil: "load" });
+ const inLibrary = await until(() => page.locator(`img[src*="/api/files/"]`).first().isVisible(), 30_000);
+ check("the result is in the Library", !!inLibrary);
+
+ // /workflows: checkmarks from the computer's check.
+ await page.goto(`${SITE}/workflows`, { waitUntil: "load" });
+ check("/workflows: checked on your computer", !!(await until(() => page.getByText(/^Checked on your computer .*Checkmarks show the models it has\.$/).isVisible(), 30_000)));
+ await shoot(page, "workflows-computer");
+
+ // /connect: the board, not "Your link didn't answer".
+ await page.goto(`${SITE}/connect`, { waitUntil: "load" });
+ check("/connect: the board, and Change where it runs", !!(await until(() => page.getByRole("link", { name: "Change where it runs" }).isVisible(), 30_000)));
+ check("/connect: never the link's words", !(await page.getByText(/Your link didn't answer/).isVisible()));
+ await shoot(page, "connect-computer");
+
+ // ComfyUI closes: the sidebar says so; it comes back and goes on.
+ await page.goto(`${SITE}/image?model=oss-z-image-turbo`, { waitUntil: "load" });
+ await stopFake(PC_PORT);
+ const down = await until(() => page.locator('[data-sidebar="footer"]').getByText("ComfyUI not running").isVisible(), 70_000, 1000);
+ check("ComfyUI closed: the sidebar says ComfyUI not running", !!down);
+ await shoot(page, "sidebar-comfy-down");
+ await startFake(PC_PORT, SITE, { guard: true });
+ check("ComfyUI back: online again", !!(await until(() => page.locator('[data-sidebar="footer"]').getByText("online").isVisible(), 70_000, 1000)));
+
+ // H2. A phone of the owner's: what the computer said, why not here, and the server way.
+ {
+ const phone = await context({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true });
+ const p = await phone.newPage();
+ await signIn(p, "owner");
+ await p.goto(`${SITE}/settings`, { waitUntil: "load" });
+ const s = p.locator("#comfyui");
+ check("a phone: the phone line", !!(await until(() => s.getByText(/Your phone can't run ComfyUI\. .* or use a ComfyUI on a server below\./).isVisible(), 30_000)));
+ check("a phone: the computer's state from the server", await s.getByText(/Your computer/).first().isVisible());
+ check("a phone: the server address right there", await s.getByRole("textbox", { name: "Server address" }).isVisible());
+ await s.scrollIntoViewIfNeeded();
+ await p.screenshot({ path: path.join(shots, `${MODE}-phone-settings-390-light.png`), fullPage: false });
+ await p.emulateMedia({ colorScheme: "dark" });
+ await sleep(300);
+ await p.screenshot({ path: path.join(shots, `${MODE}-phone-settings-390-dark.png`), fullPage: false });
+ await phone.close();
+ }
+
+ // H3. Settings → the server way: every local address is refused here, with no request.
+ await page.goto(`${SITE}/settings`, { waitUntil: "load" });
+ const sec = page.locator("#comfyui");
+ await sec.getByRole("button", { name: "Use a server address instead" }).click();
+ const addr = sec.getByRole("textbox", { name: "Server address" });
+ ctx.tests.length = 0;
+ for (const [typed, words] of [
+ [`127.0.0.1:${DEAD_PORT}`, "On this website, 127.0.0.1 is Fuobe's server, not your computer."],
+ [`http://10.255.255.1:${DEAD_PORT}`, "10.255.255.1 is on your own network, which Fuobe's server can't reach."],
+ [`http://169.254.0.1:${DEAD_PORT}`, "169.254.0.1 is on your own network, which Fuobe's server can't reach."],
+ [`http://nas.local:${DEAD_PORT}`, "nas.local is on your own network, which Fuobe's server can't reach."],
+ ]) {
+ await addr.fill(typed);
+ await sec.getByRole("button", { name: /Save and test Server address/ }).click();
+ check(`Settings: ${typed} refused with one line`, !!(await until(() => sec.getByText(words).isVisible(), 10_000)));
+ }
+ check("Settings: no connection test was sent for any of them", ctx.tests.length === 0, ctx.tests.join(" | "));
+ await shoot(page, "settings-refused", { scroll: "#comfyui" });
+ await addr.fill("");
+
+ // Disconnect: back to the server's address, nothing connected.
+ await sec.getByRole("button", { name: "Disconnect" }).click();
+ check("Disconnect: the choice again, this computer first", !!(await until(() => sec.getByText("Use the ComfyUI on this computer", { exact: true }).first().isVisible(), 15_000)));
+ check("the sidebar: Your GPU · Connect", !!(await until(() => page.locator('[data-sidebar="footer"]').getByRole("button", { name: /Your GPU\s*Connect/ }).isVisible(), 40_000, 500)));
+ await shoot(page, "settings-choose", { scroll: "#comfyui" });
+ await page.getByRole("navigation", { name: "Connections" }).getByText("Connect").waitFor({ timeout: 30_000 });
+ check("Settings' strip: Your GPU · Connect", true);
+
+ // The refusal's button starts this computer's finder in the card above.
+ await sec.getByRole("button", { name: /Use a ComfyUI on a server/ }).click();
+ await sec.getByRole("textbox", { name: "Server address" }).fill(`localhost:${DEAD_PORT}`);
+ await sec.getByRole("button", { name: /Save and test Server address/ }).click();
+ await sec.getByText("On this website, localhost is Fuobe's server, not your computer.").waitFor({ timeout: 10_000 });
+ await sec.getByRole("button", { name: "Use the ComfyUI on this computer" }).click();
+ check("the refusal's button finds this computer's ComfyUI", !!(await until(() => sec.getByText("Your GPU is connected").isVisible(), 30_000)));
+ await sec.getByRole("button", { name: "Disconnect" }).waitFor({ timeout: 1000 }).catch(() => {});
+ // Back to the server's address for H4.
+ check("back to server mode", (await send(page, "/api/settings", { comfyWhere: "server" }, "PUT")).status === 200);
+
+ // /workflows with nothing connected.
+ await page.goto(`${SITE}/workflows`, { waitUntil: "load" });
+ check("/workflows: Connect your GPU", !!(await until(() => page.getByText("ComfyUI isn't connected yet. Connect your GPU to run these on your own graphics card.").isVisible(), 30_000)));
+ await shoot(page, "workflows-connect");
+
+ // /connect with nothing connected: where ComfyUI runs comes first; no check of the server's own address. (A browser
+ // already allowed to reach ComfyUI may connect it by itself here: that's the quickest way.)
+ await page.goto(`${SITE}/connect`, { waitUntil: "load" });
+ check("/connect: Where is ComfyUI running?", !!(await until(() => page.getByRole("heading", { name: "Where is ComfyUI running?" }).isVisible(), 30_000)));
+ check("/connect: no failing check of the server's address", !(await page.getByText(/didn't answer/).isVisible()));
+ await shoot(page, "connect-choose");
+ await send(page, "/api/settings", { comfyWhere: "server" }, "PUT");
+
+ // H4. A run with nothing connected opens the dialog (no toast); once connected, it starts and runs on the computer.
+ await studio(page, "/image?model=oss-z-image-turbo");
+ const before4 = await posts(PC_PORT);
+ const pending4 = await generate(page, "a red bicycle");
+ const d4 = page.getByRole("dialog");
+ check("a refused run opens Connect your GPU to run this", !!(await until(() => d4.getByRole("heading", { name: "Connect your GPU to run this" }).isVisible(), 20_000)));
+ check("no error toast on top", (await page.locator("[data-sonner-toast]").filter({ hasText: "Connect ComfyUI in Settings" }).count()) === 0);
+ await shoot(page, "dialog-from-run");
+ const find = d4.getByRole("button", { name: "Find my ComfyUI" });
+ if (await find.isVisible().catch(() => false)) await find.click();
+ check("connected from the run", !!(await until(() => d4.getByText(/Your GPU is connected/).isVisible(), 30_000)));
+ check("the run starts in a moment", !!(await until(() => d4.getByText(/Your run starts in a moment|Starting your/).isVisible(), 15_000)));
+ const ran = await until(async () => {
+ const g = await pending4();
+ return ended(g) && g;
+ }, 90_000, 500);
+ check("the run went to the owner's computer", ran?.status === "succeeded" && (await posts(PC_PORT)) > before4, ran?.error ?? ran?.status ?? "no run");
+
+ // A1. An account on the same studio: its own computer, never the owner's.
+ {
+ await startFake(ACCOUNT_PORT, SITE, { guard: true });
+ const actx = await context({}, [APP_PORT, ACCOUNT_PORT]);
+ const ap = await actx.newPage();
+ const email = `qa-owner-pc-${Math.random().toString(36).slice(2, 8)}@example.com`;
+ await signIn(ap, email);
+ await ap.evaluate((port) => localStorage.setItem("fuobe.comfy.port", String(port)), ACCOUNT_PORT);
+ const st = (await api(ap, "/api/status")).body;
+ check("an account's status has no ownerGpu", !!st && st.ownerGpu === undefined && st.viewer?.kind === "account");
+ check("an account can't move the owner's ComfyUI", [401, 403].includes((await send(ap, "/api/settings", { comfyWhere: "server" }, "PUT")).status));
+ await studio(ap, "/image?model=oss-z-image-turbo");
+ const ownerBefore = await posts(PC_PORT);
+ const acctBefore = await posts(ACCOUNT_PORT);
+ const pendingA = await generate(ap, "a quiet harbour");
+ const da = ap.getByRole("dialog");
+ check("the account's dialog: this computer first", !!(await until(() => da.getByText("Use the ComfyUI on this computer", { exact: true }).first().isVisible(), 20_000)));
+ check("the account's dialog: a link second", await da.getByText("Run from anywhere with a link").isVisible());
+ await da.getByRole("button", { name: "Find my ComfyUI" }).click();
+ await da.getByText(/Your GPU is connected/).waitFor({ timeout: 30_000 });
+ // The owner runs one too, at the same time.
+ const ownerPending = await generate(page, "an owner's run in parallel");
+ const ga = await until(async () => {
+ const g = await pendingA();
+ return ended(g) && g;
+ }, 90_000, 500);
+ const go = await until(async () => {
+ const g = await ownerPending();
+ return ended(g) && g;
+ }, 90_000, 500);
+ check("the account's run ran on the account's computer only", ga?.status === "succeeded" && (await posts(ACCOUNT_PORT)) > acctBefore, ga?.error ?? ga?.status ?? "no run");
+ check("the owner's run ran on the owner's computer only", go?.status === "succeeded" && (await posts(PC_PORT)) === ownerBefore + 1, `${go?.status} owner posts +${(await posts(PC_PORT)) - ownerBefore}`);
+ check("the account's task was its own", taskOf(ga?.id)?.principal?.startsWith("acct:"));
+ const ownerTask = taskOf(go?.id);
+ for (const [method, url] of [
+ ["GET", `/api/gpu/computer/tasks/${ownerTask?.id}/inputs/0`],
+ ["POST", `/api/gpu/computer/tasks/${ownerTask?.id}/report`],
+ ["GET", `/api/gpu/computer/tasks/${ownerTask?.id}/outputs/0`],
+ ["PUT", `/api/gpu/computer/tasks/${ownerTask?.id}/outputs/0?offset=0&total=1`],
+ ["POST", `/api/gpu/computer/tasks/${ownerTask?.id}/release`],
+ ]) {
+ const r = await ap.evaluate(
+ async ({ method, url }) => (await fetch(url, { method, headers: { "content-type": "application/json", "x-fuobe-lease": "0".repeat(64) }, body: method === "GET" ? undefined : method === "PUT" ? "x" : JSON.stringify({ lease: "0".repeat(64), event: "gone" }) })).status,
+ { method, url },
+ );
+ check(`an account gets 404 for the owner's task: ${method} ${url.split("/").slice(-2).join("/")}`, r === 404, String(r));
+ }
+ check("the account's browser reached only its own ComfyUI", !actx.loopback.some((u) => u.includes(`:${PC_PORT}`)), actx.loopback.filter((u) => u.includes(`:${PC_PORT}`)).join(", "));
+ await shoot(ap, "account-done");
+ // The throwaway account goes.
+ check("the throwaway account is deleted", (await send(ap, "/api/auth/me", { password: "long enough password" }, "DELETE")).status === 204);
+ await actx.close();
+ await stopFake(ACCOUNT_PORT);
+ }
+
+ // G1. A guest sees nothing new, and reaches nothing on this computer.
+ {
+ const gctx = await context({}, [APP_PORT]);
+ const gp = await gctx.newPage();
+ await gp.goto(`${SITE}/`, { waitUntil: "load" });
+ await sleep(2000);
+ const st = (await api(gp, "/api/status")).body;
+ check("a guest's status has no ownerGpu", !!st && st.ownerGpu === undefined && st.viewer?.kind === "guest");
+ check("a guest can't beat as a computer", (await send(gp, "/api/gpu/computer/beat", { device: "device-guest-1" })).status === 401);
+ for (const [url, words] of [
+ ["/", "Your GPU"],
+ ["/connect", "Create a free account, then connect the ComfyUI on your computer."],
+ ["/workflows", "These are the graphs your own ComfyUI runs. Connect your GPU to see what it has and what it still needs."],
+ ["/settings", "Sign up free"],
+ ]) {
+ await gp.goto(SITE + url, { waitUntil: "load" });
+ check(`a guest on ${url} sees the same words`, !!(await until(() => gp.getByText(words).first().isVisible(), 20_000)));
+ }
+ check("a guest's browser reached nothing on this computer", gctx.loopback.length === 0, gctx.loopback.join(", "));
+ await gctx.close();
+ }
+
+ const tried = [...new Set(ctx.loopback.map((u) => new URL(u.split(" ")[1]).port))].sort();
+ check("the owner's browser reached only its stand-in ComfyUI on this computer (every other port refused in the browser)", ctx.passed.every((p) => p === PC_PORT), `tried ports ${tried.join(", ")}; let through: ${[...new Set(ctx.passed)].join(", ")}`);
+ check("nothing ever reached 8188", !ctx.passed.includes(8188));
+ await ctx.close();
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+async function local() {
+ const ctx = await context({}, [APP_PORT]);
+ const page = await ctx.newPage();
+ await signIn(page, "owner");
+ check("settings as on the live studio", (await send(page, "/api/settings", { engineMode: "open", demoMode: "off" }, "PUT")).status === 200);
+
+ // L1. Home's guide: today's ComfyUI address field with the server's address, no computer button.
+ await page.goto(`${SITE}/`, { waitUntil: "load" });
+ const card = page.getByRole("region", { name: "Use your GPU" });
+ const field = card.getByRole("textbox", { name: "ComfyUI address" });
+ await field.waitFor({ timeout: 30_000 });
+ check("local guide: the address field holds the server's address", (await field.inputValue()) === `http://127.0.0.1:${SERVER_COMFY_PORT}`);
+ check("local guide: no computer button", (await card.getByRole("button", { name: "Use the ComfyUI on this computer" }).count()) === 0);
+ await shoot(page, "home-guide");
+ await startFake(SERVER_COMFY_PORT, "off");
+ await card.getByRole("button", { name: /Connect ComfyUI address/ }).click();
+ check("local guide: Connect connects the server's ComfyUI", !!(await until(() => page.getByText("ComfyUI connected").first().isVisible(), 20_000)));
+
+ await page.goto(`${SITE}/settings`, { waitUntil: "load" });
+ const radio = page.getByRole("radiogroup", { name: "Where ComfyUI runs" });
+ check("local Settings: Where ComfyUI runs, On this server first", !!(await until(() => radio.getByRole("radio").first().getByText("On this server").isVisible(), 20_000)));
+ check("local Settings: the server URL field as before", await page.getByRole("textbox", { name: "ComfyUI server URL" }).isVisible());
+ await shoot(page, "settings", { scroll: "#comfyui" });
+
+ const before = await posts(SERVER_COMFY_PORT);
+ await studio(page, "/image?model=oss-z-image-turbo");
+ const pending = await generate(page, "a lighthouse at dusk");
+ const g = await until(async () => {
+ const x = await pending();
+ return ended(x) && x;
+ }, 90_000, 500);
+ check("local: a run goes to the server's ComfyUI", g?.status === "succeeded" && (await posts(SERVER_COMFY_PORT)) > before, g?.error ?? g?.status ?? "no run");
+
+ await stopFake(SERVER_COMFY_PORT);
+ // The status sees it gone (cached for 10 s).
+ await sleep(12_000);
+ await studio(page, "/image?model=oss-z-image-turbo");
+ await generate(page, "another one");
+ const toast = await until(() => page.locator("[data-sonner-toast]").filter({ hasText: "Connect ComfyUI in Settings" }).first().isVisible(), 20_000);
+ check("local: ComfyUI gone, Generate shows today's toast, no dialog", !!toast && !(await page.getByRole("dialog").isVisible().catch(() => false)));
+ check("the browser reached nothing on this computer but the studio", ctx.loopback.length === 0, ctx.loopback.join(", "));
+ await ctx.close();
+}