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.

Save & test: each field checks its own server, a new ComfyUI address gets no saved token, and the guide goes only for a real connection

Claudeaf1922490025
diff --git a/src/app/api/providers/test/route.ts b/src/app/api/providers/test/route.ts
index 2b9aca2d..ad44082d 100644
--- a/src/app/api/providers/test/route.ts
+++ b/src/app/api/providers/test/route.ts
@@ -1,14 +1,16 @@
-import { candidateValues, isTestProvider, settingProblem } from "@/lib/connections";
+import { candidateValues, isTestProvider, PROVIDER_SETTINGS, settingProblem } from "@/lib/connections";
import { PROVIDERS } from "@/server/providers";
import { validateSetting, withCandidates, type SettingName } from "@/server/settings";
/**
* Test a provider's connection. With `value` (the provider's main setting) or `values` (by setting
* name), the test runs with those unsaved values instead of the saved ones, so Settings can check a
- * key or an address before saving it. Nothing is stored here.
+ * key or an address before saving it. `field` names the setting being checked (else the first
+ * unsaved one), so a provider that reaches several servers tests that one: the Anthropic key is
+ * checked with Anthropic even when text steps run on Ollama. Nothing is stored here.
*/
export async function POST(request: Request) {
- const body = (await request.json().catch(() => ({}))) as { provider?: unknown; value?: unknown; values?: unknown };
+ const body = (await request.json().catch(() => ({}))) as { provider?: unknown; value?: unknown; values?: unknown; field?: unknown };
const provider = body.provider;
const adapter = isTestProvider(provider) ? PROVIDERS[provider] : undefined;
if (!isTestProvider(provider) || !adapter?.test) return Response.json({ ok: false, detail: "Unknown provider" }, { status: 400 });
@@ -18,7 +20,10 @@ export async function POST(request: Request) {
} catch (e) {
return Response.json({ ok: false, detail: (e as Error).message }, { status: 400 });
}
- const test = adapter.test.bind(adapter);
+ const settings: readonly string[] = PROVIDER_SETTINGS[provider];
+ const focus = typeof body.field === "string" && settings.includes(body.field) ? body.field : Object.keys(values)[0];
+ const check = adapter.test.bind(adapter);
+ const test = () => check({ focus });
try {
const res = await withCandidates(values, test);
// A rejected key that doesn't look like one: say what it should look like.
diff --git a/src/app/api/status/route.ts b/src/app/api/status/route.ts
index 690f4b47..32140239 100644
--- a/src/app/api/status/route.ts
+++ b/src/app/api/status/route.ts
@@ -1,7 +1,8 @@
import { connection } from "next/server";
import { PROVIDERS } from "@/server/providers";
import { probeComfy } from "@/server/providers/comfyui";
-import { getSetting } from "@/server/settings";
+import { nothingConnected, type EngineModeName } from "@/lib/connections";
+import { getSetting, setSetting } from "@/server/settings";
/** Which providers are usable right now — drives badges, the demo-mode notice and Home's first-run guide. */
export async function GET() {
@@ -13,11 +14,19 @@ export async function GET() {
{ label: p.label, configured: p.id === "comfyui" ? comfy : p.id === "mock" ? true : p.isConfigured() },
]),
);
+ const engineMode = getSetting("engineMode") as EngineModeName;
+ // The first time something this engine mode generates with is connected, the first-run guide has
+ // done its job: remember it, so a ComfyUI that is offline one morning doesn't bring "Get started" back.
+ let onboarded = getSetting("onboarded") === "1";
+ if (!onboarded && !nothingConnected({ providers, engineMode })) {
+ setSetting("onboarded", "1");
+ onboarded = true;
+ }
return Response.json({
providers,
demoMode: getSetting("demoMode"),
- engineMode: getSetting("engineMode"),
+ engineMode,
cloudProvider: getSetting("cloudProvider"),
- onboarded: getSetting("onboarded") === "1",
+ onboarded,
});
}
diff --git a/src/components/connect-field.tsx b/src/components/connect-field.tsx
index d0d82310..3e170c3b 100644
--- a/src/components/connect-field.tsx
+++ b/src/components/connect-field.tsx
@@ -7,7 +7,7 @@ import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
-import { saveSettings, testConnection, useStatus, type ConnectionTest } from "@/lib/api";
+import { saveSettings, testConnection, type ConnectionTest } from "@/lib/api";
import { settingProblem, type TestProvider } from "@/lib/connections";
import { cn } from "@/lib/utils";
@@ -19,11 +19,12 @@ export interface PublicSetting {
isSet: boolean;
}
-/** Every setting as the browser may see it (secrets masked). */
-export function useSettings() {
+/** Every setting as the browser may see it (secrets masked). `enabled: false` waits (Home's guide, until the status says it's wanted). */
+export function useSettings(enabled = true) {
return useQuery({
queryKey: ["settings"],
queryFn: async () => ((await (await fetch("/api/settings")).json()) as { settings: PublicSetting[] }).settings,
+ enabled,
});
}
@@ -65,7 +66,6 @@ export function ConnectField({
className?: string;
}) {
const qc = useQueryClient();
- const status = useStatus().data;
const inputId = useId();
const [draft, setDraft] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
@@ -87,11 +87,11 @@ export function ConnectField({
setBusy(true);
try {
const values = typed !== null ? { [name]: typed } : undefined;
- const res = await testConnection(provider, values);
+ const res = await testConnection(provider, values, name);
if (res.ok) {
- // Connected: keep it, and the first-run guide has done its job.
- const patch = { ...values, ...(status?.onboarded ? {} : { onboarded: "1" }) };
- if (Object.keys(patch).length) await saveSettings(patch);
+ // Connected: keep it. The first-run guide goes once the status sees a connection the engine
+ // mode generates with (the server remembers that), not for Ollama or an unused provider.
+ if (values) await saveSettings(values);
setDraft(null);
refresh();
onConnected?.(res);
diff --git a/src/components/get-started.tsx b/src/components/get-started.tsx
index 5818a2cb..5f46d45e 100644
--- a/src/components/get-started.tsx
+++ b/src/components/get-started.tsx
@@ -12,10 +12,14 @@ import { copyWithToast } from "@/lib/clipboard";
import { COMFY_INSTALL_COMMAND, COMFY_INSTALL_DOCS, FAL_KEYS_URL, nothingConnected } from "@/lib/connections";
import { cn } from "@/lib/utils";
-/** "What do you want to do?" — Liner's first-run question, as one tap to the right place. */
+/**
+ * "What do you want to do?" — Liner's first-run question, as one tap to the right place. Image and
+ * Edit switch Home's composer (Edit's Start then asks for the photo); "Animate a photo" opens Video
+ * itself, where the Start frame is, since Home's Video mode would run text-to-video without one.
+ */
const INTENTS = [
{ label: "Make an image", href: "/image", icon: ImageIcon, mode: "image" },
- { label: "Animate a photo", href: "/video", icon: Video, mode: "video" },
+ { label: "Animate a photo", href: "/video", icon: Video },
{ label: "Edit a photo", href: "/edit", icon: Wand2, mode: "edit" },
{ label: "Advertise a product", href: "/marketing", icon: Megaphone },
{ label: "A talking avatar", href: "/lipsync", icon: Mic2 },
@@ -73,7 +77,9 @@ export function GetStarted({
className?: string;
}) {
const qc = useQueryClient();
- const settings = useSettings().data;
+ // Not in Home's static shell (no status yet): a returning visitor's guide is gone once the status
+ // arrives, so it shouldn't cost a settings read on every Home visit.
+ const settings = useSettings(!!status).data;
const get = (n: string) => settings?.find((s) => s.name === n);
const [hiding, setHiding] = useState(false);
const titleId = useId();
diff --git a/src/components/licences-view.tsx b/src/components/licences-view.tsx
index fee76962..89953a3e 100644
--- a/src/components/licences-view.tsx
+++ b/src/components/licences-view.tsx
@@ -123,9 +123,9 @@ export function LicencesView({ list }: { list: LicenceList }) {
{catalog.length > 0 && (
<section aria-labelledby="lic-models">
- <h2 id="lic-models" className="text-[15px] font-semibold">
+ <h3 id="lic-models" className="text-[15px] font-semibold">
Open models in Fuobe&apos;s studios <span className="font-normal text-muted-foreground tabular-nums">· {catalog.length}</span>
- </h2>
+ </h3>
<ul className="divide-y">
{catalog.map((r) => (
<Row key={r.id} row={r} />
@@ -135,9 +135,9 @@ export function LicencesView({ list }: { list: LicenceList }) {
)}
{library.length > 0 && (
<section aria-labelledby="lic-library" className="pt-4">
- <h2 id="lic-library" className="text-[15px] font-semibold">
+ <h3 id="lic-library" className="text-[15px] font-semibold">
Also in the workflow library <span className="font-normal text-muted-foreground tabular-nums">· {library.length}</span>
- </h2>
+ </h3>
<p className="mt-1 text-[12px] text-muted-foreground">Workflows ready on your ComfyUI that no studio runs yet, or alternatives to the ones above.</p>
<ul className="divide-y">
{library.map((r) => (
diff --git a/src/lib/api.ts b/src/lib/api.ts
index 200def4c..4534ad97 100644
--- a/src/lib/api.ts
+++ b/src/lib/api.ts
@@ -773,7 +773,7 @@ export interface StatusInfo {
demoMode: string;
engineMode: EngineMode;
cloudProvider: string;
- /** The first-run guide was dismissed, or something tested green. */
+ /** The first-run guide was put away, or something the engine mode generates with was connected once. */
onboarded?: boolean;
}
@@ -783,9 +783,12 @@ export interface ConnectionTest {
detail: string;
}
-/** Test a provider, with unsaved values (by setting name) in place of the saved ones when given. */
-export async function testConnection(provider: TestProvider, values?: Record<string, string>): Promise<ConnectionTest> {
- const res = await fetch("/api/providers/test", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ provider, values }) });
+/**
+ * Test a provider, with unsaved values (by setting name) in place of the saved ones when given.
+ * `field` is the setting being checked (the Anthropic key, Ollama's address…), so the test checks that one.
+ */
+export async function testConnection(provider: TestProvider, values?: Record<string, string>, field?: string): Promise<ConnectionTest> {
+ const res = await fetch("/api/providers/test", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ provider, values, field }) });
const body = (await res.json().catch(() => null)) as ConnectionTest | null;
return body && typeof body.ok === "boolean" ? body : { ok: false, detail: `The test didn't answer (${res.status})` };
}
diff --git a/src/server/providers/comfyui.ts b/src/server/providers/comfyui.ts
index 6973d711..1482a11d 100644
--- a/src/server/providers/comfyui.ts
+++ b/src/server/providers/comfyui.ts
@@ -32,7 +32,7 @@ import { expandTimelineWorkflow, readTimeline } from "@/lib/av/timeline";
import { guessKind } from "@/lib/catalog/payload";
import type { GenInput, MediaKind, ModelRoute, Operation } from "@/lib/catalog/types";
import { probeMedia, type MediaInfo } from "@/lib/media-probe";
-import { getSetting } from "../settings";
+import { getSetting, isCandidate, savedSetting } from "../settings";
import { decodePng, encodePng } from "../png";
import { readRef } from "../storage";
import { ProviderError, type ProviderAdapter, type RemoteOutput } from "./types";
@@ -77,7 +77,14 @@ export function workerFor(endpoint: string | undefined): ComfyWorker {
return endpoint && loadManifest().workflows.find((w) => w.id === endpoint)?.worker === "isolated" ? "isolated" : "main";
}
-function authHeaders(): Record<string, string> {
+/** A ComfyUI address as compared: no trailing slash. */
+const sameAddress = (a: string, b: string) => a.replace(/\/+$/, "") === b.replace(/\/+$/, "");
+
+function authHeaders(worker: ComfyWorker = "main"): Record<string, string> {
+ // Save & test of an address that isn't the saved one: the saved token stays with the server it
+ // was saved for. Only a token typed for this test goes to the new address.
+ const address = worker === "isolated" ? "comfyIsolatedUrl" : "comfyUrl";
+ if (isCandidate(address) && !isCandidate("comfyToken") && !sameAddress(getSetting(address), savedSetting(address))) return {};
const t = getSetting("comfyToken");
return t ? { Authorization: `Bearer ${t}` } : {};
}
@@ -88,7 +95,7 @@ async function comfyFetch(p: string, init: RequestInit = {}, worker: ComfyWorker
throw new ProviderError(`This model runs on the isolated ComfyUI worker, which isn't set up yet: add its address in ${ISOLATED_SETTING} (or COMFYUI_ISOLATED_URL). scripts/comfy/README.md shows how to start one, usually on port 8189`);
}
try {
- return await fetch(`${base}${p}`, { ...init, headers: { ...authHeaders(), ...(init.headers ?? {}) } });
+ return await fetch(`${base}${p}`, { ...init, headers: { ...authHeaders(worker), ...(init.headers ?? {}) } });
} catch (e) {
if (worker === "isolated") throw new ProviderError(`The isolated ComfyUI worker at ${base} doesn't answer (${(e as Error).message}). Start it (scripts/comfy/README.md) or check ${ISOLATED_SETTING}`);
throw new ProviderError(`Can't reach ComfyUI at ${base} (${(e as Error).message}). Is it running?`);
@@ -722,7 +729,7 @@ async function followMetaBatch(prefix: string, manifest: ManifestWorkflow | unde
const failed = passes.find((e) => e.status?.status_str === "error");
if (failed) return { error: explainExecutionError(executionError(failed), manifest) };
for (const e of passes) {
- const files = collectOutputs(e, manifest, baseUrl(worker), authHeaders());
+ const files = collectOutputs(e, manifest, baseUrl(worker), authHeaders(worker));
if (files.length) return files;
}
return null;
@@ -810,7 +817,7 @@ export const comfyProvider: ProviderAdapter = {
forget(externalId);
return { state: "failed" as const, error: explainExecutionError(executionError(entry), manifest) };
}
- let outputs = collectOutputs(entry, manifest, baseUrl(worker), authHeaders());
+ let outputs = collectOutputs(entry, manifest, baseUrl(worker), authHeaders(worker));
if (!outputs.length && meta.metaBatch && typeof meta.prefix === "string") {
const next = await followMetaBatch(meta.prefix, manifest, worker);
if (next === "running") return { state: "running" as const, message: "Rendering the next batch of frames" };
@@ -867,7 +874,7 @@ export const comfyProvider: ProviderAdapter = {
if (q.queue_running?.some((r) => r[1] === externalId)) await post("/interrupt", { prompt_id: externalId }).catch(() => {});
},
- async test() {
+ async test(opts) {
const describe = async (worker: ComfyWorker) => {
const res = await comfyFetch("/system_stats", {}, worker);
if (!res.ok) throw new ProviderError(`HTTP ${res.status}`);
@@ -875,6 +882,15 @@ export const comfyProvider: ProviderAdapter = {
const dev = s.devices?.[0];
return `ComfyUI ${s.system?.comfyui_version ?? ""} · ${dev?.name ?? "unknown device"}${dev?.vram_total ? ` · ${(dev.vram_total / 2 ** 30).toFixed(0)} GB` : ""}`;
};
+ // Checking the isolated worker's address: that worker answers, or it isn't connected (the main
+ // server's state is the main address's test).
+ if (opts?.focus === "comfyIsolatedUrl") {
+ if (!baseUrl("isolated")) return { ok: false, detail: "No isolated worker address set" };
+ return describe("isolated").then(
+ (d) => ({ ok: true, detail: `isolated worker: ${d}` }),
+ (e: Error) => ({ ok: false, detail: /^HTTP \d/.test(e.message) ? `The isolated worker at ${baseUrl("isolated")} answered ${e.message}` : e.message }),
+ );
+ }
let detail: string;
try {
detail = await describe("main");
diff --git a/src/server/providers/llm.ts b/src/server/providers/llm.ts
index fb63ee47..9eb9207c 100644
--- a/src/server/providers/llm.ts
+++ b/src/server/providers/llm.ts
@@ -456,8 +456,25 @@ export const llmProvider: ProviderAdapter = {
jobs().delete(externalId);
},
- /** Checks each LLM text steps would use: Claude's key (a free model list call) and that Ollama has its model. */
- async test() {
+ /**
+ * Checks each LLM text steps would use: Claude's key (a free model list call) and that Ollama has
+ * its model. Checking the Anthropic key itself (focus) always asks Anthropic, also when text steps
+ * run on Ollama (Open source only, or the Enhancer set to Ollama): Assist can still use the key.
+ * Checking Ollama's address or model asks Ollama.
+ */
+ async test(opts) {
+ if (opts?.focus === "anthropicKey") {
+ if (!getSetting("anthropicKey")) return { ok: false, detail: "No Anthropic key set" };
+ const claude = await testClaude();
+ // A good key that text steps don't use: say where they run, so green doesn't read as "Claude rewrites prompts".
+ const choice = getSetting("enhanceProvider");
+ let elsewhere: string | null = null;
+ if (choice === "none") elsewhere = "text steps are off (Enhancer: Offline rewriter)";
+ else if (choice === "ollama") elsewhere = "text steps use Ollama (Enhancer)";
+ else if (choice === "auto" && engineMode() === "open") elsewhere = "Open source only mode keeps text steps on Ollama";
+ return claude.ok && elsewhere ? { ok: true, detail: `${claude.detail} · ${elsewhere}` } : claude;
+ }
+ if (opts?.focus === "ollamaUrl" || opts?.focus === "ollamaModel") return testOllama();
if (getSetting("enhanceProvider") === "none") return { ok: false, detail: "Text steps are off (Enhancer: Offline rewriter)" };
await probeOllama(true);
const b = llmBackends({ endpoint: "auto" });
diff --git a/src/server/providers/types.ts b/src/server/providers/types.ts
index 5d8c3312..bc585382 100644
--- a/src/server/providers/types.ts
+++ b/src/server/providers/types.ts
@@ -54,8 +54,12 @@ export interface ProviderAdapter {
submit(ctx: SubmitContext): Promise<SubmitResult>;
poll(ctx: PollContext): Promise<PollResult>;
cancel?(ctx: PollContext): Promise<void>;
- /** Lightweight connectivity check for the settings page. */
- test?(): Promise<{ ok: boolean; detail: string }>;
+ /**
+ * Lightweight connectivity check for the settings page. `focus` is the setting the person is
+ * checking (the Anthropic key, the isolated worker's address…), for a provider whose settings
+ * reach more than one server; the others ignore it.
+ */
+ test?(opts?: { focus?: string }): Promise<{ ok: boolean; detail: string }>;
}
export class ProviderError extends Error {
diff --git a/src/server/settings.ts b/src/server/settings.ts
index 588539c2..8af8186e 100644
--- a/src/server/settings.ts
+++ b/src/server/settings.ts
@@ -44,7 +44,7 @@ export const SETTINGS = {
enhanceProvider: { key: "enhance.provider", env: "FUOBE_ENHANCE_PROVIDER", default: "auto", options: ["auto", "anthropic", "ollama", "none"] },
ollamaUrl: { key: "ollama.url", env: "OLLAMA_URL", default: "http://127.0.0.1:11434" },
ollamaModel: { key: "ollama.model", env: "OLLAMA_MODEL", default: "qwen3:8b" },
- /** "1" once the first-run guide was dismissed or something tested green: Home stops offering it. */
+ /** "1" once the first-run guide was put away, or /api/status first saw something the engine mode generates with connected: Home stops offering it. */
onboarded: { key: "onboarding.done", default: "0", options: ["0", "1"] },
} satisfies Record<string, SettingDef>;
@@ -61,6 +61,16 @@ export function withCandidates<T>(values: Partial<Record<SettingName, string>>,
return candidates.run(values, fn);
}
+/** Inside withCandidates: whether `name` is being tried with an unsaved value. */
+export function isCandidate(name: SettingName): boolean {
+ return candidates.getStore()?.[name] !== undefined;
+}
+
+/** The value in effect without the unsaved ones (saved, environment or default), also inside withCandidates. */
+export function savedSetting(name: SettingName): string {
+ return candidates.exit(() => getSetting(name));
+}
+
export function getSetting(name: SettingName): string {
const def: SettingDef = SETTINGS[name];
const candidate = candidates.getStore()?.[name];
diff --git a/tests/connections.test.ts b/tests/connections.test.ts
index a3e722da..c0d35930 100644
--- a/tests/connections.test.ts
+++ b/tests/connections.test.ts
@@ -166,6 +166,56 @@ describe("POST /api/providers/test with unsaved values", () => {
expect(down.result.body).toMatchObject({ ok: false, detail: expect.stringMatching(/^Can't reach ComfyUI at http:\/\/10\.9\.9\.9:8188/) });
});
+ it("keeps the saved ComfyUI token with the server it was saved for", async () => {
+ const stats = { system: { comfyui_version: "0.41.0" }, devices: [{ name: "cpu", vram_total: 0 }] };
+ setSetting("comfyToken", "saved-secret-token");
+ const answers = { "http://10.1.2.3:8188/system_stats": [200, stats], "http://127.0.0.1:9/system_stats": [200, stats], "http://10.1.2.4:8189/system_stats": [200, stats] } as Record<string, [number, unknown]>;
+ // A new address gets no token unless one is typed with it.
+ const other = await withFetch(answers, () => post({ provider: "comfyui", value: "http://10.1.2.3:8188" }));
+ expect(other.result.body.ok).toBe(true);
+ expect(other.seen.map((r) => r.auth)).toEqual([undefined]);
+ const typed = await withFetch(answers, () => post({ provider: "comfyui", values: { comfyUrl: "http://10.1.2.3:8188", comfyToken: "typed-token" } }));
+ expect(typed.seen.map((r) => r.auth)).toEqual(["Bearer typed-token"]);
+ // The saved server, typed again or not, still gets it.
+ const same = await withFetch(answers, () => post({ provider: "comfyui", value: "http://127.0.0.1:9/" }));
+ expect(same.seen.map((r) => r.auth)).toEqual(["Bearer saved-secret-token"]);
+ const saved = await withFetch(answers, () => post({ provider: "comfyui" }));
+ expect(saved.seen.map((r) => r.auth)).toEqual(["Bearer saved-secret-token"]);
+ // The isolated worker's address is tested on its own, and a new one gets no token either.
+ const iso = await withFetch(answers, () => post({ provider: "comfyui", values: { comfyIsolatedUrl: "http://10.1.2.4:8189" } }));
+ expect(iso.result.body).toEqual({ ok: true, detail: "isolated worker: ComfyUI 0.41.0 · cpu" });
+ expect(iso.seen).toEqual([{ url: "http://10.1.2.4:8189/system_stats", auth: undefined }]);
+ const isoDown = await withFetch(answers, () => post({ provider: "comfyui", values: { comfyIsolatedUrl: "http://10.1.2.5:8189" } }));
+ expect(isoDown.result.body).toMatchObject({ ok: false, detail: expect.stringMatching(/isolated ComfyUI worker at http:\/\/10\.1\.2\.5:8189 doesn't answer/) });
+ setSetting("comfyToken", "");
+ });
+
+ it("checks a typed Anthropic key with Anthropic, also when text steps run on Ollama", async () => {
+ const tags = { models: [{ name: "qwen3:8b" }] };
+ const rejectedKey = { "https://api.anthropic.com/v1/models": [401, { type: "error", error: { type: "authentication_error", message: "invalid x-api-key" } }], "http://127.0.0.1:9/api/tags": [200, tags] } as Record<string, [number, unknown]>;
+ const goodKey = { "https://api.anthropic.com/v1/models": [200, { data: [], has_more: false }], "http://127.0.0.1:9/api/tags": [200, tags] } as Record<string, [number, unknown]>;
+ for (const [mode, enhancer, note] of [
+ ["open", "auto", "Open source only mode keeps text steps on Ollama"],
+ ["both", "ollama", "text steps use Ollama (Enhancer)"],
+ ] as const) {
+ setSetting("engineMode", mode);
+ setSetting("enhanceProvider", enhancer);
+ const bogus = await withFetch(rejectedKey, () => post({ provider: "llm", values: { anthropicKey: "sk-ant-bogus-key-123" } }));
+ expect(bogus.result.body, mode).toEqual({ ok: false, detail: "Anthropic rejected the key (401)" });
+ const good = await withFetch(goodKey, () => post({ provider: "llm", values: { anthropicKey: "sk-ant-good" }, field: "anthropicKey" }));
+ expect(good.result.body, mode).toEqual({ ok: true, detail: `Claude key accepted · ${note}` });
+ }
+ // The saved key, checked from its own field (nothing typed).
+ setSetting("anthropicKey", "sk-ant-saved");
+ const saved = await withFetch(rejectedKey, () => post({ provider: "llm", field: "anthropicKey" }));
+ expect(saved.result.body).toEqual({ ok: false, detail: "Anthropic rejected the key (401)" });
+ expect(saved.seen.some((r) => r.auth === "sk-ant-saved")).toBe(true);
+ // A field another provider owns is ignored: the whole text-step check runs.
+ const ollamaField = await withFetch(rejectedKey, () => post({ provider: "llm", field: "falKey" }));
+ expect(ollamaField.result.body.detail).toMatch(/Ollama/);
+ for (const n of ["engineMode", "enhanceProvider", "anthropicKey"] as const) setSetting(n, "");
+ });
+
it("tests Ollama's address and model, and an Anthropic key, for text steps", async () => {
const tags = { models: [{ name: "qwen3:8b" }] };
const ready = await withFetch({ "http://10.0.0.5:11434/api/tags": [200, tags] }, () => post({ provider: "llm", values: { ollamaUrl: "http://10.0.0.5:11434" } }));
@@ -203,9 +253,29 @@ describe("POST /api/providers/test with unsaved values", () => {
});
describe("GET /api/status", () => {
+ const onboarded = async () => ((await (await statusRoute()).json()) as { onboarded: boolean }).onboarded;
+
it("says whether the first-run guide was put away", async () => {
- expect(((await (await statusRoute()).json()) as { onboarded: boolean }).onboarded).toBe(false);
+ expect(await onboarded()).toBe(false);
setSetting("onboarded", "1");
- expect(((await (await statusRoute()).json()) as { onboarded: boolean }).onboarded).toBe(true);
+ expect(await onboarded()).toBe(true);
+ setSetting("onboarded", "");
+ });
+
+ it("remembers the first connection the engine mode generates with, so an offline day doesn't bring the guide back", async () => {
+ // Claude makes nothing by itself, and a fal.ai key doesn't serve an open-source-only install.
+ setSetting("anthropicKey", "sk-ant-x");
+ expect(await onboarded()).toBe(false);
+ setSetting("engineMode", "open");
+ setSetting("falKey", "id:secret");
+ expect(await onboarded()).toBe(false);
+ expect(getSetting("onboarded")).toBe("0");
+ setSetting("engineMode", "");
+ expect(await onboarded()).toBe(true);
+ expect(getSetting("onboarded")).toBe("1");
+ // The key goes (or ComfyUI is offline one morning): the guide stays put away.
+ setSetting("falKey", "");
+ expect(await onboarded()).toBe(true);
+ for (const n of ["anthropicKey", "onboarded"] as const) setSetting(n, "");
});
});