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 studio signature: user's words stay in the prompt, Reuse restores the chips, Soul routed by preset list

Claude8906c0d3cc8f
diff --git a/src/app/api/generations/route.ts b/src/app/api/generations/route.ts
index 52380ddd..56d6a485 100644
--- a/src/app/api/generations/route.ts
+++ b/src/app/api/generations/route.ts
@@ -2,6 +2,7 @@ import { connection } from "next/server";
import { z } from "zod";
import { createGenerations, listGenerations } from "@/server/generations";
import { ensureTrashPurge, listOptionsFrom } from "@/server/library";
+import { SignatureSchema } from "@/server/palettes";
const RequestSchema = z.object({
feature: z.string().min(1),
@@ -55,6 +56,8 @@ const RequestSchema = z.object({
presetOptions: z.record(z.string(), z.string()).optional(),
presetStrength: z.number().min(0).max(1).optional(),
mix: z.object({ presetId: z.string().max(120), strength: z.number().min(0).max(1) }).optional(),
+ // Image studio: the Color signature / Moodboard picks (its sentences join the prompt on the server).
+ signature: SignatureSchema,
});
/**
diff --git a/src/app/api/palettes/lock/route.ts b/src/app/api/palettes/lock/route.ts
index 4f6a31b4..888e8e55 100644
--- a/src/app/api/palettes/lock/route.ts
+++ b/src/app/api/palettes/lock/route.ts
@@ -1,5 +1,5 @@
import { z } from "zod";
-import { createLockedRun } from "@/server/palettes";
+import { createLockedRun, SignatureSchema } from "@/server/palettes";
const Hex = z.string().regex(/^#?[0-9a-fA-F]{6}$/);
@@ -24,6 +24,7 @@ const RequestSchema = z.object({
extra: z.record(z.string(), z.unknown()).optional(),
})
.optional(),
+ signature: SignatureSchema,
});
const Body = z.object({ request: RequestSchema, colors: z.array(Hex).min(1).max(16), strength: z.number().min(0).max(1).optional() });
diff --git a/src/components/moodboards/moodboard-panel.tsx b/src/components/moodboards/moodboard-panel.tsx
index ba8507c6..28a50eda 100644
--- a/src/components/moodboards/moodboard-panel.tsx
+++ b/src/components/moodboards/moodboard-panel.tsx
@@ -21,12 +21,12 @@ type CuratedSet = (typeof SETS)[number][0];
/**
* 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.
+ * moodboards, search, Create moodboard. It opens on the model's own preset list (Soul's styles on Soul).
*/
-export function MoodboardPanel({ value, onPick, modelId }: { value?: MoodboardPick; onPick: (m?: MoodboardPick) => void; modelId?: string }) {
+export function MoodboardPanel({ value, onPick, presetSource }: { value?: MoodboardPick; onPick: (m?: MoodboardPick) => void; presetSource?: 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 [set, setSet] = useState<CuratedSet>(value?.kind === "curated" ? (value.source ?? "soul-v2") : presetSource === "soul-v1" ? "soul-v1" : "soul-v2");
const [cat, setCat] = useState("All presets");
const [q, setQ] = useState("");
const [creating, setCreating] = useState(false);
diff --git a/src/components/moodboards/moodboards-view.tsx b/src/components/moodboards/moodboards-view.tsx
index 916b9d4f..637f488f 100644
--- a/src/components/moodboards/moodboards-view.tsx
+++ b/src/components/moodboards/moodboards-view.tsx
@@ -3,7 +3,7 @@
import { GraduationCap, Images, MoreHorizontal, Pencil, Plus, RotateCcw, Search, Trash2, Wand2 } from "lucide-react";
import Link from "next/link";
import { useRouter, useSearchParams } from "next/navigation";
-import { Suspense, useEffect, useMemo, useState } from "react";
+import { Suspense, useEffect, useMemo, useRef, useState } from "react";
import { toast } from "sonner";
import { PageHeader, PageShell } from "@/components/page-shell";
import {
@@ -22,20 +22,30 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSepara
import { Input } from "@/components/ui/input";
import { Skeleton } from "@/components/ui/skeleton";
import { EngineSwitch } from "@/components/studio/engine-switch";
-import { useEngine } from "@/lib/api";
+import { useEngine, useStatus } from "@/lib/api";
import { cn } from "@/lib/utils";
import { BoardCover, CuratedCover, StatusBadge } from "./cards";
import { CreateMoodboardDialog } from "./create-moodboard";
import { useCuratedSet, useMoodboardActions, useMoodboards } from "./hooks";
import { COPY, CURATED_TABS, inCuratedTab, MOODBOARD_LIMITS, type Moodboard } from "./logic";
-/** ?create=1 opens the Create dialog (links from the Image studio and Home). */
+/**
+ * ?create=1 opens the Create dialog once (links from the Image studio and Home); the parameter is
+ * dropped from the address, so closing the dialog keeps it closed and a reload doesn't reopen it.
+ */
function CreateFromUrl({ onOpen }: { onOpen: () => void }) {
const sp = useSearchParams();
+ const router = useRouter();
const create = sp.get("create");
+ const open = useRef(onOpen);
+ useEffect(() => {
+ open.current = onOpen;
+ });
useEffect(() => {
- if (create) onOpen();
- }, [create, onOpen]);
+ if (!create) return;
+ open.current();
+ router.replace("/moodboards", { scroll: false });
+ }, [create, router]);
return null;
}
@@ -139,7 +149,7 @@ function BoardCard({ m, onRename, onDelete }: { m: Moodboard; onRename: () => vo
export function MoodboardsView() {
const { data, isLoading } = useMoodboards();
const { rename, remove } = useMoodboardActions();
- const [engine, setEngine] = useEngine();
+ const [engine, setEngine, mode] = useEngine();
const [tab, setTab] = useState<"mine" | "curated">("mine");
const [cat, setCat] = useState("All presets");
const [q, setQ] = useState("");
@@ -150,6 +160,9 @@ export function MoodboardsView() {
const needle = q.trim().toLowerCase();
const mine = useMemo(() => (data?.items ?? []).filter((m) => !needle || m.name.toLowerCase().includes(needle)), [data, needle]);
const looks = useCuratedSet("soul-v2", tab === "curated");
+ // Curated looks are Soul 2.0 presets: with Higgsfield connected (cloud), they open on Soul 2.0 itself.
+ const status = useStatus();
+ const onSoul = engine === "cloud" && mode !== "open" && !!status.data?.providers.higgsfield?.configured;
const curated = useMemo(
() => looks.filter((c) => (needle ? `${c.name} ${c.description}`.toLowerCase().includes(needle) : inCuratedTab(c, cat))),
[looks, needle, cat],
@@ -253,7 +266,7 @@ export function MoodboardsView() {
{curated.map((c) => (
<Link
key={c.id}
- href={`/image?moodboard=curated:${c.id}`}
+ href={`/image?${onSoul ? "model=soul-2&" : ""}moodboard=curated:${c.id}`}
aria-label={`Use ${c.name} in the Image studio${c.description ? ` — ${c.description}` : ""}`}
className="group/cur min-w-0 rounded-xl outline-none focus-visible:ring-2 focus-visible:ring-ring/50"
>
@@ -265,7 +278,7 @@ export function MoodboardsView() {
</div>
{!curated.length && <p className="py-16 text-center text-[14px] text-muted-foreground">No presets match “{q}”</p>}
<p className="mt-6 text-[12.5px] text-muted-foreground">
- Curated looks are Soul 2.0 presets: Higgsfield Soul 2.0 takes them as its style; other models, including the open-source ones, get each look as a prompt.
+ Curated looks are Soul 2.0 presets: Higgsfield Soul 2.0 takes them as its style{onSoul ? " (they open on Soul 2.0)" : ""}; other models, including the open-source ones, get each look as a prompt.
</p>
</>
)}
diff --git a/src/components/palettes/palette-editor.tsx b/src/components/palettes/palette-editor.tsx
index 13775228..ffc8bc8c 100644
--- a/src/components/palettes/palette-editor.tsx
+++ b/src/components/palettes/palette-editor.tsx
@@ -5,7 +5,7 @@ import { useState } from "react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
-import { MANUAL_DEFAULT, MAX_COLORS, MAX_COLORS_RECRAFT, NAME_MAX, paletteError, randomPalettes, suggestName } from "@/lib/catalog/palettes";
+import { MANUAL_DEFAULT, MAX_COLORS, MAX_COLORS_RECRAFT, NAME_MAX, paletteError, randomPalettes, suggestName, withBackground } from "@/lib/catalog/palettes";
import { cn } from "@/lib/utils";
import { ColorPicker } from "./color-picker";
@@ -79,7 +79,7 @@ export function PaletteEditor({ value, onChange, onSave, saving }: { value: Pale
value={c}
onChange={(hex) => replace(i, hex)}
background={c === value.background}
- onBackground={(on) => set({ background: on ? c : null })}
+ onBackground={(on) => onChange(withBackground(value, c, on))}
/>
</PopoverContent>
</Popover>
diff --git a/src/components/palettes/signature-chips.tsx b/src/components/palettes/signature-chips.tsx
index b6e6e169..2d004d86 100644
--- a/src/components/palettes/signature-chips.tsx
+++ b/src/components/palettes/signature-chips.tsx
@@ -7,10 +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, soulPick, toPick } from "@/components/moodboards/logic";
+import { curatedLook, curatedPick, soulPick, toPick } from "@/components/moodboards/logic";
import { MoodboardPanel } from "@/components/moodboards/moodboard-panel";
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";
import { usePalettes } from "./hooks";
@@ -54,15 +53,15 @@ export default function SignatureChips({
value,
onChange,
engine,
- modelId,
+ presetSource,
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;
+ /** The model's own preset list (options.presets.source): the Moodboard panel opens on it ("soul-v1" = Soul's styles). */
+ presetSource?: 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;
@@ -75,10 +74,10 @@ export default function SignatureChips({
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 }) };
+ const pick: MoodboardPick = soulPick(styleId) ?? { id: styleId, kind: "curated", name: "Soul style", status: "complete", ...(presetSource === "soul-v1" && { source: "soul-v1" as const }) };
onChange((s) => (s?.moodboard ? { ...s } : { ...s, moodboard: pick }));
onStyleIdTaken?.();
- }, [styleId, modelId, onChange, onStyleIdTaken]);
+ }, [styleId, presetSource, onChange, onStyleIdTaken]);
return (
<>
<Suspense fallback={null}>
@@ -120,7 +119,7 @@ export default function SignatureChips({
<Chip icon={mb ? undefined : Images} active={!!mb} aria-label={mb ? `Moodboard: ${mb.name}` : "Moodboard"}>
{mb &&
(mb.kind === "curated" ? (
- <CuratedCover m={{ name: "", hue: hueOf(mb.id) }} className="size-4 rounded-full" />
+ <CuratedCover m={{ name: "", ...curatedLook(mb.id) }} className="size-4 rounded-full" />
) : mb.cover ? (
// eslint-disable-next-line @next/next/no-img-element
<img src={mb.cover} alt="" className="size-4 rounded-full object-cover" />
@@ -131,7 +130,7 @@ export default function SignatureChips({
>
<MoodboardPanel
value={mb}
- modelId={modelId}
+ presetSource={presetSource}
onPick={(m) => {
onChange((s) => ({ ...s, moodboard: m }));
setBoardOpen(false);
diff --git a/src/components/palettes/use-signature.ts b/src/components/palettes/use-signature.ts
index bda5cc29..991c056e 100644
--- a/src/components/palettes/use-signature.ts
+++ b/src/components/palettes/use-signature.ts
@@ -2,7 +2,7 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useCallback } from "react";
-import { applySignature, type Signature, type SignedRequest } from "@/lib/catalog/palettes";
+import { applySignature, withSignatureWords, type Signature, type SignedRequest } from "@/lib/catalog/palettes";
import type { Generation, GenerationRequest } from "@/lib/catalog/types";
import { useCatalog } from "@/components/studio/catalog";
import { usePalettes } from "./hooks";
@@ -18,7 +18,11 @@ export function useSignature(enabled: boolean, signature: Signature | undefined)
// The palette list carries which models take a palette natively; the chip has usually loaded it already.
const { caps } = usePalettes(enabled && !!signature?.palette);
const apply = useCallback(
- (req: GenerationRequest): SignedRequest => (enabled && signature ? applySignature(req, signature, { caps, getModel }) : { request: req, modelId: req.modelId, notes: [] }),
+ (req: GenerationRequest): SignedRequest & { worded: GenerationRequest } => {
+ const signed = enabled && signature ? applySignature(req, signature, { caps, getModel }) : { request: req, modelId: req.modelId, notes: [] };
+ // `request` is what's sent (the user's words in `prompt`); `worded` is how it runs, for planning and pricing.
+ return { ...signed, worded: withSignatureWords(signed.request) };
+ },
[enabled, signature, caps, getModel],
);
const qc = useQueryClient();
diff --git a/src/components/studio/composer.tsx b/src/components/studio/composer.tsx
index 18882b8d..fe8f7f8c 100644
--- a/src/components/studio/composer.tsx
+++ b/src/components/studio/composer.tsx
@@ -198,7 +198,8 @@ export function Composer({ docked }: { docked: boolean }) {
const signature = useSignature(!!config.signature, draft.signature);
const prepare = (d: typeof draft) => {
const signed = signature.apply(buildRequest(config.feature, d, studioOp, config.promptSuffix, config.multiRef?.kind));
- const raw = signed.request;
+ // Planned with the signature's sentences in the prompt (as the server runs it); sent with them apart.
+ const raw = signed.worded;
const m = catalog.getModel(raw.modelId) ?? model;
const mentions = m ? applyMentions(raw, m, elements) : { request: raw, mentioned: [], notes: [] };
const sketched = m ? applySketch(mentions.request, m) : { request: mentions.request };
@@ -377,7 +378,7 @@ export function Composer({ docked }: { docked: boolean }) {
value={draft.signature}
onChange={(update) => setDraft((d) => ({ signature: update(d.signature) }))}
engine={engine}
- modelId={draft.modelId}
+ presetSource={opts.presets?.source}
styleId={soulStyles ? (p.extra?.[opts.presets!.param] as string | undefined) : undefined}
onStyleIdTaken={() => setExtra(opts.presets!.param, undefined)}
/>
diff --git a/src/components/studio/studio-page.tsx b/src/components/studio/studio-page.tsx
index db0a7d36..065976ff 100644
--- a/src/components/studio/studio-page.tsx
+++ b/src/components/studio/studio-page.tsx
@@ -10,6 +10,8 @@ import { SidebarTrigger } from "@/components/ui/sidebar";
import type { Generation, MediaKind, ModelDef, Preset } from "@/lib/catalog/types";
import { useEngine, useGenerations } from "@/lib/api";
import { handoffKey, mergeHandoff } from "@/lib/composer";
+import { reuseSignature, withSignatureWords } from "@/lib/catalog/palettes";
+import { SoulPresetCards } from "@/components/moodboards/soul-preset-cards";
import type { StudioCatalog } from "@/lib/studio-catalog";
import { cn } from "@/lib/utils";
import { ComposerBridgeCtx, useComposerBridge, type ComposerBridge } from "./attachments";
@@ -70,8 +72,11 @@ function initialDraft(
/** Rebuild a composer draft from a past generation ("Reuse"). */
function draftFromGeneration(g: Generation, config: StudioConfig): Partial<Draft> {
- const r = g.request;
- const imgs = r.inputs?.images ?? [];
+ // A run styled by the Color signature / Moodboard chips comes back as it was before they routed it,
+ // with the picks on the chips (studios without the chips get the styled prompt instead).
+ const signed = config.signature ? reuseSignature(g.request) : null;
+ const r = signed ? { ...g.request, modelId: signed.modelId, params: signed.params } : config.signature ? g.request : withSignatureWords(g.request);
+ const imgs = signed ? signed.images : (r.inputs?.images ?? []);
const imageKeys = config.slots.filter((s) => s.accept === "image" && s.key !== "endImage" && s.key !== "mask").map((s) => s.key);
const slots: Draft["slots"] = {};
imageKeys.forEach((k, i) => (slots[k] = slot(imgs[i])));
@@ -90,6 +95,7 @@ function draftFromGeneration(g: Generation, config: StudioConfig): Partial<Draft
presetOptions: r.presetOptions ?? {},
presetStrength: r.presetStrength,
mix: r.mix,
+ signature: signed?.signature,
};
}
@@ -289,6 +295,7 @@ function StudioBody({ header, tabs }: { header?: React.ReactNode; tabs?: React.R
))}
</div>
)}
+ {!hasItems && config.signature && <SoulPresetCards />}
{dragging && (
<div className="pointer-events-none absolute inset-0 z-40 grid place-items-center bg-overlay p-8">
diff --git a/src/lib/catalog/palettes.ts b/src/lib/catalog/palettes.ts
index fe7dc785..d3a3d153 100644
--- a/src/lib/catalog/palettes.ts
+++ b/src/lib/catalog/palettes.ts
@@ -12,14 +12,18 @@
* 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: 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).
+ * - Moodboard → curated: the Soul preset's `style_id` on a model whose own preset picker is that list
+ * (options.presets.source: 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; Soul Cinema ignores style ids).
* 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
* on Z-Image Turbo.
+ * Sentences (the palette's hex list, a look described in words, a reference legend) never go into
+ * `request.prompt`: they ride in `request.signature.words`, which the server adds when it plans the
+ * run, so feeds, Library titles and Reuse keep the user's own words.
*/
-import type { GenerationRequest, ModelDef } from "./types";
+import type { GenerationRequest, GenParams, ModelDef, Operation } from "./types";
export type RGB = [number, number, number];
@@ -83,6 +87,19 @@ export function cardStrip(p: Pick<Palette, "colors" | "background">): string[] {
return out;
}
+/**
+ * "Use as background" in the manual editor: `color` becomes (or stops being) the background, and the
+ * colour that loses the flag stays in the palette as an ordinary colour (within the 12-colour limit)
+ * instead of disappearing with it.
+ */
+export function withBackground<P extends { colors: string[]; background: string | null }>(p: P, color: string, on: boolean): P {
+ const has = (c: string) => p.colors.some((x) => x.toUpperCase() === c.toUpperCase());
+ const keep = (c: string | null) => (c && !has(c) && p.colors.length < MAX_COLORS ? [...p.colors, c] : p.colors);
+ if (on) return { ...p, colors: p.background && p.background.toUpperCase() !== color.toUpperCase() ? keep(p.background) : p.colors, background: color };
+ if (p.background?.toUpperCase() !== color.toUpperCase()) return p;
+ return { ...p, colors: keep(color), background: null };
+}
+
/** The colours sent to a model: the palette's own, then the background when it isn't one of them. */
export function paletteColors(p: Pick<Palette, "colors" | "background">): string[] {
return cardStrip({ colors: p.colors, background: null }).concat(p.background && !p.colors.some((c) => c.toUpperCase() === p.background!.toUpperCase()) ? [p.background.toUpperCase()] : []);
@@ -331,6 +348,17 @@ export interface Signature {
moodboard?: MoodboardPick;
}
+/**
+ * What a signed request carries (GenerationRequest.signature): the picks (Reuse puts them back on the
+ * chips), the sentences the server adds to the prompt (the look and the palette in words, so the
+ * user's own words stay in `prompt` for titles and Reuse), and the request before the signature
+ * routed it (its model, operation, settings and how many images were the user's own).
+ */
+export interface SignatureRecord extends Signature {
+ words?: string;
+ from?: { modelId: string; op?: Operation; params?: GenParams; images: number };
+}
+
export interface SignatureCaps {
/** Models whose routes take a palette field: how many colours and the background colour's field. */
native: Record<string, { max: number; background?: string }>;
@@ -408,15 +436,40 @@ function swap(request: GenerationRequest, to: ModelDef, from: ModelDef): Generat
const setExtra = (r: GenerationRequest, key: string, value: unknown): GenerationRequest => ({ ...r, params: { ...r.params, extra: { ...r.params?.extra, [key]: value } } });
+/** The prompt as the model gets it: the user's words, then the signature's sentences (added once). */
+export function withSignatureWords(req: GenerationRequest): GenerationRequest {
+ const words = req.signature?.words?.trim();
+ return words ? { ...req, prompt: join(req.prompt, words) } : req;
+}
+
+/**
+ * Reuse of a signed run (Image studio): the request as it was before the signature routed it — its
+ * own model, settings and images — with the picks back on the chips, so nothing hidden comes along
+ * (a moved model, a palette field, a style id, the board's images). Null when it carries no signature.
+ */
+export function reuseSignature(req: GenerationRequest): { modelId: string; params: GenParams; images: string[]; signature: Signature } | null {
+ const s = req.signature;
+ if (!s || (!s.palette && !s.moodboard)) return null;
+ const images = req.inputs?.images ?? [];
+ return {
+ modelId: s.from?.modelId ?? req.modelId,
+ params: { ...(s.from?.params ?? req.params) },
+ images: images.slice(0, s.from?.images ?? images.length),
+ signature: { ...(s.palette && { palette: s.palette }), ...(s.moodboard && { moodboard: s.moodboard }) },
+ };
+}
+
/**
* Apply the composer's palette and moodboard to a request. Pure: the same call prices the run while
- * you type and builds what's sent.
+ * you type and builds what's sent. Native fields (style_id, palette, color_palette) and a model move
+ * go on the request; sentences go to `signature.words`, which the server adds to the prompt.
*/
export function applySignature(req: GenerationRequest, sig: Signature | undefined, ctx: SignatureContext): SignedRequest {
let model = ctx.getModel(req.modelId);
if (!model || (!sig?.palette && !sig?.moodboard)) return { request: req, modelId: req.modelId, notes: [] };
let r: GenerationRequest = req;
const notes: string[] = [];
+ const words: string[] = [];
const move = (id: string, why: string) => {
const to = ctx.getModel(id);
if (!to || !model || to.id === model.id) return false;
@@ -431,18 +484,24 @@ 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") {
- const soul1 = mb.source === "soul-v1";
- if (model.id === (soul1 ? SIGNATURE_MODELS.soul1 : SIGNATURE_MODELS.soul2)) r = setExtra(r, "style_id", mb.id);
+ const source = mb.source ?? "soul-v2";
+ // Native wherever the model's own preset picker is this preset's list (Soul's styles, Soul 2.0's looks).
+ const presets = model.options.presets;
+ if (presets?.source === source) r = setExtra(r, presets.param, mb.id);
else {
- r = { ...r, prompt: join(r.prompt, styleWords(mb)) };
- notes.push(`${mb.name} is a ${soul1 ? "Soul" : "Soul 2.0"} preset — described in words on ${model.name}`);
+ words.push(styleWords(mb));
+ notes.push(
+ model.family === "soul" && !presets
+ ? `${model.name} has one fixed look and no presets — ${mb.name} is described in words`
+ : `${mb.name} is a ${source === "soul-v1" ? "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);
- // A reused run already carries the board's images and their legend: nothing to add.
+ // A request that already carries the board's images (Run again of an older run): nothing to add.
const carried = [...refs, ...collages].some((u) => r.inputs?.images?.includes(u));
if (carried) {
// Leave the request as it is.
@@ -452,7 +511,11 @@ export function applySignature(req: GenerationRequest, sig: Signature | undefine
r = { ...r, params: { ...r.params, styleId: mb.styleId } };
} else if (model.family === "recraft") {
move(SIGNATURE_MODELS.recraftStyle, `Runs on {model}, styled by the “${mb.name}” images`);
- r = { ...r, op: "edit", inputs: { ...r.inputs, images: refs.slice(0, 10) } };
+ // Recraft V4 Styles reads every image as a style reference: yours first, then the board's, 10 in all.
+ const own = r.inputs?.images ?? [];
+ const max = model.options.maxImages ?? 10;
+ if (own.length) notes.push(`Your ${own.length === 1 ? "image is" : "images are"} used as style references too on ${model.name}`);
+ r = { ...r, op: "edit", inputs: { ...r.inputs, images: [...own, ...refs.filter((u) => !own.includes(u))].slice(0, max) } };
} else {
let budget = Math.min(refBudget(model, existing), 6);
if (!budget && model.id !== SIGNATURE_MODELS.cloudRefs) {
@@ -461,11 +524,12 @@ export function applySignature(req: GenerationRequest, sig: Signature | undefine
}
const take = refs.slice(0, budget);
if (!take.length) return { request: req, modelId: req.modelId, notes, blocker: "Remove a reference image to make room for the moodboard" };
- r = { ...r, op: "edit", inputs: { ...r.inputs, images: [...(r.inputs?.images ?? []), ...take] }, prompt: join(r.prompt, styleLegend(existing + 1, existing + take.length)) };
+ r = { ...r, op: "edit", inputs: { ...r.inputs, images: [...(r.inputs?.images ?? []), ...take] } };
+ words.push(styleLegend(existing + 1, existing + take.length));
}
} else if (mb.loraHandle && (model.id === SIGNATURE_MODELS.openTurbo || model.family !== "style-reference")) {
move(SIGNATURE_MODELS.openTurbo, `Runs on {model} with the trained “${mb.name}” style LoRA`);
- r = { ...r, prompt: join(r.prompt, `In the style of @${mb.loraHandle}.`) };
+ words.push(`In the style of @${mb.loraHandle}.`);
} else {
if (model.family !== "style-reference") move(SIGNATURE_MODELS.openStyle, `Runs on {model} with the “${mb.name}” collages`);
const max = model.options.maxImages ?? 2;
@@ -497,12 +561,21 @@ export function applySignature(req: GenerationRequest, sig: Signature | undefine
} else if (model.id === SIGNATURE_MODELS.cinema && pal.slug) {
r = setExtra(r, "color_palette", pal.slug);
} else {
- r = { ...r, prompt: join(r.prompt, palettePrompt(pal)), params: { ...r.params, palette: all.slice(0, 16) } };
+ words.push(palettePrompt(pal));
+ r = { ...r, params: { ...r.params, palette: all.slice(0, 16) } };
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 }) };
+ // Sentences an older run already kept in its prompt aren't added twice.
+ const sentence = words.filter((w) => !tidy(r.prompt).includes(tidy(w))).join(" ");
+ const record: SignatureRecord = {
+ ...(sig.palette && { palette: sig.palette }),
+ ...(sig.moodboard && { moodboard: sig.moodboard }),
+ ...(sentence && { words: sentence }),
+ from: { modelId: req.modelId, ...(req.op && { op: req.op }), ...(req.params && { params: req.params }), images: req.inputs?.images?.length ?? 0 },
+ };
+ return { request: { ...r, signature: record }, modelId: model.id, notes, ...(lock && { lock }) };
}
diff --git a/src/lib/catalog/types.ts b/src/lib/catalog/types.ts
index 7c8b75ef..328f141a 100644
--- a/src/lib/catalog/types.ts
+++ b/src/lib/catalog/types.ts
@@ -7,6 +7,7 @@
* (fal, replicate, comfyui, ...). Presets (apps, camera motions, effects) sit on top
* of models and add prompt templates, fixed inputs and LoRAs.
*/
+import type { SignatureRecord } from "./palettes";
export type Engine = "cloud" | "open";
@@ -438,6 +439,12 @@ export interface GenerationRequest {
title?: string;
/** Server-set: the name of the batch it belongs to (an Assist plan's summary): the Library stack's title. */
batchTitle?: string;
+ /**
+ * The Image studio's style signature (Color signature + Moodboard chips): what was picked, the
+ * sentences the server adds to the prompt (`prompt` keeps the user's own words), and the request as
+ * it was before the signature routed it (Reuse restores that). See src/lib/catalog/palettes.ts.
+ */
+ signature?: SignatureRecord;
}
export interface ChainSlot {
diff --git a/src/server/generations.ts b/src/server/generations.ts
index ac8640fc..db0c19d2 100644
--- a/src/server/generations.ts
+++ b/src/server/generations.ts
@@ -4,6 +4,7 @@ import path from "node:path";
import { nanoid } from "nanoid";
import { getModel, getPreset } from "@/lib/catalog";
import { applyMentions } from "@/lib/catalog/elements";
+import { withSignatureWords } from "@/lib/catalog/palettes";
import { applySketch, stripMotionPaths } from "@/lib/catalog/sketch";
import { cueText, type Cue } from "@/lib/cues";
import { estimateCost, planGeneration, routesFor } from "@/lib/catalog/plan";
@@ -289,8 +290,10 @@ setResolver((ids) =>
/** Resolve mentions and drawings, plan, enforce the engine mode and pick a provider route. */
function prepare(original: GenerationRequest) {
// @element mentions become reference images / LoRAs; the stored request keeps the mentions for "Reuse".
- const model = getModel(original.modelId);
- const req = model ? stripMotionPaths(applySketch(applyMentions(original, model, listElements()).request, model).request, model) : original;
+ // A style signature's sentences (palette, look) join the prompt here; the stored request keeps the user's words.
+ const worded = withSignatureWords(original);
+ const model = getModel(worded.modelId);
+ const req = model ? stripMotionPaths(applySketch(applyMentions(worded, model, listElements()).request, model).request, model) : worded;
const plan = planGeneration(req, getModel, getPreset);
const mode = engineMode();
if (mode !== "both" && plan.model.engine !== mode) {
diff --git a/src/server/palettes.ts b/src/server/palettes.ts
index 7040a62c..299a21f7 100644
--- a/src/server/palettes.ts
+++ b/src/server/palettes.ts
@@ -4,9 +4,50 @@ import { MODELS } from "@/lib/catalog";
import { PALETTES as CINEMA_PALETTES } from "@/lib/catalog/cinema";
import { MAX_COLORS_RECRAFT, MAX_COLORS, normalizeHex, paletteError, type Palette, type PaletteSource, type SignatureCaps } from "@/lib/catalog/palettes";
import type { GenerationRequest } from "@/lib/catalog/types";
+import { z } from "zod";
import { createPipeline } from "./chains";
import { db } from "./db";
+const Hex = z.string().regex(/^#?[0-9a-fA-F]{6}$/);
+const Url = z.string().max(2000);
+
+/**
+ * GenerationRequest.signature as the Image studio sends it (POST /api/generations, /api/palettes/lock):
+ * the picks, the sentences added to the prompt, and the request before the signature routed it.
+ */
+export const SignatureSchema = z
+ .object({
+ palette: z
+ .object({
+ id: z.string().max(120),
+ name: z.string().max(120),
+ colors: z.array(Hex).max(16),
+ background: Hex.nullable(),
+ slug: z.string().max(120).nullable(),
+ thumb: Url.nullable().optional(),
+ lock: z.boolean().optional(),
+ })
+ .optional(),
+ moodboard: z
+ .object({
+ id: z.string().max(120),
+ kind: z.enum(["curated", "personal"]),
+ name: z.string().max(120),
+ description: z.string().max(2000).optional(),
+ source: z.enum(["soul-v1", "soul-v2"]).optional(),
+ status: z.enum(["queued", "running", "cover", "complete", "failed"]),
+ cover: Url.nullable().optional(),
+ refs: z.array(Url).max(10).optional(),
+ collages: z.array(Url).max(2).optional(),
+ styleId: z.string().max(200).nullable().optional(),
+ loraHandle: z.string().max(120).nullable().optional(),
+ })
+ .optional(),
+ words: z.string().max(6000).optional(),
+ from: z.object({ modelId: z.string().max(120), op: z.string().max(40).optional(), params: z.record(z.string(), z.unknown()).optional(), images: z.number().int().min(0).max(14) }).optional(),
+ })
+ .optional();
+
/**
* Colour signatures: the user's palettes plus the 50 Cinema Studio 4.0 palettes (seeded once, so the
* library is shared with Cinema Studio's colour grades and its slugs stay valid for cinema-studio-4).
@@ -143,21 +184,24 @@ export function createLockedRun(request: GenerationRequest, colors: string[], st
if (!hex.length) throw new Error("Pick a palette first");
const n = Math.max(1, Math.min(4, request.params?.numOutputs ?? 1));
const batchId = nanoid(10);
+ // The recoloured image is the result: it carries the user's words; the first step says it's the before.
+ const words = request.prompt?.trim() || "Palette lock";
const items = [];
for (let i = 0; i < n; i++) {
- const step = n > 1 ? { label: `Image ${i + 1} of ${n}`, index: i, of: n } : undefined;
+ const of = n > 1 ? ` ${i + 1} of ${n}` : "";
const { items: made } = createPipeline(
[
- { key: "image", request: { ...request, params: { ...request.params, numOutputs: 1 }, ...(step && { step }) } },
+ { key: "image", request: { ...request, params: { ...request.params, numOutputs: 1 }, step: { label: `Before palette lock${of}`, index: i, of: n } } },
{
key: "lock",
request: {
feature: request.feature,
modelId: "oss-palette-image",
op: "color-match",
- prompt: "Palette lock",
+ prompt: words,
+ title: words,
params: { palette: hex, extra: { strength } },
- step: { label: n > 1 ? `Palette lock ${i + 1} of ${n}` : "Palette lock", index: i, of: n },
+ step: { label: `Palette lock${of}`, index: i, of: n },
},
after: "image",
chain: [{ slot: "images", position: "first" }],