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: fixes from the review of the owner's ComfyUI on this computer

Adarsh388148085209
diff --git a/src/app/api/settings/route.ts b/src/app/api/settings/route.ts
index 280edcc9..2f40eb4e 100644
--- a/src/app/api/settings/route.ts
+++ b/src/app/api/settings/route.ts
@@ -18,7 +18,8 @@ export async function PUT(request: Request) {
}
const onComputer = getSetting("comfyWhere") === "computer";
for (const [name, value] of entries) setSetting(name, value.trim());
- // ComfyUI no longer runs on the owner's computer: the runs still going there stop, saying why.
- if (onComputer && getSetting("comfyWhere") !== "computer") forgetComputer("owner", "switched");
+ // ComfyUI no longer runs on the owner's computer: the runs still going there stop, saying why (Disconnect, or a move).
+ const disconnected = new URL(request.url).searchParams.get("why") === "disconnected";
+ if (onComputer && getSetting("comfyWhere") !== "computer") forgetComputer("owner", disconnected ? "disconnected" : "switched");
return Response.json({ settings: publicSettings() });
}
diff --git a/src/components/app-sidebar.tsx b/src/components/app-sidebar.tsx
index 42de2cc8..5d9bbeb7 100644
--- a/src/components/app-sidebar.tsx
+++ b/src/components/app-sidebar.tsx
@@ -40,8 +40,9 @@ 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 { awayFix, openConnect, useComputerSupport } from "@/components/gpu/open-connect";
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 { 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";
@@ -436,10 +437,12 @@ function ViewerRow() {
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 = gpu;
+ // ComfyUI on this computer is closed, or runs without Fuobe's setting: the finder, at that step (elsewhere: /connect).
+ const fix = awayFix(g.connected ? g : undefined, useComputerSupport());
if (g.connected) {
const vram = g.vramBytes ? `${Math.round(g.vramBytes / 2 ** 30)} GB` : "";
- return (
- <IntentLink href="/connect" className={cls}>
+ const inner = (
+ <>
<span className="flex items-center gap-2">
<StatusDot ok={g.online} /> Your GPU
<span className="ml-auto">{g.online ? "online" : g.comfy === "down" ? "ComfyUI not running" : g.comfy === "no-setting" ? "needs a setting" : "offline"}</span>
@@ -447,6 +450,15 @@ function YourGpuChip({ gpu, guest }: { gpu: NonNullable<StatusInfo["viewer"]>["g
{(g.device || vram || g.mode === "computer") && (
<span className="truncate text-[11px]">{[g.mode === "computer" && "Your computer", deviceLabel(g.device), vram && `${vram} VRAM`].filter(Boolean).join(" · ")}</span>
)}
+ </>
+ );
+ return fix ? (
+ <button type="button" className={cls} onClick={fix}>
+ {inner}
+ </button>
+ ) : (
+ <IntentLink href="/connect" className={cls}>
+ {inner}
</IntentLink>
);
}
@@ -461,7 +473,7 @@ function YourGpuChip({ gpu, guest }: { gpu: NonNullable<StatusInfo["viewer"]>["g
{body}
</a>
) : (
- <button type="button" className={cls} onClick={() => window.dispatchEvent(new Event(CONNECT_GPU_EVENT))}>
+ <button type="button" className={cls} onClick={() => openConnect(true)}>
{body}
</button>
);
@@ -546,7 +558,8 @@ export function AppSidebar() {
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;
+ // Not in Paid APIs only mode: ComfyUI isn't used there, wherever it runs.
+ const ownerGpu = status && !status.viewer && mode !== "cloud" && (status.ownerGpu || (place === "hosted" && !comfy)) ? (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) => {
@@ -631,6 +644,14 @@ export function AppSidebar() {
</IntentLink>
)}
<YourGpuChip gpu={ownerGpu} guest={false} />
+ {(mode !== "both" || (!ready && status?.demoMode !== "off")) && (
+ <div className="flex flex-col gap-1.5 px-2 pb-1 text-[11px] text-muted-foreground group-data-[collapsible=icon]:hidden">
+ {mode !== "both" && <span>{mode === "open" ? "Open source only" : "Paid APIs only"}</span>}
+ {!ready && status?.demoMode !== "off" && (
+ <span className="w-fit rounded-sm bg-highlight/25 px-1.5 py-0.5 text-highlight-foreground dark:text-highlight">Demo mode · placeholder outputs</span>
+ )}
+ </div>
+ )}
</>
) : !status ? (
// Not known yet: no "add key / offline" the install may not have, for a visitor who never sees them.
diff --git a/src/components/connect-field.tsx b/src/components/connect-field.tsx
index fa839005..0390593f 100644
--- a/src/components/connect-field.tsx
+++ b/src/components/connect-field.tsx
@@ -105,15 +105,17 @@ export function ConnectField({
const [busy, setBusy] = useState(false);
const [result, setResult] = useState<Result | null>(null);
const secret = !!setting?.secret;
- // 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;
+ // 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");
+ // Only the built-in default (127.0.0.1 on a hosted studio means its server), or an address set on the server that the
+ // owner never typed and the server may not call from here: shown empty, nothing to test until typed.
+ const envRefused = hideDefault && place === "hosted" && !trustSaved && !!setting?.fromEnv && !!setting.value && refusedOnHosted(addressKind(setting.value), allowPrivate);
+ const onlyDefault = hideDefault && ((!setting?.isSet && !setting?.fromEnv) || envRefused);
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 || (!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;
@@ -259,7 +261,7 @@ export function ConnectField({
</div>
{hint !== undefined && (
<p id={`${inputId}-hint`} className="text-[12px] text-muted-foreground">
- {setting?.fromEnv ? "Set from an environment variable; a value saved here wins. " : ""}
+ {setting?.fromEnv && !onlyDefault ? (place === "hosted" ? "Set on the server. A value saved here replaces it. " : "Set from an environment variable; a value saved here wins. ") : ""}
{hint}
</p>
)}
diff --git a/src/components/get-started.tsx b/src/components/get-started.tsx
index a5618011..e2d3d1d7 100644
--- a/src/components/get-started.tsx
+++ b/src/components/get-started.tsx
@@ -8,9 +8,11 @@ import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { ConnectField, useSettings } from "@/components/connect-field";
import { OwnerComputerLine, OwnerServerComfy } from "@/components/gpu/connect-choice";
+import { openConnect, useComputerSupport } from "@/components/gpu/open-connect";
+import { unsupportedWords } from "@/components/gpu/this-computer";
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 { 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";
@@ -60,19 +62,26 @@ function ComfyLinks() {
* "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.
+ * computer (a guide opened again), its state. On a phone, in Safari or on a plain-http page, why this browser can't, and the
+ * server way open.
*/
function HostedGpuCard({ computer }: { computer: boolean }) {
+ const support = useComputerSupport();
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 />
+ ) : support !== "ok" ? (
+ <>
+ <p className="text-[13px] leading-relaxed text-muted-foreground">{unsupportedWords(support, true)}</p>
+ <OwnerServerComfy hosted onlyAddress />
+ </>
) : (
<>
<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))}>
+ <Button className="h-11 w-full sm:h-9 sm:w-fit" onClick={() => openConnect(true)}>
<Cpu /> Use the ComfyUI on this computer
</Button>
<p className="text-[12px] text-muted-foreground">Runs while Fuobe is open in this browser.</p>
@@ -153,6 +162,9 @@ export function GetStarted({
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();
+ // "Just try it": the owner's demo, never a visitor's, and not when the demo is off (a run then asks for a GPU instead).
+ // Unknown (undefined) in Home's static shell.
+ const demo = status ? !status.viewer && status.demoMode !== "off" : undefined;
const hide = async () => {
setHiding(true);
@@ -190,7 +202,7 @@ export function GetStarted({
</Button>
</div>
- <div className={cn("mt-4 grid gap-3", mode === "both" ? "lg:grid-cols-3" : "md:grid-cols-2")}>
+ <div className={cn("mt-4 grid gap-3", mode === "both" && demo !== false ? "lg:grid-cols-3" : "md:grid-cols-2")}>
{mode !== "open" && (
<GuideCard icon={Cloud} title="Use paid models" cost={prices ? `Pay per run with your own key: ${prices}` : "Pay per run with your own key"}>
<p className="text-[13px] leading-relaxed text-muted-foreground">The Fuobe Originals hosted on open weights, plus Nano Banana, Seedance, Kling, Veo and many more, through one fal.ai key. A Replicate token works too (Settings).</p>
@@ -248,7 +260,7 @@ export function GetStarted({
</GuideCard>
)}
{/* The owner's demo: not in the first paint (a visitor of a public studio never sees it). */}
- {status && !status.viewer && (
+ {demo && (
<GuideCard icon={Sparkles} title="Just try it" cost="Free: no keys, no GPU">
<p className="text-[13px] leading-relaxed text-muted-foreground">Click through every studio with clearly labelled placeholder results. You can connect a model later in Settings.</p>
<Button
diff --git a/src/components/gpu/computer-runner.tsx b/src/components/gpu/computer-runner.tsx
index 0505eb62..fcef8ab9 100644
--- a/src/components/gpu/computer-runner.tsx
+++ b/src/components/gpu/computer-runner.tsx
@@ -4,12 +4,13 @@ import { useQueryClient } from "@tanstack/react-query";
import { Cpu, TriangleAlert } from "lucide-react";
import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
import { toast } from "sonner";
-import { CONNECT_GPU_EVENT, useViewer } from "@/lib/api";
+import { useViewer } from "@/lib/api";
import type { Generation } from "@/lib/catalog/types";
import { shortGpu } from "@/lib/gpu/readiness";
import { RELAY_WORDS } from "@/lib/relay";
import { cn } from "@/lib/utils";
import { computerState, jobFor, RESTART_EVENT, startComputerRunner, store, stored, subscribeComputer, takeOverHere, type ComputerState, type RunnerStart } from "./computer-runtime";
+import { openFinder } from "./open-connect";
import { loopbackPermission, useComputerSupport } from "./use-local-comfy";
/**
@@ -18,9 +19,7 @@ import { loopbackPermission, useComputerSupport } from "./use-local-comfy";
* to their own computer. The sidebar shows its note (ComputerNote) while their GPU works, or when ComfyUI needs them.
*/
-/** Why the "Connect your GPU" card opens from here: ComfyUI needs the setting again, find ComfyUI, or allow this browser. */
-export type FindReason = "setting" | "find" | "browser";
-export const openFinder = (reason: FindReason) => window.dispatchEvent(new CustomEvent(CONNECT_GPU_EVENT, { detail: { reason } }));
+export { awayFix, openConnect, openFinder, type FindReason } from "./open-connect";
/**
* May this browser reach ComfyUI on this computer without a question nobody explained? Allowed: yes. Told no:
diff --git a/src/components/gpu/connect-choice.tsx b/src/components/gpu/connect-choice.tsx
index 937588e5..1b6151db 100644
--- a/src/components/gpu/connect-choice.tsx
+++ b/src/components/gpu/connect-choice.tsx
@@ -1,7 +1,7 @@
"use client";
import { useQuery, useQueryClient, type QueryClient } from "@tanstack/react-query";
-import { ChevronDown, Cpu, Globe, Info, Loader2, Search, TriangleAlert, Unplug } from "lucide-react";
+import { ChevronDown, Cpu, Globe, Info, Loader2, TriangleAlert, Unplug } from "lucide-react";
import { createContext, useContext, useState } from "react";
import { toast } from "sonner";
import { ConnectField, useAllowPrivate, useSettings } from "@/components/connect-field";
@@ -9,15 +9,14 @@ 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 { CONNECT_GPU_EVENT, useStatus, useViewer } from "@/lib/api";
+import { 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, usePagePlace } from "./use-local-comfy";
-import { openFinder, useComputerState, type FindReason } from "./computer-runner";
+import { openConnect, openFinder, useComputerState, type FindReason } from "./computer-runner";
/**
* "Connect your GPU": the ComfyUI on this computer first (the quickest way: nothing to install, runs while Fuobe is
@@ -46,8 +45,9 @@ export async function connectThisComputer(): Promise<void> {
await gpuCall("PUT", { mode: "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 }) });
+/** `disconnect`: the owner pressed Disconnect (the runs that stop say so, not "ComfyUI now runs somewhere else"). */
+async function putWhere(where: "server" | "computer", disconnect = false): Promise<void> {
+ const res = await fetch(disconnect ? "/api/settings?why=disconnected" : "/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})`);
}
@@ -58,7 +58,7 @@ export async function connectOwnerComputer(): Promise<void> {
/** 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");
+ await putWhere("server", true);
for (const key of ["viewer", "status", "settings"]) void qc.invalidateQueries({ queryKey: [key] });
}
@@ -78,7 +78,9 @@ function useHere() {
if (local.holder === "other") return { other: true as const };
const v = local.holder === "this" ? local.view : null;
if (!v || v.stopped || v.heldElsewhere) return null;
- return { other: false as const, comfy: v.comfy, access: v.access, port: v.port, facts: v.facts };
+ // Runs this tab is working on, or that wait for it: Disconnect would stop them.
+ const busy = v.waiting > 0 || v.jobs.some((j) => j.phase !== "done" && j.phase !== "failed");
+ return { other: false as const, comfy: v.comfy, access: v.access, port: v.port, facts: v.facts, busy };
}
const Act = ({ children, onClick }: { children: React.ReactNode; onClick: () => void }) => (
@@ -119,7 +121,7 @@ function ComputerProblem({ here, server }: { here: ReturnType<typeof useHere>; s
}
return (
<p className="text-[12px] text-muted-foreground">
- {server === "down" ? "ComfyUI isn't running on your computer. Start it there." : server === "no-setting" ? "ComfyUI on your computer needs Fuobe's setting again. Open Fuobe there to see how." : RELAY_WORDS.noComputer}
+ {server === "down" ? "ComfyUI isn't running on your computer. Start it there." : server === "no-setting" ? "ComfyUI on your computer needs Fuobe's setting again. Open Fuobe there to see how." : "Offline. Open Fuobe on the computer that runs ComfyUI."}
</p>
);
}
@@ -191,6 +193,7 @@ function ComputerStatus({ gpu, onDisconnect, other, look = true }: { gpu: Comput
{busy ? <Loader2 className="animate-spin" /> : <Unplug />} Disconnect
</Button>
</div>
+ {mine?.busy && <p className="text-[12px] text-muted-foreground">Disconnect stops the runs going on now.</p>}
{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>}
{look && online && guard === false && gpu.cors !== "any" && shownPort && <NoGuard port={shownPort} />}
{look && (
@@ -268,8 +271,11 @@ function ChoiceCards({
);
}
-/** "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);
+/**
+ * The way under a refused address, inside the choice: start this computer's finder there ("Use the ComfyUI on this
+ * computer"), or, while ComfyUI runs there already, fold the server address away ("Keep using this computer").
+ */
+const FindHere = createContext<{ label: string; go: () => 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
@@ -284,8 +290,8 @@ export function HostedRefusal({ line }: { line: string }) {
<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 size="sm" onClick={() => (find ? find.go() : openConnect(true))}>
+ <Cpu /> {find?.label ?? "Use the ComfyUI on this computer"}
</Button>
)}
</div>
@@ -296,9 +302,10 @@ export function HostedRefusal({ line }: { line: string }) {
* 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).
+ * `onlyAddress`: the address alone (the first-run guide). On a hosted page the second ComfyUI (the isolated worker) is
+ * only in Settings (`advanced`), never in the connect dialog.
*/
-export function OwnerServerComfy({ hosted, computer = false, onlyAddress = false }: { hosted: boolean; computer?: boolean; onlyAddress?: boolean }) {
+export function OwnerServerComfy({ hosted, computer = false, onlyAddress = false, advanced = false }: { hosted: boolean; computer?: boolean; onlyAddress?: boolean; advanced?: boolean }) {
const qc = useQueryClient();
const settings = useSettings().data;
const status = useStatus().data;
@@ -340,14 +347,18 @@ export function OwnerServerComfy({ hosted, computer = false, onlyAddress = false
refusal={refusal}
/>
)}
- {!onlyAddress && !computer && (
+ {!onlyAddress && !computer && (!hosted || advanced) && (
<ConnectField
name="comfyIsolatedUrl"
setting={get("comfyIsolatedUrl")}
provider="comfyui"
- label="Isolated worker URL (optional)"
+ label={hosted ? "Second ComfyUI for lip sync and sound (optional)" : "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."
+ hint={
+ hosted
+ ? "LatentSync 1.6 and ThinkSound need add-ons that can't share your main ComfyUI. Give the address of a second one here."
+ : "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}
/>
@@ -372,6 +383,14 @@ export interface ConnectChoiceProps {
onNotNow?: () => void;
/** The two options' box (and the link's form): 36rem at most from sm up, unless a wider page lifts that (sm:max-w-none). */
className?: string;
+ /**
+ * Opened by a button that already said "Use the ComfyUI on this computer" (the guide, the sidebar's Connect): look at
+ * once. Without it (and without a run or a reason) the finder waits for "Find my ComfyUI": a card that only shows the
+ * choice (Settings, /connect) never moves the runs to this computer by itself.
+ */
+ look?: boolean;
+ /** Settings: the owner's server way has the second ComfyUI (the isolated worker) too. */
+ advanced?: boolean;
}
export function ConnectChoice(props: ConnectChoiceProps) {
@@ -380,7 +399,7 @@ export function ConnectChoice(props: ConnectChoiceProps) {
return viewer.owner ? <OwnerChoice {...props} /> : <AccountChoice {...props} />;
}
-function AccountChoice({ fromRun, kind, reason, onStart, onNotNow, className }: ConnectChoiceProps) {
+function AccountChoice({ fromRun, kind, reason, onStart, onNotNow, className, look }: ConnectChoiceProps) {
const qc = useQueryClient();
const support = useComputerSupport();
const q = useAccountGpu();
@@ -431,8 +450,9 @@ function AccountChoice({ fromRun, kind, reason, onStart, onNotNow, className }:
kind={kind}
onStart={onStart}
onNotNow={onNotNow}
- autoLook={reason === "setting" || reason === "find"}
+ autoLook={reason === "setting" || reason === "find" || look}
again={reason === "setting"}
+ waitForTap={!fromRun && !reason && !look}
/>
</div>
}
@@ -448,7 +468,7 @@ function AccountChoice({ fromRun, kind, reason, onStart, onNotNow, className }:
* 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) {
+function OwnerChoice({ fromRun, kind, reason, onStart, onNotNow, className, look, advanced }: ConnectChoiceProps) {
const qc = useQueryClient();
const support = useComputerSupport();
const place = usePagePlace();
@@ -460,9 +480,9 @@ function OwnerChoice({ fromRun, kind, reason, onStart, onNotNow, className }: Co
// 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");
+ // This computer's finder looks by itself only when the person asked for this computer (a run, a reason, a button that
+ // said so). Anywhere else, and after Disconnect, it waits for "Find my ComfyUI".
+ const [armed, setArmed] = useState<"tap" | "look">(look ? "look" : "tap");
const thisComputer = (
<ThisComputer
connect={async () => {
@@ -479,13 +499,9 @@ function OwnerChoice({ fromRun, kind, reason, onStart, onNotNow, className }: Co
again={reason === "setting"}
doneWords={OWNER_DONE}
lookNow={lookNow}
+ waitForTap={!fromRun && !reason && armed === "tap"}
/>
);
- 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" />;
@@ -496,13 +512,18 @@ function OwnerChoice({ fromRun, kind, reason, onStart, onNotNow, className }: Co
// 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 serverForm = <OwnerServerComfy hosted={hosted} computer={computer} advanced={advanced} />;
+ const findHere = {
+ label: "Use the ComfyUI on this computer",
+ go: () => {
+ setServerOpen(false);
+ setFlow(true);
+ setArmed("look");
+ setLookNow((n) => n + 1);
+ },
};
+ // ComfyUI runs on this computer already: a refused server address only folds away.
+ const keepHere = { label: "Keep using this computer", go: () => setServerOpen(false) };
const disconnect = async () => {
await disconnectOwnerComputer(qc);
setArmed("tap");
@@ -544,7 +565,7 @@ function OwnerChoice({ fromRun, kind, reason, onStart, onNotNow, className }: Co
);
if (computer && !flow)
return (
- <FindHere.Provider value={() => setServerOpen(false)}>
+ <FindHere.Provider value={keepHere}>
<div className={cn("w-full min-w-0 space-y-3 sm:max-w-[36rem]", className)}>
{state}
{serverOpen && serverBox}
@@ -560,7 +581,7 @@ function OwnerChoice({ fromRun, kind, reason, onStart, onNotNow, className }: Co
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>}
+ computer={<div onClickCapture={() => setFlow(true)}>{thisComputer}</div>}
>
{serverForm}
</ChoiceCards>
diff --git a/src/components/gpu/connect-gpu.tsx b/src/components/gpu/connect-gpu.tsx
index 8c2c135b..ca461dd1 100644
--- a/src/components/gpu/connect-gpu.tsx
+++ b/src/components/gpu/connect-gpu.tsx
@@ -9,6 +9,7 @@ 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 { openFinder, useComputerSupport } from "@/components/gpu/open-connect";
import { usePagePlace } from "@/components/gpu/use-local-comfy";
import { KeyInstead } from "@/components/keys/your-keys";
import { Button } from "@/components/ui/button";
@@ -57,6 +58,7 @@ export function ConnectGpu() {
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 support = useComputerSupport();
const lastUrl = useRef<string | null | undefined>(undefined);
useEffect(() => {
if (!isAccount || gpu.isLoading) return;
@@ -181,7 +183,18 @@ export function ConnectGpu() {
const report = view?.report;
const problem = view?.problem;
- const showList = check.running || check.lines.length > 0;
+ const linesFailed = check.lines.some((l) => l.step === "found" && l.state === "fail");
+ // A failed check that a later one (the finder's, once ComfyUI is back) put right is no longer shown.
+ const showList = check.running || (check.lines.length > 0 && !(linesFailed && !problem));
+ const foundFailed = showList && linesFailed;
+ const computerFix =
+ view?.target === "computer" && support === "ok"
+ ? problem === "cors-off"
+ ? { label: "Show me how", go: () => openFinder("setting") }
+ : problem === "unreachable" || problem === "timeout"
+ ? { label: "Find my ComfyUI", go: () => openFinder("find") }
+ : null
+ : null;
return (
<div className="space-y-6">
{header(report && !check.running ? 3 : 2, !!report && !check.running)}
@@ -217,13 +230,22 @@ export function ConnectGpu() {
)}
{problem && !check.running && (
<div className="mt-3 space-y-2 text-[13px]">
- <p className="flex items-start gap-2">
- <CircleAlert aria-hidden className="mt-0.5 size-4 shrink-0 text-destructive" />
- <span>
- {view?.problemText}
- {view?.problemDetail && <span className="block text-[12px] text-muted-foreground">{view.problemDetail}</span>}
- </span>
- </p>
+ {/* The checklist above says it already: one line, never two. */}
+ {!foundFailed && (
+ <p className="flex items-start gap-2">
+ <CircleAlert aria-hidden className="mt-0.5 size-4 shrink-0 text-destructive" />
+ <span>
+ {view?.problemText}
+ {view?.problemDetail && view.target !== "computer" && <span className="block text-[12px] text-muted-foreground">{view.problemDetail}</span>}
+ </span>
+ </p>
+ )}
+ {/* ComfyUI on this computer without Fuobe's setting, or closed: the finder gives the one fix and goes on by itself. */}
+ {computerFix && (
+ <Button className="mr-2 h-11 sm:h-9" onClick={computerFix.go}>
+ {computerFix.label}
+ </Button>
+ )}
<Button variant="secondary" className="h-11 sm:h-9" onClick={() => void check.start()}>
Check again
</Button>
diff --git a/src/components/gpu/open-connect.ts b/src/components/gpu/open-connect.ts
new file mode 100644
index 00000000..6a145bae
--- /dev/null
+++ b/src/components/gpu/open-connect.ts
@@ -0,0 +1,51 @@
+"use client";
+
+import { useSyncExternalStore } from "react";
+import { CONNECT_GPU_EVENT, type ConnectGpuDetail } from "@/lib/api";
+import { browserSupport, pageCanReach } from "@/lib/local-comfy";
+
+/**
+ * Opening "Connect your GPU" (GuestPrompt) from anywhere, and whether this browser can use the ComfyUI on its computer.
+ * Kept small: the sidebar and the header pill use it without loading the finder or the runner.
+ */
+
+/** Why the "Connect your GPU" card opens from the runner: ComfyUI needs the setting again, find ComfyUI, or allow this browser. */
+export type FindReason = NonNullable<ConnectGpuDetail["reason"]>;
+
+const open = (detail: ConnectGpuDetail) => window.dispatchEvent(new CustomEvent<ConnectGpuDetail>(CONNECT_GPU_EVENT, { detail }));
+
+export const openFinder = (reason: FindReason) => open({ reason });
+
+/**
+ * Open "Connect your GPU" from a button (never with a run: only a refused run's card starts one). `look`: the button said
+ * "Use the ComfyUI on this computer", so the dialog opens already looking; otherwise it waits for "Find my ComfyUI".
+ */
+export const openConnect = (look = false) => open({ look });
+
+/**
+ * The one fix for the person's computer from a status line ("ComfyUI not running", "needs a setting"), when this browser
+ * can make it: the finder, at the right step. Null on a phone or in Safari, or when nothing needs fixing here.
+ */
+export function awayFix(g: { mode?: string; online?: boolean; comfy?: "down" | "no-setting" } | undefined, support: string): (() => void) | null {
+ if (!g || g.mode !== "computer" || g.online || support !== "ok") return null;
+ if (g.comfy === "no-setting") return () => openFinder("setting");
+ if (g.comfy === "down") return () => openFinder("find");
+ return null;
+}
+
+const NARROW = "(max-width: 767px)";
+const subscribeNarrow = (cb: () => void) => {
+ const m = window.matchMedia(NARROW);
+ m.addEventListener("change", cb);
+ return () => m.removeEventListener("change", cb);
+};
+
+/** Can this browser use the ComfyUI on its computer at all ("ok"), or why not. */
+export function useComputerSupport(): "ok" | "safari" | "phone" | "http" {
+ const narrow = useSyncExternalStore(subscribeNarrow, () => window.matchMedia(NARROW).matches, () => false);
+ if (typeof window === "undefined") return "ok";
+ const coarse = window.matchMedia("(pointer: coarse)").matches && !window.matchMedia("(hover: hover)").matches;
+ const b = browserSupport(navigator as Navigator & { userAgentData?: { mobile?: boolean; platform?: string } }, { narrow, coarse });
+ if (b !== "ok") return b;
+ return pageCanReach(window.location.origin, window.isSecureContext) ? "ok" : "http";
+}
diff --git a/src/components/gpu/readiness-chip.tsx b/src/components/gpu/readiness-chip.tsx
index 74f7c6d7..1d396d1a 100644
--- a/src/components/gpu/readiness-chip.tsx
+++ b/src/components/gpu/readiness-chip.tsx
@@ -2,9 +2,10 @@
import { CheckCircle2, Cpu, Download, Layers } from "lucide-react";
import { badgeState, badgeText } from "@/hooks/use-gpu";
-import { ownGpuOf, useStatus } from "@/lib/api";
+import { ownGpuOf, useHydrated, useStatus } from "@/lib/api";
import type { Badge } from "@/lib/gpu/types";
import { cn } from "@/lib/utils";
+import { awayFix, useComputerSupport } from "./open-connect";
/**
* A tool's state on the viewer's GPU (UX §6): Ready · One step away · Needs setup · Needs a bigger GPU. Each state has
@@ -52,11 +53,14 @@ export function CardChip({ badge, gpu }: { badge: Badge; gpu?: string }) {
/**
* The header pill (StudioHeader, PresetHeader): a button when it opens the guided fix. A tool that's ready on a GPU that
- * isn't there right now (ComfyUI closed, without Fuobe's setting, a link that doesn't answer) says that instead.
+ * isn't there right now (ComfyUI closed, without Fuobe's setting, a link that doesn't answer) says that instead, and on the
+ * computer that runs ComfyUI it is a button to the one fix (the finder).
*/
export function HeaderPill({ badge, gpu, onOpen, compact }: { badge: Badge; gpu?: string; onOpen?: () => void; compact?: boolean }) {
// 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 support = useComputerSupport();
+ const hydrated = useHydrated();
const s = badgeState(badge);
const t = badgeText(badge, gpu);
const tenths = badge[2];
@@ -75,6 +79,13 @@ export function HeaderPill({ badge, gpu, onOpen, compact }: { badge: Badge; gpu?
<span className={cn(compact && "max-sm:sr-only")}>{label}</span>
</>
);
+ const fix = away && hydrated ? awayFix(own, support) : null;
+ if (fix)
+ return (
+ <button type="button" onClick={fix} aria-label={label} title={label} className={cn(cls, "transition-opacity hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none")}>
+ {inner}
+ </button>
+ );
if (!onOpen || s === "ready") return <span role="status" aria-label={t.long} title={t.long} className={cls}>{inner}</span>;
return (
<button type="button" onClick={onOpen} aria-label={`${label}: ${t.long}`} title={t.long} className={cn(cls, "transition-opacity hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none")}>
diff --git a/src/components/gpu/this-computer.tsx b/src/components/gpu/this-computer.tsx
index 5b71372b..cbeb56c4 100644
--- a/src/components/gpu/this-computer.tsx
+++ b/src/components/gpu/this-computer.tsx
@@ -82,6 +82,16 @@ function PromptPicture() {
);
}
+/** The browser's question, explained: its picture and what to press. */
+function AllowNote() {
+ return (
+ <div className="flex flex-wrap items-center gap-3">
+ <PromptPicture />
+ <p className="min-w-[12rem] flex-1 text-[12px] text-muted-foreground">Your browser will ask to let Fuobe reach apps on this computer. Press Allow. Fuobe only talks to ComfyUI.</p>
+ </div>
+ );
+}
+
function blockedSteps(): string {
const ua = typeof navigator === "undefined" ? "" : navigator.userAgent;
if (/Firefox\//.test(ua)) return "Click the icon to the left of the address and allow apps and services on this device, then reload.";
@@ -388,6 +398,11 @@ export interface ThisComputerProps {
doneWords?: string;
/** Changes when something outside asks to look now ("Use the ComfyUI on this computer" under a refused address). */
lookNow?: number;
+ /**
+ * Wait for "Find my ComfyUI", even when the browser lets Fuobe in already: a card that only shows the choice (Settings,
+ * /connect, a dialog opened without a run) never moves the runs to this computer by itself.
+ */
+ waitForTap?: boolean;
}
/** Is Fuobe's guard in this ComfyUI (it answers at /fuobe/guard)? */
@@ -398,9 +413,9 @@ 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, doneWords, lookNow }: ThisComputerProps) {
+export function ThisComputer({ connect, fromRun, kind, onStart, onNotNow, autoLook, again, doneWords, lookNow, waitForTap }: ThisComputerProps) {
const qc = useQueryClient();
- const { state, look, choose } = useLocalComfy(true);
+ const { state, look, choose, perm } = useLocalComfy(true, { auto: !waitForTap });
const [done, setDone] = useState<Connected | null>(null);
const [error, setError] = useState<string | null>(null);
const connecting = useRef<string | null>(null);
@@ -462,7 +477,7 @@ export function ThisComputer({ connect, fromRun, kind, onStart, onNotNow, autoLo
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} />
+ <Screen state={state} look={look} choose={choose} again={again} asks={perm !== "granted"} />
{error && <p className="text-[12px] text-destructive">{error}</p>}
</div>
);
@@ -492,7 +507,8 @@ function WaitingScreen({ port, since, onLook }: { port: number; since: number; o
);
}
-function Screen({ state, look, choose, again }: { state: Finder; look: ReturnType<typeof useLocalComfy>["look"]; choose: (port: number) => void; again?: boolean }) {
+/** `asks`: the browser may still ask to let Fuobe reach apps on this computer (its question is explained). */
+function Screen({ state, look, choose, again, asks }: { state: Finder; look: ReturnType<typeof useLocalComfy>["look"]; choose: (port: number) => void; again?: boolean; asks: boolean }) {
const lookAt = (port: number, host: string) => void look({ ports: [{ port, host }] });
switch (state.s) {
case "unsupported":
@@ -507,17 +523,17 @@ function Screen({ state, look, choose, again }: { state: Finder; look: ReturnTyp
<Button className="h-11 sm:h-9" onClick={() => void look()}>
<Search /> Find my ComfyUI
</Button>
- <div className="flex flex-wrap items-center gap-3">
- <PromptPicture />
- <p className="min-w-[12rem] flex-1 text-[12px] text-muted-foreground">Your browser will ask to let Fuobe reach apps on this computer. Press Allow. Fuobe only talks to ComfyUI.</p>
- </div>
+ {asks && <AllowNote />}
</div>
);
case "looking":
return (
- <p className="flex items-center gap-2 text-muted-foreground">
- <Loader2 className="size-4 animate-spin" /> Looking for ComfyUI on this computer…
- </p>
+ <div className="space-y-3">
+ <p className="flex items-center gap-2 text-muted-foreground">
+ <Loader2 className="size-4 animate-spin" /> Looking for ComfyUI on this computer…
+ </p>
+ {asks && <AllowNote />}
+ </div>
);
case "found":
return (
diff --git a/src/components/gpu/use-local-comfy.ts b/src/components/gpu/use-local-comfy.ts
index a5130998..0a268b6f 100644
--- a/src/components/gpu/use-local-comfy.ts
+++ b/src/components/gpu/use-local-comfy.ts
@@ -1,15 +1,18 @@
"use client";
-import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react";
+import { useCallback, useEffect, useRef, useState } from "react";
import { loopbackFetch } from "@/lib/gpu/browser-check";
-import { browserSupport, localBase, pageCanReach, portsToLook, sameFinder, settled, type Finder, type PortLook, type SystemStats } from "@/lib/local-comfy";import { rememberedComfy } from "./computer-runtime";
+import { localBase, portsToLook, sameFinder, settled, type Finder, type PortLook, type SystemStats } from "@/lib/local-comfy";
+import { rememberedComfy } from "./computer-runtime";
+import { useComputerSupport } from "./open-connect";
/**
* Finding the ComfyUI on this computer from the page ("Use the ComfyUI on this computer"). It looks at the ports
* ComfyUI uses (the one that answered last first), tells a ComfyUI it can read from one that answers without Fuobe's
* setting, and, while the card is open and the tab is in view, looks again quietly at every port: every 2 s while it
* waits for ComfyUI to come back with the setting, every 5 s while nothing answers. It never looks on its own while the
- * browser would still ask (Chrome's advice): the person's click does the first look.
+ * browser would still ask (Chrome's advice): the person's click does the first look. `auto: false`: not even when the
+ * browser lets Fuobe in already (a card that only shows the choice must never connect by itself).
*/
export type { Finder };
@@ -60,31 +63,17 @@ export async function loopbackPermission(): Promise<{ state: Permission; status?
return { state: "unknown" };
}
-const NARROW = "(max-width: 767px)";
-const subscribeNarrow = (cb: () => void) => {
- const m = window.matchMedia(NARROW);
- m.addEventListener("change", cb);
- return () => m.removeEventListener("change", cb);
-};
-
-/** Can this browser use the ComfyUI on its computer at all ("ok"), or why not. */
-export function useComputerSupport(): "ok" | "safari" | "phone" | "http" {
- const narrow = useSyncExternalStore(subscribeNarrow, () => window.matchMedia(NARROW).matches, () => false);
- if (typeof window === "undefined") return "ok";
- const coarse = window.matchMedia("(pointer: coarse)").matches && !window.matchMedia("(hover: hover)").matches;
- const b = browserSupport(navigator as Navigator & { userAgentData?: { mobile?: boolean; platform?: string } }, { narrow, coarse });
- if (b !== "ok") return b;
- return pageCanReach(window.location.origin, window.isSecureContext) ? "ok" : "http";
-}
-
+export { useComputerSupport } from "./open-connect";
export { usePagePlace } from "./use-page-place";
const visible = () => typeof document === "undefined" || document.visibilityState === "visible";
-/** The finder, while `active` (the card is open). */
-export function useLocalComfy(active: boolean) {
+/** The finder, while `active` (the card is open). `perm`: whether the browser would still ask, once known. */
+export function useLocalComfy(active: boolean, o: { auto?: boolean } = {}) {
+ const auto = o.auto !== false;
const support = useComputerSupport();
const [state, setState] = useState<Finder>({ s: "start" });
+ const [perm, setPerm] = useState<Permission | null>(null);
const cur = useRef(state);
useEffect(() => {
cur.current = state;
@@ -130,21 +119,23 @@ export function useLocalComfy(active: boolean) {
let alive = true;
let status: PermissionStatus | undefined;
const onChange = () => {
+ if (status) setPerm(status.state as Permission);
if (status?.state === "denied") setState({ s: "blocked" });
else if (status?.state === "granted" && cur.current.s === "blocked") void look();
};
void loopbackPermission().then((p) => {
if (!alive) return;
status = p.status;
+ setPerm(p.state);
status?.addEventListener("change", onChange);
- if (p.state === "granted" && cur.current.s === "start") void look();
+ if (p.state === "granted" && cur.current.s === "start" && auto) void look();
else if (p.state === "denied") setState({ s: "blocked" });
});
return () => {
alive = false;
status?.removeEventListener("change", onChange);
};
- }, [active, support, look]);
+ }, [active, support, look, auto]);
// Quiet looks at every port while it waits for ComfyUI (with the setting: a readable ComfyUI on any port connects) or
// for any ComfyUI to start.
@@ -155,5 +146,5 @@ export function useLocalComfy(active: boolean) {
return () => clearInterval(id);
}, [active, every, look]);
- return { state: support !== "ok" ? ({ s: "unsupported", why: support } as Finder) : state, look, choose, support };
+ return { state: support !== "ok" ? ({ s: "unsupported", why: support } as Finder) : state, look, choose, support, perm };
}
diff --git a/src/components/guest-prompt.tsx b/src/components/guest-prompt.tsx
index 2f460730..843d1d1c 100644
--- a/src/components/guest-prompt.tsx
+++ b/src/components/guest-prompt.tsx
@@ -11,7 +11,7 @@ import { takeGpuRetry } from "@/hooks/use-gpu";
import { KeyInstead } from "@/components/keys/your-keys";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
-import { CONNECT_GPU_EVENT, GUEST_PROMPT_EVENT, refusalCard, signInHref, useStatus, useViewer, watchGuestRefusals, type RefusalAction, type RefusalCard, type RefusalDetail } from "@/lib/api";
+import { CONNECT_GPU_EVENT, GUEST_PROMPT_EVENT, refusalCard, signInHref, useStatus, useViewer, watchGuestRefusals, type ConnectGpuDetail as ConnectDetail, type RefusalAction, type RefusalCard } from "@/lib/api";
import { CLOUD_KEY } from "@/lib/your-keys";
/**
@@ -35,6 +35,8 @@ export function GuestPrompt() {
// What was refused: a run (or any other change), or a file of the visitor's own.
const [action, setAction] = useState<RefusalAction | "connect">("run");
const [retry, setRetry] = useState<{ retry: () => void; kind?: string } | null>(null);
+ // Opened by a button that said "Use the ComfyUI on this computer": the finder looks at once.
+ const [look, setLook] = useState(false);
const close = useCallback(() => {
setOpen(false);
setRetry(null);
@@ -59,8 +61,8 @@ export function GuestPrompt() {
setOpen(true);
return true;
};
- // A bare Event (the sidebar's "Connect your GPU") has no detail: a run.
- const detail = (e: Event) => (e as CustomEvent<(RefusalDetail & { reason?: FindReason }) | null>).detail ?? {};
+ // A button that only opens the card sends no action (and a bare Event no detail at all): no run waits.
+ const detail = (e: Event) => (e as CustomEvent<ConnectDetail | null>).detail ?? {};
const guest = (e: Event) => {
// Signed in a moment ago: not an offer to sign up, but to log in again; and the page asks who is looking.
const out = was.current;
@@ -75,13 +77,15 @@ export function GuestPrompt() {
}
};
const gpu = (e: Event) => {
- const { action: refused = "run", reason: why } = detail(e);
- // The run that was refused (the composer leaves its retry as it sends): kept until the GPU is connected.
- const r = refused === "run" ? takeGpuRetry() : null;
+ const d = detail(e);
+ // Only a refused run carries its retry (watchGuestRefusals says "run"): a button that just opens this card never
+ // starts the last run again.
+ const r = d.action === "run" ? takeGpuRetry() : null;
if (!show("gpu")) return;
setRetry(r);
- setReason(why);
- setAction(refused);
+ setReason(d.reason);
+ setAction(d.action ?? "connect");
+ setLook(!!d.look);
};
window.addEventListener(GUEST_PROMPT_EVENT, guest);
window.addEventListener(CONNECT_GPU_EVENT, gpu);
@@ -96,7 +100,15 @@ export function GuestPrompt() {
<CloseOnNavigation close={close} />
</Suspense>
<Dialog open={open} onOpenChange={(o) => !o && close()}>
- <DialogContent className={card?.kind === "gpu" ? "max-h-[90svh] grid-cols-[minmax(0,1fr)] overflow-y-auto sm:max-w-xl" : "sm:max-w-sm"}>
+ <DialogContent
+ className={card?.kind === "gpu" ? "max-h-[90svh] grid-cols-[minmax(0,1fr)] overflow-y-auto sm:max-w-xl" : "sm:max-w-sm"}
+ // "Connect your GPU" starts on the card itself, not in an address field (a phone's keyboard would cover it).
+ onOpenAutoFocus={(e) => {
+ if (card?.kind !== "gpu") return;
+ e.preventDefault();
+ (e.currentTarget as HTMLElement | null)?.focus?.();
+ }}
+ >
{card?.kind === "gpu" ? (
<>
<DialogHeader>
@@ -126,6 +138,7 @@ export function GuestPrompt() {
fromRun={!!retry}
kind={retry?.kind}
reason={reason}
+ look={look}
onStart={() => {
const r = retry;
close();
diff --git a/src/components/home-view.tsx b/src/components/home-view.tsx
index 4f659dc4..41b76708 100644
--- a/src/components/home-view.tsx
+++ b/src/components/home-view.tsx
@@ -402,7 +402,14 @@ 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.{" "}
+ {/* With the demo off, a run asks for a GPU or a key: no promise of placeholders. */}
+ {status?.demoMode === "off" ? (
+ "Nothing is connected yet. "
+ ) : (
+ <>
+ You’re in <span className="font-medium text-foreground">demo mode</span> — outputs are placeholders.{" "}
+ </>
+ )}
{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
@@ -412,7 +419,7 @@ export function HomeView({
{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.
+ {status?.demoMode === "off" ? "to make the real thing." : "to generate for real."}
</p>
)}
</div>
diff --git a/src/components/settings-form.tsx b/src/components/settings-form.tsx
index 805ce554..50ebb92c 100644
--- a/src/components/settings-form.tsx
+++ b/src/components/settings-form.tsx
@@ -631,7 +631,7 @@ export function SettingsForm({ prices }: { prices?: string }) {
}
inactive={mode === "cloud" ? "Not used in Paid APIs only mode" : undefined}
>
- {hosted ? <ConnectChoice /> : <LocalComfy get={get} onWhere={(v) => save.mutateAsync({ comfyWhere: v })} />}
+ {hosted ? <ConnectChoice advanced /> : <LocalComfy get={get} onWhere={(v) => save.mutateAsync({ comfyWhere: v })} />}
</Section>
<Section
diff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsx
index b6dcda91..15bfdb81 100644
--- a/src/components/studio/composer.tsx
+++ b/src/components/studio/composer.tsx
@@ -72,7 +72,7 @@ import { formatCost } from "@/lib/format";
import { toastError } from "@/lib/refusals";
import { addKeyLabel, billedTo, CLOUD_KEY, needsKey, paidThrough, startingModel } from "@/lib/your-keys";
import { cn } from "@/lib/utils";
-import { badgeFor, badgeText, openGpuSetup, setGpuRetry, useGpuBadges } from "@/hooks/use-gpu";
+import { badgeFor, badgeText, dropGpuRetry, openGpuSetup, setGpuRetry, useGpuBadges } from "@/hooks/use-gpu";
import { AttachMenu } from "./attach-menu";
import { useAttach, useComposerBridge, useUploadReaper } from "./attachments";
import { DialogueEditor, LanguageChip, VoicePicker } from "./audio-controls";
@@ -607,6 +607,8 @@ export function Composer({ docked }: { docked: boolean }) {
model?.kind,
);
create.mutate(skipGpu ? ({ ...sent.request, gpuCheck: "skip" } as typeof sent.request) : sent.request, {
+ // Accepted: nothing to try again (a card opened later never starts this run a second time).
+ onSuccess: () => dropGpuRetry(),
// Stopped by the GPU pre-flight, or refused with its own card: the guided fix or the card is open already, so no error toast on top.
onError: (e) => void ((e as { gpuSetup?: boolean }).gpuSetup || toastError(e)),
});
diff --git a/src/hooks/use-gpu.ts b/src/hooks/use-gpu.ts
index 5559d02a..67108072 100644
--- a/src/hooks/use-gpu.ts
+++ b/src/hooks/use-gpu.ts
@@ -107,6 +107,11 @@ export function setGpuRetry(retry: () => void, skip: () => void, kind?: string):
pendingRetry = { at: Date.now(), retry, skip, ...(kind && { kind }) };
}
+/** The run went through: its retry is no longer anyone's to start. */
+export function dropGpuRetry(): void {
+ pendingRetry = null;
+}
+
/** The composer's retry, when it asked within the last few seconds (another page's stale one never applies). */
export function takeGpuRetry(): { retry: () => void; skip: () => void; kind?: string } | null {
const p = pendingRetry;
diff --git a/src/lib/api.ts b/src/lib/api.ts
index 30d4d6bd..2f85970c 100644
--- a/src/lib/api.ts
+++ b/src/lib/api.ts
@@ -1239,6 +1239,15 @@ export function signInHref(mode: "signup" | "login", next?: string): string {
export const GUEST_PROMPT_EVENT = "fuobe:guest-prompt";
export const CONNECT_GPU_EVENT = "fuobe:connect-gpu";
+/**
+ * What opened "Connect your GPU": `action` a refusal (watchGuestRefusals, or a file chooser that asks first): a refused
+ * run's card keeps that run and starts it once connected; `reason` the runner's note; `look` a button that said "Use the
+ * ComfyUI on this computer". With none of them, a button that only opens the card: no run waits.
+ */
+export interface ConnectGpuDetail extends RefusalDetail {
+ reason?: "setting" | "find" | "browser";
+ look?: boolean;
+}
/** A run started from this tab (components/gpu/computer-runtime.ts listens). */
export const COMPUTER_KICK_EVENT = "fuobe:computer-kick";
/** The guided fix (src/components/gpu/guided-fix.tsx): { ref, plan? }. */
diff --git a/src/lib/gpu/browser-check.ts b/src/lib/gpu/browser-check.ts
index 9a34df7a..040c7c73 100644
--- a/src/lib/gpu/browser-check.ts
+++ b/src/lib/gpu/browser-check.ts
@@ -4,7 +4,7 @@
* read, then sent to the server (PUT /api/gpu/inventory), which keeps it for this person's board, chips and fixes.
*/
import { localBase, preflightPath } from "../local-comfy";
-import { gatherInventory } from "./gather";
+import { gatherInventory, problemText } from "./gather";
import { parseIndex } from "./requirements";
import { fetchTransport } from "./transport";
import type { CheckLine, GpuInventory, RequirementIndex } from "./types";
@@ -37,15 +37,25 @@ export async function checkThisComputer(port: number, o: { host?: string; onLine
},
{ decodes: true },
);
- const inv = await gatherInventory(t, await requirements(), { where: "computer", statsTimeoutMs: 1500, onLine: o.onLine, classes: o.classes, folders: o.folders });
+ // The first line's failure waits: it may be a ComfyUI that runs without Fuobe's setting, not one that's closed.
+ let held: CheckLine | null = null;
+ const onLine = (l: CheckLine) => (l.step === "found" && l.state === "fail" ? (held = l) : o.onLine?.(l));
+ const inv = await gatherInventory(t, await requirements(), { where: "computer", statsTimeoutMs: 1500, onLine, classes: o.classes, folders: o.folders });
// The browser can't read a ComfyUI started without Fuobe's setting: a look that can't read the answer still sees it's there.
- if (inv.problem === "unreachable") {
- const answers = await loopbackFetch(`${base}/system_stats`, { mode: "no-cors" }).then(
- () => true,
- () => false,
- );
- if (answers) return { ...inv, problem: "cors-off" };
+ if (inv.problem === "unreachable" || inv.problem === "timeout") {
+ const answers =
+ inv.problem === "unreachable" &&
+ (await loopbackFetch(`${base}/system_stats`, { mode: "no-cors" }).then(
+ () => true,
+ () => false,
+ ));
+ // The browser's own words ("Failed to fetch") say nothing to the person: one line says what to do.
+ const out: GpuInventory = { ...inv, ...(answers && { problem: "cors-off" as const }) };
+ delete out.problemDetail;
+ o.onLine?.({ step: "found", state: "fail", text: problemText(out.problem!, "computer") });
+ return out;
}
+ if (held) o.onLine?.(held);
return inv;
}
diff --git a/src/lib/relay.ts b/src/lib/relay.ts
index 287d859d..ab0da6b0 100644
--- a/src/lib/relay.ts
+++ b/src/lib/relay.ts
@@ -278,6 +278,9 @@ export const RELAY_WORDS = {
tooBig: "Your ComfyUI made a file over 1 GB. Try a shorter clip or a lower size.",
stopped: "Stopped",
switched: "This run stopped because ComfyUI now runs somewhere else. Press Retry.",
+ disconnected: "You disconnected your computer, so this run stopped. Press Retry.",
+ /** A run sent to the computer whose Fuobe tab stopped answering (closed, asleep): it goes on once that tab is back. */
+ computerAway: "Waiting for your computer. Open Fuobe there to finish this run.",
} as const;
/** A script's open-source run (an API token) while the owner's ComfyUI is on the owner's computer. */
diff --git a/src/server/computer/tasks.ts b/src/server/computer/tasks.ts
index 3582ea5a..4d03db00 100644
--- a/src/server/computer/tasks.ts
+++ b/src/server/computer/tasks.ts
@@ -249,8 +249,11 @@ export function runnerFacts(principal: Principal): (ComputerFacts & { port?: num
return { ...json<ComputerFacts>(r.facts_json, {}), ...(r.port && { port: r.port }), seenAt: r.seen_at, online: here && r.comfy === "ok", ...(here && r.comfy !== "ok" && { comfy: r.comfy }) };
}
-/** Forget a principal's computer (it disconnected, its runs moved elsewhere: `switched`, or the account went). */
-export function forgetComputer(principal: Principal, why: "Stopped" | "switched" = "Stopped"): void {
+/**
+ * Forget a principal's computer (it disconnected: `disconnected` when the owner pressed Disconnect, its runs moved
+ * elsewhere: `switched`, or the account went).
+ */
+export function forgetComputer(principal: Principal, why: "Stopped" | "switched" | "disconnected" = "Stopped"): void {
rdb().prepare("DELETE FROM relay_runners WHERE principal = ?").run(principal);
for (const t of rdb().prepare(`SELECT id FROM relay_tasks WHERE principal = ? AND state IN (${ACTIVE_STATES.map(() => "?").join(",")})`).all(principal, ...ACTIVE_STATES) as { id: string }[]) {
endTask(t.id, "canceled", { error: why });
diff --git a/src/server/providers/comfyui.ts b/src/server/providers/comfyui.ts
index 2542ccf4..64151182 100644
--- a/src/server/providers/comfyui.ts
+++ b/src/server/providers/comfyui.ts
@@ -72,7 +72,7 @@ import { outsideTenant, runAsTenant, tenantAccount } from "../tenant";
import { ask, checkReach, reachSync, sharedCheck, type Reach } from "./reach";
import { ProviderError, type PollResult, type ProviderAdapter, type RemoteOutput } from "./types";
import { isOutOfMemory } from "@/lib/gpu/fix-codes";
-import { makingWords, queueWords, RELAY_WORDS, savingWords, sendingWords, tabFailureWords, type HistoryEntryLike, type TabFailure, type WantedFile } from "@/lib/relay";
+import { makingWords, queueWords, RELAY_TIMES, RELAY_WORDS, savingWords, sendingWords, tabFailureWords, type HistoryEntryLike, type TabFailure, type WantedFile } from "@/lib/relay";
import type { GenerationFix } from "@/lib/catalog/types";
import {
checkClocks,
@@ -1785,7 +1785,10 @@ async function pollComputer(principal: Principal, meta: Record<string, unknown>,
const kind = extraOf(t).made ?? made ?? "image";
const waitMs = tenantAccount() ? ACCOUNT_LIMITS.queueMs : 4 * 3_600_000;
const sentAt = t.sent_at ?? undefined;
- const down = t.down_at ? (t.down_why === "setting" ? RELAY_WORDS.comfyNoSetting : RELAY_WORDS.comfyDown) : undefined;
+ // Sent, and the computer's tab stopped answering (closed, asleep): not a run that looks alive for half an hour.
+ const r = t.state === "waiting" ? null : runnerFacts(principal);
+ const away = t.state !== "waiting" && (!r || Date.now() - r.seenAt >= RELAY_TIMES.onlineMs);
+ const down = t.down_at ? (t.down_why === "setting" ? RELAY_WORDS.comfyNoSetting : RELAY_WORDS.comfyDown) : away ? RELAY_WORDS.computerAway : undefined;
switch (t.state) {
case "waiting": {
// The computer's tab is open, but its ComfyUI is closed or runs without Fuobe's setting: say that, not "open Fuobe".
@@ -1824,7 +1827,7 @@ async function pollComputer(principal: Principal, meta: Record<string, unknown>,
return { state: "succeeded", outputs: await withLayerBoxes(outputs) };
}
case "canceled":
- return { state: "failed", error: t.error === "switched" ? RELAY_WORDS.switched : RELAY_WORDS.stopped };
+ return { state: "failed", error: t.error === "switched" ? RELAY_WORDS.switched : t.error === "disconnected" ? RELAY_WORDS.disconnected : RELAY_WORDS.stopped };
default:
return { state: "failed", ...relayFailure(t, manifest) };
}
diff --git a/tests/computer-relay.test.ts b/tests/computer-relay.test.ts
index 5fca0044..7c92dd8c 100644
--- a/tests/computer-relay.test.ts
+++ b/tests/computer-relay.test.ts
@@ -481,6 +481,45 @@ describe("a run on the ComfyUI on the person's own computer", () => {
}
});
+ it("the owner's Disconnect stops a run on the computer saying so, not that ComfyUI moved", async () => {
+ const { setSetting } = await import("@/server/settings");
+ const settingsRoute = await import("@/app/api/settings/route");
+ setSetting("comfyWhere", "computer");
+ setSetting("engineMode", "open");
+ setSetting("demoMode", "off");
+ const owner = `${auth.SESSION_COOKIE}=${auth.createSession().value}`;
+ try {
+ const text = JSON.stringify({ feature: "image", modelId: "oss-z-image-turbo", prompt: "a lighthouse at dusk" });
+ const r = await generationsRoute.POST(new Request("http://localhost:3000/api/generations", { method: "POST", headers: { cookie: owner, ...SITE_HEADERS, "content-type": "application/json", "content-length": String(Buffer.byteLength(text)) }, body: text }));
+ expect(r.status).toBe(201);
+ const id = ((await r.json()).items as { id: string }[])[0].id;
+ await handedOver(id);
+ await settingsRoute.PUT(new Request("http://localhost:3000/api/settings?why=disconnected", { method: "PUT", headers: { "content-type": "application/json" }, body: JSON.stringify({ comfyWhere: "server" }) }));
+ const g = await settle(id);
+ expect(g?.status).toBe("failed");
+ expect(g?.error).toBe(RELAY_WORDS.disconnected);
+ } finally {
+ setSetting("comfyWhere", "server");
+ }
+ });
+
+ it("a run already sent says it waits for the computer once that computer's tab stops answering", async () => {
+ await gpuRoute.PUT(json("/api/account/gpu", "PUT", { mode: "computer" }));
+ const pic = await uploadPng();
+ const [id] = await run({ feature: "app", modelId: "oss-qwen-edit", presetId: "app-headshot-generator", prompt: "", inputs: { images: [pic.url] } });
+ await handedOver(id);
+ const t = tab(routes, cookie, fake.port, { device: "device-away-1" });
+ await t.runner.beat();
+ // Claimed (sent to the tab), and the tab goes quiet: closed, or the computer asleep.
+ const claim = await t.api("/api/gpu/computer/claim", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ device: "device-away-1" }) });
+ expect(claim.status).toBe(200);
+ await tick();
+ expect(getGeneration(id)?.message).not.toBe(RELAY_WORDS.computerAway);
+ db().prepare("UPDATE relay_runners SET seen_at = seen_at - 120000").run();
+ await tick();
+ expect(getGeneration(id)).toMatchObject({ status: "queued", message: RELAY_WORDS.computerAway });
+ });
+
it("stops a job whose run went, and forgets a deleted account's computer and files", async () => {
const { createTask, purgeComputer, stageInput, sweepRelay, relayDir } = await import("@/server/computer/tasks");
const name = stageInput(`acct:${a}`, FAKE_PNG, "image/png", "x.png");
diff --git a/tests/computer-security.test.ts b/tests/computer-security.test.ts
index 0f06bd0b..475ee0a3 100644
--- a/tests/computer-security.test.ts
+++ b/tests/computer-security.test.ts
@@ -282,9 +282,22 @@ describe("the owner's computer and an account's never mix", () => {
const { relayFile } = await import("@/server/providers/comfyui");
const { asAccount } = await import("@/server/generations");
setSetting("comfyWhere", "computer");
+ // A finished job of the owner's, its result sent in: something real to find, so a refusal means the principal.
const t = waitingTask("owner");
- const url = `relay:${t.id}/view?filename=x.png&n=0`;
+ const c = await claimed("owner", "device-owner-sec-1");
+ expect(c.id).toBe(t.id);
+ expect((await call("owner", "POST", `/api/gpu/computer/tasks/${c.id}/report`, { headers: { "x-fuobe-lease": c.lease }, body: { event: "sent", promptId: c.promptId } })).status).toBe(200);
+ const fin = await call("owner", "POST", `/api/gpu/computer/tasks/${c.id}/report`, {
+ headers: { "x-fuobe-lease": c.lease },
+ body: { event: "finished", entry: { status: { status_str: "success", completed: true }, outputs: ONE_PNG } },
+ });
+ expect(fin.status).toBe(200);
+ expect((await put("owner", c.id, 0, c.lease, FAKE_PNG)).status).toBe(200);
+ const url = `relay:${c.id}/view?filename=x_00001_.png&subfolder=fuobe&type=output&n=0`;
+ expect(relayFile(url)).not.toBeNull();
+ expect((await onComputer("owner", () => outputFetch(url))).status).toBe(200);
expect(asAccount(a, () => relayFile(url))).toBeNull();
+ expect(onComputer(`acct:${a}`, () => relayFile(url))).toBeNull();
expect((await onComputer(`acct:${a}`, () => outputFetch(url))).status).toBe(404);
});
diff --git a/tests/e2e/owner-computer.mjs b/tests/e2e/owner-computer.mjs
index 037b6d7d..a6634ced 100644
--- a/tests/e2e/owner-computer.mjs
+++ b/tests/e2e/owner-computer.mjs
@@ -236,17 +236,17 @@ async function hosted() {
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.
+ // The guide's button opens the dialog already looking (the button said "this computer"): connected, with the owner's
+ // words, and no second "Find my ComfyUI" to press.
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());
+ check("the dialog doesn't start in an address field", !(await page.evaluate(() => document.activeElement?.tagName === "INPUT")));
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("found and connected with one tap (the guide's)", !!(await until(() => dialog.getByText("Your GPU is connected").isVisible(), 30_000)));
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");
@@ -300,6 +300,28 @@ async function hosted() {
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)));
+ // ComfyUI started the usual way (without Fuobe's setting): the sidebar's line opens the fix; /connect says it once.
+ await stopFake(PC_PORT);
+ await startFake(PC_PORT, "off");
+ const needs = page.locator('[data-sidebar="footer"]').getByRole("button", { name: /needs a setting/ });
+ check("no setting: the sidebar says needs a setting, as a button", !!(await until(() => needs.isVisible(), 70_000, 1000)));
+ await needs.click();
+ check("the sidebar's button opens the setting's fix", !!(await until(() => page.getByRole("dialog").getByRole("heading", { name: "Your ComfyUI needs Fuobe's setting again" }).isVisible(), 15_000)));
+ check("the fix: the start file", !!(await until(() => page.getByRole("dialog").getByRole("button", { name: /Download start file/ }).first().isVisible(), 15_000)));
+ await shoot(page, "dialog-no-setting");
+ await page.keyboard.press("Escape");
+ await page.goto(`${SITE}/connect`, { waitUntil: "load" });
+ await page.getByRole("button", { name: /Check again|Check my GPU/ }).first().click({ timeout: 30_000 });
+ await until(() => page.getByText("ComfyUI is running, but it isn't letting this page in yet.").first().isVisible(), 30_000);
+ const connectText = await page.locator("body").innerText();
+ check("/connect, no setting: one line, never the closed line", (connectText.match(/isn't letting this page in yet/g) ?? []).length === 1 && !connectText.includes("isn't answering on this computer"), connectText.slice(0, 400));
+ check("/connect, no setting: no browser error words", !/Failed to fetch|NetworkError/.test(connectText));
+ check("/connect, no setting: Show me how", await page.getByRole("button", { name: "Show me how" }).isVisible());
+ await shoot(page, "connect-no-setting");
+ await stopFake(PC_PORT);
+ await startFake(PC_PORT, SITE, { guard: true });
+ check("ComfyUI back with the setting: 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 });
@@ -335,6 +357,7 @@ async function hosted() {
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(" | "));
+ check("already on this computer, the refusal offers to keep it", await sec.getByRole("button", { name: "Keep using this computer" }).isVisible());
await shoot(page, "settings-refused", { scroll: "#comfyui" });
await addr.fill("");
@@ -345,6 +368,14 @@ async function hosted() {
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);
+ const where = async () => (await api(page, "/api/settings")).body?.settings?.find((s) => s.name === "comfyWhere")?.value;
+
+ // Disconnect sticks: Settings opened again (this browser may reach ComfyUI already) waits for Find my ComfyUI.
+ await page.goto(`${SITE}/`, { waitUntil: "load" });
+ await page.goto(`${SITE}/settings`, { waitUntil: "load" });
+ await page.locator("#comfyui").getByRole("button", { name: "Find my ComfyUI" }).waitFor({ timeout: 30_000 });
+ await sleep(8000);
+ check("Disconnect sticks: Settings opened again doesn't connect by itself", (await where()) !== "computer" && (await page.locator("#comfyui").getByRole("button", { name: "Find my ComfyUI" }).isVisible()), String(await where()));
// 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();
@@ -367,9 +398,42 @@ async function hosted() {
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 sleep(8000);
+ check("/connect doesn't connect this computer by itself", (await where()) !== "computer", String(await where()));
await shoot(page, "connect-choose");
await send(page, "/api/settings", { comfyWhere: "server" }, "PUT");
+ // A ComfyUI at a server address that answers (here the server's own stand-in): opening Settings keeps the runs there.
+ await startFake(SERVER_COMFY_PORT, "off");
+ check("a server address that answers", (await send(page, "/api/settings", { comfyUrl: `http://127.0.0.1:${SERVER_COMFY_PORT}`, comfyWhere: "server" }, "PUT")).status === 200);
+ await until(async () => (await api(page, "/api/status")).body?.providers?.comfyui?.configured, 30_000, 1000);
+ await page.goto(`${SITE}/settings`, { waitUntil: "load" });
+ await page.locator("#comfyui").getByText("Use the ComfyUI on this computer instead").first().waitFor({ timeout: 30_000 });
+ await sleep(8000);
+ check("server mode: opening Settings keeps the runs on the server address", (await where()) === "server", String(await where()));
+ await send(page, "/api/settings", { comfyUrl: "" }, "PUT");
+ await stopFake(SERVER_COMFY_PORT);
+
+ // A run that went through (a demo), then "Your GPU · Connect": the card never starts that run again.
+ check("demo on for a moment", (await send(page, "/api/settings", { demoMode: "auto" }, "PUT")).status === 200);
+ await until(async () => !(await api(page, "/api/status")).body?.providers?.comfyui?.configured, 30_000, 1000);
+ await studio(page, "/image?model=oss-z-image-turbo");
+ const demoRun = await generate(page, "a demo first");
+ const demoDone = await until(async () => {
+ const g = await demoRun();
+ return ended(g) && g;
+ }, 60_000, 500);
+ check("the demo run went through", demoDone?.status === "succeeded", demoDone?.error ?? demoDone?.status ?? "no run");
+ const count = (await runs(page)).length;
+ await page.locator('[data-sidebar="footer"]').getByRole("button", { name: /Your GPU\s*Connect/ }).click();
+ const d3 = page.getByRole("dialog");
+ check("the sidebar's Connect: Connect your GPU, with no run waiting", !!(await until(() => d3.getByRole("heading", { name: "Connect your GPU", exact: true }).isVisible(), 15_000)));
+ check("the sidebar's Connect looks at once", !!(await until(() => d3.getByText(/Your GPU is connected/).isVisible(), 30_000)));
+ await sleep(6000);
+ check("no run started again", (await runs(page)).length === count, `${(await runs(page)).length} vs ${count}`);
+ await page.keyboard.press("Escape");
+ await send(page, "/api/settings", { comfyWhere: "server", demoMode: "off" }, "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);