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.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Skills W2 fixes: Make a skill from every viewer, words by keyboard, honest dry-run badge
Claudea48fbc9f3d76
diff --git a/src/app/(studio)/layout.tsx b/src/app/(studio)/layout.tsxindex 3b727d02..931737bd 100644--- a/src/app/(studio)/layout.tsx+++ b/src/app/(studio)/layout.tsx@@ -1,13 +1,10 @@import { StudioChrome } from "@/components/app-sidebar";import { ShareProvider } from "@/components/share/share-provider";-import { SkillBuilderProvider } from "@/components/skills/skill-builder-provider";export default function StudioLayout({ children }: { children: React.ReactNode }) {return (<StudioChrome>- <ShareProvider>- <SkillBuilderProvider>{children}</SkillBuilderProvider>- </ShareProvider>+ <ShareProvider>{children}</ShareProvider></StudioChrome>);}diff --git a/src/components/app-sidebar.tsx b/src/components/app-sidebar.tsxindex d8f6496d..257de088 100644--- a/src/components/app-sidebar.tsx+++ b/src/components/app-sidebar.tsx@@ -28,6 +28,7 @@ import { CommandPalette, CommandPaletteProvider, useCommandPalette } from "@/comimport { IntentLink } from "@/components/intent-link";import { JobNotifications } from "@/components/job-notifications";import { NAV, type NavGroupDef } from "@/components/nav-items";+import { SkillBuilderProvider } from "@/components/skills/skill-builder-provider";import { useEngineMode, useStatus } from "@/lib/api";import { useModKey } from "@/lib/keys";import { fullScreenStudio, groupId, NAV_CLOSED_KEY, navActive, parseClosed, sidebarCookie, SIDEBAR_STATE_SCRIPT, sidebarOpenFromCookie } from "@/lib/nav";@@ -240,19 +241,22 @@ export function StudioChrome({ children }: { children: React.ReactNode }) {// The shell stays static: the remembered collapsed state is read on the client (and applied// before first paint by AppSidebar's inline script), not from cookies() on the server.<CommandPaletteProvider>- <SidebarShell style={{ "--sidebar-width": "15.5rem", "--sidebar-width-icon": "3.25rem" } as React.CSSProperties}>- <SkipLink />- <AppSidebar />- <SidebarInset- id="content"- tabIndex={-1}- className="min-h-svh min-w-0 outline-none md:m-0 md:mt-2 md:rounded-none md:rounded-tl-xl md:border-t-[0.5px] md:border-l-[0.5px] md:shadow-[-2px_0_6px_rgba(0,0,0,.02)] md:peer-data-[variant=inset]:m-0 md:peer-data-[variant=inset]:mt-2 md:peer-data-[variant=inset]:rounded-none md:peer-data-[variant=inset]:rounded-tl-xl"- >- {children}- </SidebarInset>- <CommandPalette />- <JobNotifications />- </SidebarShell>+ {/* Make a skill from any result's ⋯ menu: a page's, the ⌘K palette's and a job notification's viewer. */}+ <SkillBuilderProvider>+ <SidebarShell style={{ "--sidebar-width": "15.5rem", "--sidebar-width-icon": "3.25rem" } as React.CSSProperties}>+ <SkipLink />+ <AppSidebar />+ <SidebarInset+ id="content"+ tabIndex={-1}+ className="min-h-svh min-w-0 outline-none md:m-0 md:mt-2 md:rounded-none md:rounded-tl-xl md:border-t-[0.5px] md:border-l-[0.5px] md:shadow-[-2px_0_6px_rgba(0,0,0,.02)] md:peer-data-[variant=inset]:m-0 md:peer-data-[variant=inset]:mt-2 md:peer-data-[variant=inset]:rounded-none md:peer-data-[variant=inset]:rounded-tl-xl"+ >+ {children}+ </SidebarInset>+ <CommandPalette />+ <JobNotifications />+ </SidebarShell>+ </SkillBuilderProvider></CommandPaletteProvider>);}diff --git a/src/components/assist/hooks.ts b/src/components/assist/hooks.tsindex 8bf994a0..fdda011f 100644--- a/src/components/assist/hooks.ts+++ b/src/components/assist/hooks.ts@@ -248,7 +248,10 @@ export function useSkillDraft(ids: string[]) {queryKey: ["skill-draft", ids.join(",")],enabled: ids.length > 0,retry: false,+ // Read once while the review is open, and dropped when it closes: opened again, it is drafted again (a name saved+ // since is taken, a result trashed since is gone).staleTime: Infinity,+ gcTime: 0,queryFn: () => recipeCall<{ draft: SkillDraft | null; refusals: DraftRefusal[] }>("/api/assist/skills/draft", { generations: ids }),});}@@ -263,6 +266,7 @@ export function useDraftActions() {save: async (body: { name: string; title: string; description: string; whenToUse?: string; body: string; recipe: unknown }) => {const view = await recipeCall<RecipeView>("/api/assist/skills/draft/save", body);qc.setQueryData(["assist-recipe", view.name], view);+ qc.removeQueries({ queryKey: ["skill-draft"] });void qc.invalidateQueries({ queryKey: ["assist-skills"] });return view;},diff --git a/src/components/skills/skill-builder.tsx b/src/components/skills/skill-builder.tsxindex 9d9152d3..160201b0 100644--- a/src/components/skills/skill-builder.tsx+++ b/src/components/skills/skill-builder.tsx@@ -1,7 +1,7 @@"use client";import { AlertTriangle, ArrowRight, AudioLines, Box, Check, ChevronDown, Cloud, Cpu, FileText, Info, Loader2, ShieldCheck, Sparkles, Undo2, X } from "lucide-react";-import { useMemo, useRef, useState } from "react";+import { useEffect, useMemo, useRef, useState } from "react";import { toast } from "sonner";import { RunSkillDialog } from "@/components/assist/run-skill-dialog";import { useDraftActions, useSkillDraft, type DraftCheckResult } from "@/components/assist/hooks";@@ -176,7 +176,8 @@ function Review({ draft, refusals, ids, onClose, onSaved, header }: { draft: Ski}};- const varying = draft.candidates.filter((c) => varies[c.id]).length + new Set(slots.map((s) => s.id)).size;+ // What the Run form will ask for (an element whose words vary as a whole, or words no prompt has, asks for nothing).+ const varying = recipe.params.length;const status = statusLine(current, busy, own);return (@@ -367,6 +368,9 @@ function priceOf(e: DraftCheckResult["engines"][number]): string {function CheckBadges({ check }: { check: CheckState }) {const demo = check.demo;+ // Every engine's dry run skipped (a studio tool step): say so, rather than "passed".+ const ran = demo && demo !== "running" ? demo.engines.filter((e) => e.dryRun) : [];+ const skipped = demo && demo !== "running" && demo.ok && ran.length > 0 && ran.every((e) => e.dryRun?.skipped) ? ran[0].dryRun!.skipped : undefined;return (<div className="flex flex-wrap gap-1.5">{check.plan!.engines.map((e) => (@@ -380,7 +384,13 @@ function CheckBadges({ check }: { check: CheckState }) {<Loader2 className="size-3 animate-spin" /> Dry run…</span>)}- {demo && demo !== "running" && (+ {demo && demo !== "running" && skipped && (+ // A studio step's dry run would make a record you'd see (a demo dub): its plan is its check, and nothing ran.+ <span className="inline-flex h-6 items-center gap-1 rounded-full bg-muted px-2 text-[12px] text-muted-foreground" title={skipped}>+ <Info className="size-3" /> No dry run: a studio step is checked by its plan+ </span>+ )}+ {demo && demo !== "running" && !skipped && (<span className={cn("inline-flex h-6 items-center gap-1 rounded-full px-2 text-[12px] font-medium", demo.ok ? "bg-brand-faint text-brand-text" : "bg-destructive/10 text-destructive")} title={demo.ok ? undefined : demo.engines.flatMap((e) => e.dryRun?.problems ?? []).join("; ")}>{demo.ok ? <Check className="size-3" /> : <X className="size-3" />} Dry run {demo.ok ? "passed" : "failed"}</span>@@ -579,33 +589,51 @@ function FixedVaries({ value, onChange, disabled, label }: { value: boolean; onCfunction Words({ c, varies, slots, setSlots, takenIds }: { c: DraftCandidate; varies: boolean; slots: Slot[]; setSlots: React.Dispatch<React.SetStateAction<Slot[]>>; takenIds: string[] }) {const text = String(c.example);const step = c.at[0]?.step;+ // The words to make an input: selected in the text (a mouse, a finger dragging the handles) or typed (a keyboard).const [picked, setPicked] = useState("");+ const [typing, setTyping] = useState(false);const [slotLabel, setSlotLabel] = useState("");const box = useRef<HTMLParagraphElement>(null);+ const field = useRef<HTMLInputElement>(null);const mine = slots.filter((s) => text.includes(s.text));- const readSelection = () => {- const sel = window.getSelection();- if (!sel || !box.current || !sel.anchorNode || !box.current.contains(sel.anchorNode)) return;- const words = sel.toString().replace(/\s+/g, " ").trim();- if (words.length >= 2 && words.length <= 200 && text.includes(words)) {- setPicked(words);- setSlotLabel((l) => l || (words.split(" ").length <= 3 ? words.replace(/^./, (x) => x.toUpperCase()) : ""));- }- };+ const words = picked.replace(/\s+/g, " ").trim();+ const fits = words.length >= 2 && words.length <= 200 && text.includes(words);+ useEffect(() => {+ if (varies) return;+ // Every change of the selection, so dragging a phone's handles counts (no touchend reaches the text then).+ const read = () => {+ const sel = window.getSelection();+ if (!sel || !box.current || !sel.anchorNode || !box.current.contains(sel.anchorNode)) return;+ const chosen = sel.toString().replace(/\s+/g, " ").trim();+ if (chosen.length >= 2 && chosen.length <= 200 && text.includes(chosen)) {+ setPicked(chosen);+ setSlotLabel((l) => l || (chosen.split(" ").length <= 3 ? chosen.replace(/^./, (x) => x.toUpperCase()) : ""));+ }+ };+ document.addEventListener("selectionchange", read);+ return () => document.removeEventListener("selectionchange", read);+ }, [text, varies]);const add = () => {+ if (!fits) return;const label = slotLabel.trim() || "Words";const id = paramIdFrom(label, takenIds);- setSlots((x) => [...x, { step: step ?? "", text: picked, id, label: label.slice(0, 60) }]);+ setSlots((x) => [...x, { step: step ?? "", text: words, id, label: label.slice(0, 60) }]);setPicked("");setSlotLabel("");+ setTyping(false);window.getSelection()?.removeAllRanges();};+ const cancel = () => {+ setPicked("");+ setSlotLabel("");+ setTyping(false);+ };if (varies) {return <p className="mt-2 line-clamp-3 rounded-lg bg-muted/60 px-3 py-2 text-[12px] break-words text-muted-foreground">The whole prompt is an input. Was: “{text}”</p>;}return (<div className="mt-2 space-y-2">- <p ref={box} onMouseUp={readSelection} onKeyUp={readSelection} onTouchEnd={() => setTimeout(readSelection, 0)} className="rounded-lg bg-muted/60 px-3 py-2 text-[13px] leading-relaxed break-words select-text">+ <p ref={box} className="rounded-lg bg-muted/60 px-3 py-2 text-[13px] leading-relaxed break-words select-text"><Highlighted text={text} slots={mine} /></p>{mine.length > 0 && (@@ -622,21 +650,44 @@ function Words({ c, varies, slots, setSlots, takenIds }: { c: DraftCandidate; va))}</div>)}- {picked ? (+ {picked || typing ? (<div className="flex flex-wrap items-center gap-1.5 text-[12px]">- <span className="min-w-0 truncate">- Make “<span className="font-medium">{picked}</span>” an input:- </span>- <Input aria-label="Its label" placeholder="Label, e.g. Product" value={slotLabel} maxLength={60} onChange={(e) => setSlotLabel(e.target.value)} className="h-8 w-40 text-[13px]" />- <Button size="sm" variant="outline" onClick={add}>+ <Input+ ref={field}+ aria-label="Words from the prompt to make an input"+ placeholder="Words from the prompt"+ value={picked}+ maxLength={200}+ onChange={(e) => setPicked(e.target.value)}+ onKeyDown={(e) => e.key === "Enter" && add()}+ aria-invalid={!!words && !fits}+ className="h-8 w-56 max-w-full text-[13px]"+ />+ <Input aria-label="Its label" placeholder="Label, e.g. Product" value={slotLabel} maxLength={60} onChange={(e) => setSlotLabel(e.target.value)} onKeyDown={(e) => e.key === "Enter" && add()} className="h-8 w-40 max-w-full text-[13px]" />+ <Button size="sm" variant="outline" onClick={add} disabled={!fits}>Make it an input</Button>- <Button size="sm" variant="ghost" onClick={() => setPicked("")}>+ <Button size="sm" variant="ghost" onClick={cancel}>Cancel</Button>+ {words && !fits && <p className="w-full text-muted-foreground">Type the words as they are in the prompt.</p>}</div>) : (- <p className="text-[12px] text-muted-foreground">To change only some words next time (a product, a name), select them above.</p>+ <p className="text-[12px] text-muted-foreground">+ To change only some words next time (a product, a name), select them above, or{" "}+ <button+ type="button"+ onClick={() => {+ setTyping(true);+ // The field appears on the next render: focus it then, for the keyboard.+ setTimeout(() => field.current?.focus(), 0);+ }}+ className="font-medium text-foreground underline underline-offset-2"+ >+ type them+ </button>+ .+ </p>)}</div>);diff --git a/tests/e2e/skills-builder.mjs b/tests/e2e/skills-builder.mjsindex bd47250e..2c56802b 100644--- a/tests/e2e/skills-builder.mjs+++ b/tests/e2e/skills-builder.mjs@@ -3,9 +3,11 @@// in the Library and turned into a skill with the bulk bar's "Make a skill": the review screen shows the 3 steps,// waiting for each other; one input is switched to Varies and words selected in a prompt become an input of their own;// Check it prices it and dry-runs it for free; Save opens the-// Run form ("Try it with new inputs"), which runs it with new words. The result ⋯ menu offers "Make a skill from-// this…" too. At 1440 and 390 px, light and dark: nothing scrolls sideways, on a phone the review fills the screen and-// the bulk bar keeps Make a skill. The skill is deleted at the end.+// Run form ("Try it with new inputs"), which runs it with new words. That whole flow runs at 1440 px light (words picked+// with the mouse) and at 390 px dark (on a phone, the words typed: the keyboard's way). The result ⋯ menu offers "Make a+// skill from this…" too, and so does a creation opened from ⌘K (a viewer outside the page). At 1440 and 390 px, light+// and dark: nothing scrolls sideways, on a phone the review fills the screen and the bulk bar keeps Make a skill. The+// skills are deleted at the end.// Usage: node tests/e2e/skills-builder.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";@@ -68,7 +70,7 @@ async function compose(page, route, words) {}const words = { still: `${tag} brass desk lamp, studio light`, edit: `${tag} brass desk lamp on a travertine plinth`, clip: `${tag} slow turntable of the brass desk lamp` };-let skillName = null;+const skillNames = [];const browser = await launch();try {// ---------------------------------------------------------------------------@@ -99,7 +101,7 @@ try {await page.waitForTimeout(1500);const dialog = page.getByRole("dialog");- if (width === 1440 && scheme === "light") {+ if ((width === 1440 && scheme === "light") || (phone && scheme === "dark")) {// 2. Select the three results, then Make a skill from the bulk bar.await page.getByRole("button", { name: "Select", exact: true }).click();for (const w of Object.values(words)) await page.getByRole("button", { name: new RegExp(`^Select “${w.slice(0, 24)}`) }).first().click({ force: true });@@ -115,19 +117,32 @@ try {const words1 = dialog.getByRole("radiogroup", { name: /Words for “Text to image”/ });await words1.getByRole("radio", { name: "Varies" }).click();check(`${tagLine}: one input switched to Varies`, (await dialog.getByText("1 input for the Run form").count()) === 1);- const editWords = dialog.locator("li", { has: page.getByRole("radiogroup", { name: /Words for “Image edit”/ }) }).locator("p.select-text");- await editWords.evaluate((el) => {- const node = [...el.childNodes].map((n) => (n.nodeType === 3 ? n : n.firstChild)).find((n) => n?.textContent?.includes("brass desk lamp"));- const at = node.textContent.indexOf("brass desk lamp");- const range = document.createRange();- range.setStart(node, at);- range.setEnd(node, at + "brass desk lamp".length);- const sel = window.getSelection();- sel.removeAllRanges();- sel.addRange(range);- el.dispatchEvent(new MouseEvent("mouseup", { bubbles: true }));- });- await dialog.getByRole("button", { name: "Make it an input" }).click();+ const editRow = dialog.locator("li", { has: page.getByRole("radiogroup", { name: /Words for “Image edit”/ }) });+ if (!phone) {+ // Selected in the text (the selection is read as it changes).+ await editRow.locator("p.select-text").evaluate((el) => {+ const node = [...el.childNodes].map((n) => (n.nodeType === 3 ? n : n.firstChild)).find((n) => n?.textContent?.includes("brass desk lamp"));+ const at = node.textContent.indexOf("brass desk lamp");+ const range = document.createRange();+ range.setStart(node, at);+ range.setEnd(node, at + "brass desk lamp".length);+ const sel = window.getSelection();+ sel.removeAllRanges();+ sel.addRange(range);+ });+ } else {+ // Typed: "type them" focuses the field, and words not in the prompt can't become an input.+ await editRow.getByRole("button", { name: "type them" }).click();+ const field = editRow.getByRole("textbox", { name: "Words from the prompt to make an input" });+ await field.waitFor();+ await page.waitForTimeout(150);+ check(`${tagLine}: "type them" puts the keyboard in the words field`, await field.evaluate((el) => el === document.activeElement));+ await page.keyboard.type("brass desk lamps");+ check(`${tagLine}: words that aren't in the prompt can't become an input`, await editRow.getByRole("button", { name: "Make it an input" }).isDisabled());+ await page.keyboard.press("Backspace");+ await editRow.getByRole("textbox", { name: "Its label" }).fill("Brass desk lamp");+ }+ await editRow.getByRole("button", { name: "Make it an input" }).click();check(`${tagLine}: selected words become an input, marked in the text`, (await dialog.locator("mark", { hasText: "brass desk lamp" }).count()) >= 1 && (await dialog.getByText("2 inputs for the Run form").count()) === 1);await shot(page, `builder-${width}-${scheme}`);// 4. Check it: priced on each engine, then a free dry run in the background.@@ -136,7 +151,8 @@ try {check(`${tagLine}: the dry run passes (free, on the demo provider)`, await seen(dialog.getByText("Dry run passed"), 120_000));// 5. Save: the Run form opens with the inputs it was made from.const title = await dialog.getByLabel("Title").inputValue();- skillName = await page.locator("#sb-name").inputValue();+ const skillName = await page.locator("#sb-name").inputValue();+ skillNames.push(skillName);await api("DELETE", `/api/assist/skills/${skillName}`);await dialog.getByRole("button", { name: "Save skill" }).click();check(`${tagLine}: Save opens "Try it with new inputs"`, await seen(page.getByRole("dialog").getByText(/Try it with new inputs/), 30_000));@@ -153,6 +169,12 @@ try {const r = await api("GET", "/api/generations?limit=50&steps=1");const mine = (r?.items ?? []).filter((g) => g.request?.skill?.name === skillName);check(`${tagLine}: one run of 3 steps with the new words`, mine.length === 3 && mine.some((g) => g.request.prompt === `${tag} green ceramic vase, studio light`) && mine.some((g) => g.request.prompt === `${tag} slow turntable of the brass desk lamp`), `${mine.length} rows`);+ // The run's rows share the chain's words: once done, to the Trash, out of the next flow's selection.+ for (const until = Date.now() + 60_000; Date.now() < until; await new Promise((r) => setTimeout(r, 500))) {+ const rows = ((await api("GET", "/api/generations?limit=50&steps=1"))?.items ?? []).filter((g) => g.request?.skill?.name === skillName);+ if (rows.every((g) => ["succeeded", "failed", "canceled"].includes(g.status))) break;+ }+ if (mine.length) await api("POST", "/api/generations/bulk", { action: "trash", ids: mine.map((g) => g.id) });await page.keyboard.press("Escape");}@@ -177,6 +199,20 @@ try {await shot(page, `builder-menu-${width}-${scheme}`);await page.keyboard.press("Escape");+ if (!phone && scheme === "light") {+ // A viewer outside the page (a creation opened from ⌘K) makes a skill too.+ await openRoute(page, `${app}/settings`, { settleMs: 1200 });+ await page.keyboard.press("Control+k");+ const palette = page.getByRole("dialog", { name: "Search Fuobe" });+ await palette.waitFor();+ await page.keyboard.type(words.still);+ await page.waitForTimeout(1500);+ await palette.getByRole("option").filter({ hasText: words.still }).first().click();+ await page.getByRole("button", { name: "Make a skill from this…" }).last().click();+ check(`${tagLine}: from a creation opened with ⌘K, Make a skill opens the review`, await seen(page.getByRole("dialog").getByText("What changes next time"), 30_000));+ await page.keyboard.press("Escape");+ }+if (phone) {// The bulk bar keeps Make a skill on a phone (its label hides, the button stays), and still fits.await openRoute(page, `${app}/library`, { settleMs: 1200 });@@ -195,7 +231,7 @@ try {console.log(`FAIL the script stopped: ${e.stack ?? e}`);} finally {await browser.close().catch(() => {});- if (skillName) await api("DELETE", `/api/assist/skills/${skillName}`).catch(() => {});+ for (const n of skillNames) await api("DELETE", `/api/assist/skills/${n}`).catch(() => {});}if (errors.length) console.log(`page errors:\n${errors.join("\n")}`);console.log(failures.length || errors.length ? `${failures.length} check(s) failed` : "All skill builder checks passed");