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.

Photodump, Fashion Factory, Character Sheet: retry inside the run, keyboard pickers, honest notes, distinct covers

Claude768beba33596
diff --git a/src/app/api/photodump/character/route.ts b/src/app/api/photodump/character/route.ts
index 544fcafb..339a659b 100644
--- a/src/app/api/photodump/character/route.ts
+++ b/src/app/api/photodump/character/route.ts
@@ -14,16 +14,28 @@ const Body = z.discriminatedUnion("mode", [
z.object({ mode: z.literal("describe"), engine: Engine, prompt: z.string().max(2000) }),
]);
+/** What's wrong with a body, said for the mode it was meant for (Higgsfield's words where it has them). */
+function bodyError(mode: unknown, issues: z.core.$ZodIssue[]): string {
+ const at = (key: string) => issues.some((i) => i.path[0] === key);
+ if (at("engine")) return "Pick Cloud or Open source";
+ if (mode === "reference") {
+ if (issues.some((i) => i.path[0] === "images" && i.code === "too_big")) return "Maximum 5 images";
+ if (at("images")) return "Upload at least 1 image";
+ if (at("details")) return "Keep the details under 300 characters";
+ }
+ if (mode === "cast") return at("details") ? "Keep the details under 300 characters" : "Check the cast fields";
+ if (mode === "describe") return at("prompt") && issues.some((i) => i.code === "too_big") ? "Keep the description under 2,000 characters" : "Describe your character first";
+ return "Pick how to build the character: From Reference, Build from scratch or From a description";
+}
+
/**
* Character Sheet: a turnaround sheet from 1–5 reference photos, from a Soul Cast build, or from a
* description (the AI Influencer app). `?preview=1` prices it instead.
*/
export async function POST(request: Request) {
- const parsed = Body.safeParse(await request.json().catch(() => null));
- if (!parsed.success) {
- const images = (parsed.error.issues.find((i) => i.path[0] === "images") && "Maximum 5 images") || "Upload at least 1 image";
- return Response.json({ error: images }, { status: 400 });
- }
+ const body = (await request.json().catch(() => null)) as { mode?: unknown } | null;
+ const parsed = Body.safeParse(body);
+ if (!parsed.success) return Response.json({ error: bodyError(body?.mode, parsed.error.issues) }, { status: 400 });
const input = parsed.data as SheetRun;
if (new URL(request.url).searchParams.get("preview")) return Response.json(previewSheet(input));
try {
diff --git a/src/app/api/photodump/retry/route.ts b/src/app/api/photodump/retry/route.ts
new file mode 100644
index 00000000..a375ecac
--- /dev/null
+++ b/src/app/api/photodump/retry/route.ts
@@ -0,0 +1,18 @@
+import { z } from "zod";
+import { retryPhoto } from "@/server/photodump";
+
+const Body = z.object({ id: z.string().min(1).max(40) });
+
+/**
+ * Retry a failed or canceled photo of a Photodump / Fashion Factory / Character Sheet run: the same
+ * request in the same batch, replacing the failed one (it goes to the Trash).
+ */
+export async function POST(request: Request) {
+ const parsed = Body.safeParse(await request.json().catch(() => null));
+ if (!parsed.success) return Response.json({ error: "Pick the photo to retry" }, { status: 400 });
+ try {
+ return Response.json({ items: retryPhoto(parsed.data.id) }, { status: 201 });
+ } catch (e) {
+ return Response.json({ error: (e as Error).message }, { status: 422 });
+ }
+}
diff --git a/src/components/fashion/character-sheet.tsx b/src/components/fashion/character-sheet.tsx
index b60e5bca..53206872 100644
--- a/src/components/fashion/character-sheet.tsx
+++ b/src/components/fashion/character-sheet.tsx
@@ -1,9 +1,8 @@
"use client";
-import { AtSign, ImagePlus, Loader2, RotateCcw, Shuffle, Sparkles, UserRoundPlus, X } from "lucide-react";
+import { AtSign, Check, ImagePlus, Loader2, RotateCcw, Shuffle, Sparkles, UserRoundPlus, X } from "lucide-react";
import Link from "next/link";
-import { useRouter } from "next/navigation";
-import { useMemo, useState } from "react";
+import { useMemo, useRef, useState } from "react";
import { toast } from "sonner";
import { PageHeader, PageShell } from "@/components/page-shell";
import { Button } from "@/components/ui/button";
@@ -15,7 +14,7 @@ import { radioKeys, radioTab } from "@/components/studio/radio-keys";
import { useRun, useRunPreview } from "@/components/photodump/hooks";
import { ResultsGrid } from "@/components/photodump/results";
import { RunLine } from "@/components/photodump/steps";
-import { useEngine, useGenerations, useSaveElement } from "@/lib/api";
+import { useElements, useEngine, useGenerations, useSaveElement } from "@/lib/api";
import { castFieldVisible, castNameFor, randomCast, SHEET_MAX_REFS, type CastAnswers, type CastFieldData } from "@/lib/catalog/packs";
import type { Generation } from "@/lib/catalog/types";
import { cn } from "@/lib/utils";
@@ -90,12 +89,32 @@ function CastForm({ fields, values, set }: { fields: CastFieldData[]; values: Ca
);
}
-/** Save a finished sheet as a character (its sheet, views and the source photos as references). */
+/**
+ * Save a finished sheet as a character (its sheet, views and the source photos as references), once:
+ * a sheet that is already a character (its image is one of the character's references) shows that
+ * character instead, also after a reload.
+ */
function SaveCharacter({ item, extra, defaultName }: { item: Generation; extra: string[]; defaultName: string }) {
const [name, setName] = useState(defaultName);
const save = useSaveElement();
- const router = useRouter();
+ const elements = useElements();
const refs = [...item.outputs.filter((o) => o.kind === "image").map((o) => o.url), ...extra].slice(0, 20);
+ const saved = save.data ?? elements.data?.find((e) => e.kind === "character" && !!refs[0] && e.references.includes(refs[0]));
+ if (saved)
+ return (
+ <div className="flex flex-wrap items-center gap-2 rounded-2xl border bg-background p-3">
+ <span className="grid size-7 place-items-center rounded-full bg-success/15 text-success">
+ <Check className="size-4" />
+ </span>
+ <p className="min-w-0 flex-1 text-[13px]">
+ Saved as <span className="font-medium">@{saved.handle}</span> — use it anywhere with <AtSign className="inline size-3" />
+ mentions, in <Link href="/photodump" className="text-brand-text hover:underline">Photodump</Link> or <Link href="/fashion-factory" className="text-brand-text hover:underline">Fashion Factory</Link>.
+ </p>
+ <Button asChild variant="outline" size="sm">
+ <Link href={`/elements/${saved.id}`}>Open @{saved.handle}</Link>
+ </Button>
+ </div>
+ );
return (
<div className="flex flex-wrap items-end gap-2 rounded-2xl border bg-background p-3">
<label className="min-w-40 flex-1 space-y-1">
@@ -103,13 +122,12 @@ function SaveCharacter({ item, extra, defaultName }: { item: Generation; extra:
<Input value={name} onChange={(e) => setName(e.target.value)} maxLength={60} className="h-8" />
</label>
<Button
- disabled={!name.trim() || save.isPending}
+ disabled={!name.trim() || save.isPending || elements.isLoading}
onClick={() =>
save.mutate(
{ name: name.trim(), kind: "character", references: refs },
{
- onSuccess: (el) =>
- toast.success(`Saved as @${el.handle}`, { action: { label: "Open", onClick: () => router.push(`/elements/${el.id}`) } }),
+ // The card turns into "Saved as @handle · Open": no toast needed.
onError: (e) => toast.error((e as Error).message),
},
)
@@ -139,6 +157,7 @@ export function CharacterSheetView({ fields, defaults }: { fields: CastFieldData
const [brief, setBrief] = useState("");
const [ids, setIds] = useState<string[]>([]);
const [over, setOver] = useState(false);
+ const fileInput = useRef<HTMLInputElement>(null);
const run = useRun<Record<string, unknown>>("/api/photodump/character");
const { data } = useGenerations({ features: ["character-sheet", "app:app-ai-influencer"], limit: 60 });
// This visit's sheets; after a reload, the most recent ones.
@@ -189,7 +208,7 @@ export function CharacterSheetView({ fields, defaults }: { fields: CastFieldData
{mode === "reference" && (
<div className="space-y-3">
- <label
+ <div
onDragOver={(e) => (e.preventDefault(), setOver(true))}
onDragLeave={() => setOver(false)}
onDrop={(e) => {
@@ -197,13 +216,20 @@ export function CharacterSheetView({ fields, defaults }: { fields: CastFieldData
setOver(false);
addFiles(e.dataTransfer.files);
}}
- className={cn("flex cursor-pointer flex-col items-center justify-center gap-2 rounded-2xl border border-dashed px-4 py-10 text-center transition-colors hover:bg-accent", over && "border-primary bg-brand-faint")}
+ onPaste={(e) => addFiles(e.clipboardData.files)}
+ className={cn("rounded-2xl border border-dashed transition-colors", over && "border-primary bg-brand-faint")}
>
- <ImagePlus className="size-6 text-muted-foreground" />
- <span className="text-[14px] font-medium">Drop images here</span>
- <span className="text-[12.5px] text-muted-foreground">1–{SHEET_MAX_REFS} photos of one person · PNG, JPG or WebP</span>
- <input type="file" accept="image/png,image/jpeg,image/webp" multiple hidden onChange={(e) => (addFiles(e.target.files ?? []), (e.target.value = ""))} />
- </label>
+ <button
+ type="button"
+ onClick={() => fileInput.current?.click()}
+ className="flex w-full flex-col items-center justify-center gap-2 rounded-2xl px-4 py-10 text-center outline-none transition-colors hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset"
+ >
+ <ImagePlus className="size-6 text-muted-foreground" />
+ <span className="text-[14px] font-medium">Drop images here</span>
+ <span className="text-[12.5px] text-muted-foreground">1–{SHEET_MAX_REFS} photos of one person · PNG, JPG or WebP · or click to choose</span>
+ </button>
+ <input ref={fileInput} type="file" accept="image/png,image/jpeg,image/webp" multiple hidden onChange={(e) => (addFiles(e.target.files ?? []), (e.target.value = ""))} />
+ </div>
{photos.length > 0 && (
<div className="grid grid-cols-5 gap-2">
{photos.map((p, i) => (
@@ -263,7 +289,12 @@ export function CharacterSheetView({ fields, defaults }: { fields: CastFieldData
{mine.length ? (
<>
{!ids.length && <p className="text-[13px] font-medium text-muted-foreground">Recent sheets</p>}
- <ResultsGrid items={mine} ratio={16 / 9} className="sm:grid-cols-1 lg:grid-cols-1" />
+ <ResultsGrid
+ items={mine}
+ ratio={16 / 9}
+ className="sm:grid-cols-1 lg:grid-cols-1"
+ onRetried={(from, to) => setIds((xs) => (xs.length ? xs.flatMap((id) => (id === from ? to : [id])) : xs))}
+ />
{latest && (
<SaveCharacter
key={latest.id}
diff --git a/src/components/fashion/fashion-view.tsx b/src/components/fashion/fashion-view.tsx
index 00a53d51..452d0476 100644
--- a/src/components/fashion/fashion-view.tsx
+++ b/src/components/fashion/fashion-view.tsx
@@ -214,7 +214,7 @@ export function FashionView() {
<RefreshCw /> Regenerate
</Button>
</div>
- <ResultsGrid items={baseItems} picked={s.base} onPick={(url) => dispatch({ type: "pickBase", url })} />
+ <ResultsGrid items={baseItems} picked={s.base} onPick={(url) => dispatch({ type: "pickBase", url })} onRetried={(from, to) => dispatch({ type: "retried", from, to })} />
<Footer onBack={() => dispatch({ type: "back" })}>
<Button onClick={() => !block(fashionBlocker(s)) && dispatch({ type: "next" })}>
Next <ArrowRight />
@@ -254,7 +254,13 @@ export function FashionView() {
{s.outfitIds.length ? (
<>
<p className="text-[14px] text-muted-foreground">Select a result to generate your photoset from. Edit your outfit or continue</p>
- <ResultsGrid items={outfitItems} picked={s.outfit} onPick={(url) => dispatch({ type: "pickOutfit", url })} className="lg:grid-cols-3" />
+ <ResultsGrid
+ items={outfitItems}
+ picked={s.outfit}
+ onPick={(url) => dispatch({ type: "pickOutfit", url })}
+ onRetried={(from, to) => dispatch({ type: "retried", from, to })}
+ className="lg:grid-cols-3"
+ />
</>
) : (
<div className="grid h-full min-h-48 place-items-center rounded-2xl border border-dashed p-6 text-center text-[13px] text-muted-foreground">Upload the outfit, then Generate outfit to dress your base shot.</div>
diff --git a/src/components/moodboards/cards.tsx b/src/components/moodboards/cards.tsx
index dad2d636..9fbe478f 100644
--- a/src/components/moodboards/cards.tsx
+++ b/src/components/moodboards/cards.tsx
@@ -3,19 +3,17 @@
import { AlertCircle, Check, Loader2 } from "lucide-react";
import type { MoodboardStatus } from "@/lib/catalog/palettes";
import { cn } from "@/lib/utils";
+import { DrawnTile } from "@/components/photodump/covers";
import { STATUS_LABEL, type CuratedMoodboard, type Moodboard } from "./logic";
/**
* A curated look's cover: Higgsfield's preview when its live list loaded (a key is set), otherwise
- * drawn from the look's hue (no Higgsfield images are hot-linked without a key); its name on top.
+ * drawn in the look's hue and treatment — grain for black and white, a flash hotspot, gels… (no
+ * Higgsfield images are hot-linked without a key); its name on top.
*/
-export function CuratedCover({ m, className }: { m: Pick<CuratedMoodboard, "name" | "hue" | "preview">; className?: string }) {
+export function CuratedCover({ m, className }: { m: Pick<CuratedMoodboard, "name" | "hue" | "preview" | "tone">; className?: string }) {
return (
- <span
- aria-hidden
- className={cn("relative block overflow-hidden", className)}
- style={{ background: `radial-gradient(120% 90% at 20% 15%, oklch(0.86 0.09 ${m.hue}), transparent 60%), linear-gradient(160deg, oklch(0.62 0.14 ${(m.hue + 30) % 360}), oklch(0.32 0.08 ${(m.hue + 70) % 360}))` }}
- >
+ <DrawnTile hue={m.hue} tone={m.tone ?? "plain"} className={className}>
{m.preview && (
<>
{/* eslint-disable-next-line @next/next/no-img-element */}
@@ -24,7 +22,7 @@ export function CuratedCover({ m, className }: { m: Pick<CuratedMoodboard, "name
</>
)}
{m.name && <span className="absolute inset-x-2 bottom-2 font-heading text-[19px] leading-tight text-white drop-shadow-sm">{m.name}</span>}
- </span>
+ </DrawnTile>
);
}
diff --git a/src/components/moodboards/logic.ts b/src/components/moodboards/logic.ts
index fa6a5ca6..8e617fc2 100644
--- a/src/components/moodboards/logic.ts
+++ b/src/components/moodboards/logic.ts
@@ -4,7 +4,7 @@
* images best represent a board, and the 2×2 collages open-source style models take.
*/
import { SOUL_CATEGORIES, SOUL_PRESETS, type SoulPreset, type SoulPresetModel } from "@/lib/catalog/higgsfield-presets.generated";
-import { getSoulPreset, hueOf } from "@/lib/catalog/packs";
+import { coverTone, getSoulPreset, hueOf, spreadHue, type CoverTone } 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";
@@ -34,7 +34,9 @@ export interface CuratedMoodboard {
name: string;
category: string;
description: string;
+ /** The drawn cover: a hue spread by the look's place in its set, and a treatment from its words. */
hue: number;
+ tone?: CoverTone;
/** 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. */
@@ -43,13 +45,14 @@ export interface CuratedMoodboard {
preview?: string;
}
-const toCurated = (p: SoulPreset): CuratedMoodboard => ({
+const toCurated = (p: SoulPreset, i: number): CuratedMoodboard => ({
id: p.id,
name: p.name,
category: p.categories[0] ?? "All presets",
categories: p.categories,
description: p.description,
- hue: hueOf(p.id),
+ hue: spreadHue(i),
+ tone: coverTone(p.name, p.description),
...(p.model === "soul-v1" && { source: p.model }),
});
@@ -64,6 +67,13 @@ export const CURATED_SETS: Record<SoulPresetModel, CuratedMoodboard[]> = {
};
export const SOUL_STYLES = CURATED_SETS["soul-v1"];
+const LOOKS = new Map([...CURATED_SETS["soul-v2"], ...CURATED_SETS["soul-v1"]].map((c) => [c.id, c]));
+/** A curated look's drawn cover by id (the composer chip's dot); unknown ids get a hue of their own. */
+export const curatedLook = (id: string): { hue: number; tone: CoverTone } => {
+ const c = LOOKS.get(id);
+ return c ? { hue: c.hue, tone: c.tone ?? "plain" } : { hue: hueOf(id), tone: "plain" };
+};
+
/** What GET /api/providers/higgsfield/presets returns (Higgsfield's live list, or the built-in one as `fallback`). */
export interface LivePresets {
items?: { id: string; name: string; preview?: string }[];
diff --git a/src/components/photodump/covers.tsx b/src/components/photodump/covers.tsx
index 7eae0255..4690d123 100644
--- a/src/components/photodump/covers.tsx
+++ b/src/components/photodump/covers.tsx
@@ -1,30 +1,82 @@
"use client";
-import { hueOf } from "@/lib/catalog/packs";
+import { hueOf, type CoverTone } from "@/lib/catalog/packs";
import { cn } from "@/lib/utils";
+/** A fine noise layer (film grain) drawn by the browser, no image file. */
+const GRAIN =
+ "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E\")";
+
+/**
+ * A drawn cover's background for a look: its hue under the look's treatment, `k` (0–3) shifting the
+ * light a little for the tiles of a contact sheet.
+ */
+export function drawnCover(hue: number, tone: CoverTone, k = 0): { background: string; grain: boolean } {
+ const h = (d: number) => (hue + d + 360) % 360;
+ const l = [0, 0.06, -0.05, 0.03][k % 4];
+ switch (tone) {
+ case "mono":
+ return { background: `radial-gradient(90% 70% at 35% 25%, oklch(${0.86 + l} 0 0), transparent 65%), linear-gradient(${160 + k * 30}deg, oklch(${0.58 + l} 0 0), oklch(${0.2 + l / 2} 0 0))`, grain: true };
+ case "flash":
+ return { background: `radial-gradient(40% 32% at 50% 38%, oklch(0.98 0.02 ${h(0)}), oklch(${0.72 + l} 0.12 ${h(0)}) 45%, oklch(0.2 0.04 ${h(40)}) 100%)`, grain: false };
+ case "gel":
+ return { background: `radial-gradient(70% 60% at 50% 60%, oklch(0.25 0.03 280 / 0.6), transparent), linear-gradient(${105 + k * 20}deg, oklch(${0.55 + l} 0.22 25), oklch(0.3 0.08 300) 50%, oklch(${0.52 + l} 0.19 255))`, grain: false };
+ case "pastel":
+ return { background: `linear-gradient(${150 + k * 35}deg, oklch(${0.93 + l / 2} 0.05 ${h(0)}), oklch(${0.86 + l / 2} 0.07 ${h(70)}))`, grain: false };
+ case "film":
+ return { background: `radial-gradient(120% 100% at 50% 40%, transparent 55%, oklch(0.2 0.03 ${h(20)} / 0.55)), linear-gradient(${150 + k * 35}deg, oklch(${0.78 + l} 0.09 ${h(0)}), oklch(${0.5 + l} 0.08 ${h(35)}))`, grain: true };
+ case "spot":
+ return { background: `radial-gradient(38% 46% at 50% 42%, oklch(${0.72 + l} 0.12 ${h(0)}), oklch(0.32 0.08 ${h(20)}) 55%, oklch(0.12 0.02 ${h(30)}) 100%)`, grain: false };
+ default:
+ return { background: `radial-gradient(120% 90% at 20% 15%, oklch(${0.86 + l / 2} 0.09 ${h(0)}), transparent 60%), linear-gradient(${150 + k * 35}deg, oklch(${0.64 + l} 0.14 ${h(30)}), oklch(0.32 0.08 ${h(70)}))`, grain: false };
+ }
+}
+
+/** One drawn tile (decorative: the card around it carries the name): the background plus film grain when the treatment has it. */
+export function DrawnTile({ hue, tone, k = 0, className, children }: { hue: number; tone: CoverTone; k?: number; className?: string; children?: React.ReactNode }) {
+ const c = drawnCover(hue, tone, k);
+ return (
+ <span aria-hidden className={cn("relative block overflow-hidden", className)} style={{ background: c.background }}>
+ {c.grain && <span aria-hidden className="absolute inset-0 opacity-35 mix-blend-overlay" style={{ backgroundImage: GRAIN }} />}
+ {children}
+ </span>
+ );
+}
+
/**
- * A drawn pack cover (Fuobe ships no copies of Higgsfield's sample photos): a 2×2 contact sheet of
- * soft tiles in the pack's hue family, its name and photo count.
+ * A drawn pack cover (Fuobe ships no copies of Higgsfield's sample photos): a 2×2 contact sheet in the
+ * pack's own hue and treatment (flash, film, gels…), its name and photo count. User packs show their
+ * reference photos.
*/
-export function PackCover({ id, name, count, className, refs, bare }: { id: string; name: string; count: number; className?: string; refs?: string[]; bare?: boolean }) {
- const h = hueOf(id);
- // One hue family per pack (a little drift and different light per tile), so packs read apart at a glance.
- const tiles = [
- [0, 0.82],
- [18, 0.66],
- [-16, 0.58],
- [34, 0.74],
- ].map(([d, l], i) => `linear-gradient(${140 + i * 35}deg, oklch(${l} 0.11 ${(h + d + 360) % 360}), oklch(${l - 0.24} 0.13 ${(h + d + 30 + 360) % 360}))`);
+export function PackCover({
+ id,
+ name,
+ count,
+ className,
+ refs,
+ bare,
+ hue,
+ tone = "plain",
+}: {
+ id: string;
+ name: string;
+ count: number;
+ className?: string;
+ refs?: string[];
+ bare?: boolean;
+ hue?: number;
+ tone?: CoverTone;
+}) {
+ const h = hue ?? hueOf(id);
return (
<span className={cn("relative block overflow-hidden bg-muted", className)}>
<span className="grid size-full grid-cols-2 grid-rows-2 gap-0.5">
- {tiles.map((bg, i) =>
+ {[0, 1, 2, 3].map((i) =>
refs?.[i] ? (
// eslint-disable-next-line @next/next/no-img-element
<img key={i} src={refs[i]} alt="" loading="lazy" className="size-full object-cover" />
) : (
- <span key={i} style={{ background: bg }} />
+ <DrawnTile key={i} hue={(h + [0, 18, -16, 34][i] + 360) % 360} tone={tone} k={i} className="size-full" />
),
)}
</span>
diff --git a/src/components/photodump/hooks.ts b/src/components/photodump/hooks.ts
index bdc32af1..209e398a 100644
--- a/src/components/photodump/hooks.ts
+++ b/src/components/photodump/hooks.ts
@@ -17,6 +17,8 @@ export interface RunPreview {
count?: number;
costUsd?: number | null;
demo?: boolean;
+ /** The model keeps the input photo's shape (no aspect ratio setting: Qwen-Image-Edit, try-on). */
+ fixedAspect?: boolean;
notes: string[];
error?: string;
}
@@ -51,6 +53,18 @@ export function useRun<B>(url: string) {
});
}
+/** Retry a failed photo inside its run (same batch); the failed one goes to the Trash. */
+export function useRetryPhoto() {
+ const qc = useQueryClient();
+ return useMutation({
+ mutationFn: (id: string) => post<{ items: Generation[] }>("/api/photodump/retry", { id }),
+ onSuccess: () => {
+ void qc.invalidateQueries({ queryKey: ["generations"] });
+ void qc.invalidateQueries({ queryKey: ["library"] });
+ },
+ });
+}
+
export function useUserPacks() {
return useQuery({ queryKey: ["photodump-packs"], queryFn: async () => (await json<{ packs: UserPack[] }>(await fetch("/api/photodump/packs"))).packs });
}
diff --git a/src/components/photodump/photodump-view.tsx b/src/components/photodump/photodump-view.tsx
index 6784e0de..1a28c497 100644
--- a/src/components/photodump/photodump-view.tsx
+++ b/src/components/photodump/photodump-view.tsx
@@ -2,7 +2,7 @@
import { ArrowLeft, ArrowRight, History, Library, Loader2, Plus, RotateCcw, Search, Trash2, X } from "lucide-react";
import Link from "next/link";
-import { useMemo, useState } from "react";
+import { useMemo, useRef, useState } from "react";
import { toast } from "sonner";
import { PageHeader, PageShell } from "@/components/page-shell";
import { Button } from "@/components/ui/button";
@@ -11,14 +11,14 @@ import { Input } from "@/components/ui/input";
import { EngineSwitch } from "@/components/studio/engine-switch";
import { fileToList, type SlotValue } from "@/components/studio/media-slot";
import { radioKeys, radioTab } from "@/components/studio/radio-keys";
-import { useEngine, useGenerations } from "@/lib/api";
+import { useElements, useEngine, useGenerations } from "@/lib/api";
import { customPack, DEFAULT_ASPECT, MAX_PACK_REFS, MAX_SELFIE_MB, PACKS, PHOTODUMP_ASPECTS, PHOTODUMP_MODELS, type Pack } from "@/lib/catalog/packs";
import type { Generation } from "@/lib/catalog/types";
import { timeAgo } from "@/lib/format";
import { cn } from "@/lib/utils";
import { PackCover } from "./covers";
import { useRun, useRunPreview, usePackActions, useUserPacks } from "./hooks";
-import { DownloadAll, ResultsGrid } from "./results";
+import { DownloadAll, ResultsGrid, runState } from "./results";
import { RunLine, Steps } from "./steps";
import { CharacterPicker } from "./subject";
import { UploadBox } from "./upload-box";
@@ -46,6 +46,7 @@ const ratioOf = (a: string) => {
function CreatePack({ open, onOpenChange, onCreated }: { open: boolean; onOpenChange: (o: boolean) => void; onCreated: (id: string) => void }) {
const [name, setName] = useState("");
const [refs, setRefs] = useState<SlotValue[]>([]);
+ const fileInput = useRef<HTMLInputElement>(null);
const { create } = usePackActions();
const busy = refs.some((r) => r.uploading);
return (
@@ -73,18 +74,23 @@ function CreatePack({ open, onOpenChange, onCreated }: { open: boolean; onOpenCh
</div>
))}
{refs.length < MAX_PACK_REFS && (
- <label className="grid aspect-square cursor-pointer place-items-center rounded-md border border-dashed text-muted-foreground hover:bg-accent">
+ <button
+ type="button"
+ onClick={() => fileInput.current?.click()}
+ aria-label="Add reference photos"
+ className="grid aspect-square place-items-center rounded-md border border-dashed text-muted-foreground outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring"
+ >
<Plus className="size-4" />
- <span className="sr-only">Add reference photos</span>
- <input
- type="file"
- accept="image/png,image/jpeg,image/webp"
- multiple
- hidden
- onChange={(e) => ([...(e.target.files ?? [])].slice(0, MAX_PACK_REFS - refs.length).forEach((f) => fileToList(f, setRefs, "image")), (e.target.value = ""))}
- />
- </label>
+ </button>
)}
+ <input
+ ref={fileInput}
+ type="file"
+ accept="image/png,image/jpeg,image/webp"
+ multiple
+ hidden
+ onChange={(e) => ([...(e.target.files ?? [])].slice(0, MAX_PACK_REFS - refs.length).forEach((f) => fileToList(f, setRefs, "image")), (e.target.value = ""))}
+ />
</div>
<DialogFooter>
<Button
@@ -170,13 +176,25 @@ export function PhotodumpView() {
};
const subjectReady = subjectMode === "selfie" ? !!selfie?.ref && !selfie.uploading : !!elementId;
+ // The Model choice follows the engine: a pick the other engine had counts as Auto (one radio is always checked).
+ const elements = useElements();
+ const character = subjectMode === "character" ? elements.data?.find((e) => e.id === elementId) : undefined;
+ const choices: (string | undefined)[] = [undefined, ...PHOTODUMP_MODELS[engine]];
+ const unavailable = (m?: string): string | null => {
+ if (m !== "oss-z-image-turbo") return null;
+ if (pack?.custom) return "Your own packs recreate each reference photo with Qwen-Image-Edit";
+ if (!character) return "Needs a character with a trained LoRA";
+ return character.loras.some((l) => l.modelId === "oss-z-image-turbo" && l.engine === "open" && !l.referenceId) ? null : `${character.name} has no trained LoRA yet`;
+ };
+ const pick = choices.includes(modelPick) && !unavailable(modelPick) ? modelPick : undefined;
const body = pack && subjectReady
- ? { packId: pack.id, engine, aspectRatio: aspect, modelId: modelPick, ...(subjectMode === "selfie" ? { selfie: selfie!.ref } : { elementId }) }
+ ? { packId: pack.id, engine, aspectRatio: aspect, modelId: pick, ...(subjectMode === "selfie" ? { selfie: selfie!.ref } : { elementId }) }
: null;
const preview = useRunPreview("/api/photodump", step === 1 ? body : null);
+ const fixedAspect = !!body && !!preview.data?.fixedAspect;
const current = runs.find((r) => r.batchId === batchId);
const items = current?.items ?? [];
- const finished = items.length > 0 && items.every((g) => g.status !== "queued" && g.status !== "running");
+ const state = runState(items);
const product = pack?.product === "photodump" ? "Photodump" : "Instadump";
const generate = () => {
@@ -236,7 +254,7 @@ export function PhotodumpView() {
onDoubleClick={() => (setPackId(p.id), go(1))}
className={cn("block w-full overflow-hidden rounded-xl text-left outline-none focus-visible:ring-2 focus-visible:ring-ring", sel && "ring-3 ring-primary")}
>
- <PackCover id={p.id} name={p.name} count={p.count} refs={p.refs} className="aspect-[3/4]" />
+ <PackCover id={p.id} name={p.name} count={p.count} refs={p.refs} hue={p.hue} tone={p.tone} className="aspect-[3/4]" />
</button>
<p className="mt-1.5 line-clamp-2 px-0.5 text-[12px] text-muted-foreground">
{p.custom ? "Your pack" : p.product === "instadump" ? `Instadump${p.author ? ` · by ${p.author}` : ""}` : "Soul 2.0 Photodump"} · {p.description}
@@ -320,7 +338,7 @@ export function PhotodumpView() {
</div>
<aside className="space-y-5 rounded-2xl border p-4 lg:sticky lg:top-6 lg:self-start">
<div className="flex items-center gap-3">
- <PackCover id={pack.id} name={pack.name} count={pack.count} refs={pack.refs} bare className="size-14 shrink-0 rounded-lg" />
+ <PackCover id={pack.id} name={pack.name} count={pack.count} refs={pack.refs} hue={pack.hue} tone={pack.tone} bare className="size-14 shrink-0 rounded-lg" />
<div className="min-w-0">
<p className="truncate text-[14px] font-medium">{pack.name}</p>
<p className="text-[12px] text-muted-foreground">{pack.count} photos</p>
@@ -328,9 +346,22 @@ export function PhotodumpView() {
</div>
<div className="space-y-2">
<p className="text-[12.5px] font-medium">Aspect ratio</p>
- <div role="radiogroup" aria-label="Aspect ratio" onKeyDown={radioKeys} className="flex flex-wrap gap-1">
+ {/* A model that keeps the photo's shape (Qwen-Image-Edit) ignores the aspect ratio: the picker is off and the run line says why. */}
+ <div role="radiogroup" aria-label="Aspect ratio" aria-disabled={fixedAspect || undefined} onKeyDown={radioKeys} className="flex flex-wrap gap-1">
{PHOTODUMP_ASPECTS.map((a) => (
- <button key={a} role="radio" aria-checked={aspect === a} tabIndex={radioTab(aspect === a)} onClick={() => setAspect(a)} className={cn("h-8 rounded-full border px-2.5 text-[12.5px] font-medium transition-colors", aspect === a ? "border-primary bg-brand-faint text-brand-text" : "text-muted-foreground hover:bg-accent")}>
+ <button
+ key={a}
+ role="radio"
+ aria-checked={aspect === a}
+ tabIndex={radioTab(aspect === a)}
+ disabled={fixedAspect && aspect !== a}
+ onClick={() => setAspect(a)}
+ className={cn(
+ "h-8 rounded-full border px-2.5 text-[12.5px] font-medium transition-colors disabled:opacity-40",
+ aspect === a ? "border-primary bg-brand-faint text-brand-text" : "text-muted-foreground hover:bg-accent",
+ fixedAspect && aspect === a && "opacity-60",
+ )}
+ >
{a === "auto" ? "Auto" : a}
</button>
))}
@@ -339,11 +370,27 @@ export function PhotodumpView() {
<div className="space-y-2">
<p className="text-[12.5px] font-medium">Model</p>
<div role="radiogroup" aria-label="Model" onKeyDown={radioKeys} className="flex flex-wrap gap-1">
- {[undefined, ...PHOTODUMP_MODELS[engine]].map((m) => (
- <button key={m ?? "auto"} role="radio" aria-checked={modelPick === m} tabIndex={radioTab(modelPick === m)} onClick={() => setModelPick(m)} className={cn("h-8 rounded-full border px-2.5 text-[12.5px] font-medium transition-colors", modelPick === m ? "border-primary bg-brand-faint text-brand-text" : "text-muted-foreground hover:bg-accent")}>
- {m ? MODEL_NAMES[m] : "Auto"}
- </button>
- ))}
+ {choices.map((m) => {
+ const why = unavailable(m);
+ return (
+ <button
+ key={m ?? "auto"}
+ role="radio"
+ aria-checked={pick === m}
+ tabIndex={radioTab(pick === m)}
+ disabled={!!why}
+ title={why ?? undefined}
+ aria-label={why ? `${m ? MODEL_NAMES[m] : "Auto"} — ${why}` : undefined}
+ onClick={() => setModelPick(m)}
+ className={cn(
+ "h-8 rounded-full border px-2.5 text-[12.5px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-40",
+ pick === m ? "border-primary bg-brand-faint text-brand-text" : "text-muted-foreground hover:bg-accent",
+ )}
+ >
+ {m ? MODEL_NAMES[m] : "Auto"}
+ </button>
+ );
+ })}
</div>
</div>
<RunLine preview={body ? preview.data : undefined} loading={preview.isFetching} />
@@ -365,7 +412,13 @@ export function PhotodumpView() {
<div className="min-w-0">
<h2 className="font-heading text-[26px] leading-tight">Get your {product}</h2>
<p className="text-[14px] text-muted-foreground">
- {!items.length ? "Starting…" : finished ? "Your new photos are ready - download, post, share and enjoy!" : `Making ${items.length} photos — they appear here as they finish.`}
+ {!items.length
+ ? "Starting…"
+ : state.busy
+ ? `Making ${state.total} photos — they appear here as they finish.`
+ : state.failed
+ ? `${state.done} of ${state.total} photos are ready — retry the ${state.failed === 1 ? "one" : "ones"} that didn't make it.`
+ : "Your new photos are ready - download, post, share and enjoy!"}
</p>
</div>
<div className="flex flex-wrap gap-2">
diff --git a/src/components/photodump/results.tsx b/src/components/photodump/results.tsx
index 99229194..0ff513d9 100644
--- a/src/components/photodump/results.tsx
+++ b/src/components/photodump/results.tsx
@@ -1,15 +1,16 @@
"use client";
-import { Check, Download, Film, Maximize2, Pencil, Trash2 } from "lucide-react";
+import { Check, Download, Film, Loader2, Maximize2, Pencil, RotateCcw, Trash2 } from "lucide-react";
import Link from "next/link";
import { useMemo, useState } from "react";
import { toast } from "sonner";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
-import { FailedTile, MediaThumb, PendingTile } from "@/components/studio/feed";
+import { MediaThumb, PendingTile } from "@/components/studio/feed";
import { Viewer } from "@/components/studio/viewer";
-import { useCreateGeneration, useGenerationActions } from "@/lib/api";
+import { useGenerationActions } from "@/lib/api";
import type { Generation, OutputFile } from "@/lib/catalog/types";
import { cn } from "@/lib/utils";
+import { useRetryPhoto } from "./hooks";
export interface Tile {
g: Generation;
@@ -54,6 +55,40 @@ function IconLink({ href, label, icon: Icon, onClick }: { href?: string; label:
);
}
+/** A photo that failed or was canceled: which one it was ("Photo 3 of 9"), why, and Retry (inside the run). */
+function RetryTile({ g, ratio, busy, onRetry }: { g: Generation; ratio: number; busy: boolean; onRetry: () => void }) {
+ const which = g.request.step?.label;
+ return (
+ <div className="flex flex-col justify-between rounded-xl border border-dashed bg-background p-3" style={{ aspectRatio: Math.max(ratio, 0.8) }}>
+ <div className="min-h-0 space-y-1 overflow-hidden">
+ {which && <p className="text-[11.5px] font-medium text-muted-foreground">{which}</p>}
+ <p className="text-[13px] font-medium">{g.status === "canceled" ? "Canceled" : "Couldn't generate this one"}</p>
+ {g.error && <p className="line-clamp-4 text-[12px] leading-snug break-words whitespace-pre-line text-muted-foreground">{g.error}</p>}
+ </div>
+ <button
+ type="button"
+ onClick={onRetry}
+ disabled={busy}
+ aria-label={`Retry ${which ?? "this photo"}`}
+ className="mt-2 inline-flex h-7 w-fit items-center gap-1.5 rounded-full bg-secondary px-2.5 text-[12px] font-medium outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring/50 disabled:opacity-60"
+ >
+ {busy ? <Loader2 className="size-3 animate-spin" /> : <RotateCcw className="size-3" />} Retry
+ </button>
+ </div>
+ );
+}
+
+/** How a run is doing: everything made, some still rendering, or some that failed. */
+export function runState(items: Generation[]): { total: number; done: number; failed: number; busy: boolean } {
+ const tiles = tilesOf(items);
+ return {
+ total: tiles.length,
+ done: tiles.filter((t) => t.o).length,
+ failed: items.filter((g) => g.status === "failed" || g.status === "canceled").length,
+ busy: items.some((g) => g.status === "queued" || g.status === "running"),
+ };
+}
+
/**
* A grid of results: placeholders while they render, a retry card when one fails, and finished images
* with Animate / Edit / Delete. With `onPick`, clicking an image selects it (Fashion Factory's "pick 1")
@@ -65,18 +100,21 @@ export function ResultsGrid({
picked,
onPick,
className,
+ onRetried,
}: {
items: Generation[];
ratio?: number;
picked?: string;
onPick?: (url: string) => void;
className?: string;
+ /** A failed photo was retried: `from` is replaced by `to` (runs that track their generation ids). */
+ onRetried?: (from: string, to: string[]) => void;
}) {
const tiles = useMemo(() => tilesOf(items), [items]);
const done = tiles.filter((t) => t.o);
const [open, setOpen] = useState<number | null>(null);
const { trash } = useGenerationActions();
- const create = useCreateGeneration();
+ const retry = useRetryPhoto();
const viewing = open !== null ? done[open] : undefined;
return (
<>
@@ -85,11 +123,17 @@ export function ResultsGrid({
if (!t.o) {
if (t.g.status === "queued" || t.g.status === "running") return <PendingTile key={t.key} g={t.g} ratio={ratio} />;
return (
- <FailedTile
+ <RetryTile
key={t.key}
g={t.g}
ratio={ratio}
- onRetry={() => create.mutate({ ...t.g.request, title: undefined, batchTitle: undefined }, { onError: (e) => toast.error((e as Error).message) })}
+ busy={retry.isPending && retry.variables === t.g.id}
+ onRetry={() =>
+ retry.mutate(t.g.id, {
+ onSuccess: (r) => onRetried?.(t.g.id, r.items.map((x) => x.id)),
+ onError: (e) => toast.error((e as Error).message),
+ })
+ }
/>
);
}
diff --git a/src/components/photodump/subject.tsx b/src/components/photodump/subject.tsx
index 5e066071..28ef5efb 100644
--- a/src/components/photodump/subject.tsx
+++ b/src/components/photodump/subject.tsx
@@ -2,7 +2,7 @@
import { Check, Loader2, Plus, UserRound, X } from "lucide-react";
import Link from "next/link";
-import { useState } from "react";
+import { useRef, useState } from "react";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
@@ -20,21 +20,50 @@ export function identityLabel(el: StudioElement): string {
return `${el.references.length} photo${el.references.length === 1 ? "" : "s"}`;
}
-/** Create a character from a few photos, without leaving the page. */
+/** Higgsfield's character-creation copy (docs/research/higgsfield-image-studios.md §2). */
+const CREATE_COPY = {
+ more: "Upload 20+ photos for best results",
+ moreTitle: "More Photos, Better Results",
+ avoidTitle: "Avoid These Types of Photos",
+ avoid: "No duplicates, group shots, pets, nudes, filters, face-covering accessories, or masks",
+ consent: "By clicking Save character, I consent to this biometric data processing and confirm these photos are of me or of a person at least 18 years old who gave written permission.",
+} as const;
+
+const MAX_PHOTOS = 20;
+
+/** Create a character from photos of one person, without leaving the page. */
export function QuickCharacter({ open, onOpenChange, onCreated }: { open: boolean; onOpenChange: (o: boolean) => void; onCreated: (el: StudioElement) => void }) {
const [name, setName] = useState("");
const [photos, setPhotos] = useState<SlotValue[]>([]);
+ const [over, setOver] = useState(false);
+ const fileInput = useRef<HTMLInputElement>(null);
const save = useSaveElement();
const busy = photos.some((p) => p.uploading);
+ const addFiles = (files: Iterable<File>) => [...files].filter((f) => /^image\/(png|jpe?g|webp)$/.test(f.type)).slice(0, MAX_PHOTOS - photos.length).forEach((f) => fileToList(f, setPhotos, "image"));
return (
<Dialog open={open} onOpenChange={onOpenChange}>
- <DialogContent className="sm:max-w-md">
+ <DialogContent
+ className="max-h-[92svh] overflow-y-auto sm:max-w-md"
+ onPaste={(e) => addFiles(e.clipboardData.files)}
+ onDragOver={(e) => (e.preventDefault(), setOver(true))}
+ onDragLeave={() => setOver(false)}
+ onDrop={(e) => {
+ e.preventDefault();
+ setOver(false);
+ addFiles(e.dataTransfer.files);
+ }}
+ >
<DialogHeader>
<DialogTitle>New character</DialogTitle>
- <DialogDescription>A few clear photos of one person: different angles, at least one full-body, no sunglasses, filters or group shots.</DialogDescription>
+ <DialogDescription>
+ <span className="font-medium text-foreground">{CREATE_COPY.moreTitle}</span> · {CREATE_COPY.more}: different angles, at least one full-body.
+ </DialogDescription>
</DialogHeader>
+ <p className="rounded-lg bg-destructive/10 px-3 py-2 text-[12.5px]">
+ <span className="font-medium">{CREATE_COPY.avoidTitle}</span> · {CREATE_COPY.avoid}
+ </p>
<Input value={name} onChange={(e) => setName(e.target.value)} placeholder="Name, e.g. “Maya”" maxLength={60} aria-label="Character name" />
- <div className="grid grid-cols-4 gap-1.5">
+ <div className={cn("grid grid-cols-4 gap-1.5 rounded-lg transition-colors", over && "bg-brand-faint")}>
{photos.map((p, i) => (
<div key={p.id ?? i} className="relative aspect-square overflow-hidden rounded-md bg-muted">
{/* eslint-disable-next-line @next/next/no-img-element */}
@@ -49,17 +78,25 @@ export function QuickCharacter({ open, onOpenChange, onCreated }: { open: boolea
</button>
</div>
))}
- {photos.length < 20 && (
- <label className="grid aspect-square cursor-pointer place-items-center rounded-md border border-dashed text-muted-foreground hover:bg-accent">
+ {photos.length < MAX_PHOTOS && (
+ <button
+ type="button"
+ onClick={() => fileInput.current?.click()}
+ aria-label="Add photos"
+ className="grid aspect-square place-items-center rounded-md border border-dashed text-muted-foreground outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring"
+ >
<Plus className="size-4" />
- <span className="sr-only">Add photos</span>
- <input type="file" accept="image/png,image/jpeg,image/webp" multiple hidden onChange={(e) => ([...(e.target.files ?? [])].slice(0, 20 - photos.length).forEach((f) => fileToList(f, setPhotos, "image")), (e.target.value = ""))} />
- </label>
+ </button>
)}
</div>
+ <input ref={fileInput} type="file" accept="image/png,image/jpeg,image/webp" multiple hidden onChange={(e) => (addFiles(e.target.files ?? []), (e.target.value = ""))} />
+ <p className="text-[11.5px] text-muted-foreground tabular-nums">
+ {photos.length}/{MAX_PHOTOS} photos · PNG, JPG or paste
+ </p>
<p className="text-[12px] text-muted-foreground">
Or <Link href="/character-sheet" className="text-brand-text hover:underline">build one with Character Sheet</Link>, then pick it here.
</p>
+ <p className="text-[11.5px] leading-snug text-muted-foreground">{CREATE_COPY.consent}</p>
<DialogFooter>
<Button
disabled={!name.trim() || !photos.length || busy || save.isPending}
diff --git a/src/lib/catalog/packs.ts b/src/lib/catalog/packs.ts
index bf735614..c1e16309 100644
--- a/src/lib/catalog/packs.ts
+++ b/src/lib/catalog/packs.ts
@@ -41,6 +41,31 @@ export function hueOf(s: string): number {
return (h >>> 0) % 360;
}
+/** Evenly spread hues for the i-th cover of a set (the golden angle: neighbours never share a band). */
+export const spreadHue = (i: number, offset = 18) => Math.round((offset + i * 137.508) % 360);
+
+/**
+ * How a drawn cover is treated (Fuobe ships no sample photos, so the cover is the only cue): black and
+ * white with grain, a hard flash hotspot, red and blue gels, a pastel wash, film grain, a spotlight in
+ * the dark, or a plain gradient in the look's hue.
+ */
+export type CoverTone = "mono" | "flash" | "gel" | "pastel" | "film" | "spot" | "plain";
+
+const TONES: [RegExp, CoverTone][] = [
+ [/black-and-white|\bb\s?&\s?w\b|\bbw\b|monochrome|noir|grayscale|greyscale/i, "mono"],
+ [/\bgels?\b|neon|solaris/i, "gel"],
+ [/flash|digicam|disposable|paparazzi/i, "flash"],
+ [/pastel|candy|bubbles|\baqua\b/i, "pastel"],
+ [/\bfilm\b|grain|noise|low-res|vintage|nostalgi|retro|35mm|vhs/i, "film"],
+ [/spotlight|shadows|\bdark\b|moody|melanchol|night/i, "spot"],
+];
+
+/** A look's cover treatment from its name and description ("Retro BW" → mono, "80s horror" → gel). */
+export function coverTone(...words: (string | undefined)[]): CoverTone {
+ const text = words.filter(Boolean).join(" ");
+ return TONES.find(([re]) => re.test(text))?.[1] ?? "plain";
+}
+
const isSoulSource = (s: string): s is SoulPresetModel => s === "soul-v1" || s === "soul-v2";
/**
@@ -317,15 +342,31 @@ const PACK_LOOK: Record<string, string> = {
"editorial-shots": "High-end fashion magazine editorial",
};
+/** Each pack's drawn cover, set by hand so the 14 read apart (hues are spread by position). */
+const PACK_TONE: Record<string, CoverTone> = {
+ "sleepy-head": "pastel",
+ "alter-ego": "spot",
+ "cool-girl-dump": "film",
+ "male-archive": "film",
+ "winter-special": "pastel",
+ "aura-farming": "spot",
+ "2000s-nostalgia": "flash",
+ "editorial-shots": "mono",
+ "surreal-self-ii": "gel",
+};
+
export interface Pack extends PackMeta {
shots: string[];
look: string;
/** User packs: one reference photo per shot (the photo to recreate). */
refs?: string[];
custom?: boolean;
+ /** The drawn cover: its hue and treatment. */
+ hue: number;
+ tone: CoverTone;
}
-export const PACKS: Pack[] = PHOTODUMP_PACKS.map((p) => ({ ...p, shots: SHOTS[p.id] ?? [], look: PACK_LOOK[p.id] ?? "" }));
+export const PACKS: Pack[] = PHOTODUMP_PACKS.map((p, i) => ({ ...p, shots: SHOTS[p.id] ?? [], look: PACK_LOOK[p.id] ?? "", hue: spreadHue(i), tone: PACK_TONE[p.id] ?? "plain" }));
export const getPack = (id: string) => PACKS.find((p) => p.id === id);
/** A user's own pack (Instadump's "Create pack"): up to 15 reference photos to recreate. */
@@ -354,6 +395,8 @@ export function customPack(p: CustomPackLike): Pack {
look: "",
refs: p.refs,
custom: true,
+ hue: hueOf(p.id),
+ tone: "plain",
};
}
@@ -386,7 +429,16 @@ const turboLora = (s: PhotoSubject) => (s.kind === "element" ? s.loras.find((l)
export function photodumpModel(subject: PhotoSubject, engine: Engine, caps: PlanCaps, pick?: string, custom = false): { modelId: string; note?: string } {
if (engine === "open") {
if (!custom && turboLora(subject) && pick !== "oss-qwen-edit") return { modelId: "oss-z-image-turbo" };
- return { modelId: "oss-qwen-edit", note: subject.kind === "element" && !turboLora(subject) && !custom ? "No trained LoRA yet — Qwen-Image-Edit works from the character's photos" : undefined };
+ // Say why when the pick (or a character without a LoRA) ends up on Qwen-Image-Edit.
+ const note =
+ pick === "oss-z-image-turbo" && custom
+ ? "Your own packs recreate each reference photo — Qwen-Image-Edit runs them"
+ : pick === "oss-z-image-turbo" && subject.kind === "selfie"
+ ? "Z-Image Turbo + LoRA needs a character with a trained LoRA — Qwen-Image-Edit works from your photo"
+ : subject.kind === "element" && !turboLora(subject) && !custom
+ ? "No trained LoRA yet — Qwen-Image-Edit works from the character's photos"
+ : undefined;
+ return { modelId: "oss-qwen-edit", note };
}
if (!custom && soulId(subject) && caps.higgsfield && (!pick || pick === "soul-2")) return { modelId: "soul-2" };
const m = pick === "seedream-5-pro" ? "seedream-5-pro" : "nano-banana-pro";
@@ -663,6 +715,8 @@ export type FashionAction =
| { type: "outfitStarted"; ids: string[] }
| { type: "pickOutfit"; url: string }
| { type: "photosetStarted"; batchId: string }
+ /** A failed base shot or outfit was retried: its new generation(s) take its place. */
+ | { type: "retried"; from: string; to: string[] }
| { type: "reset" };
/** The exact message Higgsfield shows when a step can't go on, or null. */
@@ -714,6 +768,12 @@ export function fashionReducer(s: FashionState, a: FashionAction): FashionState
return { ...s, outfit: a.url };
case "photosetStarted":
return { ...s, step: "photoset", photosetBatch: a.batchId };
+ case "retried": {
+ const swap = (ids: string[]) => (ids.includes(a.from) ? ids.flatMap((id) => (id === a.from ? a.to : [id])) : ids);
+ const baseIds = swap(s.baseIds);
+ const outfitIds = swap(s.outfitIds);
+ return baseIds === s.baseIds && outfitIds === s.outfitIds ? s : { ...s, baseIds, outfitIds };
+ }
case "reset":
return FASHION_START;
}
@@ -734,6 +794,8 @@ export function sheetFromReference(images: string[], engine: Engine, details?: s
const notes: string[] = [];
const max = engine === "open" ? 3 : SHEET_MAX_REFS;
if (images.length > max) notes.push(`Qwen-Image-Edit takes 3 photos — the first 3 are used`);
+ // The open workflow has no size setting: the sheet comes out in the first photo's shape.
+ if (engine === "open") notes.push("Qwen-Image-Edit keeps the shape of your first photo — put a landscape photo first for a wide sheet");
const extra = details?.trim().replace(/[.\s]+$/, "");
return {
request: {
diff --git a/src/server/photodump.ts b/src/server/photodump.ts
index c83fe42e..7b62c14b 100644
--- a/src/server/photodump.ts
+++ b/src/server/photodump.ts
@@ -21,7 +21,8 @@ import type { Engine, Generation, GenerationRequest } from "@/lib/catalog/types"
import { createPipeline } from "./chains";
import { db } from "./db";
import { getElement } from "./elements";
-import { createGenerations, previewGeneration } from "./generations";
+import { createGenerations, getGeneration, previewGeneration } from "./generations";
+import { trashGenerations } from "./library";
import { higgsfieldKey } from "./providers/higgsfield";
import { engineMode } from "./settings";
@@ -129,13 +130,17 @@ export function previewRun(requests: GenerationRequest[], notes: string[] = [])
const previews = requests.map((r) => previewGeneration(fitted(r)));
const first = previews[0];
const costs = previews.map((p) => p.costUsd);
+ // No aspect ratio setting (Qwen-Image-Edit's open workflow): the result follows image 1's shape — say so.
+ const fixedAspect = !first.model.options.aspectRatios?.length;
+ const asked = requests.some((r) => r.params?.aspectRatio && r.params.aspectRatio !== "auto");
return {
modelId: first.model.id,
modelName: first.model.name,
count: previews.reduce((n, p) => n + p.outputs, 0),
costUsd: costs.some((c) => c === null) ? null : Math.round(costs.reduce((a, b) => a! + b!, 0)! * 1000) / 1000,
demo: previews.some((p) => p.demo),
- notes,
+ fixedAspect,
+ notes: fixedAspect && asked ? [...notes, `${first.model.name} keeps the shape of your photo — the aspect ratio doesn't apply`] : notes,
};
} catch (e) {
return { error: (e as Error).message, notes };
@@ -152,6 +157,28 @@ export function createBatch(requests: GenerationRequest[], title: string): { bat
return { batchId, items };
}
+/** The features whose photos can be retried from their run's grid (Photodump, Fashion Factory, Character Sheet). */
+const RETRY_FEATURES = new Set(["photodump", "fashion", "character-sheet", "app:app-ai-influencer"]);
+
+/**
+ * Run a failed or canceled photo again inside its run: the same request in the same batch (so the
+ * run's grid, Download all and the Library stack keep it), and the failed one goes to the Trash.
+ * A job that was one of several made from one request (×4 base shots on a one-per-job model) is
+ * retried as one job of its own share of photos.
+ */
+export function retryPhoto(id: string): Generation[] {
+ const g = getGeneration(id);
+ if (!g) throw new Error("That photo is gone");
+ if (!RETRY_FEATURES.has(g.feature)) throw new Error("This result isn't part of a photo run");
+ if (g.status !== "failed" && g.status !== "canceled") throw new Error("Only a failed or canceled photo can be retried");
+ const req = fitted(g.request);
+ const p = previewGeneration(req);
+ const per = p.jobs > 1 ? Math.max(1, Math.round(p.outputs / p.jobs)) : undefined;
+ const items = createGenerations(per ? { ...req, params: { ...req.params, numOutputs: per } } : req, g.batchId ? { batchId: g.batchId } : {});
+ trashGenerations([id]);
+ return items;
+}
+
// ---------------------------------------------------------------------------
// Photodump