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.

Image studios: Soul's 106 styles in the Moodboard chip, one style picker on Soul, no double styling on Reuse

Claude892ef3a32db6
diff --git a/src/components/fashion/character-sheet.tsx b/src/components/fashion/character-sheet.tsx
index b9742e2e..b60e5bca 100644
--- a/src/components/fashion/character-sheet.tsx
+++ b/src/components/fashion/character-sheet.tsx
@@ -166,10 +166,8 @@ export function CharacterSheetView({ fields, defaults }: { fields: CastFieldData
if (mode === "reference" && !photos.length) return toast("Upload at least 1 image");
if (!body) return toast(mode === "describe" ? "Describe your character first" : "Wait for the uploads to finish");
run.mutate(body, {
- onSuccess: (r) => {
- setIds((xs) => [...r.items.map((g) => g.id), ...xs]);
- r.notes?.forEach((n) => toast(n));
- },
+ // The run line already says which model runs and why (its notes), so no toast here.
+ onSuccess: (r) => setIds((xs) => [...r.items.map((g) => g.id), ...xs]),
onError: (e) => toast.error((e as Error).message || "Failed to create character sheet"),
});
};
diff --git a/src/components/moodboards/logic.ts b/src/components/moodboards/logic.ts
index 9ad51868..28d56012 100644
--- a/src/components/moodboards/logic.ts
+++ b/src/components/moodboards/logic.ts
@@ -3,6 +3,8 @@
* Higgsfield's limits and exact copy, the status a board shows while its cover job runs, which
* images best represent a board, and the 2×2 collages open-source style models take.
*/
+import { SOUL_CATEGORIES, SOUL_PRESETS, type SoulPresetModel } from "@/lib/catalog/higgsfield-presets.generated";
+import { getSoulPreset, hueOf } from "@/lib/catalog/packs";
import { kmeans, suggestName, type MoodboardPick, type MoodboardStatus, type RGB } from "@/lib/catalog/palettes";
import type { Engine, Generation } from "@/lib/catalog/types";
@@ -33,6 +35,38 @@ export interface CuratedMoodboard {
category: string;
description: string;
hue: number;
+ /** Soul's styles: every category the preset is in (Soul 2.0's looks have one). */
+ categories?: string[];
+ /** Whose preset: Soul 2.0's looks (the default) or Soul's styles. */
+ source?: SoulPresetModel;
+}
+
+/**
+ * Soul's 106 styles, the Moodboard panel's second curated set: `style_id` on Soul, the description
+ * as words on every other model (the open route's prompt template).
+ */
+export const SOUL_STYLES: CuratedMoodboard[] = SOUL_PRESETS.filter((p) => p.model === "soul-v1").map((p) => ({
+ id: p.id,
+ name: p.name,
+ category: p.categories[0] ?? "All presets",
+ categories: p.categories,
+ description: p.description,
+ hue: hueOf(p.id),
+ source: "soul-v1",
+}));
+
+/** The category pills of each curated set ("All presets" first). */
+export const CURATED_TABS: Record<SoulPresetModel, string[]> = {
+ "soul-v2": ["All presets", ...SOUL_CATEGORIES["soul-v2"]],
+ "soul-v1": ["All presets", ...SOUL_CATEGORIES["soul-v1"]],
+};
+
+export const inCuratedTab = (c: Pick<CuratedMoodboard, "category" | "categories">, tab: string) => tab === "All presets" || (c.categories ?? [c.category]).includes(tab);
+
+/** Any Soul preset (either model) as a curated pick, by Higgsfield's style id (a reused run's `style_id`). */
+export function soulPick(id: string): MoodboardPick | undefined {
+ const p = getSoulPreset(id);
+ return p && { id: p.id, kind: "curated", name: p.name, description: p.description, status: "complete", ...(p.model === "soul-v1" && { source: p.model }) };
}
export const MOODBOARD_LIMITS = { min: 5, max: 80, minPx: 256, nameMax: 100, refs: 10, collages: 2 } as const;
@@ -179,5 +213,5 @@ export function toPick(m: Moodboard): MoodboardPick {
}
export function curatedPick(c: CuratedMoodboard): MoodboardPick {
- return { id: c.id, kind: "curated", name: c.name, description: c.description, status: "complete" };
+ return { id: c.id, kind: "curated", name: c.name, description: c.description, status: "complete", ...(c.source === "soul-v1" && { source: c.source }) };
}
diff --git a/src/components/moodboards/moodboard-panel.tsx b/src/components/moodboards/moodboard-panel.tsx
index c4501b0a..d7c6c432 100644
--- a/src/components/moodboards/moodboard-panel.tsx
+++ b/src/components/moodboards/moodboard-panel.tsx
@@ -3,6 +3,7 @@
import { Plus, Search } from "lucide-react";
import Link from "next/link";
import { useMemo, useState } from "react";
+import { radioKeys, radioTab } from "@/components/studio/radio-keys";
import { Skeleton } from "@/components/ui/skeleton";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import type { MoodboardPick } from "@/lib/catalog/palettes";
@@ -10,22 +11,34 @@ import { cn } from "@/lib/utils";
import { BoardCover, CuratedCover, StatusBadge } from "./cards";
import { CreateMoodboardDialog } from "./create-moodboard";
import { useMoodboards } from "./hooks";
-import { COPY, curatedPick, toPick } from "./logic";
+import { COPY, CURATED_TABS, curatedPick, inCuratedTab, SOUL_STYLES, toPick } from "./logic";
-const CURATED_TABS = ["All presets", "Mood", "Styles", "Camera"];
+const SETS = [
+ ["soul-v2", "Soul 2.0"],
+ ["soul-v1", "Soul"],
+] as const;
+type CuratedSet = (typeof SETS)[number][0];
-/** The composer's Moodboard panel: Curated (Soul 2.0's looks) and My moodboards, search, Create moodboard. */
-export function MoodboardPanel({ value, onPick }: { value?: MoodboardPick; onPick: (m?: MoodboardPick) => void }) {
+/**
+ * The composer's Moodboard panel: Curated (Soul 2.0's 33 looks, and Soul's 106 styles) and My
+ * moodboards, search, Create moodboard. It opens on Soul's styles when Soul is the model.
+ */
+export function MoodboardPanel({ value, onPick, modelId }: { value?: MoodboardPick; onPick: (m?: MoodboardPick) => void; modelId?: string }) {
const { data, isLoading } = useMoodboards();
const [tab, setTab] = useState<"curated" | "mine">(value?.kind === "personal" ? "mine" : "curated");
+ const [set, setSet] = useState<CuratedSet>(value?.kind === "curated" ? (value.source ?? "soul-v2") : modelId === "soul-1" ? "soul-v1" : "soul-v2");
const [cat, setCat] = useState("All presets");
const [q, setQ] = useState("");
const [creating, setCreating] = useState(false);
const needle = q.trim().toLowerCase();
const curated = useMemo(
- () => (data?.curated ?? []).filter((c) => (needle ? `${c.name} ${c.description}`.toLowerCase().includes(needle) : cat === "All presets" || c.category === cat)),
- [data, needle, cat],
+ () =>
+ (set === "soul-v1" ? SOUL_STYLES : (data?.curated ?? [])).filter((c) =>
+ needle ? `${c.name} ${c.description}`.toLowerCase().includes(needle) : inCuratedTab(c, cat),
+ ),
+ [data, needle, cat, set],
);
+ const loadingCurated = isLoading && set === "soul-v2";
const mine = useMemo(() => (data?.items ?? []).filter((m) => !needle || m.name.toLowerCase().includes(needle)), [data, needle]);
const card = "group block w-full min-w-0 rounded-lg text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/50";
@@ -65,30 +78,47 @@ export function MoodboardPanel({ value, onPick }: { value?: MoodboardPick; onPic
{tab === "curated" ? (
<>
- {!needle && (
- <div className="scrollbar-none flex gap-1 overflow-x-auto">
- {CURATED_TABS.map((c) => (
+ <div className="flex min-w-0 items-center gap-2">
+ <div role="radiogroup" aria-label="Curated set" onKeyDown={radioKeys} className="inline-flex shrink-0 rounded-full border p-0.5">
+ {SETS.map(([id, label]) => (
<button
- key={c}
+ key={id}
type="button"
- aria-pressed={cat === c}
- onClick={() => setCat(c)}
- className={cn("h-7 shrink-0 rounded-full px-2.5 text-[12px] font-medium transition-colors", cat === c ? "bg-brand-faint text-brand-text" : "text-muted-foreground hover:bg-accent")}
+ role="radio"
+ aria-checked={set === id}
+ tabIndex={radioTab(set === id)}
+ onClick={() => (setSet(id), setCat("All presets"))}
+ className={cn("h-6 rounded-full px-2.5 text-[11.5px] font-medium text-muted-foreground transition", set === id && "bg-secondary text-foreground")}
>
- {c}
+ {label}
</button>
))}
</div>
- )}
+ {!needle && (
+ <div className="scrollbar-none flex min-w-0 flex-1 gap-1 overflow-x-auto">
+ {CURATED_TABS[set].map((c) => (
+ <button
+ key={c}
+ type="button"
+ aria-pressed={cat === c}
+ onClick={() => setCat(c)}
+ className={cn("h-7 shrink-0 rounded-full px-2.5 text-[12px] font-medium transition-colors", cat === c ? "bg-brand-faint text-brand-text" : "text-muted-foreground hover:bg-accent")}
+ >
+ {c}
+ </button>
+ ))}
+ </div>
+ )}
+ </div>
<div className="grid max-h-[46svh] grid-cols-3 gap-1.5 overflow-y-auto sm:max-h-[320px]">
- {isLoading
+ {loadingCurated
? Array.from({ length: 6 }, (_, i) => <Skeleton key={i} className="aspect-[3/4]" />)
: curated.map((c) => (
<button key={c.id} type="button" title={c.description} aria-pressed={value?.id === c.id} onClick={() => onPick(value?.id === c.id ? undefined : curatedPick(c))} className={card}>
<CuratedCover m={c} className={cn("aspect-[3/4] rounded-lg ring-offset-2 ring-offset-background", value?.id === c.id && "ring-2 ring-primary")} />
</button>
))}
- {!isLoading && !curated.length && <p className="col-span-3 py-6 text-center text-[13px] text-muted-foreground">No presets match “{q}”</p>}
+ {!loadingCurated && !curated.length && <p className="col-span-3 py-6 text-center text-[13px] text-muted-foreground">No presets match “{q}”</p>}
</div>
</>
) : (
@@ -131,7 +161,7 @@ export function MoodboardPanel({ value, onPick }: { value?: MoodboardPick; onPic
</div>
)}
<p className="text-[11.5px] text-muted-foreground">
- Soul 2.0 takes curated looks natively; other models get the look in words or your board&apos;s images as style references.{" "}
+ Soul and Soul 2.0 take their own presets natively; other models get the look in words, or your board&apos;s images as style references.{" "}
<Link href="/moodboards" className="text-brand-text hover:underline">
Manage moodboards
</Link>
diff --git a/src/components/palettes/signature-chips.tsx b/src/components/palettes/signature-chips.tsx
index aa0db74b..b6e6e169 100644
--- a/src/components/palettes/signature-chips.tsx
+++ b/src/components/palettes/signature-chips.tsx
@@ -7,9 +7,9 @@ import { Chip, ClearableChip } from "@/components/studio/chip";
import { ResponsivePanel } from "@/components/studio/responsive-panel";
import { CuratedCover } from "@/components/moodboards/cards";
import { useMoodboards } from "@/components/moodboards/hooks";
-import { curatedPick, toPick } from "@/components/moodboards/logic";
+import { curatedPick, soulPick, toPick } from "@/components/moodboards/logic";
import { MoodboardPanel } from "@/components/moodboards/moodboard-panel";
-import { cardStrip, type Signature } from "@/lib/catalog/palettes";
+import { cardStrip, type MoodboardPick, type Signature } from "@/lib/catalog/palettes";
import { hueOf } from "@/lib/catalog/packs";
import type { Engine } from "@/lib/catalog/types";
import { ColorSignaturePanel, toPalettePick } from "./color-signature-panel";
@@ -32,7 +32,7 @@ function UrlSignature({ onChange }: { onChange: (update: (s: Signature | undefin
done.current.mb = true;
const curated = boards.data.curated.find((c) => c.id === mb.replace(/^curated:/, ""));
const mine = boards.data.items.find((m) => m.id === mb);
- const pick = mine ? toPick(mine) : curated ? curatedPick(curated) : undefined;
+ const pick = mine ? toPick(mine) : curated ? curatedPick(curated) : mb.startsWith("curated:") ? soulPick(mb.slice(8)) : undefined;
if (pick) onChange((s) => ({ ...s, moodboard: pick }));
}
}, [mb, boards.data, onChange]);
@@ -54,15 +54,31 @@ export default function SignatureChips({
value,
onChange,
engine,
+ modelId,
+ styleId,
+ onStyleIdTaken,
}: {
value: Signature | undefined;
onChange: (update: (s: Signature | undefined) => Signature) => void;
engine: Engine;
+ /** The composer's model (the Moodboard panel opens on Soul's styles for Soul). */
+ modelId?: string;
+ /** A Soul `style_id` in the draft's settings (a reused Soul run): shown and kept as the Moodboard pick. */
+ styleId?: string;
+ onStyleIdTaken?: () => void;
}) {
const [colorOpen, setColorOpen] = useState(false);
const [boardOpen, setBoardOpen] = useState(false);
const pal = value?.palette;
const mb = value?.moodboard;
+ // Soul's style picker is this chip: a style id restored by Reuse becomes the curated pick (a picked moodboard wins).
+ useEffect(() => {
+ if (!styleId) return;
+ // A live Higgsfield style the built-in list doesn't know still shows (and clears) as one.
+ const pick: MoodboardPick = soulPick(styleId) ?? { id: styleId, kind: "curated", name: "Soul style", status: "complete", ...(modelId === "soul-1" && { source: "soul-v1" as const }) };
+ onChange((s) => (s?.moodboard ? { ...s } : { ...s, moodboard: pick }));
+ onStyleIdTaken?.();
+ }, [styleId, modelId, onChange, onStyleIdTaken]);
return (
<>
<Suspense fallback={null}>
@@ -115,6 +131,7 @@ export default function SignatureChips({
>
<MoodboardPanel
value={mb}
+ modelId={modelId}
onPick={(m) => {
onChange((s) => ({ ...s, moodboard: m }));
setBoardOpen(false);
diff --git a/src/components/photodump/photodump-view.tsx b/src/components/photodump/photodump-view.tsx
index 7ee19019..6784e0de 100644
--- a/src/components/photodump/photodump-view.tsx
+++ b/src/components/photodump/photodump-view.tsx
@@ -93,8 +93,8 @@ function CreatePack({ open, onOpenChange, onCreated }: { open: boolean; onOpenCh
create.mutate(
{ name: name.trim(), refs: refs.map((r) => r.ref).filter(Boolean) },
{
+ // The new pack shows up selected under My packs: no toast needed.
onSuccess: (p) => {
- toast.success("Pack created");
setName("");
setRefs([]);
onOpenChange(false);
@@ -182,9 +182,9 @@ export function PhotodumpView() {
const generate = () => {
if (!body) return toast(subjectMode === "selfie" ? "Add your photo first" : "Pick a character first");
run.mutate(body, {
+ // The run line showed the model and its notes before Generate: no toast.
onSuccess: (res) => {
setBatchId(res.batchId ?? res.items[0]?.batchId ?? undefined);
- res.notes?.forEach((n) => toast(n));
go(2);
},
onError: (e) => toast.error((e as Error).message || "Cannot start photodump generation, please try again"),
diff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsx
index 4fec1ec3..18882b8d 100644
--- a/src/components/studio/composer.tsx
+++ b/src/components/studio/composer.tsx
@@ -301,6 +301,8 @@ export function Composer({ docked }: { docked: boolean }) {
else extra[key] = v;
return { params: { ...d.params, extra: Object.keys(extra).length ? extra : undefined } };
});
+ // Studios with the Moodboard chip pick Soul's styles there (its Curated tab), not in a second Style chip.
+ const soulStyles = !!config.signature && (opts.presets?.source === "soul-v1" || opts.presets?.source === "soul-v2");
const opNote = op && model ? routesFor(model, op)[0]?.note : undefined;
const showPrompt = !config.hidePrompt && preset?.userPrompt !== "none" && !opts.promptless;
const effectiveOp = studioOp ?? op;
@@ -370,8 +372,17 @@ export function Composer({ docked }: { docked: boolean }) {
onMix={(patch) => setDraft(patch)}
/>
)}
- {config.signature && <SignatureChips value={draft.signature} onChange={(update) => setDraft((d) => ({ signature: update(d.signature) }))} engine={engine} />}
- {opts.presets && <ProviderPresetChip spec={opts.presets} value={p.extra?.[opts.presets.param] as string | undefined} onChange={(id) => setExtra(opts.presets!.param, id)} />}
+ {config.signature && (
+ <SignatureChips
+ value={draft.signature}
+ onChange={(update) => setDraft((d) => ({ signature: update(d.signature) }))}
+ engine={engine}
+ modelId={draft.modelId}
+ styleId={soulStyles ? (p.extra?.[opts.presets!.param] as string | undefined) : undefined}
+ onStyleIdTaken={() => setExtra(opts.presets!.param, undefined)}
+ />
+ )}
+ {opts.presets && !soulStyles && <ProviderPresetChip spec={opts.presets} value={p.extra?.[opts.presets.param] as string | undefined} onChange={(id) => setExtra(opts.presets!.param, id)} />}
{opts.controls && <ControlsChip controls={opts.controls} values={p.extra ?? {}} onChange={setExtra} />}
</>
);
diff --git a/src/lib/catalog/palettes.ts b/src/lib/catalog/palettes.ts
index fb388819..fe7dc785 100644
--- a/src/lib/catalog/palettes.ts
+++ b/src/lib/catalog/palettes.ts
@@ -12,7 +12,8 @@
* palette's slug as `color_palette`; every other model: the hex list written into the prompt. Open
* engine: Z-Image Turbo becomes Z-Image Turbo · Palette (hex in the prompt + a ColorTransfer lock to
* a swatch); other open models can add a palette-transfer post-step (oss-palette-image, chained).
- * - Moodboard → curated: Soul 2.0's `style_id` on soul-2, the preset's description as words elsewhere.
+ * - Moodboard → curated: the Soul preset's `style_id` on its own model (Soul 2.0's 33 looks on soul-2,
+ * Soul's 106 styles on soul-1), its description as words on every other model (the open route).
* Personal: cloud = the board's Recraft style id (Recraft models) or its most representative images
* as style references (Nano Banana Pro and other multi-reference models); open = the board's collages
* on Qwen-Image-Edit Style Reference (or the style-reference model picked), or its trained style LoRA
@@ -311,6 +312,8 @@ export interface MoodboardPick {
kind: "curated" | "personal";
name: string;
description?: string;
+ /** Curated: whose preset it is — Soul 2.0's looks (the default) or Soul's styles ("soul-v1"). */
+ source?: "soul-v1" | "soul-v2";
status: MoodboardStatus;
cover?: string | null;
/** Personal: the most representative images, best first (≤10). */
@@ -360,6 +363,7 @@ export const SIGNATURE_MODELS = {
openTurbo: "oss-z-image-turbo",
paletteLock: "oss-palette-image",
soul2: "soul-2",
+ soul1: "soul-1",
cinema: "cinema-studio-4",
} as const;
@@ -369,7 +373,12 @@ const hasOp = (m: ModelDef, op: string) => m.routes.some((r) => r.op === op);
/** Room for style references beyond the user's own images (multi-reference edit models; a one-image edit would just edit the reference). */
const refBudget = (m: ModelDef, existing: number) => (hasOp(m, "edit") && (m.options.maxImages ?? 1) >= 2 ? Math.max(0, (m.options.maxImages ?? 1) - existing) : 0);
const tidy = (s: string | undefined) => (s ?? "").trim().replace(/[.\s]+$/, "");
-const join = (prompt: string | undefined, sentence: string) => (tidy(prompt) ? `${tidy(prompt)}. ${sentence}` : sentence);
+/** The prompt with a sentence added once (a reused run already carries it). */
+const join = (prompt: string | undefined, sentence: string) => {
+ const p = tidy(prompt);
+ if (!p) return sentence;
+ return p.includes(tidy(sentence)) ? (prompt ?? "") : `${p}. ${sentence}`;
+};
/** "In the style of “Retro BW”: grainy black-and-white film portrait." */
export function styleWords(m: Pick<MoodboardPick, "name" | "description">): string {
@@ -422,17 +431,22 @@ export function applySignature(req: GenerationRequest, sig: Signature | undefine
if (mb) {
if (mb.kind === "personal" && mb.status !== "complete") return { request: req, modelId: req.modelId, notes: [], blocker: mb.status === "failed" ? "This moodboard failed to build — retry it on the Moodboards page" : NOT_READY };
if (mb.kind === "curated") {
- if (model.id === SIGNATURE_MODELS.soul2) r = setExtra(r, "style_id", mb.id);
+ const soul1 = mb.source === "soul-v1";
+ if (model.id === (soul1 ? SIGNATURE_MODELS.soul1 : SIGNATURE_MODELS.soul2)) r = setExtra(r, "style_id", mb.id);
else {
r = { ...r, prompt: join(r.prompt, styleWords(mb)) };
- notes.push(`${mb.name} is a Soul 2.0 preset — described in words on ${model.name}`);
+ notes.push(`${mb.name} is a ${soul1 ? "Soul" : "Soul 2.0"} preset — described in words on ${model.name}`);
}
styled = true;
} else {
const existing = r.inputs?.images?.length ?? 0;
const refs = mb.refs ?? [];
const collages = mb.collages?.length ? mb.collages : refs.slice(0, 2);
- if (model.engine === "cloud") {
+ // A reused run already carries the board's images and their legend: nothing to add.
+ const carried = [...refs, ...collages].some((u) => r.inputs?.images?.includes(u));
+ if (carried) {
+ // Leave the request as it is.
+ } else if (model.engine === "cloud") {
if (model.family === "recraft" && mb.styleId) {
move(SIGNATURE_MODELS.recraftSaved, `Runs on {model} with the saved “${mb.name}” Recraft style`);
r = { ...r, params: { ...r.params, styleId: mb.styleId } };
@@ -484,7 +498,10 @@ export function applySignature(req: GenerationRequest, sig: Signature | undefine
r = setExtra(r, "color_palette", pal.slug);
} else {
r = { ...r, prompt: join(r.prompt, palettePrompt(pal)), params: { ...r.params, palette: all.slice(0, 16) } };
- if (model.engine === "open" && pal.lock) lock = { colors: all };
+ if (model.engine === "open" && pal.lock) {
+ lock = { colors: all };
+ notes.push(`Then recoloured to “${pal.name}” by a palette-transfer step`);
+ }
}
}
return { request: r, modelId: model.id, notes, ...(lock && { lock }) };
diff --git a/src/server/moodboards.ts b/src/server/moodboards.ts
index a8c56433..dc22166e 100644
--- a/src/server/moodboards.ts
+++ b/src/server/moodboards.ts
@@ -1,13 +1,14 @@
import "server-only";
import { nanoid } from "nanoid";
import { CURATED_MOODBOARDS, hueOf } from "@/lib/catalog/packs";
+import { getTrainingTarget } from "@/lib/catalog/training";
import type { Engine, Generation } from "@/lib/catalog/types";
import { COVER_PROMPT, MOODBOARD_LIMITS, moodboardStatus, moodboardError, type Moodboard } from "@/components/moodboards/logic";
import { db } from "./db";
import { createElement, getElement } from "./elements";
import { createGenerations, getGeneration } from "./generations";
import { engineMode } from "./settings";
-import { startTraining } from "./training";
+import { startTraining, trainingBlocker } from "./training";
/**
* Moodboards (Soul 2.0's "presets evolved"): a named set of 5–80 reference images in one style.
@@ -180,6 +181,9 @@ export function deleteMoodboard(id: string): boolean {
return db().prepare("DELETE FROM moodboards WHERE id = ?").run(id).changes > 0;
}
+/** A board's persistent open-source style: a Z-Image Turbo LoRA trained on AI-Toolkit. */
+const STYLE_TARGET = "aitk-z-image";
+
/**
* Train a persistent open-source style: a style element with the board's 20 most representative
* images, trained as a Z-Image Turbo LoRA on AI-Toolkit (the same path as character LoRAs).
@@ -188,15 +192,15 @@ export function trainMoodboard(id: string): Moodboard {
const m = getMoodboard(id);
if (!m) throw new Error("Moodboard not found");
if (m.status !== "complete") throw new Error("This moodboard is still training. Try again once it is ready.");
+ // Say what's missing (an AI-Toolkit URL) before making the style element, so a refusal leaves nothing behind.
+ const target = getTrainingTarget(STYLE_TARGET);
+ const blocker = target && trainingBlocker(target);
+ if (blocker) throw new Error(blocker);
let el = m.lora ? getElement(m.lora.elementId) : null;
if (!el) {
el = createElement({ name: m.name.slice(0, 60), kind: "style", description: `the visual style of the “${m.name}” moodboard`, references: m.images.slice(0, 20) });
update(id, { element_id: el.id });
}
- try {
- startTraining(el.id, "aitk-z-image");
- } catch (e) {
- throw new Error((e as Error).message);
- }
+ startTraining(el.id, STYLE_TARGET);
return getMoodboard(id)!;
}
diff --git a/tests/image-studios-api.test.ts b/tests/image-studios-api.test.ts
index dccd59b7..ba940388 100644
--- a/tests/image-studios-api.test.ts
+++ b/tests/image-studios-api.test.ts
@@ -129,6 +129,9 @@ describe("moodboards", () => {
expect(list.items.map((x) => x.id)).toContain(m.id);
expect(list.curated).toHaveLength(33);
expect(new Set(list.curated.map((c) => c.category))).toEqual(new Set(["All presets", "Mood", "Styles", "Camera"]));
+ // A style LoRA needs AI-Toolkit: without its URL the board says where to set it up and makes no element.
+ expect(() => moodboards.trainMoodboard(m.id)).toThrow(/AI-Toolkit URL/);
+ expect(moodboards.getMoodboard(m.id)!.lora).toBeNull();
}, 45_000);
it("prepares cloud boards on Recraft V4 Styles with the 10 most representative images", () => {
diff --git a/tests/image-studios.test.ts b/tests/image-studios.test.ts
index 2367d346..8de50b0e 100644
--- a/tests/image-studios.test.ts
+++ b/tests/image-studios.test.ts
@@ -52,7 +52,20 @@ import { planGeneration } from "@/lib/catalog/plan";
import type { GenerationRequest } from "@/lib/catalog/types";
import { studioCatalog } from "@/lib/studio-catalog";
import { IMAGE_STUDIO } from "@/lib/studios";
-import { collageGroups, colorFeature, coverCrop, imageProblem, moodboardError, moodboardStatus, representativeOrder } from "@/components/moodboards/logic";
+import {
+ collageGroups,
+ colorFeature,
+ coverCrop,
+ CURATED_TABS,
+ curatedPick,
+ imageProblem,
+ inCuratedTab,
+ moodboardError,
+ moodboardStatus,
+ representativeOrder,
+ SOUL_STYLES,
+ soulPick,
+} from "@/components/moodboards/logic";
// The caps GET /api/palettes sends (src/server/palettes.ts signatureCaps, checked against the catalog in image-studios-api.test.ts).
const CAPS: SignatureCaps = {
@@ -184,6 +197,7 @@ describe("palettes: routing per model", () => {
expect(free.request.prompt).toMatch(/Color palette/);
const locked = applySignature(req("oss-qwen-image"), { palette: { ...PAL, lock: true } }, ctx);
expect(locked.lock?.colors).toEqual([...PAL.colors, "#264653"]);
+ expect(locked.notes).toEqual(["Then recoloured to “Teal Dusk” by a palette-transfer step"]);
});
it("leaves requests alone without a signature or an unknown model", () => {
@@ -250,6 +264,38 @@ describe("moodboards: routing per model", () => {
expect(lora.request.prompt).toBe("a rooftop party. In the style of @Neon_Haze.");
});
+ it("Soul's 106 styles are curated picks too: style_id on soul-1, words on Soul 2.0 and everything else", () => {
+ expect(SOUL_STYLES).toHaveLength(106);
+ expect(CURATED_TABS["soul-v1"]).toEqual(["All presets", "New", "TikTok Core", "Instagram Aesthetics", "Camera Presets", "Beauty", "Mood", "Surreal", "Graphic Art"]);
+ // Soul's presets sit in several categories at once.
+ const sunset = SOUL_STYLES.find((s) => s.name === "Sunset beach")!;
+ expect(["New", "Camera Presets", "Beauty"].every((c) => inCuratedTab(sunset, c))).toBe(true);
+ const pick = curatedPick(sunset);
+ expect(pick.source).toBe("soul-v1");
+ expect(soulPick(sunset.id)).toEqual(pick);
+ expect(soulPick(CURATED_MOODBOARDS[0].id)?.source).toBeUndefined();
+ expect(soulPick("not-a-preset")).toBeUndefined();
+
+ const soul1 = applySignature(req("soul-1"), { moodboard: pick }, ctx);
+ expect(soul1.request.params?.extra?.style_id).toBe(sunset.id);
+ expect(soul1.notes).toEqual([]);
+ const soul2 = applySignature(req("soul-2"), { moodboard: pick }, ctx);
+ expect(soul2.request.params?.extra?.style_id).toBeUndefined();
+ expect(soul2.notes[0]).toBe("Sunset beach is a Soul preset — described in words on Higgsfield Soul 2.0");
+ const turbo = applySignature(req("oss-z-image-turbo"), { moodboard: pick }, ctx);
+ expect(turbo.request.prompt).toBe(presetPrompt(sunset, "a rooftop party"));
+ });
+
+ it("a reused run isn't styled twice (Reuse keeps the composer's chips)", () => {
+ const once = applySignature(req("oss-z-image-turbo"), { moodboard: curated, palette: PAL }, ctx);
+ const twice = applySignature({ ...req(once.modelId), prompt: once.request.prompt, inputs: once.request.inputs }, { moodboard: curated, palette: PAL }, ctx);
+ expect(twice.request.prompt).toBe(once.request.prompt);
+ const nano = applySignature(req("nano-banana-pro"), { moodboard: board }, ctx);
+ const again = applySignature({ ...nano.request, op: undefined }, { moodboard: board }, ctx);
+ expect(again.request.inputs?.images).toEqual(nano.request.inputs?.images);
+ expect(again.request.prompt).toBe(nano.request.prompt);
+ });
+
it("a board that isn't ready blocks with Higgsfield's copy; palette + moodboard combine", () => {
expect(applySignature(req("nano-banana-pro"), { moodboard: { ...board, status: "running" } }, ctx).blocker).toBe("This moodboard is still training. Try again once it is ready.");
const both = applySignature(req("oss-z-image-turbo"), { moodboard: board, palette: PAL }, ctx);