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.

Skills W1: browser check for running a skill, the Run form in the phone-width sweep

Claude57dae56e48b7
diff --git a/src/components/assist/run-skill-dialog.tsx b/src/components/assist/run-skill-dialog.tsx
index 09a79e28..981a2b01 100644
--- a/src/components/assist/run-skill-dialog.tsx
+++ b/src/components/assist/run-skill-dialog.tsx
@@ -164,7 +164,7 @@ function Loaded({ view, onClose }: { view: RecipeView; onClose: () => void }) {
return (
<>
<DialogHeader className="flex-row items-start gap-3 border-b px-5 pt-5 pb-4 text-left">
- <SkillIcon name={name} size="lg" />
+ <SkillIcon name={name} icon={view.icon} size="lg" />
<div className="min-w-0 flex-1 pr-6">
<DialogTitle className="font-heading text-[24px] leading-tight font-normal">Run {view.title}</DialogTitle>
<DialogDescription className="mt-1">Same steps, new inputs. Priced before anything starts; no chat needed.</DialogDescription>
@@ -352,7 +352,8 @@ function Field({
}
const example = typeof p.example === "string" || typeof p.example === "number" ? String(p.example) : undefined;
if (p.type === "text") {
- const long = (p.max ?? RECIPE_LIMITS.text) > 120;
+ // A name or a line fits one row; a description (no limit, or a long one) gets a box.
+ const long = (p.max ?? RECIPE_LIMITS.text) > 300;
return (
<div className="space-y-1.5">
{label}
@@ -402,7 +403,7 @@ function Field({
<p className="text-sm font-medium" id={id}>
{p.label}
</p>
- <div role="radiogroup" aria-labelledby={id} onKeyDown={radioKeys} className="flex max-w-full flex-wrap gap-1 rounded-2xl bg-muted p-0.5">
+ <div role="radiogroup" aria-labelledby={id} onKeyDown={radioKeys} className="flex w-fit max-w-full flex-wrap gap-1 rounded-2xl bg-muted p-0.5">
{options.map((o) => (
<button
key={o}
diff --git a/src/components/assist/skills-view.tsx b/src/components/assist/skills-view.tsx
index cf40acfe..b2177699 100644
--- a/src/components/assist/skills-view.tsx
+++ b/src/components/assist/skills-view.tsx
@@ -370,7 +370,7 @@ function SkillDetail({ name, onClose, onEdit, onRun }: { name: string | null; on
<Download /> Download <ChevronDown className="opacity-60" />
</Button>
</DropdownMenuTrigger>
- <DropdownMenuContent align="start">
+ <DropdownMenuContent align="start" className="min-w-56">
<DropdownMenuItem asChild>
<a href={`/api/assist/skills/${s.name}/download`} download>
SKILL.md
diff --git a/src/lib/recipe.ts b/src/lib/recipe.ts
index d8cb0115..479ba29f 100644
--- a/src/lib/recipe.ts
+++ b/src/lib/recipe.ts
@@ -817,6 +817,8 @@ export interface RecipePlace {
export interface RecipeView {
name: string;
title: string;
+ /** The skill's icon (a lucide name from SKILL_ICONS). */
+ icon?: string;
builtin: boolean;
recipe: Recipe;
/** Engines its steps allow on this install. */
diff --git a/src/server/mcp.ts b/src/server/mcp.ts
index 40b88171..ebec6419 100644
--- a/src/server/mcp.ts
+++ b/src/server/mcp.ts
@@ -4,7 +4,8 @@ import { z } from "zod";
import "./assist/studio-routes";
import { apiSchema, executeTool, getTool, planFor, TOOLS, type ToolContext } from "./assist/tools";
import { engineMode } from "./settings";
-import { enabledSkills, getSkill } from "./skills";
+import { recipeMarkdown } from "@/lib/recipe";
+import { enabledSkills, getSkill, skillRecipe } from "./skills";
/**
* Fuobe as an MCP server (Model Context Protocol, streamable HTTP transport, stateless):
@@ -142,6 +143,9 @@ function promptGet(params: unknown) {
const s = getSkill(p.data.name);
if (!s || !s.enabled) return undefined;
const request = p.data.arguments?.request?.trim();
+ // A skill that runs by itself says how (its "Run it" section), after its instructions.
+ const recipe = s.recipe ? skillRecipe(s.name) : null;
+ const runs = recipe ? `\n\n${recipeMarkdown(recipe, { name: s.name })}` : "";
return {
description: s.description,
messages: [
@@ -149,7 +153,7 @@ function promptGet(params: unknown) {
role: "user",
content: {
type: "text",
- text: `Follow the “${s.title}” skill from Fuobe for this job, using Fuobe's tools (search_models, generate and the studio tools).\n\n${s.body}${request ? `\n\n---\n\nThe job: ${request}` : ""}`,
+ text: `Follow the “${s.title}” skill from Fuobe for this job, using Fuobe's tools (search_models, generate and the studio tools).\n\n${s.body}${runs}${request ? `\n\n---\n\nThe job: ${request}` : ""}`,
},
},
],
diff --git a/src/server/recipes.ts b/src/server/recipes.ts
index 2153dcdb..3c45445f 100644
--- a/src/server/recipes.ts
+++ b/src/server/recipes.ts
@@ -331,6 +331,7 @@ export function recipeView(name: string): RecipeView {
return {
name: skill.name,
title: skill.title,
+ ...(skill.icon && { icon: skill.icon }),
builtin: skill.source === "builtin",
recipe,
engines,
diff --git a/tests/assist-polish.test.ts b/tests/assist-polish.test.ts
index 36f15c9a..137d9557 100644
--- a/tests/assist-polish.test.ts
+++ b/tests/assist-polish.test.ts
@@ -5,7 +5,7 @@ import { NextRequest } from "next/server";
import { describe, expect, it } from "vitest";
import { HUB_MODES } from "@/lib/hubs";
// Plain .mjs helper shared with the Playwright scripts.
-import { dynamicSamples, hubModePaths, studioRoutes } from "./e2e/_routes.mjs";
+import { dynamicSamples, hubModePaths, querySamples, studioRoutes } from "./e2e/_routes.mjs";
const root = process.cwd();
// The proxy reads the sign-in settings from the data folder: use an empty one (no password).
@@ -37,6 +37,9 @@ describe("the 390 px sweep visits dynamic routes", () => {
for (const p of patterns) expect(byPattern[p]?.length, p).toBeGreaterThan(0);
expect(urls.filter((u) => /\[/.test(u))).toEqual([]);
expect(urls).toEqual(expect.arrayContaining(["/cinema/c1", "/cinema/does-not-exist", "/canvas/v1", "/canvas/does-not-exist", "/assist/projects/p1", "/apps/does-not-exist"]));
+ // Dialogs a query opens: a skill's Run form.
+ expect(querySamples({ recipeSkill: "lamp" })).toEqual(["/assist/skills?run=lamp", "/assist/skills?run=does-not-exist"]);
+ expect(querySamples()).toEqual(["/assist/skills?run=does-not-exist"]);
});
it("gives a route added later (another branch's /faceless/[id]/[episode]) a not-found sample by itself", () => {
diff --git a/tests/e2e/_routes.mjs b/tests/e2e/_routes.mjs
index 9f6d03d5..f614989a 100644
--- a/tests/e2e/_routes.mjs
+++ b/tests/e2e/_routes.mjs
@@ -68,3 +68,11 @@ export function dynamicSamples(root, ids = {}) {
}
return { urls, byPattern, generated };
}
+
+/**
+ * Pages a query opens a dialog on, with sample values: `ids.recipeSkill` names a skill with a recipe (its Run form,
+ * /assist/skills?run=…); an unknown one is visited too (the form says so in the dialog).
+ */
+export function querySamples(ids = {}) {
+ return [ids.recipeSkill && `/assist/skills?run=${ids.recipeSkill}`, "/assist/skills?run=does-not-exist"].filter(Boolean);
+}
diff --git a/tests/e2e/no-horizontal-scroll.mjs b/tests/e2e/no-horizontal-scroll.mjs
index bd95ff41..26e349f9 100644
--- a/tests/e2e/no-horizontal-scroll.mjs
+++ b/tests/e2e/no-horizontal-scroll.mjs
@@ -11,7 +11,7 @@
// asserts document.documentElement.scrollWidth === clientWidth once the page has rendered, and names
// the widest elements when it isn't. Pages that don't load are reported apart from layout failures.
import { launch, openRoute, PHONE, post, root } from "./_browser.mjs";
-import { dynamicSamples, studioRoutes } from "./_routes.mjs";
+import { dynamicSamples, querySamples, studioRoutes } from "./_routes.mjs";
const args = process.argv.slice(2);
const app = (args.find((a) => !a.startsWith("--")) ?? "http://localhost:3000").replace(/\/$/, "");
@@ -30,7 +30,10 @@ async function discoverRoutes() {
const autoRun = await post(app, "/api/assist", { text: brief, engine: "cloud", autoApprove: true, mode: { mode: "free" } });
const { urls, generated } = dynamicSamples(root, { cinema: project?.id, canvas: canvas?.id, assistProject: assistProject?.id });
const chats = [askFirst?.id, autoRun?.id].filter(Boolean).map((id) => `/assist?c=${id}`);
- const samples = [...urls, ...chats, "/library?tab=favorites", "/login", "/this-page-does-not-exist"];
+ // A skill with a recipe: its Run form opens from /assist/skills?run=<name>.
+ const recipeSkill = await recipeSkillSample();
+ const samples = [...urls, ...chats, ...querySamples({ recipeSkill }), "/library?tab=favorites", "/login", "/this-page-does-not-exist"];
+ if (!recipeSkill) console.log("note: couldn't create a sample skill with a recipe, only an unknown /assist/skills?run= is checked");
if (!project?.id) console.log("note: couldn't create a sample cinema project, only an unknown /cinema/[id] is checked");
if (!canvas?.id) console.log("note: couldn't create a sample canvas, only an unknown /canvas/[id] is checked");
if (!assistProject?.id) console.log("note: couldn't create a sample Assist project, only an unknown /assist/projects/[id] is checked");
@@ -39,6 +42,33 @@ async function discoverRoutes() {
return [...new Set([...out, ...samples])];
}
+/** A user skill with a two-input recipe (a picture and a name), made for the check; its name, or null. */
+async function recipeSkillSample() {
+ const name = "layout-check-run";
+ try {
+ await fetch(`${app}/api/assist/skills/${name}`, { method: "DELETE" });
+ await post(app, "/api/assist/skills", { name, title: "Layout check", description: "A poster from a product photo.", body: "# Poster" });
+ const res = await fetch(`${app}/api/assist/skills/${name}/recipe`, {
+ method: "PUT",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({
+ fuobeRecipe: 1,
+ params: [
+ { id: "product", label: "Product photo", type: "image", required: true },
+ { id: "name", label: "Product name with a long label to wrap", type: "text", required: true, example: "Lumen desk lamp" },
+ { id: "shape", label: "Shape", type: "choice", options: ["1:1", "9:16", "16:9", "4:5", "3:4", "21:9"], default: "1:1" },
+ ],
+ steps: [{ key: "poster", kind: "generate", request: { feature: "skill", modelId: "nano-banana-pro", op: "edit", prompt: "{{name}} on a plinth", inputs: { images: ["{{product}}"] }, params: { aspectRatio: "{{shape}}" } } }],
+ }),
+ });
+ if (!res.ok) return null;
+ await post(app, `/api/assist/skills/${name}/verify`, { level: "plan" });
+ return name;
+ } catch {
+ return null;
+ }
+}
+
const routes = only ?? (await discoverRoutes());
const browser = await launch();
const wide = [];
diff --git a/tests/e2e/skills-run.mjs b/tests/e2e/skills-run.mjs
new file mode 100644
index 00000000..a7e31034
--- /dev/null
+++ b/tests/e2e/skills-run.mjs
@@ -0,0 +1,223 @@
+// Skills W1 in a real browser (demo mode: no keys, ComfyUI unreachable). A skill with a recipe is seeded over the API;
+// its card says "Runs by itself"; /assist/skills?run=<name> opens the Run form, which asks for a free check first,
+// then runs it once from the form (a photo, a name, a shape) and three times from pasted CSV rows, each priced first
+// ("Demo" here); the skill's dialog says where it was checked, and in amber that it needs a re-check after its route
+// changed, and Re-check clears it. ⌘K lists "Run <skill>…". At 1440 and 390 px, light and dark: nothing scrolls
+// sideways, and on a phone the form fills the screen.
+// Usage: node tests/e2e/skills-run.mjs [appUrl] [--shots <dir>] (app running in demo mode). Exits 1 on a failed check.
+import fs from "node:fs";
+import path from "node:path";
+import { launch, openRoute, root } from "./_browser.mjs";
+
+const argv = process.argv.slice(2);
+const app = (argv.find((a) => !a.startsWith("--") && argv[argv.indexOf(a) - 1] !== "--shots") ?? "http://localhost:3000").replace(/\/$/, "");
+const shots = argv.includes("--shots") ? argv[argv.indexOf("--shots") + 1] : undefined;
+if (shots) fs.mkdirSync(shots, { recursive: true });
+
+const failures = [];
+const check = (label, ok, extra = "") => {
+ console.log(`${ok ? "ok " : "FAIL"} ${label.padEnd(76)}${extra ? ` ${extra}` : ""}`);
+ if (!ok) failures.push(label);
+};
+const send = (method, route, body) => fetch(app + route, { method, headers: { "content-type": "application/json" }, body: body === undefined ? undefined : JSON.stringify(body) });
+
+async function upload(file, type, name) {
+ const form = new FormData();
+ form.append("file", new Blob([fs.readFileSync(path.join(root, file))], { type }), name);
+ const res = await fetch(`${app}/api/uploads`, { method: "POST", body: form });
+ if (!res.ok) throw new Error(`upload failed: ${res.status}`);
+ return (await res.json()).url;
+}
+
+const NAME = "e2e-poster";
+const photoFile = "public/samples/grade-sample.jpg";
+const photo = await upload(photoFile, "image/jpeg", "lamp.jpg");
+await send("DELETE", `/api/assist/skills/${NAME}`);
+await send("POST", "/api/assist/skills", { name: NAME, title: "E2E Poster", description: "A staged product poster from a product photo.", body: "# Poster\n\n1. Cut the product out.\n2. Stage it." });
+const put = await send("PUT", `/api/assist/skills/${NAME}/recipe`, {
+ fuobeRecipe: 1,
+ params: [
+ { id: "product", label: "Product photo", type: "image", required: true, example: photo },
+ { id: "name", label: "Product name", type: "text", required: true, example: "Lumen desk lamp", max: 200 },
+ { id: "aspect", label: "Shape", type: "choice", options: ["1:1", "9:16", "16:9"], default: "1:1" },
+ ],
+ steps: [
+ { key: "cutout", kind: "generate", label: "Cut-out", request: { feature: "skill", modelId: "birefnet-cloud", op: "bg-remove", inputs: { images: ["{{product}}"] } } },
+ {
+ key: "scene",
+ kind: "generate",
+ label: "Poster",
+ after: ["cutout"],
+ chain: [{ slot: "images", position: "first" }],
+ request: { feature: "skill", modelId: "nano-banana-pro", op: "edit", prompt: "{{name}} on a travertine plinth, soft window light", params: { aspectRatio: "{{aspect}}" } },
+ },
+ ],
+});
+check("seed: a recipe skill saves over the API", put.ok, put.ok ? "" : await put.text());
+
+/** Generations a run of the skill made (the server's stamp), newest first. */
+async function stamped() {
+ const r = await (await fetch(`${app}/api/generations?limit=200&steps=1`)).json();
+ return r.items.filter((g) => g.request?.skill?.name === NAME);
+}
+
+/** Whether a locator shows up within `ms` (the dialog's content loads after it opens). */
+const seen = (locator, ms = 20_000) =>
+ locator
+ .first()
+ .waitFor({ state: "visible", timeout: ms })
+ .then(() => true)
+ .catch(() => false);
+const noSideScroll = (page) => page.evaluate(() => document.documentElement.scrollWidth <= document.documentElement.clientWidth);
+const shot = (page, name) => shots && page.screenshot({ path: path.join(shots, `${name}.png`) });
+
+const browser = await launch();
+try {
+ let flowsDone = false;
+ for (const [width, height] of [
+ [1440, 900],
+ [390, 844],
+ ]) {
+ for (const scheme of ["light", "dark"]) {
+ const tag = `${width} ${scheme}`;
+ const context = await browser.newContext({ viewport: { width, height }, colorScheme: scheme, ...(width < 500 ? { isMobile: true, hasTouch: true } : {}) });
+ const page = await context.newPage();
+ // The card's chip.
+ await openRoute(page, `${app}/assist/skills`);
+ await page.getByRole("tab", { name: /My skills/ }).click();
+ check(`${tag}: the card says "Runs by itself"`, await seen(page.getByText("Runs by itself").first()));
+
+ // The Run form, by its deep link.
+ await openRoute(page, `${app}/assist/skills?run=${NAME}`);
+ const dialog = page.getByRole("dialog");
+ check(`${tag}: ?run= opens the Run form`, await seen(dialog.getByRole("heading", { name: "Run E2E Poster" })));
+ if (!flowsDone) {
+ // 1. Unchecked: the form asks for the free check first.
+ check(`${tag}: it asks for a free check first`, await seen(dialog.getByText("Check it once first")));
+ await dialog.getByRole("button", { name: "Check it (free)" }).click();
+ const checked = await page
+ .getByText(/Checked — it runs on Cloud/)
+ .first()
+ .waitFor({ timeout: 90_000 })
+ .then(() => true)
+ .catch(() => false);
+ check(`${tag}: the check passes (plan + a free dry run)`, checked);
+ // 2. One run: a photo, a name, a shape; the price before it starts.
+ await dialog.locator('input[type="file"][accept^="image"]').first().setInputFiles(path.join(root, photoFile));
+ await dialog.getByLabel("Product name").fill("Arc floor lamp");
+ await dialog.getByRole("radio", { name: "16:9" }).click();
+ const priced = await dialog
+ .getByText(/Demo — no provider connected/)
+ .waitFor({ timeout: 30_000 })
+ .then(() => true)
+ .catch(() => false);
+ check(`${tag}: the form is priced before it runs (demo)`, priced);
+ await dialog.getByRole("button", { name: "What runs" }).click();
+ check(`${tag}: "What runs" lists both steps`, (await dialog.getByText("Cut-out").count()) > 0 && (await dialog.getByText(/Nano Banana Pro/).count()) > 0);
+ await shot(page, `run-form-${width}-${scheme}`);
+ const before = (await stamped()).length;
+ await dialog.getByRole("button", { name: /^Run/ }).click();
+ const started = await page
+ .getByText("Started the run")
+ .waitFor({ timeout: 30_000 })
+ .then(() => true)
+ .catch(() => false);
+ check(`${tag}: Run starts it ("Started the run")`, started);
+ const mine = await stamped();
+ const batch = mine.slice(0, mine.length - before);
+ check(`${tag}: one run is one batch of 2 steps with the skill's stamp`, batch.length === 2 && new Set(batch.map((g) => g.batchId)).size === 1 && batch.every((g) => g.request.batchTitle === "E2E Poster"), `${batch.length} rows`);
+ check(`${tag}: the run took the form's inputs`, batch.some((g) => g.request.prompt === "Arc floor lamp on a travertine plinth, soft window light" && g.request.params?.aspectRatio === "16:9"));
+ // 3. Many: three CSV rows, checked, priced together.
+ await openRoute(page, `${app}/assist/skills?run=${NAME}`);
+ await dialog.getByRole("tab", { name: "Many" }).click();
+ await dialog.getByLabel("Rows to run").fill(`Product photo,Product name,Shape\n${photo},Desk lamp,1:1\n${photo},"Lamp, brass",9:16\n${photo},Floor lamp,16:9\n`);
+ check(`${tag}: the rows are checked ("3 runs · all fine")`, await seen(dialog.getByText("3 runs · all fine")));
+ const total = await dialog
+ .getByText(/Demo — no provider connected, free · 3 runs/)
+ .waitFor({ timeout: 30_000 })
+ .then(() => true)
+ .catch(() => false);
+ check(`${tag}: the rows are priced together`, total);
+ await shot(page, `run-many-${width}-${scheme}`);
+ const before3 = (await stamped()).length;
+ await dialog.getByRole("button", { name: /^Run 3/ }).click();
+ const started3 = await page
+ .getByText("Started 3 runs")
+ .waitFor({ timeout: 30_000 })
+ .then(() => true)
+ .catch(() => false);
+ check(`${tag}: Run 3 starts three runs`, started3);
+ const rows = (await stamped()).slice(0, -before3 || undefined);
+ check(`${tag}: three runs are three batches`, new Set(rows.map((g) => g.batchId)).size === 3 && rows.length === 6, `${rows.length} rows`);
+ // A bad row is said inline, and nothing runs.
+ await openRoute(page, `${app}/assist/skills?run=${NAME}`);
+ await dialog.getByRole("tab", { name: "Many" }).click();
+ await dialog.getByLabel("Rows to run").fill(`product,name\n${photo},Desk lamp\nnot-a-link,Floor lamp\n`);
+ check(`${tag}: a bad row is marked inline`, await seen(dialog.getByText(/Product photo: a file from Fuobe/)));
+ check(`${tag}: …and the footer says to fix it, with no price`, await seen(dialog.getByText("Fix the rows marked below")));
+ // 4. Re-check: a different route than the one checked (Replicate preferred) needs a re-check, and Re-check clears it.
+ await send("PUT", "/api/settings", { cloudProvider: "replicate" });
+ await openRoute(page, `${app}/assist/skills?skill=${NAME}`);
+ const amber = await page
+ .getByText(/Needs a re-check:/)
+ .first()
+ .waitFor({ timeout: 15_000 })
+ .then(() => true)
+ .catch(() => false);
+ check(`${tag}: the skill says it needs a re-check after its route changed`, amber);
+ await shot(page, `recheck-${width}-${scheme}`);
+ if (amber) {
+ await page.getByRole("button", { name: "Re-check" }).click();
+ const ok = await page
+ .getByText(/Checked — it still runs/)
+ .first()
+ .waitFor({ timeout: 90_000 })
+ .then(() => true)
+ .catch(() => false);
+ check(`${tag}: Re-check passes and clears it`, ok && (await seen(page.getByText(/Checked \d+ \w+ · Cloud ✓/).first())));
+ }
+ await send("PUT", "/api/settings", { cloudProvider: "auto" });
+ await send("POST", `/api/assist/skills/${NAME}/verify`, { level: "demo" });
+ // 5. ⌘K: "Run E2E Poster…".
+ await openRoute(page, `${app}/library`);
+ await page.keyboard.press("Control+k");
+ await page.getByRole("combobox", { name: "Search Fuobe" }).fill("Run E2E");
+ const listed = await page
+ .getByRole("option", { name: /Run E2E Poster…/ })
+ .waitFor({ timeout: 10_000 })
+ .then(() => true)
+ .catch(() => false);
+ check(`${tag}: ⌘K lists "Run E2E Poster…"`, listed);
+ if (listed) {
+ await page.keyboard.press("Enter");
+ await page.waitForURL(/\/assist\/skills\?run=e2e-poster/, { timeout: 15_000 }).catch(() => {});
+ check(`${tag}: …and opens its Run form`, await seen(page.getByRole("heading", { name: "Run E2E Poster" })));
+ }
+ flowsDone = true;
+ await openRoute(page, `${app}/assist/skills?run=${NAME}`);
+ }
+ // Layout: ready to run, at this size and scheme.
+ check(`${tag}: the form is ready to run (checked on Cloud)`, await seen(dialog.getByText("Runs in the cloud")));
+ const box = await dialog.boundingBox();
+ check(`${tag}: the dialog fits the screen`, !!box && box.width <= width + 1 && box.x >= -1, box ? `${Math.round(box.width)}×${Math.round(box.height)}` : "");
+ if (width < 500) check(`${tag}: on a phone it fills the screen`, !!box && box.height >= height - 2);
+ await dialog.getByRole("tab", { name: "Many" }).click();
+ await dialog.getByLabel("Rows to run").fill(`Product photo,Product name,Shape\n${photo},A very long product name that keeps on going and going,16:9\n`);
+ check(`${tag}: nothing scrolls sideways`, await noSideScroll(page));
+ await shot(page, `layout-${width}-${scheme}`);
+ await openRoute(page, `${app}/assist/skills?skill=${NAME}`);
+ check(`${tag}: the skill's dialog offers Run… and the .zip`, await seen(page.getByRole("button", { name: "Run…" })));
+ await page.getByRole("button", { name: /Download/ }).click();
+ check(`${tag}: …Download offers SKILL.md and the .zip`, await seen(page.getByRole("menuitem", { name: "Skill with its files (.zip)" })));
+ await page.keyboard.press("Escape");
+ check(`${tag}: the skill's dialog doesn't scroll sideways`, await noSideScroll(page));
+ await shot(page, `detail-${width}-${scheme}`);
+ await context.close();
+ }
+ }
+} finally {
+ await browser.close();
+ await send("PUT", "/api/settings", { cloudProvider: "auto" });
+}
+console.log(failures.length ? `\n${failures.length} failed` : "\nall passed");
+process.exit(failures.length ? 1 : 0);
diff --git a/tests/recipes.test.ts b/tests/recipes.test.ts
index 7363e8da..ccc37ef8 100644
--- a/tests/recipes.test.ts
+++ b/tests/recipes.test.ts
@@ -26,6 +26,8 @@ const recipeRoute = await import("@/app/api/assist/skills/[name]/recipe/route");
const runRoute = await import("@/app/api/assist/skills/[name]/run/route");
const estimateRoute = await import("@/app/api/assist/skills/[name]/estimate/route");
const verifyRoute = await import("@/app/api/assist/skills/[name]/verify/route");
+const generationsRoute = await import("@/app/api/generations/route");
+const { handleMcp } = await import("@/server/mcp");
afterAll(() => fs.rmSync(dir, { recursive: true, force: true }));
@@ -308,6 +310,28 @@ describe("checking a recipe", () => {
});
});
+describe("the server-set fields", () => {
+ it("strips skill and demo from API input, like chainFilled", async () => {
+ setSetting("demoMode", "off");
+ try {
+ const res = await generationsRoute.POST(json({ feature: "image", modelId: "nano-banana-pro", op: "t2i", prompt: "a lamp", demo: true, skill: { name: "lamp", run: "forged" }, chainFilled: true }));
+ // Without the flag, Demo mode off and no key: the API refuses, rather than running a free demo.
+ expect(res.status).toBe(422);
+ expect(((await res.json()) as { error: string }).error).toMatch(/Connect/);
+ } finally {
+ setSetting("demoMode", "auto");
+ }
+ const ok = (await (await generationsRoute.POST(json({ feature: "image", modelId: "nano-banana-pro", op: "t2i", prompt: "a lamp", demo: true, skill: { name: "lamp", run: "forged" } }))).json()) as { items: { request: Record<string, unknown> }[] };
+ expect(ok.items[0].request.skill).toBeUndefined();
+ expect(ok.items[0].request.demo).toBeUndefined();
+ });
+
+ it("serves a recipe skill's Run it section in its MCP prompt", async () => {
+ const r = (await handleMcp({ jsonrpc: "2.0", id: 1, method: "prompts/get", params: { name: "lamp" } })) as { result: { messages: { content: { text: string } }[] } };
+ expect(r.result.messages[0].content.text).toContain("## Run it");
+ });
+});
+
describe("the recipe routes", () => {
it("reads, saves, prices, checks and runs over HTTP", async () => {
skills.createSkill({ name: "via-api", title: "Via API", description: "x", body: "x" });