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.

Set it up with my AI: the open tab reports only when something changes

Adarshac323a6333be
diff --git a/src/components/gpu/ai-setup/ai-setup-panel.tsx b/src/components/gpu/ai-setup/ai-setup-panel.tsx
index 2ccd644d..0171ccba 100644
--- a/src/components/gpu/ai-setup/ai-setup-panel.tsx
+++ b/src/components/gpu/ai-setup/ai-setup-panel.tsx
@@ -198,10 +198,12 @@ export function AiSetupPanel({ onBack, fromRun, onStart, onNotNow }: AiSetupPane
// Connected: what this ComfyUI has (once), and again every 45 s while it needs a model download.
const checkedFor = useRef<string | null>(null);
+ // Only stable values here: a new recheck on every render would start the 45 s timer over each time.
+ const startCheck = check.start;
const recheck = useCallback(async () => {
- if (way === "address") await check.start();
+ if (way === "address") await startCheck();
else if (probe.port && probe.host) await checkHere(qc, probe.port, probe.host).catch(() => {});
- }, [way, check, probe.port, probe.host, qc]);
+ }, [way, startCheck, probe.port, probe.host, qc]);
useEffect(() => {
if (!connected) return;
const key = `${way}:${saved}`;
diff --git a/src/components/gpu/ai-setup/first-picture.tsx b/src/components/gpu/ai-setup/first-picture.tsx
index d9428e1a..0f4420c9 100644
--- a/src/components/gpu/ai-setup/first-picture.tsx
+++ b/src/components/gpu/ai-setup/first-picture.tsx
@@ -78,7 +78,7 @@ export function FinishCard({ picture, gpu, cpu, onClose }: { picture: FirstPictu
const on = cpu ? "your computer's processor" : gpu ? `your ${gpu}` : "your GPU";
return (
<div className="grid items-center gap-5 sm:grid-cols-[minmax(0,13rem)_minmax(0,1fr)]">
- <div className="mx-auto aspect-[4/5] w-full max-w-[13rem] overflow-hidden rounded-xl bg-muted max-sm:max-h-[50svh] max-sm:w-auto">
+ <div className="mx-auto aspect-[4/5] w-full max-w-[13rem] overflow-hidden rounded-xl bg-muted max-sm:max-h-[50svh] max-sm:max-w-none">
{picture.url && (
// eslint-disable-next-line @next/next/no-img-element -- the run's own file, any size
<img
diff --git a/src/components/gpu/ai-setup/use-setup-session.ts b/src/components/gpu/ai-setup/use-setup-session.ts
index 478f82e2..66d07301 100644
--- a/src/components/gpu/ai-setup/use-setup-session.ts
+++ b/src/components/gpu/ai-setup/use-setup-session.ts
@@ -150,12 +150,14 @@ export function useSetupSession(o: { way: Way; os: Os; phone: boolean; facts: Om
setS((x) => ({ ...x, offline: false, aiReadAt: j?.aiReadAt ?? x.aiReadAt, mine: j?.mine ?? true, next: j?.next ?? x.next }));
}, [make]);
// A report when what the tab sees changes (a moment after, so a burst of changes is one report).
- const factsKey = JSON.stringify(o.facts);
+ // Keyed on the facts' text, never on the object: the panel makes a new one on every render, and each report's answer
+ // renders the panel again.
+ const factsKey = o.facts ? JSON.stringify(o.facts) : "";
useEffect(() => {
- if (!s.code || s.ended || !o.facts) return;
+ if (!s.code || s.ended || !factsKey) return;
const t = setTimeout(() => void report(), 300);
return () => clearTimeout(t);
- }, [factsKey, s.code, s.ended, report, o.facts]);
+ }, [factsKey, s.code, s.ended, report]);
// The wait for the AI's reads: a loop on network answers, not timers, so it goes on in a hidden tab (whose timers the
// browser slows down). A poke asks for a fresh look first; every answer ends with a report (the heartbeat).
diff --git a/tests/e2e/ai-setup.mjs b/tests/e2e/ai-setup.mjs
index 7b52d1e6..aa8362c7 100644
--- a/tests/e2e/ai-setup.mjs
+++ b/tests/e2e/ai-setup.mjs
@@ -82,12 +82,14 @@ async function context(browser, opts, { safari = false } = {}) {
const ctx = await browser.newContext(opts);
ctx.map = {};
ctx.failed = [];
+ ctx.reports = 0;
if (safari)
await ctx.addInitScript(() => {
Object.defineProperty(Navigator.prototype, "userAgentData", { get: () => undefined });
Object.defineProperty(Navigator.prototype, "platform", { get: () => (/iPhone/.test(navigator.userAgent) ? "iPhone" : "MacIntel") });
});
ctx.on("response", (r) => {
+ if (/^\/api\/setup\/session\/[^/]+\/report$/.test(new URL(r.url()).pathname)) ctx.reports++;
// A code that just ended answers 404 to a report on its way: the tab makes a new one. Anything else is a failure.
if (new URL(r.url()).pathname.startsWith("/api/setup/session") && r.status() >= 400 && r.status() !== 404) ctx.failed.push(`${r.status()} ${r.request().method()} ${new URL(r.url()).pathname}`);
});
@@ -165,6 +167,11 @@ try {
const chat = page.getByRole("button", { name: /Open in ChatGPT/ });
check(`${tag}: the hand-offs wait for the browser's question first`, await chat.isDisabled().catch(() => false));
await page.screenshot({ path: path.join(shots, `${tag}-1-open.png`), fullPage: true });
+ // Nothing changes while nobody acts: the tab reports a change once, then only its heartbeat (every 25 s at most).
+ await sleep(2000);
+ const before = ctx.reports;
+ await sleep(8000);
+ check(`${tag}: a quiet tab sends few reports`, ctx.reports - before <= 2, `${ctx.reports - before} in 8 s`);
// ComfyUI that doesn't let this page in yet.
ctx.map = { 8188: CLOSED };