The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Fuobe Connect: offered on Connect your GPU, and first in Set it up with my AI
Adarsh75854aff19de
diff --git a/src/components/gpu/ai-setup/ai-setup-panel.tsx b/src/components/gpu/ai-setup/ai-setup-panel.tsxindex 50e92615..69c7c191 100644--- a/src/components/gpu/ai-setup/ai-setup-panel.tsx+++ b/src/components/gpu/ai-setup/ai-setup-panel.tsx@@ -21,14 +21,15 @@ import { agentLine, AGENTS, AI_TARGETS, chatLink, fullInstructions, isAgent, preimport { nextOf } from "@/lib/ai-setup/next-step";import { personWords } from "@/lib/ai-setup/person-words";import { quietFacts, quietWords, RESTART_SLOW_MS, RESTART_WAIT_MIN } from "@/lib/ai-setup/restart";-import { isConnected, isDone, stepsOf } from "@/lib/ai-setup/steps";+import { isConnected, isDone, isPairing, stepsOf } from "@/lib/ai-setup/steps";import { aiSetupHref, BROWSER_LABEL, browserOf, OS_NAME, pickWay, WAY_LABEL, waysFor, type Os, type Way } from "@/lib/ai-setup/ways";import { useStatus } from "@/lib/api";import { copyText, copyWithToast } from "@/lib/clipboard";import { platformOf } from "@/lib/comfy-install";-import { FUOBE_CONNECT_PUBLISHED } from "@/lib/fuobe-connect";+import { FUOBE_CONNECT, FUOBE_CONNECT_PUBLISHED, pairedOnline } from "@/lib/fuobe-connect";import { deviceLabel } from "@/lib/gpu/readiness";import { cn } from "@/lib/utils";+import { PairWithCode, usePaired } from "../fuobe-connect";import { useComputerSupport } from "../open-connect";import { AllowNote, blockedSteps, GuardFix, OtherPort } from "../this-computer";import { FinishCard, useFirstPicture } from "./first-picture";@@ -135,14 +136,17 @@ export function AiSetupPanel({ onBack, fromRun, onStart, onNotNow, startWay }: A// This browser's way: the ComfyUI on this computer, watched while the AI works.const [connectedHere, setConnectedHere] = useState(false);- const probe = useSetupProbe(way === "direct" && support === "ok", !connectedHere);+ // Fuobe Connect reads ComfyUI from this tab too (in a browser that can reach this computer); a phone, Safari and a page+ // on plain http pair it with a code instead.+ const tabWay = way !== "address";+ const probe = useSetupProbe(tabWay && support === "ok", !connectedHere);const [skipGuard, setSkipGuard] = useState(false);const [switchOk, setSwitchOk] = useState(false);const found = probe.state.s === "found";const allowed = found && (probe.cors === "exact" || probe.guard === "connect") && !probe.listen;const guarded = probe.guard === "guard" || probe.guard === "connect";const auto = useAutoConnect({- ready: way === "direct" && allowed && (guarded || skipGuard) && (saved !== "link" || switchOk),+ ready: tabWay && allowed && (guarded || skipGuard) && (saved !== "link" || switchOk),port: probe.port,host: probe.host,stats: probe.stats,@@ -162,7 +166,7 @@ export function AiSetupPanel({ onBack, fromRun, onStart, onNotNow, startWay }: Aconst now = useNow(5000);const browserState: TabFacts["browser"] =- way !== "direct" ? "unknown" : support !== "ok" ? "unsupported" : probe.state.s === "blocked" ? "blocked" : probe.perm === "granted" ? "granted" : probe.state.s === "start" ? "ask" : "unknown";+ way === "address" ? "unknown" : support !== "ok" ? "unsupported" : probe.state.s === "blocked" ? "blocked" : probe.perm === "granted" ? "granted" : probe.state.s === "start" ? "ask" : "unknown";// Where ComfyUI last answered, and when it stopped: a ComfyUI that went quiet up to 5 minutes ago is starting again// (Fuobe's start file, the AI; a portable one loads every add-on first), so the setup says so, with the time so far,// and doesn't ask to install it. Past that, it says that ComfyUI didn't come back.@@ -214,11 +218,15 @@ export function AiSetupPanel({ onBack, fromRun, onStart, onNotNow, startWay }: A...(picture.cause && { pictureCause: picture.cause }),...(fromRun && { fromRun: true }),};- const server = { gpu: saved, online: saved === "none" ? false : status.data ? online : null } as const;+ // Fuobe Connect: a ComfyUI paired with this account that was heard from in the last minute.+ const pairedQ = usePaired(way === "connect");+ const pairedNow = (pairedQ.data?.paired ?? []).some((p) => pairedOnline(p, now));+ const server = { gpu: saved, online: saved === "none" ? false : status.data ? online || pairedNow : null, paired: pairedNow } as const;const viewNow = { site: typeof window === "undefined" ? "" : window.location.origin, way, os: os ?? "other", phone, tab: { ...facts, tabId: "this-tab-0" }, tabAt: now, server };const steps = stepsOf(viewNow);const connected = isConnected(viewNow);const done = isDone(viewNow);+ const pairing = isPairing(viewNow);// The AI read the status: a fresh look, and while a model is missing, a fresh check of what ComfyUI has.const afterPoke = useRef<() => void>(() => {});@@ -303,7 +311,7 @@ export function AiSetupPanel({ onBack, fromRun, onStart, onNotNow, startWay }: A// ---- The rows' own controls.const extras: Partial<Record<(typeof steps)[number]["id"], React.ReactNode>> = {};- if (way === "direct") {+ if (tabWay && !pairing) {const s = probe.state.s;if (s === "start")extras.comfyui = (@@ -340,15 +348,17 @@ export function AiSetupPanel({ onBack, fromRun, onStart, onNotNow, startWay }: A</>);else if (s === "none") extras.comfyui = <NoComfy onLook={(port, host) => void probe.look({ ports: [{ port, host }] })} missed={probe.state.missed} notComfy={probe.state.notComfy} />;- if (found && saved === "link" && !switchOk && allowed)- extras.allowed = (- <div className="flex flex-wrap items-center gap-2 rounded-lg bg-muted/60 px-2.5 py-2 text-[12px]">- <span>Use this computer instead of your web address?</span>- <Button size="sm" variant="secondary" className="h-8" onClick={() => setSwitchOk(true)}>- Switch- </Button>- </div>- );+ const switchRow = found && saved === "link" && !switchOk && allowed && (+ <div className="flex flex-wrap items-center gap-2 rounded-lg bg-muted/60 px-2.5 py-2 text-[12px]">+ <span>Use this computer instead of your web address?</span>+ <Button size="sm" variant="secondary" className="h-8" onClick={() => setSwitchOk(true)}>+ Switch+ </Button>+ </div>+ );+ if (way === "connect")+ extras.connect = auto.error ? <p className="text-[12px] text-destructive">{auto.error}</p> : switchRow || (probe.guard !== "connect" && <ConnectNote />);+ else if (switchRow) extras.allowed = switchRow;else if (probe.state.s === "needs-setting" && probe.install === "portable" && probe.port)extras.allowed = (<div className="space-y-1.5">@@ -356,14 +366,26 @@ export function AiSetupPanel({ onBack, fromRun, onStart, onNotNow, startWay }: A<GuardFix port={probe.port} install="portable" /></div>);- if (allowed && !guarded && !skipGuard)+ if (way === "direct" && allowed && !guarded && !skipGuard)extras.guard = (<p className="text-[12px] text-muted-foreground">Your AI adds it next. It keeps other websites out of your ComfyUI.{" "}{allowedAt && now - allowedAt > GUARD_WAIT_MS && <Quiet onClick={() => setSkipGuard(true)}>Connect anyway</Quiet>}</p>);- if (auto.error) extras.guard = <p className="text-[12px] text-destructive">{auto.error}</p>;+ if (way === "direct" && auto.error) extras.guard = <p className="text-[12px] text-destructive">{auto.error}</p>;+ }+ // Pairing (a phone, Safari, a page on plain http, a browser that blocks this computer): the code ComfyUI shows.+ if (pairing && !connected) {+ extras.connect = <ConnectNote pairing />;+ extras.paired = (+ <div className="space-y-2">+ <p className="text-[12px] text-muted-foreground">+ In ComfyUI on your computer, open <span className="text-foreground">Extensions → Connect to Fuobe</span> and press Connect. Type the code it shows here.+ </p>+ <PairWithCode />+ </div>+ );}if (way === "address" && !(saved === "link" && online && address.state !== "failed"))extras.address = (@@ -439,13 +461,13 @@ export function AiSetupPanel({ onBack, fromRun, onStart, onNotNow, startWay }: A</div>{/* What Fuobe picked for this browser, and the way to change it. */}- {!phone && (+ {(!phone || ways.length > 1) && (<div className="space-y-2"><p className="flex flex-wrap items-center gap-x-2 text-[12px] text-muted-foreground"><span>{way === "direct"? `For ${OS_NAME[os ?? "other"] || "your computer"} and ${BROWSER_LABEL[browser]}, with ComfyUI on this computer.`- : `For ComfyUI on your ${OS_NAME[os ?? "other"] ? `${OS_NAME[os ?? "other"]} ` : ""}computer, through a web address.`}+ : `For ComfyUI on your ${OS_NAME[os ?? "other"] ? `${OS_NAME[os ?? "other"]} ` : ""}computer, ${way === "connect" ? "with Fuobe Connect" : "through a web address"}.`}</span><Quiet onClick={() => setChanging((v) => !v)}>{changing ? "Done" : "Change"}</Quiet></p>@@ -467,23 +489,25 @@ export function AiSetupPanel({ onBack, fromRun, onStart, onNotNow, startWay }: A</button>))}</TabRow>- <Select value={os ?? undefined} onValueChange={(v) => setOsPicked(v as Os)}>- <SelectTrigger className="h-9 w-36" aria-label="Computer">- <SelectValue placeholder="Computer" />- </SelectTrigger>- <SelectContent>- <SelectItem value="windows">Windows</SelectItem>- <SelectItem value="mac">Mac</SelectItem>- <SelectItem value="linux">Linux</SelectItem>- </SelectContent>- </Select>+ {!phone && (+ <Select value={os ?? undefined} onValueChange={(v) => setOsPicked(v as Os)}>+ <SelectTrigger className="h-9 w-36" aria-label="Computer">+ <SelectValue placeholder="Computer" />+ </SelectTrigger>+ <SelectContent>+ <SelectItem value="windows">Windows</SelectItem>+ <SelectItem value="mac">Mac</SelectItem>+ <SelectItem value="linux">Linux</SelectItem>+ </SelectContent>+ </Select>+ )}</div>)}{(changing || off.length > 0) && <p className="text-[12px] text-muted-foreground">{wayLine(way, support)}</p>}</div>)}- {phone && <PhoneSend site={site} os={os} onOs={setOsPicked} />}+ {phone && <PhoneSend site={site} os={os} way={way} onOs={setOsPicked} />}{!session.mine && (<div className="flex flex-wrap items-center justify-between gap-2 rounded-xl bg-muted px-3 py-2.5 text-[13px]">@@ -529,7 +553,7 @@ export function AiSetupPanel({ onBack, fromRun, onStart, onNotNow, startWay }: Astuck={stuck}next={nextOf(viewNow, now)}onSelf={onBack}- onAddress={way === "direct" ? () => setWay("address") : undefined}+ onAddress={way !== "address" ? () => setWay("address") : undefined}code={session.code}/>}@@ -550,13 +574,40 @@ export function AiSetupPanel({ onBack, fromRun, onStart, onNotNow, startWay }: A/** One line about the way picked. */function wayLine(way: Way, support: string): string {+ if (way === "connect")+ return support === "safari"+ ? "Safari can't reach ComfyUI from a website. With Fuobe Connect, you pair ComfyUI with your account by a code instead, and runs go on with this tab closed."+ : support === "http"+ ? "Your browser marks this page as not secure, so it can't reach ComfyUI from here. With Fuobe Connect, you pair ComfyUI with your account by a code instead."+ : support === "phone"+ ? "Install Fuobe Connect in ComfyUI on your computer, then approve the code it shows on this phone. Runs go on with no Fuobe tab open."+ : "Install Fuobe Connect in ComfyUI once. Fuobe then uses ComfyUI from this tab, or from any browser and phone with a code.";if (support === "safari") return "Safari can't reach ComfyUI from a website. In Chrome, Edge or Firefox, Fuobe uses ComfyUI right from the tab, with nothing public.";if (support === "http") return "Your browser marks this page as not secure, so it can't reach ComfyUI from here. A web address works.";if (way === "address") return "ComfyUI gets a web address. It works from Safari and phones, and runs go on with this tab closed.";- if (way === "connect") return "Install Fuobe Connect once. It works in every browser and with this tab closed.";return "Fuobe uses ComfyUI right from this tab. Runs go while Fuobe is open here.";}+/**+ * Fuobe Connect isn't in ComfyUI yet: the AI installs it, with a link to its page. On this computer's tab, a ComfyUI on+ * another computer can pair with a code instead (`pairing`: the setup pairs already).+ */+function ConnectNote({ pairing }: { pairing?: boolean }) {+ const [code, setCode] = useState(false);+ return (+ <div className="space-y-2">+ <p className="text-[12px] text-muted-foreground">+ {pairing ? "Your AI installs it in ComfyUI on your computer, then restarts ComfyUI." : "Your AI installs it next, then restarts ComfyUI. Fuobe connects by itself once it's there."}{" "}+ <a href={FUOBE_CONNECT.gitUrl} target="_blank" rel="noopener noreferrer" className="text-brand-text underline-offset-4 hover:underline">+ Fuobe Connect on GitHub+ <span className="sr-only"> (opens a new tab)</span>+ </a>+ </p>+ {!pairing && (code ? <PairWithCode /> : <Quiet onClick={() => setCode(true)}>ComfyUI on another computer? Pair it with a code</Quiet>)}+ </div>+ );+}+/** Nothing answers: install it with the AI, or a port of its own (`installed`: ComfyUI ran here a while ago, so no install). */function NoComfy({ onLook, missed, notComfy, installed }: { onLook: (port: number, host: string) => void; missed?: number; notComfy?: number; installed?: boolean }) {const [port, setPort] = useState(false);@@ -1058,7 +1109,7 @@ function ModelDownload({ model, gbTenths, os, onCheck, checking }: { model: Firs}/** On a phone: the steps run on the computer. Send this page there, or use an AI app here with the computer's system picked. */-function PhoneSend({ site, os, onOs }: { site: string; os: Os | null; onOs: (os: Os) => void }) {+function PhoneSend({ site, os, way, onOs }: { site: string; os: Os | null; way: Way; onOs: (os: Os) => void }) {const link = `${site}/connect?setup=ai`;const share = typeof navigator !== "undefined" && typeof navigator.share === "function";return (@@ -1079,7 +1130,11 @@ function PhoneSend({ site, os, onOs }: { site: string; os: Os | null; onOs: (os:</Button><div className="space-y-1.5"><p className="text-[12px] text-muted-foreground">- Or start with an AI app on this phone. The commands run on your computer, and at the end you paste an address into Fuobe on that computer, signed in to this account. Which computer runs ComfyUI?+ Or start with an AI app on this phone. The commands run on your computer.{" "}+ {way === "connect"+ ? "At the end, ComfyUI shows a code, and you type it here."+ : "At the end, you paste an address into Fuobe on that computer, signed in to this account."}{" "}+ Which computer runs ComfyUI?</p><TabRow role="tablist" aria-label="Computer" fade={false} className="w-fit">{(["windows", "mac", "linux"] as Os[]).map((o) => (diff --git a/src/lib/ai-setup/facts.ts b/src/lib/ai-setup/facts.tsindex 2ab17938..ad44a4a2 100644--- a/src/lib/ai-setup/facts.ts+++ b/src/lib/ai-setup/facts.ts@@ -100,6 +100,8 @@ export interface ServerFacts {gpu: "none" | "link" | "computer";/** Answering: a link's last check (null: not checked in the last 30 s), or the computer's tab beating with ComfyUI. */online: boolean | null;+ /** A ComfyUI paired with Fuobe Connect was heard from in the last minute. */+ paired?: boolean;}/** One setup as the steps and the next step read it. */diff --git a/src/lib/ai-setup/guide.ts b/src/lib/ai-setup/guide.tsindex 36da08e6..0f696a44 100644--- a/src/lib/ai-setup/guide.ts+++ b/src/lib/ai-setup/guide.ts@@ -6,6 +6,7 @@*/import { GUARD_SHA256 } from "@/lib/comfy-guard";import { LIVE_NODES_SHA256 } from "@/lib/comfy-live-nodes";+import { FUOBE_CONNECT, trustedByDefault } from "@/lib/fuobe-connect";import { showCode } from "./code";import { MODEL_STEP, STOP_STEP } from "./next-step";import { aiSetupHref, OS_NAME, type BrowserName, type Os, type Way } from "./ways";@@ -45,7 +46,7 @@ function header(i: GuideInput): string {return lines(`# Connect ComfyUI to Fuobe with Fuobe Connect: ${os}`,"",- `This page shows how to connect the ComfyUI on ${on} to Fuobe (${i.site}) with Fuobe Connect, a ComfyUI add-on. Fuobe is a website that makes pictures, video and sound on the person's own GPU.`,+ `This page shows how to connect the ComfyUI on ${on} to Fuobe (${i.site}) with Fuobe Connect, a ComfyUI add-on (${FUOBE_CONNECT.gitUrl}). Fuobe is a website that makes pictures, video and sound on the person's own GPU. With Fuobe Connect, the Fuobe page in Chrome, Edge or Firefox on this computer uses ComfyUI with no new setting. In Safari, on a phone, or on a computer with no screen, the person pairs ComfyUI with their Fuobe account by a code instead, and runs go to it with no Fuobe tab open.`,);return lines(`# Connect ComfyUI to Fuobe: this browser, ${os}`,@@ -96,6 +97,19 @@ function rules(i: GuideInput): string {"7. Use the setup code only with the status address.",...(shell ? ["", shell] : []),);+ if (i.way === "connect")+ return lines(+ "## Rules",+ "",+ "1. Before each command, show it and say in one line what it does. Wait for the person to say yes.",+ "2. This way needs no new ComfyUI setting. Do not add --enable-cors-header. Never use --listen.",+ "3. Do not open ports in a firewall or a router. Do not turn off antivirus, the firewall, SmartScreen or Gatekeeper.",+ "4. Do not change or delete the person's own start files.",+ "5. Restarting ComfyUI stops what it is making now. Ask before it restarts. Do not stop ComfyUI's python yourself: ask the person to close ComfyUI's window.",+ `6. Install only Fuobe Connect, from ${FUOBE_CONNECT.gitUrl} . Do not install other custom nodes. Do not change models or other settings, except the picture model the status asks for${trustedByDefault(i.site) ? "" : " and Fuobe Connect's own list of studios (Step 2)"}.`,+ "7. Use the setup code only with the status address.",+ ...(shell ? ["", shell] : []),+ );return lines("## Rules","",@@ -105,9 +119,7 @@ function rules(i: GuideInput): string {"4. Do not open ports in a firewall or a router. Do not turn off antivirus, the firewall, SmartScreen or Gatekeeper.","5. Do not change or delete the person's own start files. If a start file is needed, make a new one.","6. Restarting ComfyUI stops what it is making now. Ask before it restarts. Do not stop ComfyUI's python yourself: ask the person to close ComfyUI's window.",- i.way === "connect"- ? "7. Install only Fuobe Connect. Do not change models or other settings, except the picture model the status asks for."- : "7. Install only Fuobe's two files (fuobe_guard.py and fuobe_live.py). Do not install other custom nodes. Do not change models or other settings, except the picture model the status asks for.",+ "7. Install only Fuobe's two files (fuobe_guard.py and fuobe_live.py). Do not install other custom nodes. Do not change models or other settings, except the picture model the status asks for.","8. Use the setup code only with the status address.",...(shell ? ["", shell] : []),);@@ -196,8 +208,10 @@ function findComfy(i: GuideInput): string {" tr '\\0' ' ' < /proc/PID/cmdline; echo"," readlink /proc/PID/cwd"," If the command has --base-directory <folder>, that folder holds custom_nodes and models. If not, custom_nodes and models are next to main.py.",- i.way !== "address" &&+ i.way === "direct" &&"4. If ComfyUI runs as a service or in Docker, the setting goes into the start command of that service or container. Ask the person before you change a service or a container.",+ i.way === "connect" &&+ "4. If ComfyUI runs in Docker, custom_nodes is the folder that the container maps to its custom_nodes. Ask the person which folder that is.","","Common places for custom_nodes:","- A git install: ~/ComfyUI/custom_nodes",@@ -439,23 +453,67 @@ function addressSteps(i: GuideInput): string {}function connectSteps(i: GuideInput): string {- return lines(- stepZero(i),- "",- findComfy(i),- "",+ const c = curl(i.os);+ const s = sep(i.os);+ const { gitUrl, folder, archive } = FUOBE_CONNECT;+ const dir = `<custom_nodes>${s}${folder}`;+ const own = !trustedByDefault(i.site);+ const download =+ i.os === "windows"+ ? [+ ` curl.exe -fsSL -o "${dir}.zip" ${archive}.zip`,+ ` Expand-Archive "${dir}.zip" "<custom_nodes>"`,+ ` Rename-Item "${dir}-main" ${folder}`,+ ` Remove-Item "${dir}.zip"`,+ ]+ : [` mkdir -p "${dir}"`, ` curl -fsSL ${archive}.tar.gz | tar -xz --strip-components=1 -C "${dir}"`];+ const install = lines("## Step 2: Install Fuobe Connect","",- "In ComfyUI, the person opens Manager, then Custom Nodes Manager, searches Fuobe Connect, presses Install, then Restart. If there is no Manager, run this in custom_nodes, then restart ComfyUI:",- " git clone https://github.com/workingprototype/ComfyUI-Fuobe-Connect",- "",+ `Fuobe Connect is a ComfyUI add-on (a custom node pack) from ${gitUrl} . It installs no Python packages.`,+ "ComfyUI-Manager's search may not list Fuobe Connect yet. Install it with git or with the download below. The person can also use Install via Git URL in ComfyUI-Manager with the same address, if their Manager allows it.",+ `1. Look in custom_nodes (Step 1) for a folder named ${folder}. If it is there, Fuobe Connect is installed: go to item 5.`,+ "2. Look for git:",+ " git --version",+ " If it answers, clone Fuobe Connect into custom_nodes. Put the real folder in place of <custom_nodes>:",+ ` git clone ${gitUrl} "${dir}"`,+ "3. If git is missing, download Fuobe Connect and unpack it into custom_nodes instead. Put the real folder in place of <custom_nodes>:",+ ...download,+ "4. Restart ComfyUI, so that it loads Fuobe Connect. Ask the person first. Do the part for their install:",+ i.os !== "linux" && " - ComfyUI Desktop: in ComfyUI, Manager, then Restart. Or quit ComfyUI Desktop and open it again.",+ i.os === "windows" && " - Portable or Easy-Install: close ComfyUI's window, then start ComfyUI again the usual way (for example run_nvidia_gpu.bat).",+ " - Stability Matrix: stop ComfyUI and launch it again.",+ ` - Started from ${i.os === "mac" ? "Terminal" : "a terminal"}: stop ComfyUI with Ctrl+C in its window, then start it again with the same command.`,+ i.os === "linux" && " - A service or Docker: restart that service or container.",+ `5. Make sure that ComfyUI loaded it. Put ComfyUI's port in place of 8188. The answer has "connect": 1:`,+ ` ${c} -s http://127.0.0.1:8188/fuobe/connect`,+ ` If nothing answers, ComfyUI is still starting: wait 30 seconds, then try again. If the answer is 404, ComfyUI didn't load Fuobe Connect: make sure that __init__.py is right inside ${dir} (not in a second folder inside it), and read the last lines of ComfyUI's window with the person.`,+ own &&+ `6. Fuobe Connect trusts https://fuobe.com by itself, not this studio. Ask the person to open ComfyUI's Settings, then Fuobe Connect, and to enter ${i.site} in Fuobe studios that may use this ComfyUI. Or start ComfyUI with the environment variable FUOBE_CONNECT_ORIGINS=${i.site}.`,+ );+ const host = new URL(i.site).host;+ const headless =+ i.os === "windows"+ ? `3. On a computer with no screen, start ComfyUI with the environment variable FUOBE_CONNECT_PAIR=1${own ? ` and FUOBE_CONNECT_SITE=${i.site}` : ""}: in Command Prompt, run set FUOBE_CONNECT_PAIR=1${own ? ` and set FUOBE_CONNECT_SITE=${i.site}` : ""}, then start ComfyUI in the same window. The code and the link to approve it are then in ComfyUI's window.`+ : `3. On a computer with no screen, start ComfyUI with the environment variable FUOBE_CONNECT_PAIR=1${own ? ` and FUOBE_CONNECT_SITE=${i.site}` : ""}, for example in ComfyUI's folder:`;+ const connect = lines("## Step 3: Connect","",- "- In Chrome, Edge or Firefox: Fuobe connects by itself.",- `- In Safari or on a phone: in ComfyUI open Extensions, then Connect to Fuobe. The person approves the code it shows at ${i.site}/connect.`,+ "In Chrome, Edge or Firefox on the computer that runs ComfyUI:",+ `1. The browser can ask the person to let ${host} access other apps and services on this device. The person presses Allow.`,+ "2. If the browser blocked it before:",+ ...BROWSER_LINES.map((b) => b.line),+ "3. Read the status. Fuobe connects by itself when it sees Fuobe Connect.","",- modelStep(i),+ "In Safari, on a phone, or for a computer with no screen, pair ComfyUI with the person's Fuobe account. The commands still run on the computer that runs ComfyUI:",+ "1. In ComfyUI, the person opens Extensions (in ComfyUI's top menu), then Connect to Fuobe, and presses the Connect button. ComfyUI shows a code like ABCD-EFGH.",+ `2. The person types that code into Fuobe, in the box The code ComfyUI shows, and presses Approve. The box is on Fuobe's setup page, and at ${i.site}/connect?pair=1, signed in to the same account.`,+ headless,+ i.os !== "windows" && ` ${own ? `FUOBE_CONNECT_SITE=${i.site} ` : ""}FUOBE_CONNECT_PAIR=1 python3 main.py`,+ i.os !== "windows" && " The code and the link to approve it are then in ComfyUI's window or its log.",+ "4. Read the status. Once the person approves the code, runs go to this ComfyUI with no Fuobe tab open, while ComfyUI runs.",);+ return lines(stepZero(i), "", findComfy(i), "", install, "", connect, "", modelStep(i));}/** The guide for a computer whose system isn't known: which one, then that guide. */diff --git a/src/lib/ai-setup/handoff.ts b/src/lib/ai-setup/handoff.tsindex 25ce536e..14f41ef9 100644--- a/src/lib/ai-setup/handoff.ts+++ b/src/lib/ai-setup/handoff.ts@@ -36,10 +36,11 @@ const hostOf = (site: string) => new URL(site).host;export function prefillText(i: HandoffInput): string {const code = showCode(i.code);const steps = `Steps: ${i.site}/api/setup/guide/${i.way}/${i.os}`;+ const where = i.phone ? " I am on my phone now, so every command runs on the computer." : ` I use ${BROWSER_LABEL[i.browser]}.`;const first =i.way === "address"- ? `Please help me give the ComfyUI ${onMyComputer(i.os)} a web address for Fuobe (${hostOf(i.site)}), so Fuobe can run on my own GPU.${i.phone ? " I am on my phone now, so every command runs on the computer." : ` I use ${BROWSER_LABEL[i.browser]}.`}`- : `Please help me connect ComfyUI ${onMyComputer(i.os)} to Fuobe (${hostOf(i.site)}), so Fuobe can run on my own GPU. I use ${BROWSER_LABEL[i.browser]}.`;+ ? `Please help me give the ComfyUI ${onMyComputer(i.os)} a web address for Fuobe (${hostOf(i.site)}), so Fuobe can run on my own GPU.${where}`+ : `Please help me connect ComfyUI ${onMyComputer(i.os)} to Fuobe (${hostOf(i.site)})${i.way === "connect" ? " with Fuobe Connect" : ""}, so Fuobe can run on my own GPU.${where}`;const core = [first, steps, `My setup code: ${code}`, `Fuobe's status for it: ${i.site}/api/setup/${code}`, "Read the steps first. Then guide me one step at a time. Show me each command and wait for my OK before it runs."];// Kept while the message stays short (a long studio address leaves less room).const extra = ["If you can't open links, tell me and I will paste the steps.", ...(i.way === "address" ? ["The web address cloudflared makes works like a key: help me put it into Fuobe, not into this chat."] : [])];diff --git a/src/lib/ai-setup/next-step.ts b/src/lib/ai-setup/next-step.tsindex c7f9b050..79a2e660 100644--- a/src/lib/ai-setup/next-step.ts+++ b/src/lib/ai-setup/next-step.ts@@ -3,11 +3,12 @@* shows it. The status (GET /api/setup/<code>) and the panel's "Stuck?" say the same. Every word comes from the tables* here; only fixed words, whole numbers and the studio's own address go into them. ASCII only. Pure.*/+import { FUOBE_CONNECT, trustedByDefault } from "@/lib/fuobe-connect";import { COMFY_PORTS } from "@/lib/local-comfy";import { FIRST_MODEL_NAME } from "./first-picture";import type { AddressCause, InstallKind, SetupView } from "./facts";import { RESTART_WAIT_MIN } from "./restart";-import { isConnected, isDone } from "./steps";+import { isConnected, isDone, isPairing } from "./steps";import { aiSetupHref, type BrowserName, type Os, type Way } from "./ways";export interface NextStep {@@ -90,6 +91,28 @@ const ON_COMPUTER_HOW = ["The person pastes the address there (it is on that computer's clipboard) and presses Connect.",];+const curlOf = (os: Os) => (os === "windows" ? "curl.exe" : "curl");++/** A studio Fuobe Connect doesn't trust by itself (a self-hosted one): the person adds its address in ComfyUI. */+const ADD_STUDIO = "Fuobe Connect trusts https://fuobe.com by itself, not this studio. In ComfyUI, the person opens Settings, then Fuobe Connect, and enters {site} (guide Step 2).";++/** Fuobe Connect isn't in ComfyUI yet: where it comes from. */+const installHow = (site: string): string[] => [+ `ComfyUI-Manager's search may not list Fuobe Connect yet. Clone ${FUOBE_CONNECT.gitUrl} into custom_nodes, or use the download in guide Step 2.`,+ ...(trustedByDefault(site) ? [] : [ADD_STUDIO]),+];++/** Pairing: the code that ComfyUI shows, approved in Fuobe by the person. */+function pairHow(v: SetupView): string[] {+ const own = !trustedByDefault(v.site);+ return [+ "In ComfyUI on the computer, the person opens Extensions (in ComfyUI's top menu), then Connect to Fuobe, and presses the Connect button. ComfyUI shows a code like ABCD-EFGH.",+ `The person types that code into Fuobe${v.phone ? " on the phone" : ""}, in the box The code ComfyUI shows, and presses Approve. Or at {site}/connect?pair=1, signed in to the same account.`,+ `On a computer with no screen, start ComfyUI with the environment variable FUOBE_CONNECT_PAIR=1${own ? " (and FUOBE_CONNECT_SITE={site})" : ""}. The code is then in ComfyUI's window or its log.`,+ ...(own ? [ADD_STUDIO] : []),+ ];+}+const gb = (tenths: number) => `${(tenths / 10).toFixed(tenths >= 100 ? 0 : 1)} GB`;/** The status words' site: the studio's own address (never a visitor's word). */@@ -125,17 +148,33 @@ export function nextOf(v: SetupView, now: number): NextStep {// The Fuobe tab: its checks need it open. A web address that Fuobe doesn't have yet needs no tab until it is pasted// (a phone's tab sleeps while the person reads their AI): the next step is the tunnel, and the page to paste it in.+ // Pairing needs no tab either until the code is approved: the server sees the paired ComfyUI itself.const quiet = !t || now - v.tabAt > TAB_QUIET_MS;- if (quiet && !(way === "address" && v.server.gpu !== "link")) {+ const pairs = isPairing(v);+ if (quiet && !(way === "address" && v.server.gpu !== "link") && !pairs) {if (t && !t.visible)return say("wake-fuobe", "The Fuobe tab is asleep in the background, so Fuobe can't check. Ask the person to click on the Fuobe tab once, then come back to you.");return way === "address"? say("open-fuobe", `The Fuobe page isn't open. Ask the person to open ${ADDRESS_PAGE} in a browser on the computer that runs ComfyUI, signed in to the same account. The setup code stays the same.`): say("open-fuobe",- `The Fuobe page isn't open. Ask the person to open {site}${aiSetupHref()} in Chrome, Edge or Firefox on the computer that runs ComfyUI, signed in to the same account. The setup code stays the same.`,+ `The Fuobe page isn't open. Ask the person to open {site}${aiSetupHref(way)} in ${way === "connect" ? "a browser" : "Chrome, Edge or Firefox"} on the computer that runs ComfyUI, signed in to the same account. The setup code stays the same.`,);}+ if (pairs) {+ if (isDone(v))+ return say("done", "Done. Fuobe uses this GPU now. Nothing else to do.", [+ "Runs go to the paired ComfyUI while it runs, with no Fuobe tab open.",+ `If ComfyUI has no picture model yet, guide Step ${MODEL_STEP.connect} lists one for each size of GPU. Ask the person first: the files are big.`,+ ]);+ const blocked = t?.browser === "blocked" ? [`Or, to connect from this browser instead: ${BLOCKED_HOW[t.browserName ?? "other"]}`] : [];+ return say(+ "pair",+ "Fuobe Connect pairs ComfyUI with the person's Fuobe account. If it isn't in ComfyUI yet, install it (guide Step 2) and restart ComfyUI. Then pair it (guide Step 3).",+ [...pairHow(v), ...blocked],+ 2,+ );+ }if (!t || quiet) return startTunnel(v, say, false);if (isDone(v)) {@@ -145,7 +184,9 @@ export function nextOf(v: SetupView, now: number): NextStep {"Keep cloudflared running while runs go. Each time cloudflared starts again, it makes a new address: paste the new one in Fuobe.",`Tell the person that closing the cloudflared window stops the address, and that anyone with the address can use ComfyUI while it runs. When they are done for the day, stop cloudflared (guide Step ${STOP_STEP}).`,]- : ["Keep a Fuobe tab open on this computer while runs go."];+ : way === "connect"+ ? ["Keep a Fuobe tab open on this computer while runs go.", "For runs with no Fuobe tab open, the person can also pair this ComfyUI with a code (guide Step 3)."]+ : ["Keep a Fuobe tab open on this computer while runs go."];return say("done", "Done. Fuobe uses this GPU now. Nothing else to do.", keep);}@@ -167,7 +208,7 @@ export function nextOf(v: SetupView, now: number): NextStep {"allow-browser","Fuobe hasn't looked for ComfyUI on this computer yet. If ComfyUI runs now, ask the person to press Let Fuobe look in Fuobe, and Allow if the browser asks. If ComfyUI isn't installed yet, start with guide Step 0, and ask for the press once it runs.",[],- 5,+ way === "connect" ? 3 : 5,);if (t.browser === "blocked")return say("unblock-browser", "The browser blocks Fuobe from reaching apps on this computer.", [BLOCKED_HOW[t.browserName ?? "other"], "Or the person switches to A web address in Fuobe."], 5);@@ -197,7 +238,19 @@ export function nextOf(v: SetupView, now: number): NextStep {["If the person closed ComfyUI, ask them to start it again.", `Fuobe says so if ComfyUI isn't back after ${RESTART_WAIT_MIN} minutes.`],);if (way === "connect") {- if (t.guard !== "connect") return say("install-connect", "Fuobe Connect isn't in ComfyUI yet. Install it (guide Step 2), then restart ComfyUI.", [], 2);+ if (t.guard !== "connect" && t.comfy === "unreadable" && t.restarted)+ return say(+ "connect-not-loaded",+ "ComfyUI restarted, but Fuobe still can't use it. ComfyUI didn't load Fuobe Connect.",+ [+ `The folder ${FUOBE_CONNECT.folder} in custom_nodes must hold __init__.py itself, not in a second folder inside it.`,+ `${curlOf(v.os)} -s http://127.0.0.1:${t.port ?? 8188}/fuobe/connect answers {"connect": 1, ...} once ComfyUI loaded it. If it answers 404, read the last lines in ComfyUI's window with the person: they name each add-on that didn't load, and why.`,+ ...(trustedByDefault(site) ? [] : [ADD_STUDIO]),+ ],+ 2,+ );+ if (t.guard !== "connect") return say("install-connect", "Fuobe Connect isn't in ComfyUI yet. Install it (guide Step 2), then restart ComfyUI.", installHow(site), 2);+ if (t.listen) return say("remove-listen", "ComfyUI listens on the network (--listen). Fuobe doesn't need that, and it lets other computers use ComfyUI. Restart ComfyUI without --listen.");return say("connecting", "Fuobe sees ComfyUI and is connecting. Wait a few seconds, then check again.");}if (t.comfy === "unreadable") {diff --git a/src/lib/ai-setup/person-words.ts b/src/lib/ai-setup/person-words.tsindex 2b84ac27..64849af1 100644--- a/src/lib/ai-setup/person-words.ts+++ b/src/lib/ai-setup/person-words.ts@@ -16,6 +16,8 @@ const WORDS: Record<string, string> = {restarting: "ComfyUI is starting again, or it was closed. A portable ComfyUI can take up to 5 minutes to start.","not-back": "ComfyUI stopped a few minutes ago and hasn't come back. Look at its window for an error, or start it again.","install-connect": "Fuobe Connect isn't in ComfyUI yet. Your AI installs it next.",+ "connect-not-loaded": "ComfyUI restarted, but it didn't load Fuobe Connect. Your AI checks the folder and ComfyUI's window.",+ pair: "Once Fuobe Connect is in ComfyUI, open Extensions, then Connect to Fuobe, in ComfyUI. Type the code it shows here.",connecting: "Fuobe sees ComfyUI and is connecting. It takes a few seconds.","setting-not-taken": "ComfyUI restarted, but it still doesn't let Fuobe in. Your AI checks the setting.","add-setting": "ComfyUI runs, but it doesn't let Fuobe in yet. Your AI adds Fuobe's setting next.",diff --git a/src/lib/ai-setup/steps.ts b/src/lib/ai-setup/steps.tsindex 2af4f993..5f83186a 100644--- a/src/lib/ai-setup/steps.ts+++ b/src/lib/ai-setup/steps.ts@@ -7,7 +7,7 @@ import { FIRST_MODEL_NAME } from "./first-picture";import type { InstallKind, SetupView } from "./facts";import { RESTART_WAIT_MIN } from "./restart";-export type StepId = "comfyui" | "allowed" | "guard" | "connect" | "address" | "connected" | "model" | "picture";+export type StepId = "comfyui" | "allowed" | "guard" | "connect" | "paired" | "address" | "connected" | "model" | "picture";export type StepState = "done" | "todo" | "working" | "warn";export interface Step {@@ -29,6 +29,7 @@ export const STEP_LABEL: Record<StepId, string> = {allowed: "ComfyUI lets Fuobe in",guard: "Other websites are kept out",connect: "Fuobe Connect is installed",+ paired: "ComfyUI is paired with your account",address: "Web address works",connected: "Fuobe is connected",model: "A picture model is ready",@@ -45,15 +46,33 @@ const hostOf = (site: string) => {const gb = (tenths: number) => `${(tenths / 10).toFixed(tenths >= 100 ? 0 : 1)} GB`;+/** A ComfyUI paired with Fuobe Connect answers, and the account's runs go to it. */+const pairedOnline = (v: SetupView): boolean => v.server.gpu === "computer" && v.server.paired === true;++/**+ * Fuobe Connect by pairing: on a phone, in a browser that can't reach this computer (Safari, a page on plain http) or+ * blocks it, or when a paired ComfyUI answers while this tab sees no ComfyUI here. The person approves the code that+ * ComfyUI shows, and the setup ends once that ComfyUI answers (Fuobe reads its models only from a tab on its computer).+ */+export function isPairing(v: SetupView): boolean {+ if (v.way !== "connect") return false;+ const t = v.tab;+ return v.phone || t?.browser === "unsupported" || t?.browser === "blocked" || (pairedOnline(v) && t?.comfy !== "found");+}+/** Runs go to this setup's ComfyUI now. */export function isConnected(v: SetupView): boolean {const t = v.tab;if (v.way === "address") return v.server.gpu === "link" && v.server.online === true;+ if (isPairing(v)) return pairedOnline(v);return !!t?.connected || (v.server.gpu === "computer" && v.server.online === true && t?.comfy === "found");}-/** The setup is finished: the first picture is made, or (opened from a run) runs go to the GPU and that run starts. */-export const isDone = (v: SetupView): boolean => v.tab?.picture === "ok" || (!!v.tab?.fromRun && isConnected(v));+/**+ * The setup is finished: the first picture is made, or (opened from a run) runs go to the GPU and that run starts, or a+ * paired ComfyUI answers.+ */+export const isDone = (v: SetupView): boolean => v.tab?.picture === "ok" || ((!!v.tab?.fromRun || isPairing(v)) && isConnected(v));function step(id: StepId, state: StepState, detail?: string): Step {return { id, label: STEP_LABEL[id], state, ...(detail && { detail }) };@@ -94,6 +113,7 @@ export function stepsOf(v: SetupView): Step[] {const t = v.tab;const connected = isConnected(v);const tail = (): Step[] => (t?.fromRun ? [pictureStep(v, connected)] : [modelStep(v, connected), pictureStep(v, connected)]);+ if (isPairing(v)) return [step("connect", connected ? "done" : "todo"), step("paired", connected ? "done" : "todo", connected ? "Runs go there with no Fuobe tab open" : undefined)];if (v.way === "address") {const linked = v.server.gpu === "link";const address =@@ -129,8 +149,15 @@ export function stepsOf(v: SetupView): Step[] {: step("comfyui", "todo");if (v.way === "connect") {- const guarded = t?.guard === "connect" ? step("connect", "done", "Other websites stay out") : step("connect", "todo");- return [running, guarded, ...tail()];+ const installed =+ t?.guard === "connect"+ ? t.listen+ ? step("connect", "warn", "ComfyUI is open to the network")+ : step("connect", "done", "Other websites stay out")+ : t?.comfy === "unreadable" && t.restarted+ ? step("connect", "warn", "ComfyUI didn't load it")+ : step("connect", "todo");+ return [running, installed, ...tail()];}const found = t?.comfy === "found";diff --git a/src/lib/ai-setup/ways.ts b/src/lib/ai-setup/ways.tsindex 5f02e78f..e18d1a95 100644--- a/src/lib/ai-setup/ways.ts+++ b/src/lib/ai-setup/ways.ts@@ -6,7 +6,9 @@* runs the jobs. Chrome, Edge, Firefox, Brave or Opera on a computer.* - address ("A web address"): a cloudflared quick tunnel, whose address the person pastes into Fuobe. Safari, phones,* and runs that go on with the tab closed.- * - connect ("Fuobe Connect"): offered first once FUOBE_CONNECT_PUBLISHED is true.+ * - connect ("Fuobe Connect"): the ComfyUI add-on, offered first while FUOBE_CONNECT_PUBLISHED is true. Chrome, Edge+ * or Firefox on the computer use ComfyUI from the tab, with no setting; Safari, phones, a blocked browser and a+ * computer with no screen pair ComfyUI with the account by a code, and runs go on with the tab closed.*/import type { Platform } from "@/lib/comfy-install";diff --git a/src/lib/fuobe-connect.ts b/src/lib/fuobe-connect.tsindex 3564755a..fdecf015 100644--- a/src/lib/fuobe-connect.ts+++ b/src/lib/fuobe-connect.ts@@ -6,17 +6,21 @@/*** Fuobe Connect's repository is published: the "Connect your GPU" screens offer it (install it, pair with a code), and- * "Set it up with my AI" offers it first. Until then they offer Fuobe's setting with Fuobe's guard, and a web address.+ * "Set it up with my AI" offers it first. Turned off, they offer Fuobe's setting with Fuobe's guard, and a web address.* Nothing else decides whether Fuobe Connect is offered.*/-export const FUOBE_CONNECT_PUBLISHED: boolean = false;+export const FUOBE_CONNECT_PUBLISHED: boolean = true;export const FUOBE_CONNECT = {name: "Fuobe Connect",- /** What to type in ComfyUI-Manager's Custom Nodes Manager. */+ /** What to type in ComfyUI-Manager's Custom Nodes Manager (it finds it once the Comfy Registry lists it). */search: "Fuobe Connect",- /** For "Install via Git URL", or a git clone in ComfyUI's custom_nodes folder. */+ /** Its page, for "Install via Git URL", and for a git clone in ComfyUI's custom_nodes folder. */gitUrl: "https://github.com/workingprototype/ComfyUI-Fuobe-Connect",+ /** Its folder in custom_nodes. */+ folder: "ComfyUI-Fuobe-Connect",+ /** The main branch as a download, for a computer with no git (.zip or .tar.gz after it). */+ archive: "https://github.com/workingprototype/ComfyUI-Fuobe-Connect/archive/refs/heads/main",/** The studios it trusts when the person names none. */defaultStudios: ["https://fuobe.com", "https://www.fuobe.com"],} as const;diff --git a/src/server/ai-setup.ts b/src/server/ai-setup.tsindex 947ad62b..c0c751ee 100644--- a/src/server/ai-setup.ts+++ b/src/server/ai-setup.ts@@ -7,8 +7,10 @@ import type { ServerFacts, SetupView, TabFacts } from "@/lib/ai-setup/facts";import { TAB_QUIET_MS } from "@/lib/ai-setup/next-step";import { isDone } from "@/lib/ai-setup/steps";import { isOs, isWay, type Os, type Way } from "@/lib/ai-setup/ways";+import { pairedOnline } from "@/lib/fuobe-connect";import { cachedGpuState, computerView } from "./account-gpu";import { accountById, accountGpu, LoginGuard } from "./auth";+import { pairedOf } from "./computer/workers";import { open, seal } from "./secret-box";/**@@ -149,11 +151,18 @@ export function siteOf(headers: Headers, url: string): string | null {// ---------------------------------------------------------------------------// What the server knows itself-/** The account's saved GPU (a database read) and whether it answers: a link's cached check, or the computer's tab. Never a call to the GPU. */-export function serverFacts(accountId: string): ServerFacts {+/**+ * The account's saved GPU (a database read) and whether it answers: a link's cached check, or the computer (its tab, or+ * a ComfyUI paired with Fuobe Connect). Never a call to the GPU.+ */+export function serverFacts(accountId: string, now = Date.now()): ServerFacts {const gpu = accountGpu(accountId);if (!gpu) return { gpu: "none", online: false };- if (gpu.mode === "computer") return { gpu: "computer", online: computerView(`acct:${accountId}`).online };+ if (gpu.mode === "computer") {+ const principal = `acct:${accountId}` as const;+ const paired = pairedOf(principal).some((p) => pairedOnline(p, now));+ return { gpu: "computer", online: computerView(principal).online || paired, paired };+ }return { gpu: "link", online: cachedGpuState(accountId, gpu.url)?.online ?? null };}diff --git a/tests/ai-setup-guide.test.ts b/tests/ai-setup-guide.test.tsindex 714390fb..f11adcdb 100644--- a/tests/ai-setup-guide.test.ts+++ b/tests/ai-setup-guide.test.ts@@ -18,7 +18,7 @@ const MODELS: GuideModel[] = [{ name: "Z-Image Turbo", fits: "for a GPU with 12 GB or more", files: [{ file: "z_image_turbo_bf16.safetensors", folder: "diffusion_models", url: "https://huggingface.co/x/resolve/main/z.safetensors", sizeGb: 12.31 }] },{ name: "SDXL", fits: "for a GPU with 8 GB or more", files: [{ file: "sd_xl_base_1.0.safetensors", folder: "checkpoints", url: "https://huggingface.co/y/resolve/main/s.safetensors?download=true", sizeGb: 6.94 }] },];-const WAYS: Way[] = ["direct", "address"];+const WAYS: Way[] = ["direct", "address", "connect"];const guides = WAYS.flatMap((way) => OSES.map((os) => ({ way, os, text: guideText({ way, os, site: SITE, models: MODELS }) })));const commands = (text: string) => text.split("\n").filter((l) => /^ {3}\S/.test(l));@@ -101,7 +101,7 @@ describe("the guide", () => {it("Windows commands have no $ and no braces, so they also run through powershell.exe -Command", () => {for (const g of guides.filter((g) => g.os === "windows")) {for (const line of commands(g.text)) {- if (!/^ {3}(curl\.exe|Get-|New-Item|Start-Process|Select-String|Remove-Item|Stop-Process|certutil|winget|cloudflared)/.test(line)) continue;+ if (!/^ {3}(curl\.exe|Get-|New-Item|Start-Process|Select-String|Remove-Item|Stop-Process|Expand-Archive|Rename-Item|certutil|winget|cloudflared|git )/.test(line)) continue;expect(line.replace("%{http_code}", ""), line).not.toMatch(/[$`{}]/);}expect(g.text).toContain("winget install --id Cloudflare.cloudflared -e --accept-source-agreements --accept-package-agreements".repeat(g.way === "address" ? 1 : 0));@@ -131,6 +131,71 @@ describe("the guide", () => {expect(other).toContain(`${SITE}/api/setup/guide/direct/windows`);});+ it("installs Fuobe Connect from its repository, with every command written out, then restarts ComfyUI", () => {+ const REPO = "https://github.com/workingprototype/ComfyUI-Fuobe-Connect";+ const step2 = (t: string) => t.slice(t.indexOf("## Step 2: Install Fuobe Connect"), t.indexOf("## Step 3: Connect"));+ const expected: Record<"windows" | "mac" | "linux", string[]> = {+ windows: [+ " git --version",+ ` git clone ${REPO} "<custom_nodes>\\ComfyUI-Fuobe-Connect"`,+ ` curl.exe -fsSL -o "<custom_nodes>\\ComfyUI-Fuobe-Connect.zip" ${REPO}/archive/refs/heads/main.zip`,+ ' Expand-Archive "<custom_nodes>\\ComfyUI-Fuobe-Connect.zip" "<custom_nodes>"',+ ' Rename-Item "<custom_nodes>\\ComfyUI-Fuobe-Connect-main" ComfyUI-Fuobe-Connect',+ ' Remove-Item "<custom_nodes>\\ComfyUI-Fuobe-Connect.zip"',+ " curl.exe -s http://127.0.0.1:8188/fuobe/connect",+ ],+ mac: [+ " git --version",+ ` git clone ${REPO} "<custom_nodes>/ComfyUI-Fuobe-Connect"`,+ ' mkdir -p "<custom_nodes>/ComfyUI-Fuobe-Connect"',+ ` curl -fsSL ${REPO}/archive/refs/heads/main.tar.gz | tar -xz --strip-components=1 -C "<custom_nodes>/ComfyUI-Fuobe-Connect"`,+ " curl -s http://127.0.0.1:8188/fuobe/connect",+ ],+ linux: [],+ };+ expected.linux = expected.mac;+ for (const g of guides.filter((g) => g.way === "connect" && g.os !== "other")) {+ const os = g.os as "windows" | "mac" | "linux";+ // Every command of the install, and nothing else: a command line starts with a program, never a dash or a sentence.+ expect(commands(step2(g.text)).filter((l) => !/^ {3}(- |[A-Z][a-z]+ )/.test(l)), os).toEqual(expected[os]);+ expect(g.text).toContain(`Fuobe Connect is a ComfyUI add-on (a custom node pack) from ${REPO} .`);+ expect(g.text).toContain("ComfyUI-Manager's search may not list Fuobe Connect yet.");+ expect(g.text).toContain("Install via Git URL");+ expect(g.text).toContain(`6. Install only Fuobe Connect, from ${REPO} . Do not install other custom nodes.`);+ expect(g.text).toContain("2. This way needs no new ComfyUI setting. Do not add --enable-cors-header. Never use --listen.");+ expect(g.text).toContain("Do not change or delete the person's own start files.");+ expect(g.text).toContain("Restarting ComfyUI stops what it is making now. Ask before it restarts.");+ // Nothing runs a downloaded script, and nothing installs Python packages.+ expect(g.text).not.toMatch(/\|\s*(sh|bash|iex|python)\b|Invoke-Expression|pip install/);+ // The restart for each install the person can have on this system.+ expect(g.text).toContain("4. Restart ComfyUI, so that it loads Fuobe Connect.");+ expect(g.text).toContain(" - Stability Matrix: stop ComfyUI and launch it again.");+ expect(g.text).toContain("stop ComfyUI with Ctrl+C in its window, then start it again with the same command.");+ expect(g.text.includes(" - ComfyUI Desktop: in ComfyUI, Manager, then Restart."), os).toBe(os !== "linux");+ expect(g.text.includes(" - Portable or Easy-Install: close ComfyUI's window"), os).toBe(os === "windows");+ expect(g.text.includes(" - A service or Docker: restart that service or container."), os).toBe(os === "linux");+ // Pairing: the code ComfyUI shows, approved in Fuobe; never a code from a link.+ expect(g.text).toContain("then Connect to Fuobe, and presses the Connect button");+ expect(g.text).toContain(`${SITE}/connect?pair=1`);+ expect(g.text).toContain("FUOBE_CONNECT_PAIR=1");+ // fuobe.com is trusted by Fuobe Connect itself: no studio to add.+ expect(g.text).not.toMatch(/FUOBE_CONNECT_ORIGINS|FUOBE_CONNECT_SITE|studios that may use this ComfyUI/);+ expect(g.text).toContain(`## Step ${MODEL_STEP.connect}: Get a first picture model`);+ }+ });++ it("adds a self-hosted studio to Fuobe Connect's list, which trusts only fuobe.com by itself", () => {+ const own = "https://studio.example.com";+ for (const os of ["windows", "mac", "linux"] as const) {+ const g = guideText({ way: "connect", os, site: own });+ expect(g).toContain(`enter ${own} in Fuobe studios that may use this ComfyUI. Or start ComfyUI with the environment variable FUOBE_CONNECT_ORIGINS=${own}.`);+ expect(g).toContain("except the picture model the status asks for and Fuobe Connect's own list of studios (Step 2).");+ expect(g).toContain(`FUOBE_CONNECT_SITE=${own}`);+ expect(g).toContain(`${own}/connect?pair=1`);+ expect(g).not.toContain("https://fuobe.com/");+ }+ });+it("fills in the code and keeps only the person's browser for Copy instructions", () => {const g = guideText({ way: "direct", os: "windows", site: SITE });const filled = withCode(g, "ABCDEFGHJKMN", SITE, "firefox");diff --git a/tests/ai-setup-routes.test.ts b/tests/ai-setup-routes.test.tsindex 336d49cb..10fb23b0 100644--- a/tests/ai-setup-routes.test.ts+++ b/tests/ai-setup-routes.test.ts@@ -110,9 +110,21 @@ describe("making a setup code", () => {expect((await read(fresh.body.code)).status).toBe(200);});- it("refuses unknown keys, Fuobe Connect while it isn't out, and a site it doesn't know", async () => {+ it("takes Fuobe Connect as a way, with its own guide", async () => {+ const r = await create(a, { way: "connect", os: "windows" });+ expect(r.status).toBe(201);+ expect(r.body.guideUrl).toBe("https://fuobe.com/api/setup/guide/connect/windows");+ const again = await create(a, { way: "connect", os: "mac" });+ expect(again.status).toBe(200);+ expect(again.body.code).toBe(r.body.code);+ expect(again.body.guideUrl).toBe("https://fuobe.com/api/setup/guide/connect/mac");+ expect((await read(r.body.code)).status).toBe(200);+ expect((await create(a, { way: "plugin", os: "mac" })).status).toBe(400);+ });++ it("refuses unknown keys, an unknown way, and a site it doesn't know", async () => {expect((await create(a, { way: "direct", os: "windows", extra: 1 })).status).toBe(400);- expect((await create(a, { way: "connect", os: "windows" })).status).toBe(400);+ expect((await create(a, { way: "connect", os: "beos" })).status).toBe(400);const r = await sessionRoute.POST(new Request("https://evil.example/api/setup/session", { method: "POST", headers: { host: "evil.example", cookie: `${auth.SESSION_COOKIE}=${a}`, "content-type": "application/json" }, body: JSON.stringify({ way: "direct", os: "windows" }) }));expect(r.status).toBe(400);});@@ -335,8 +347,25 @@ describe("the guide and Fuobe's files", () => {expect(text).toContain("z_image_turbo_bf16.safetensors");const evil = await guideRoute.GET(new Request("https://evil.example/api/setup/guide/direct/windows", { headers: { host: "evil.example" } }), ctx({ way: "direct", os: "windows" }));expect(evil.status).toBe(404);- expect((await guideRoute.GET(req("/api/setup/guide/connect/windows"), ctx({ way: "connect", os: "windows" }))).status).toBe(404);expect((await guideRoute.GET(req("/api/setup/guide/direct/beos"), ctx({ way: "direct", os: "beos" }))).status).toBe(404);+ expect((await guideRoute.GET(req("/api/setup/guide/plugin/windows"), ctx({ way: "plugin", os: "windows" }))).status).toBe(404);+ });++ it("serve Fuobe Connect's steps: install it from its repository, then connect or pair", async () => {+ for (const os of ["windows", "mac", "linux"]) {+ const g = await guideRoute.GET(req(`/api/setup/guide/connect/${os}`), ctx({ way: "connect", os }));+ expect(g.status, os).toBe(200);+ const text = await g.text();+ expect(text).toContain("# Connect ComfyUI to Fuobe with Fuobe Connect");+ expect(text).toContain("git clone https://github.com/workingprototype/ComfyUI-Fuobe-Connect");+ expect(text).toContain("ComfyUI-Manager's search may not list Fuobe Connect yet.");+ expect(text).not.toContain("--enable-cors-header https://");+ expect(text).toContain("z_image_turbo_bf16.safetensors");+ }+ const other = await guideRoute.GET(req("/api/setup/guide/connect/other"), ctx({ way: "connect", os: "other" }));+ expect(await other.text()).toContain("https://fuobe.com/api/setup/guide/connect/windows");+ const evil = await guideRoute.GET(new Request("https://evil.example/api/setup/guide/connect/windows", { headers: { host: "evil.example" } }), ctx({ way: "connect", os: "windows" }));+ expect(evil.status).toBe(404);});it("serves the guard Fuobe's guide checks, and the start file for a port", async () => {diff --git a/tests/ai-setup-status.test.ts b/tests/ai-setup-status.test.tsindex 33befcea..96435ed2 100644--- a/tests/ai-setup-status.test.ts+++ b/tests/ai-setup-status.test.ts@@ -138,6 +138,18 @@ describe("the steps and the next step", () => {["on the processor, a PyTorch without CUDA", { comfy: "found", cors: "exact", guard: "guard", connected: true, model: "none", cpu: true }, {}, "cpu-only", "run_nvidia_gpu.bat"],["a GPU too small", { comfy: "found", cors: "exact", guard: "guard", connected: true, model: "none", modelWhy: "small" }, {}, "no-model-fits", "Your keys"],["a model needs more than a download", { comfy: "found", cors: "exact", guard: "guard", connected: true, model: "none", modelWhy: "setup" }, {}, "model-setup", "Update ComfyUI"],+ ["connect: not installed yet", { way: "connect", comfy: "unreadable", port: 8188 }, {}, "install-connect", "ComfyUI-Manager's search may not list Fuobe Connect yet. Clone https://github.com/workingprototype/ComfyUI-Fuobe-Connect into custom_nodes"],+ ["connect: ComfyUI didn't load it", { way: "connect", comfy: "unreadable", port: 8000, restarted: true }, {}, "connect-not-loaded", "curl.exe -s http://127.0.0.1:8000/fuobe/connect"],+ ["connect: installed, connecting", { way: "connect", comfy: "found", port: 8188, guard: "connect" }, {}, "connecting"],+ ["connect: --listen", { way: "connect", comfy: "found", port: 8188, guard: "connect", listen: true }, {}, "remove-listen"],+ ["connect: done in this tab", { way: "connect", comfy: "found", guard: "connect", connected: true, model: "ready", picture: "ok" }, {}, "done", "pair this ComfyUI with a code"],+ ["connect: no tab yet", null, { way: "connect" }, "open-fuobe", `${SITE}/connect?setup=ai&way=connect in a browser`],+ ["connect: from a phone, pair it", { way: "connect", browser: "unsupported" }, { phone: true }, "pair", "Extensions (in ComfyUI's top menu), then Connect to Fuobe"],+ ["connect: a phone's tab asleep: still pairing", { way: "connect", browser: "unsupported", visible: false }, { phone: true, tabAt: NOW - 120_000 }, "pair", "on the phone"],+ ["connect: Safari pairs", { way: "connect", browser: "unsupported", browserName: "safari" }, {}, "pair", `${SITE}/connect?pair=1`],+ ["connect: a blocked browser pairs, or unblocks", { way: "connect", browser: "blocked", browserName: "chrome" }, {}, "pair", "Or, to connect from this browser instead"],+ ["connect: paired and answering", { way: "connect", browser: "unsupported" }, { phone: true, server: { gpu: "computer", online: true, paired: true } }, "done", "with no Fuobe tab open"],+ ["connect: paired elsewhere, nothing here", { way: "connect", comfy: "none" }, { server: { gpu: "computer", online: true, paired: true } }, "done"],];it.each(cases)("%s", (_name, facts, o, id, words) => {const v = view(facts, o);@@ -173,6 +185,22 @@ describe("the steps and the next step", () => {expect(stepsOf(view({ way: "address" }, { server: { gpu: "link", online: true } })).map((s) => s.id)).toEqual(["address", "connected", "model", "picture"]);});+ it("ticks Fuobe Connect off in this tab, or by pairing", () => {+ const states = (f: Partial<TabFacts> | null, o: Partial<SetupView> = {}) => stepsOf(view(f && { way: "connect", ...f }, { way: "connect", ...o })).map((s) => `${s.id}:${s.state}`);+ expect(states({ comfy: "unreadable", port: 8188 })).toEqual(["comfyui:done", "connect:todo", "model:todo", "picture:todo"]);+ expect(states({ comfy: "unreadable", port: 8188, restarted: true })).toEqual(["comfyui:done", "connect:warn", "model:todo", "picture:todo"]);+ expect(states({ comfy: "found", port: 8188, guard: "connect", connected: true, model: "ready", modelId: "oss-sdxl" })).toEqual(["comfyui:done", "connect:done", "model:done", "picture:todo"]);+ expect(states({ browser: "unsupported" }, { phone: true })).toEqual(["connect:todo", "paired:todo"]);+ // Pairing ends once the paired ComfyUI answers, whether or not this tab's own check sees it.+ expect(states({ browser: "unsupported" }, { phone: true, server: { gpu: "computer", online: false, paired: true } })).toEqual(["connect:done", "paired:done"]);+ expect(states({ browser: "unsupported" }, { phone: true, server: { gpu: "link", online: true, paired: true } })).toEqual(["connect:todo", "paired:todo"]);+ // The status points into Fuobe Connect's own steps.+ const at = (f: Partial<TabFacts>, o: Partial<SetupView> = {}) => nextOf(view({ way: "connect", ...f }, { way: "connect", ...o }), NOW).guide;+ expect(at({ browser: "ask" })).toBe(`${SITE}/api/setup/guide/connect/windows#step-3`);+ expect(at({ comfy: "unreadable", port: 8188 })).toBe(`${SITE}/api/setup/guide/connect/windows#step-2`);+ expect(at({ browser: "unsupported" }, { phone: true })).toBe(`${SITE}/api/setup/guide/connect/windows#step-2`);+ });+it("says how long ComfyUI has been starting again, and when it didn't come back", () => {expect(stepsOf(view({ comfy: "waiting", port: 8188 }))[0]).toMatchObject({ state: "working", detail: "Restarting, or closed" });expect(stepsOf(view({ comfy: "waiting", port: 8188, quietMin: 2 }))[0]).toMatchObject({ state: "working", detail: "Starting again: 2 min so far" });