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.

Fixes 5: AI-Toolkit's Save & test counts only the trainings still going

Claude66191430f60d
diff --git a/src/server/training.ts b/src/server/training.ts
index 1d1bb683..df5b5967 100644
--- a/src/server/training.ts
+++ b/src/server/training.ts
@@ -333,7 +333,9 @@ export async function testAiToolkit(opts?: { focus?: string }): Promise<{ ok: bo
if (!res.ok) return { ok: false, detail: `AI-Toolkit answered HTTP ${res.status}` };
const jobs = ((await res.json().catch(() => null)) as { jobs?: unknown } | null)?.jobs;
if (!Array.isArray(jobs)) return { ok: false, detail: `Something answers at ${base}, but it isn't AI-Toolkit's UI (port 8675 by default)` };
- return { ok: true, detail: jobs.length ? `AI-Toolkit · ${jobs.length} training${jobs.length > 1 ? "s" : ""} running` : "AI-Toolkit · ready, no training running" };
+ // An older UI that ignores only_active lists every job: count the ones still going.
+ const active = jobs.filter((j) => ["running", "queued", "stopping"].includes(String((j as { status?: unknown } | null)?.status))).length;
+ return { ok: true, detail: active ? `AI-Toolkit · ${active} training${active > 1 ? "s" : ""} running` : "AI-Toolkit · ready, no training running" };
}
/** Whether Fuobe can write the training photos to the folder (its nearest existing folder, when it isn't made yet). */
diff --git a/tests/connections.test.ts b/tests/connections.test.ts
index 5be873c3..cd60e12b 100644
--- a/tests/connections.test.ts
+++ b/tests/connections.test.ts
@@ -251,6 +251,11 @@ describe("POST /api/providers/test with unsaved values", () => {
expect(getSetting("aiToolkitUrl")).toBe("");
const busy = await withFetch({ "http://10.0.0.7:8675/api/jobs": [200, jobs(2)] }, () => post({ provider: "ai-toolkit", value: "http://10.0.0.7:8675" }));
expect(busy.result.body).toEqual({ ok: true, detail: "AI-Toolkit · 2 trainings running" });
+ // An older UI that lists every job: only the ones still going count.
+ const all = await withFetch({ "http://10.0.0.7:8675/api/jobs": [200, { jobs: [{ status: "completed" }, { status: "queued" }, { status: "error" }] }] }, () =>
+ post({ provider: "ai-toolkit", value: "http://10.0.0.7:8675" }),
+ );
+ expect(all.result.body).toEqual({ ok: true, detail: "AI-Toolkit · 1 training running" });
// AI_TOOLKIT_AUTH set on the trainer: it wants the token.
const locked = await withFetch({ "http://10.0.0.7:8675/api/jobs": [401, { error: "Unauthorized" }] }, () => post({ provider: "ai-toolkit", value: "http://10.0.0.7:8675" }));
expect(locked.result.body).toEqual({ ok: false, detail: "AI-Toolkit wants its auth token (AI_TOOLKIT_AUTH on the trainer): add it under Auth token" });