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.

Library and Skills: a "Save it as a skill?" card for a chain you keep making, each skill's History, and Suggest a fix

Claude2e906b3408b7
diff --git a/src/components/assist/hooks.ts b/src/components/assist/hooks.ts
index 9c7a985f..f3c355a8 100644
--- a/src/components/assist/hooks.ts
+++ b/src/components/assist/hooks.ts
@@ -20,7 +20,7 @@ import type {
import type { ConnectorView } from "@/lib/assist-connectors";
import type { ScheduleRule, ScheduleSkill, ScheduleView } from "@/lib/assist-schedule";
import type { Engine, Generation } from "@/lib/catalog/types";
-import type { RecipeEstimate, RecipeRun, RecipeView, VerifyResult } from "@/lib/recipe";
+import type { RecipeEstimate, RecipeRun, RecipeView, SkillHistory, SkillSuggestion, StepFix, VerifyResult } from "@/lib/recipe";
import type { DraftRefusal, Naming, SkillDraft } from "@/lib/recipe-builder";
import { responseError } from "@/lib/refusals";
@@ -232,6 +232,78 @@ export function useRecipeActions() {
};
}
+// ---------------------------------------------------------------------------
+// Suggestions, run history and fixes (W6). Under ["assist-skills", …]: saving a skill refreshes them.
+
+/** Chains made often lately that no saved skill has (the Library's card): the owner's only. */
+export function useSkillSuggestions(enabled: boolean) {
+ return useHydrationSafe(
+ useQuery({
+ queryKey: ["assist-skills", "suggestions"],
+ enabled,
+ staleTime: 5 * 60_000,
+ retry: false,
+ queryFn: async () => (await json<{ items: SkillSuggestion[] }>(await fetch("/api/assist/skills/suggestions"))).items,
+ }),
+ );
+}
+
+export function useSuggestionActions() {
+ const qc = useQueryClient();
+ return {
+ /** "Not now" (a week) or "Don't suggest this": the card goes at once. */
+ dismiss: async (shape: string, action: "later" | "dismiss") => {
+ qc.setQueryData<SkillSuggestion[]>(["assist-skills", "suggestions"], (old) => old?.filter((s) => s.shape !== shape));
+ try {
+ await send("/api/assist/skills/suggestions", "POST", { shape, action });
+ } finally {
+ void qc.invalidateQueries({ queryKey: ["assist-skills", "suggestions"] });
+ }
+ },
+ };
+}
+
+/** A skill's runs: counts, success rate, spend and the last 10. */
+export function useSkillHistory(name: string | null, enabled = true) {
+ return useHydrationSafe(
+ useQuery({
+ queryKey: ["assist-skill-history", name],
+ enabled: !!name && enabled,
+ retry: false,
+ staleTime: 15_000,
+ queryFn: async () => json<SkillHistory>(await fetch(`/api/assist/skills/${name}/history`)),
+ }),
+ );
+}
+
+/** The steps of a skill that need a fix, with the models that could take their place. */
+export function useStepFixes(name: string | null, enabled = true) {
+ return useHydrationSafe(
+ useQuery({
+ queryKey: ["assist-skill-fixes", name],
+ enabled: !!name && enabled,
+ retry: false,
+ queryFn: async () => (await json<{ items: StepFix[] }>(await fetch(`/api/assist/skills/${name}/fixes`))).items,
+ }),
+ );
+}
+
+/** Use the picked model in a step: saved once its plan and the free dry run pass. */
+export function useApplyFix() {
+ const qc = useQueryClient();
+ return async (name: string, step: string, modelId: string) => {
+ try {
+ const r = await recipeCall<VerifyResult>(`/api/assist/skills/${name}/fixes`, { step, modelId });
+ qc.setQueryData(["assist-recipe", name], r.view);
+ return r;
+ } finally {
+ void qc.invalidateQueries({ queryKey: ["assist-recipe", name] });
+ void qc.invalidateQueries({ queryKey: ["assist-skill-fixes", name] });
+ void qc.invalidateQueries({ queryKey: ["assist-skills"] });
+ }
+ };
+}
+
// ---------------------------------------------------------------------------
// Making a skill from results (W2: src/server/recipe-builder.ts)
diff --git a/src/components/assist/skill-upkeep.tsx b/src/components/assist/skill-upkeep.tsx
new file mode 100644
index 00000000..88935380
--- /dev/null
+++ b/src/components/assist/skill-upkeep.tsx
@@ -0,0 +1,155 @@
+"use client";
+
+import { Heart, Loader2, Wrench } from "lucide-react";
+import Link from "next/link";
+import { useState } from "react";
+import { toast } from "sonner";
+import { Button } from "@/components/ui/button";
+import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog";
+import { Label } from "@/components/ui/label";
+import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
+import { Skeleton } from "@/components/ui/skeleton";
+import { formatCost } from "@/lib/format";
+import { ENGINE_WORDS, type SkillRunRecord, type StepFix } from "@/lib/recipe";
+import { refusalShown } from "@/lib/refusals";
+import { cn } from "@/lib/utils";
+import { useApplyFix, useSkillHistory, type RecipeFailure } from "./hooks";
+
+/**
+ * Keeping a saved skill working (Skills W6): its run History in the skill's dialog, and Suggest a fix on its
+ * "Needs a re-check" line (a step that keeps failing, was replaced or is switched off; nothing is swapped by itself).
+ */
+
+const day = (ts: number) => new Date(ts).toLocaleDateString(undefined, { day: "numeric", month: "short" });
+
+const STATUS: Record<SkillRunRecord["status"], { label: string; dot: string }> = {
+ succeeded: { label: "Done", dot: "bg-emerald-500" },
+ failed: { label: "Failed", dot: "bg-destructive" },
+ canceled: { label: "Stopped", dot: "bg-muted-foreground" },
+ running: { label: "Running", dot: "bg-amber-500" },
+};
+
+/** A run's cost: Free on your GPU or as a demo, its price, or nothing while unknown. */
+const runCost = (r: SkillRunRecord) => (r.demo ? "Free · demo" : r.costUsd === null ? "—" : formatCost(r.costUsd));
+
+/** History, under a skill's Files: how often it ran, how it went, what it cost, and its last 10 runs. */
+export function SkillHistorySection({ name }: { name: string }) {
+ const history = useSkillHistory(name);
+ const h = history.data;
+ return (
+ <div className="mt-4 border-t pt-3">
+ <p className="text-[12px] font-medium">History</p>
+ {!h ? (
+ history.isError ? (
+ <p className="mt-1 text-[12px] text-muted-foreground">Couldn&apos;t load its runs.</p>
+ ) : (
+ <Skeleton className="mt-2 h-10" />
+ )
+ ) : !h.runs ? (
+ <p className="mt-1 text-[12px] text-muted-foreground">No runs yet. Its runs show up here, with what each one cost.</p>
+ ) : (
+ <>
+ <p className="mt-1 text-[12px] text-muted-foreground">
+ {h.runs} run{h.runs === 1 ? "" : "s"}
+ {h.successRate !== null && ` · ${Math.round(h.successRate * 100)}% succeeded`}
+ {` · ${h.spentUsd ? `${formatCost(h.spentUsd)} spent` : "nothing spent"}`}
+ {h.lastRun && ` · last ${day(h.lastRun)}`}
+ {h.favorites > 0 && ` · ${h.favorites} with a favourite`}
+ </p>
+ <ul className="mt-2 divide-y rounded-lg border text-[12px]">
+ {h.recent.map((r) => (
+ <li key={r.run} className="flex min-w-0 items-center gap-2 px-3 py-2">
+ <span className={cn("size-2 shrink-0 rounded-full", STATUS[r.status].dot)} aria-hidden />
+ <span className="w-16 shrink-0 font-medium">{STATUS[r.status].label}</span>
+ <span className="w-14 shrink-0 text-muted-foreground">{day(r.createdAt)}</span>
+ <span className="min-w-0 flex-1 truncate text-muted-foreground" title={r.error ?? undefined}>
+ {runCost(r)}
+ {r.favorite && <Heart className="ml-1.5 inline size-3 fill-current align-[-2px] text-rose-500" aria-label="A favourite" />}
+ </span>
+ {r.batchId && (
+ <Link href={`/library?batch=${encodeURIComponent(r.batchId)}`} className="shrink-0 text-brand-text underline underline-offset-2">
+ Open
+ </Link>
+ )}
+ </li>
+ ))}
+ </ul>
+ </>
+ )}
+ </div>
+ );
+}
+
+const pricing = (c: StepFix["candidates"][number]) => (c.engine === "open" ? "Free on your GPU" : c.total === null ? "Price varies" : `${formatCost(c.total)} a run`);
+
+/** Suggest a fix: each step that needs one, the models that could take its place with their prices; checked, then saved. */
+export function SuggestFix({ name, fixes, onDone }: { name: string; fixes: StepFix[]; onDone?: () => void }) {
+ const [open, setOpen] = useState(false);
+ const [picked, setPicked] = useState<Record<string, string>>({});
+ const [busy, setBusy] = useState<string | null>(null);
+ const apply = useApplyFix();
+ if (!fixes.length) return null;
+ const save = async (f: StepFix) => {
+ const modelId = picked[f.key] ?? f.candidates[0]?.modelId;
+ if (!modelId) return;
+ setBusy(f.key);
+ try {
+ const r = await apply(name, f.key, modelId);
+ toast.success(r.ok ? "Fixed — checked and saved" : "Saved — one engine's check didn't pass", { description: r.ok ? "Priced, and run once on the demo provider for free." : r.engines.flatMap((e) => [...e.plan.errors, ...(e.dryRun?.problems ?? [])])[0] });
+ if (fixes.length === 1) setOpen(false);
+ onDone?.();
+ } catch (e) {
+ const fail = e as RecipeFailure;
+ if (!refusalShown(fail)) toast.error(fail.message, { description: fail.problems?.slice(1).join("; ") || undefined });
+ } finally {
+ setBusy(null);
+ }
+ };
+ return (
+ <>
+ <Button variant="outline" size="xs" className="h-6 rounded-full px-2 text-[12px]" onClick={() => setOpen(true)}>
+ <Wrench /> Suggest a fix
+ </Button>
+ <Dialog open={open} onOpenChange={setOpen}>
+ <DialogContent className="max-h-[min(92svh,760px)] overflow-y-auto sm:max-w-[520px]">
+ <DialogHeader>
+ <DialogTitle>Suggest a fix</DialogTitle>
+ <DialogDescription>Pick a model for the step. It&apos;s priced and run once for free before it&apos;s saved; nothing changes until you do.</DialogDescription>
+ </DialogHeader>
+ <div className="space-y-5">
+ {fixes.map((f) => (
+ <section key={f.key} aria-label={f.label} className="min-w-0">
+ <p className="text-[13px] font-medium">
+ {f.label} <span className="font-normal text-muted-foreground">· {f.modelName}</span>
+ </p>
+ <p className="mt-0.5 text-[12px] text-amber-700 dark:text-amber-300">{f.why}</p>
+ {f.candidates.length ? (
+ <RadioGroup className="mt-2 gap-1.5" value={picked[f.key] ?? f.candidates[0].modelId} onValueChange={(v) => setPicked((p) => ({ ...p, [f.key]: v }))}>
+ {f.candidates.map((c) => (
+ <Label key={c.modelId} className="flex min-w-0 cursor-pointer items-center gap-2.5 rounded-lg border px-3 py-2 font-normal has-data-checked:border-primary">
+ <RadioGroupItem value={c.modelId} />
+ <span className="min-w-0 flex-1 truncate text-[13px]">{c.name}</span>
+ <span className="shrink-0 text-[12px] text-muted-foreground">
+ {ENGINE_WORDS[c.engine]} · {pricing(c)}
+ </span>
+ </Label>
+ ))}
+ </RadioGroup>
+ ) : (
+ <p className="mt-2 text-[12px] text-muted-foreground">No other model that&apos;s switched on does this. Switch one on in Settings → Models & licences.</p>
+ )}
+ {f.candidates.length > 0 && (
+ <div className="mt-2 flex justify-end">
+ <Button size="sm" onClick={() => void save(f)} disabled={!!busy}>
+ {busy === f.key && <Loader2 className="animate-spin" />} Check and save
+ </Button>
+ </div>
+ )}
+ </section>
+ ))}
+ </div>
+ </DialogContent>
+ </Dialog>
+ </>
+ );
+}
diff --git a/src/components/assist/skills-view.tsx b/src/components/assist/skills-view.tsx
index 3d24848c..e1c4009c 100644
--- a/src/components/assist/skills-view.tsx
+++ b/src/components/assist/skills-view.tsx
@@ -33,10 +33,11 @@ import { SKILL_LIMITS, SKILL_NAME_RE, skillSlug, type Skill, type SkillSummary }
import { cn } from "@/lib/utils";
import { refusalShown, toastError } from "@/lib/refusals";
import { radioKeys } from "@/components/studio/radio-keys";
-import { useRecipe, useRecipeActions, useSkill, useSkillActions, useSkills, type RecipeFailure, type SkillForm } from "./hooks";
+import { useRecipe, useRecipeActions, useSkill, useSkillActions, useSkills, useStepFixes, type RecipeFailure, type SkillForm } from "./hooks";
import { RunSkillDialog } from "./run-skill-dialog";
import { RailButton } from "./shell";
import { SKILL_ICONS, SkillIcon } from "./skill-icon";
+import { SkillHistorySection, SuggestFix } from "./skill-upkeep";
import { AssistVisitorNote } from "./visitor-note";
/**
@@ -287,9 +288,12 @@ function RecipeStatus({ skill }: { skill: Skill }) {
const recipe = useRecipe(skill.name, !!skill.recipe);
const actions = useRecipeActions();
const [busy, setBusy] = useState(false);
+ const canCheck = skill.source === "user";
+ // W6: a step that keeps failing, was replaced or is switched off gets Suggest a fix.
+ const fixes = useStepFixes(skill.name, !!skill.recipe && canCheck).data ?? [];
const v = recipe.data;
if (!skill.recipe || !v) return null;
- const recheck = Object.values(v.recheck).flat();
+ const recheck = [...Object.values(v.recheck).flat(), ...fixes.map((f) => f.why)];
const recheckNow = async () => {
setBusy(true);
try {
@@ -303,7 +307,6 @@ function RecipeStatus({ skill }: { skill: Skill }) {
setBusy(false);
}
};
- const canCheck = skill.source === "user";
return (
<div className={cn("mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-[12px]", recheck.length || v.why ? "text-amber-700 dark:text-amber-300" : "text-muted-foreground")}>
{recheck.length || v.why ? <AlertTriangle className="size-3.5 shrink-0" aria-hidden /> : <ShieldCheck className="size-3.5 shrink-0" aria-hidden />}
@@ -313,6 +316,7 @@ function RecipeStatus({ skill }: { skill: Skill }) {
{busy && <Loader2 className="animate-spin" />} {v.ready.length ? "Re-check" : "Check it (free)"}
</Button>
)}
+ {canCheck && <SuggestFix name={skill.name} fixes={fixes} />}
</div>
);
}
@@ -379,6 +383,7 @@ function SkillDetail({ name, owner, onClose, onEdit, onRun }: { name: string | n
</ul>
</div>
)}
+ {owner && s.source === "user" && s.recipe && <SkillHistorySection name={s.name} />}
</div>
<DialogFooter className="mx-0 mb-0 flex-row flex-wrap items-center gap-2 border-t px-5 py-3 sm:justify-between">
<div className="flex flex-wrap gap-1.5">
diff --git a/src/components/library-view.tsx b/src/components/library-view.tsx
index 4d3c2160..3a9526e2 100644
--- a/src/components/library-view.tsx
+++ b/src/components/library-view.tsx
@@ -16,6 +16,7 @@ import { PageShell } from "@/components/page-shell";
import { useShare } from "@/components/share/share-provider";
import { SharedLinks } from "@/components/share/shared-links";
import { useSkillBuilder } from "@/components/skills/skill-builder-provider";
+import { SkillSuggestionCard } from "@/components/skills/skill-suggestion";
import { downloadUrl, ForeverConfirmProvider, useConfirmForever } from "@/components/studio/result-actions";
import { useEdgeFade } from "@/components/studio/use-edge-fade";
import { Viewer } from "@/components/studio/viewer";
@@ -229,6 +230,8 @@ function Inner() {
const pathname = usePathname();
const tab = TABS.find((t) => t.id === sp.get("tab")) ?? TABS[0];
const folderId = sp.get("folder") ?? undefined;
+ // One run's results (a skill's History links here: /library?batch=<id>).
+ const batchId = sp.get("batch") ?? undefined;
const trash = tab.id === "trash";
const uploadsTab = tab.id === "uploads";
// A guest or an account sees its own runs only; an account with neither its own GPU nor its own key can't add files yet.
@@ -262,10 +265,11 @@ function Inner() {
// The Trash shows everything in it, helper steps too: deleting a Shorts session trashes its steps, and they can come back.
...(trash && { trashed: true, steps: true }),
...(folderId && !trash && (subtree ? { folderIds: subtree } : { folderId })),
+ ...(batchId && !trash && { batchId }),
...(dq && { q: dq }),
...filterFields(filters),
}),
- [tab, trash, folderId, subtree, dq, filters],
+ [tab, trash, folderId, subtree, batchId, dq, filters],
);
// Pinned results sit above the rest of the view (not in the Trash or Uploads); the Pinned filter shows only them.
const split = !trash && !uploadsTab && !sharedTab && !filters.pinned;
@@ -679,7 +683,17 @@ function Inner() {
{!uploadsTab && !sharedTab && !missingFolder && (
<div className="mb-4 flex flex-wrap items-center justify-between gap-2">
- <FilterBar value={filters} onChange={setFilters} facets={facets.data} subfolders={!!folder?.folders} scoped={!!folderId || tab.id !== "all" || !!dq} trash={trash} />
+ <div className="flex min-w-0 flex-wrap items-center gap-2">
+ {batchId && !trash && (
+ <span className="inline-flex h-8 items-center gap-1 rounded-full bg-muted pr-1 pl-3 text-[13px] font-medium">
+ One run
+ <button type="button" onClick={() => go({ batch: undefined })} aria-label="Show everything" className="inline-flex size-6 items-center justify-center rounded-full text-muted-foreground hover:bg-accent hover:text-foreground">
+ <X className="size-3.5" />
+ </button>
+ </span>
+ )}
+ <FilterBar value={filters} onChange={setFilters} facets={facets.data} subfolders={!!folder?.folders} scoped={!!folderId || !!batchId || tab.id !== "all" || !!dq} trash={trash} />
+ </div>
{trash && (
<div className="flex items-center gap-3 text-[13px] text-muted-foreground">
<span>Items stay here for {TRASH_DAYS} days.</span>
@@ -693,6 +707,9 @@ function Inner() {
</div>
)}
+ {/* A chain made often lately that no skill has yet: "Save it as a skill?" (the owner's, in All only). */}
+ {skillBuilder && tab.id === "all" && !folderId && !batchId && !dq && <SkillSuggestionCard onMake={(list) => skillBuilder.open(list)} />}
+
{sharedTab ? (
<SharedLinks />
) : missingFolder ? (
diff --git a/src/components/skills/skill-suggestion.tsx b/src/components/skills/skill-suggestion.tsx
new file mode 100644
index 00000000..63a79c8d
--- /dev/null
+++ b/src/components/skills/skill-suggestion.tsx
@@ -0,0 +1,48 @@
+"use client";
+
+import { Sparkles } from "lucide-react";
+import { useSkillSuggestions, useSuggestionActions } from "@/components/assist/hooks";
+import { Button } from "@/components/ui/button";
+import { shapeWords } from "@/lib/recipe";
+import { toastError } from "@/lib/refusals";
+
+/**
+ * The Library's "Save it as a skill?" card (Skills W6): a chain the owner made SUGGEST_RULE.runs times lately that no
+ * saved skill has. Make a skill opens the builder (W2) with the newest run's results; Not now puts it off for a week;
+ * Don't suggest this never shows it again. One card at a time, the most made first.
+ */
+export function SkillSuggestionCard({ onMake }: { onMake: (ids: string[]) => void }) {
+ const list = useSkillSuggestions(true);
+ const actions = useSuggestionActions();
+ const s = list.data?.[0];
+ if (!s) return null;
+ const dismiss = (action: "later" | "dismiss") => actions.dismiss(s.shape, action).catch((e) => toastError(e));
+ return (
+ <section aria-label="A skill to save" className="mb-4 flex w-full flex-col gap-3 rounded-xl border bg-card px-4 py-3 sm:flex-row sm:items-center">
+ <div className="flex min-w-0 flex-1 items-start gap-3">
+ <span className="mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-brand-faint text-brand-text" aria-hidden>
+ <Sparkles className="size-4" />
+ </span>
+ <div className="min-w-0">
+ <p className="text-[14px] leading-snug font-medium break-words">
+ You&apos;ve made &lsquo;{shapeWords(s.labels)}&rsquo; {s.count} times. Save it as a skill?
+ </p>
+ <p className="mt-0.5 text-[12px] text-muted-foreground">
+ {s.demo ? "Made with demo results so far. " : ""}A skill runs the same steps again with new inputs, priced before it starts.
+ </p>
+ </div>
+ </div>
+ <div className="flex shrink-0 flex-wrap items-center gap-1.5 sm:justify-end">
+ <Button size="sm" onClick={() => onMake(s.ids)}>
+ Make a skill
+ </Button>
+ <Button size="sm" variant="ghost" onClick={() => void dismiss("later")}>
+ Not now
+ </Button>
+ <Button size="sm" variant="ghost" className="text-muted-foreground" onClick={() => void dismiss("dismiss")}>
+ Don&apos;t suggest this
+ </Button>
+ </div>
+ </section>
+ );
+}
diff --git a/src/lib/library.ts b/src/lib/library.ts
index ab15012b..038c3ffe 100644
--- a/src/lib/library.ts
+++ b/src/lib/library.ts
@@ -17,6 +17,8 @@ export interface FeedFilter {
limit?: number;
models?: string[];
statuses?: GenerationStatus[];
+ /** One run's rows (a batch): a skill's History links to its run here. Shows its helper steps too, as the server does. */
+ batchId?: string;
/** createdAt range: since ≤ t < until. */
since?: number;
until?: number;
@@ -59,6 +61,7 @@ export function filterToSearch(f: FeedFilter, before?: string | number): URLSear
if (f.q?.trim()) qs.set("q", f.q.trim());
if (f.models?.length) qs.set("models", f.models.join(","));
if (f.statuses?.length) qs.set("statuses", f.statuses.join(","));
+ if (f.batchId) qs.set("batch", f.batchId);
if (f.since) qs.set("since", String(f.since));
if (f.until) qs.set("until", String(f.until));
if (f.folderId) qs.set("folder", f.folderId);
@@ -83,13 +86,14 @@ export function matchesFilter(g: Generation, f: FeedFilter): boolean {
if (f.favorites && !g.favorite) return false;
if (f.models?.length && !f.models.includes(g.modelId)) return false;
if (f.statuses?.length && !f.statuses.includes(g.status)) return false;
+ if (f.batchId && g.batchId !== f.batchId) return false;
if (f.since && g.createdAt < f.since) return false;
if (f.until && g.createdAt >= f.until) return false;
if (f.folderId && g.folderId !== f.folderId) return false;
if (f.folderIds?.length && !f.folderIds.includes(g.folderId ?? "")) return false;
if (f.pinned !== undefined && !!g.pinnedAt !== f.pinned) return false;
if (f.reviews?.length && !f.reviews.includes(g.review ?? "none")) return false;
- if (!f.steps && !f.features?.length && isHelperFeature(g.feature)) return false;
+ if (!f.steps && !f.features?.length && !f.batchId && isHelperFeature(g.feature)) return false;
const q = f.q?.trim().toLowerCase();
if (q && !`${g.prompt ?? ""}\n${g.request.prompt ?? ""}`.toLowerCase().includes(q)) return false;
return true;
diff --git a/src/server/recipes.ts b/src/server/recipes.ts
index 401bcb49..854be80c 100644
--- a/src/server/recipes.ts
+++ b/src/server/recipes.ts
@@ -1196,8 +1196,9 @@ function withModel(recipe: Recipe, key: string, modelId: string): Recipe {
...recipe,
steps: recipe.steps.map((s) => {
if (s.kind !== "generate" || s.key !== key) return s;
- const { engine: _engine, ...request } = s.request;
- return { ...s, request: { ...request, modelId } as typeof s.request };
+ const request: Record<string, unknown> = { ...s.request, modelId };
+ delete request.engine;
+ return { ...s, request: request as typeof s.request };
}),
};
}
diff --git a/tests/skill-suggest.test.ts b/tests/skill-suggest.test.ts
index 9368f4ed..7d4d0f2b 100644
--- a/tests/skill-suggest.test.ts
+++ b/tests/skill-suggest.test.ts
@@ -42,7 +42,7 @@ let n = 0;
/** One stored row, as the runner leaves a finished generation. */
function row(o: { request: Record<string, unknown>; after?: string[]; at: number; provider?: string; feature?: string; status?: string; batch?: string }): string {
const id = `g${++n}`.padEnd(12, "x");
- const req = { feature: o.feature ?? "image", ...o.request };
+ const req: Record<string, unknown> = { feature: o.feature ?? "image", ...o.request };
db()
.prepare(
`INSERT INTO generations (id, batch_id, feature, model_id, engine, provider, op, kind, status, request_json, outputs_json, created_at, updated_at, depends_on)
@@ -97,7 +97,7 @@ describe("shapeOf", () => {
{ key: "scene", kind: "generate" as const, after: ["cutout"], chain: [{ slot: "images" as const, position: "first" as const }], request: { feature: "skill", modelId: "nano-banana-pro", op: "edit" } },
],
};
- expect(shapeOfRecipe(recipe)!.key).toBe(shapeOf([node("x", "birefnet-cloud", "bg-remove"), node("y", "nano-banana-pro", "edit", ["x"])]).key);
+ expect(shapeOfRecipe(recipe as unknown as Parameters<typeof shapeOfRecipe>[0])!.key).toBe(shapeOf([node("x", "birefnet-cloud", "bg-remove"), node("y", "nano-banana-pro", "edit", ["x"])]).key);
expect(shapeOfRecipe({ steps: [{ key: "c", kind: "tool", tool: "add_captions", input: {} }] })).toBeNull();
});
});