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.

Studio and Settings: an empty key balance said plainly, and Use this computer says why it can't run here

Adarsheef07cc96bc9
diff --git a/src/components/gpu/your-gpu.tsx b/src/components/gpu/your-gpu.tsx
index 06ea66f0..9a18c545 100644
--- a/src/components/gpu/your-gpu.tsx
+++ b/src/components/gpu/your-gpu.tsx
@@ -51,6 +51,29 @@ async function call<T>(method: string, body?: unknown, test = false): Promise<T>
return j;
}
+/** "Use this computer": the account's runs go to the ComfyUI on this computer (its Fuobe tab runs them). */
+export const chooseThisComputer = () => call<GpuState>("PUT", { mode: "computer" });
+
+/** Why this browser can't use the ComfyUI on its computer, said where Use this computer would be. */
+export const USE_COMPUTER_ELSEWHERE: Record<Exclude<ReturnType<typeof useComputerSupport>, "ok">, string> = {
+ safari: "Use this computer works in Chrome, Edge or Firefox. Safari doesn't let a website reach programs on your Mac.",
+ phone: "Use this computer works in a browser on your computer, not on a phone or tablet.",
+ http: "Use this computer needs a secure page, and your browser marks this one as not secure.",
+};
+
+/**
+ * Under a local address: Use this computer where this browser can reach its ComfyUI (else why not, in a line), and Pair
+ * with a code.
+ */
+export function LocalAddressWays({ support, onUseComputer }: { support: ReturnType<typeof useComputerSupport>; onUseComputer: () => void | Promise<unknown> }) {
+ return (
+ <>
+ <TroubleActions actions={diagnoseAddress("local").actions} handlers={support === "ok" ? { onUseComputer } : {}} />
+ {support !== "ok" && <p className="text-[12px] text-muted-foreground">{USE_COMPUTER_ELSEWHERE[support]}</p>}
+ </>
+ );
+}
+
/** A check that didn't pass, as shown under the field: its words, details and buttons, and when it checks again by itself. */
interface Failed {
words: string;
@@ -161,7 +184,7 @@ export function YourGpu({ className, onLinked }: { className?: string; onLinked?
// "Use this computer": runs go to the ComfyUI on this computer (its Fuobe tab runs them), not a web address.
const useComputer = async () => {
try {
- await call("PUT", { mode: "computer" });
+ await chooseThisComputer();
void qc.invalidateQueries({ queryKey: ["account-gpu"] });
linked();
toast.success("Your runs go to the ComfyUI on this computer now. Keep a Fuobe tab open here.");
@@ -247,7 +270,7 @@ export function YourGpu({ className, onLinked }: { className?: string; onLinked?
<div className="space-y-1.5">
<p className="text-[12px] text-destructive">That address only works on your own computer or network. Paste the one cloudflared shows, ending in trycloudflare.com.</p>
{/* Or the ways that need no web address: the ComfyUI on this computer (where this browser can reach it), or a code. */}
- <TroubleActions actions={diagnoseAddress("local").actions} handlers={support === "ok" ? { onUseComputer: useComputer } : {}} />
+ <LocalAddressWays support={support} onUseComputer={useComputer} />
</div>
)}
{note && <p className="text-[12px] text-muted-foreground">{note}</p>}
diff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsx
index e749ae2d..e06c27a0 100644
--- a/src/components/studio/composer.tsx
+++ b/src/components/studio/composer.tsx
@@ -1781,7 +1781,7 @@ export function Composer({ docked }: { docked: boolean }) {
)}
{emptyPayer && model && (
<div role="note" className="mx-1 mt-2 flex flex-wrap items-center gap-x-3 gap-y-1.5 rounded-xl border border-dashed px-3 py-2 text-[12px] leading-snug text-muted-foreground">
- <p className="min-w-0 flex-1 basis-56">Your {CLOUD_KEY[emptyPayer].label} balance ran out on your last run. Add credit there, then run.</p>
+ <p className="min-w-0 flex-1 basis-56">Your {CLOUD_KEY[emptyPayer].label} balance is empty. Add credit there, then run.</p>
<TroubleActions actions={[{ kind: "add-credit", label: `Add credit on ${CLOUD_KEY[emptyPayer].label}`, target: BILLING_URL[emptyPayer] }]} />
</div>
)}
diff --git a/src/lib/api.ts b/src/lib/api.ts
index d87403ce..3225cafc 100644
--- a/src/lib/api.ts
+++ b/src/lib/api.ts
@@ -900,7 +900,7 @@ export interface StatusInfo {
keys?: CloudProvider[];
/** Of those, the ones a run would be taken on now (not refused, balance not known to be empty). */
usableKeys?: CloudProvider[];
- /** Keys whose provider account's balance ran out on a run (Add credit before the next one). */
+ /** Keys whose provider account's balance is empty, found on a run or by a check of the key (Add credit before the next run). */
emptyKeys?: CloudProvider[];
paidAllowed?: boolean;
/** Hosted runs (FUOBE_HOSTED_RUNS=1): runs may go to this studio's GPUs, so a GPU of one's own is optional. */
diff --git a/tests/own-graceful-ui.test.ts b/tests/own-graceful-ui.test.ts
index 57a2d0be..6fd79221 100644
--- a/tests/own-graceful-ui.test.ts
+++ b/tests/own-graceful-ui.test.ts
@@ -252,6 +252,38 @@ describe("a run's buttons, in a studio and in the Library", () => {
});
});
+describe("Settings → Your GPU: a local address", () => {
+ it("offers Use this computer where this browser can reach its ComfyUI, and elsewhere says why, with Pair with a code", async () => {
+ const { LocalAddressWays, USE_COMPUTER_ELSEWHERE } = await import("@/components/gpu/your-gpu");
+ const button = '<span class="truncate">Use this computer</span>';
+ const ok = render(createElement(LocalAddressWays, { support: "ok", onUseComputer: () => {} }));
+ expect(ok).toContain(button);
+ expect(ok).toContain("Pair with a code");
+ for (const why of ["safari", "phone", "http"] as const) {
+ const html = render(createElement(LocalAddressWays, { support: why, onUseComputer: () => {} }));
+ expect(html).not.toContain(button);
+ expect(html).toContain(USE_COMPUTER_ELSEWHERE[why].replaceAll("'", "&#x27;"));
+ expect(html).toContain("Pair with a code");
+ }
+ expect(USE_COMPUTER_ELSEWHERE.safari).toBe("Use this computer works in Chrome, Edge or Firefox. Safari doesn't let a website reach programs on your Mac.");
+ });
+
+ it("Use this computer sends the account's runs to the ComfyUI on this computer", async () => {
+ const { chooseThisComputer } = await import("@/components/gpu/your-gpu");
+ const calls: { url: string; method?: string; body?: unknown }[] = [];
+ vi.stubGlobal("fetch", async (url: string, init?: RequestInit) => {
+ calls.push({ url, method: init?.method, body: init?.body });
+ return Response.json({ gpu: { mode: "computer" } });
+ });
+ try {
+ expect(await chooseThisComputer()).toEqual({ gpu: { mode: "computer" } });
+ } finally {
+ vi.unstubAllGlobals();
+ }
+ expect(calls).toEqual([{ url: "/api/account/gpu", method: "PUT", body: JSON.stringify({ mode: "computer" }) }]);
+ });
+});
+
describe("Try one size smaller", () => {
it("steps the size down first, then the length, and offers nothing when neither can", () => {
const model = { options: { resolutions: ["480p", "720p", "1080p"], durations: [5, 10] }, defaults: { resolution: "1080p", duration: 10 } };