The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Originals O5: /genjutsu Character swap mode, source badges, Soul looks; no Higgsfield
Claude586d48f77ec3
diff --git a/scripts/comfy/README.md b/scripts/comfy/README.mdindex 8a682916..654a40d4 100644--- a/scripts/comfy/README.md+++ b/scripts/comfy/README.md@@ -286,6 +286,36 @@ node validate-workflows.mjs image-to-3d-trellis2-multiview image-to-3d-trellis2- **Not open**: rigging. UniRig (MIT) has no ComfyUI pack verified against v0.41, so Rig & animate is Meshy on fal only.SAM 3D Objects has no open route either (the core SAM 3D nodes are body only).+### Genjutsu Character swap (o/genjutsu-original, 2026-10-27)++Two hand-built entries for Genjutsu's Character swap on MiniMax H3 (docs/research/openjutsu-6.md):++```bash+npm run build -- video-character-swap-h3 video-character-swap-h3-relay+node validate-workflows.mjs video-character-swap-h3 video-character-swap-h3-relay --shared+```++| id | capability | what | validated here |+|---|---|---|---|+| `video-character-swap-h3` | video-character-swap | Openjutsu's `swap.api.json` (Akatz Labs' H3 Character Swap graph at `0670e4f` with a `Video Slice` in front): the part (start + length, 5–15 s, longer continues window by window), quality as the unpatched pack's string (`"480"` / `"768"`), H3 reference tags in the prompt, who to swap (SAM 3.1 words, largest / leftmost / rightmost / index, or clicks as JSON points on H3's canvas), the anchor first frame as `image2` (absent: its loader and fit are deleted and the shot's `use_anchor` is off), the swap LoRA release (V1.5, V1, or none: the Turbo LoRA alone) | no: `missing_node_type` (the `h3_character_swap` nodes are not on this server; its 22 core nodes are in `object_info.subset.json`) |+| `video-character-swap-h3-relay` | video-character-swap | H3 Relay 2.0's character-swap example (akatz-ai/h3-relay at `e2a7665b`) with a `Video Slice`: the same part, quality, words, seed and who; no anchor | no: `missing_node_type` (`H3RelayAppendWindow`) |++- **Node packs**: `h3_character_swap` (GPL-3.0) is copied out of `akatz-labs/h3-character-swap-tool` at+ `0670e4fdf95adf2262caa4b81afed2a9c4ae4b7b` by `install-comfyui.sh` (`H3_PACK=0` skips it; it needs FFmpeg and FFprobe on+ PATH). H3 Relay (GPL-3.0) registers HTTP routes and patches H3's layout in memory when it loads, so it is opt-in:+ `H3_RELAY=1` clones it at `e2a7665b6eb8ea37a88c0de2c9c6b69a8f7c9220`. Neither pack is installed on the CPU server+ these graphs were built on, so both entries are recorded with `validated: false` and the missing node named.+- **Weights** (46.33 GB, pinned to Hugging Face revisions in `library.spec.mjs`): H3 Ref2VA int8, its video and audio VAEs and+ the NVFP4 Qwen3-VL text encoder (Comfy-Org/MiniMax-H3), lightx2v's FL2V Turbo 8-step LoRA, SAM 3.1, and Akatz Labs'+ Character Swap LoRA V1.5 (V1 optional). The provider downloads the two LoRAs before a run (`graphLoras`).+- **Licences, as information**: MiniMax H3 Community License (territory excludes the US, the EU, the UK and South Korea;+ over US$20M yearly revenue needs MiniMax's written authorization; show "MiniMax H3"), Meta's SAM License, Apache-2.0+ (Turbo LoRA), GPL-3.0 (both packs). The admin decides what runs (Settings → Models & licences).+- **GPU**: tested by their authors on a 96 GB RTX PRO 6000 and on a 24 GB RTX 4090 with 128 GB RAM and offloading.+- **Comfy Developer Platform** (what Openjutsu deploys to): a deployment is not a plain ComfyUI server — it is driven by+ the v2 API (`@comfyorg/sdk`: upload, job, poll), not `/prompt` and `/history` — so Fuobe does not add a provider for it.+ Point `COMFYUI_URL` at a ComfyUI that has the packs installed instead.+## Adding a workflow1. Find the template name in `$COMFYUI_DIR/.venv/lib/python3.*/site-packages/comfyui_workflow_templates_json/templates/index.json`diff --git a/src/components/genjutsu/character-panel.tsx b/src/components/genjutsu/character-panel.tsxnew file mode 100644index 00000000..f04c7fec--- /dev/null+++ b/src/components/genjutsu/character-panel.tsx@@ -0,0 +1,284 @@+"use client";++import { Cpu, Scale, TriangleAlert } from "lucide-react";+import { Input } from "@/components/ui/input";+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";+import { Switch } from "@/components/ui/switch";+import { Textarea } from "@/components/ui/textarea";+import { Field, Segmented } from "@/components/shorts/ui";+import {+ ANCHOR_MODELS,+ anchorModel,+ CHARACTER_GPU,+ CHARACTER_LIMITS,+ CHARACTER_SWAP,+ characterLicenceLine,+ HISTORY_CHOICES,+ SPEECH_LABELS,+ SWAP_LORAS,+ WHO_LABELS,+ WINDOW_CHOICES,+ type CharacterOptions,+ type CharacterQuality,+ type SwapLora,+ type SwapSpeech,+ type SwapWho,+} from "@/lib/catalog/character-swap";+import type { GenjutsuTarget, Maker } from "@/lib/catalog/genjutsu";+import type { Engine } from "@/lib/catalog/types";++/**+ * Character swap's own settings (Openjutsu's and Akatz Labs' H3 Character Swap tool's, on Genjutsu): who to swap,+ * the quality, the first frame made first, what the character looks like, the seed, and under Advanced the speech,+ * the swap LoRA's release and the H3 settings of the open graph. The limits and the GPU line sit under it.+ */+export function CharacterControls({+ engine,+ maker,+ target,+ value,+ onChange,+ quality,+ onQuality,+ seed,+ onSeed,+ seedProblem,+}: {+ engine: Engine;+ maker: Maker | null;+ target?: GenjutsuTarget;+ value: CharacterOptions;+ onChange: (v: CharacterOptions) => void;+ quality: CharacterQuality;+ onQuality: (q: CharacterQuality) => void;+ seed: string;+ onSeed: (s: string) => void;+ seedProblem?: string | null;+}) {+ const set = (patch: Partial<CharacterOptions>) => onChange({ ...value, ...patch });+ const h3 = !!maker?.h3;+ const open = engine === "open";+ const anchors = ANCHOR_MODELS[engine];+ const who: SwapWho = value.who ?? "largest";+ return (+ <div className="space-y-4">+ {target === "type" && (+ <Field label="Who to swap" hint={who === "largest" ? "The largest person in the first frame" : undefined}>+ <Segmented+ label="Who to swap"+ value={who}+ onChange={(w) => set({ who: w, ...(w === "index" ? { index: value.index ?? 0 } : {}) })}+ options={(Object.keys(WHO_LABELS) as SwapWho[]).map((w) => ({ value: w, label: WHO_LABELS[w] }))}+ />+ {who === "index" && (+ <div className="flex items-center gap-2 pt-1">+ <label htmlFor="gj-person" className="text-[12px] text-muted-foreground">+ Person number, from the left+ </label>+ <Input+ id="gj-person"+ type="number"+ inputMode="numeric"+ min={1}+ max={CHARACTER_SWAP.maxPeople}+ value={(value.index ?? 0) + 1}+ onChange={(e) => set({ index: Math.max(0, Math.min(CHARACTER_SWAP.maxPeople - 1, Math.round(Number(e.target.value) || 1) - 1)) })}+ className="h-8 w-20 text-[13px]"+ />+ </div>+ )}+ </Field>+ )}+ {(target === "type" || !open) && (+ <Field label="Who, in words (optional)" htmlFor="gj-who-words" hint={open ? "What SAM 3.1 looks for" : "Said in the prompt"}>+ <Input+ id="gj-who-words"+ value={value.subject ?? ""}+ onChange={(e) => set({ subject: e.target.value || undefined })}+ maxLength={120}+ placeholder="e.g. “the man in the red jacket”"+ className="text-[13px]"+ />+ </Field>+ )}++ {h3 && (+ <Field label="Quality" hint={quality === "480p" ? "Faster and cheaper" : "H3's native top"}>+ <Segmented label="Quality" value={quality} onChange={onQuality} options={CHARACTER_SWAP.qualities.map((q) => ({ value: q, label: q }))} />+ </Field>+ )}++ {maker?.h3?.anchor && (+ <div className="space-y-2 rounded-xl bg-muted/50 p-3">+ <label className="flex items-start justify-between gap-3 text-[13px]">+ <span className="min-w-0">+ <span className="block font-medium">Make the first frame first</span>+ <span className="block text-[12px] leading-snug text-muted-foreground">+ Your character put into the part's first frame, then H3 follows it. If it can't be made, the swap runs without it and says so.+ </span>+ </span>+ <Switch checked={value.anchor !== false} onCheckedChange={(on) => set({ anchor: on ? undefined : false })} aria-label="Make the first frame first" />+ </label>+ {value.anchor !== false && anchors.length > 1 && (+ <Segmented+ label="First frame model"+ value={anchorModel(engine, value.anchorModel).id}+ onChange={(id) => set({ anchorModel: id === anchors[0].id ? undefined : id })}+ options={anchors.map((a) => ({ value: a.id, label: a.label, title: a.note }))}+ />+ )}+ {value.anchor !== false && <p className="text-[12px] text-muted-foreground">{anchorModel(engine, value.anchorModel).note}</p>}+ </div>+ )}++ <Field label="What your character looks like (optional)" htmlFor="gj-description">+ <Input+ id="gj-description"+ value={value.description ?? ""}+ onChange={(e) => set({ description: e.target.value || undefined })}+ maxLength={CHARACTER_SWAP.maxDescriptionChars}+ placeholder="e.g. “a young woman with short silver hair and a green raincoat”"+ className="text-[13px]"+ />+ </Field>++ <Field label="Seed (optional)" htmlFor="gj-seed" hint={seedProblem ?? "Blank is random; the same seed repeats a take"}>+ <Input id="gj-seed" type="number" inputMode="numeric" min={0} max={CHARACTER_SWAP.maxSeed} value={seed} onChange={(e) => onSeed(e.target.value)} placeholder="Random" className="text-[13px]" aria-invalid={!!seedProblem} />+ </Field>++ {h3 && (+ <details className="group rounded-xl border px-3 py-2 [&_summary::-webkit-details-marker]:hidden">+ <summary className="cursor-pointer list-none text-[13px] font-medium outline-none select-none focus-visible:ring-2 focus-visible:ring-ring">+ Advanced <span className="text-[12px] font-normal text-muted-foreground">· speech, LoRA{open ? ", mask, windows" : ""}</span>+ </summary>+ <div className="space-y-3 pt-3">+ <Field label="Who speaks in the part" htmlFor="gj-speech">+ <Select value={value.speech ?? "character"} onValueChange={(v) => set({ speech: v === "character" ? undefined : (v as SwapSpeech) })}>+ <SelectTrigger id="gj-speech" className="h-8 w-full text-[13px]">+ <SelectValue>{SPEECH_LABELS[value.speech ?? "character"].label}</SelectValue>+ </SelectTrigger>+ <SelectContent>+ {(Object.keys(SPEECH_LABELS) as SwapSpeech[]).map((s) => (+ <SelectItem key={s} value={s}>+ {SPEECH_LABELS[s].label} — {SPEECH_LABELS[s].hint}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </Field>+ {value.speech !== "none" && (+ <Field label="What's said (optional)" htmlFor="gj-dialogue">+ <Textarea+ id="gj-dialogue"+ value={value.dialogue ?? ""}+ onChange={(e) => set({ dialogue: e.target.value || undefined })}+ maxLength={2000}+ rows={2}+ placeholder="The words in the part, so the lips follow them"+ className="resize-none text-[13px]"+ />+ </Field>+ )}+ <Field label="Swap LoRA" hint="Akatz Labs' Character Swap LoRA">+ <Segmented+ label="Swap LoRA"+ value={value.lora ?? "v1.5"}+ onChange={(l: SwapLora) => set({ lora: l === "v1.5" ? undefined : l })}+ options={[+ { value: "v1.5" as const, label: "V1.5", title: SWAP_LORAS["v1.5"].label },+ { value: "v1" as const, label: "V1", title: SWAP_LORAS.v1.label },+ { value: "none" as const, label: "None", title: "MiniMax H3 with the Turbo LoRA only" },+ ]}+ />+ </Field>+ {open && (+ <>+ <label className="flex items-center justify-between gap-3 text-[13px]">+ <span>+ Audio guide <span className="text-[12px] text-muted-foreground">· the clip's sound guides the performance</span>+ </span>+ <Switch checked={value.audioGuide !== false} onCheckedChange={(on) => set({ audioGuide: on ? undefined : false })} aria-label="Audio guide" />+ </label>+ <label className="flex items-center justify-between gap-3 text-[13px]">+ <span>+ Masked generation <span className="text-[12px] text-muted-foreground">· only the person is remade</span>+ </span>+ <Switch checked={value.useMask !== false} onCheckedChange={(on) => set({ useMask: on ? undefined : false })} aria-label="Masked generation" />+ </label>+ <Field label="Mask margin" htmlFor="gj-grow" hint="Pixels around the person">+ <Input+ id="gj-grow"+ type="number"+ inputMode="numeric"+ min={0}+ max={256}+ value={value.maskGrow ?? CHARACTER_SWAP.maskGrow}+ onChange={(e) => set({ maskGrow: Math.max(0, Math.min(256, Math.round(Number(e.target.value) || 0))) })}+ className="h-8 text-[13px]"+ />+ </Field>+ <div className="grid grid-cols-2 gap-2">+ <FrameSelect id="gj-window" label="Window" value={value.windowFrames ?? CHARACTER_SWAP.window} choices={WINDOW_CHOICES} onChange={(n) => set({ windowFrames: n === CHARACTER_SWAP.window ? undefined : n })} />+ <FrameSelect id="gj-history" label="History" value={value.historyFrames ?? CHARACTER_SWAP.history} choices={HISTORY_CHOICES} onChange={(n) => set({ historyFrames: n === CHARACTER_SWAP.history ? undefined : n })} />+ </div>+ </>+ )}+ </div>+ </details>+ )}+ </div>+ );+}++function FrameSelect({ id, label, value, choices, onChange }: { id: string; label: string; value: number; choices: number[]; onChange: (n: number) => void }) {+ return (+ <Field label={label} htmlFor={id}>+ <Select value={String(value)} onValueChange={(v) => onChange(Number(v))}>+ <SelectTrigger id={id} className="h-8 w-full text-[13px] tabular-nums">+ <SelectValue>{value} frames</SelectValue>+ </SelectTrigger>+ <SelectContent>+ {choices.map((n) => (+ <SelectItem key={n} value={String(n)}>+ {n} frames+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </Field>+ );+}++/** The limits, the cut warning, the GPU it was tested on (open) and the licence, as information under the settings. */+export function CharacterFacts({ engine, maker, cut }: { engine: Engine; maker: Maker | null; cut: string | null }) {+ return (+ <div className="space-y-2 text-[12px] leading-snug text-muted-foreground">+ {cut && (+ <p role="status" className="flex gap-1.5 rounded-lg bg-warning/10 p-2 text-foreground">+ <TriangleAlert className="mt-0.5 size-3.5 shrink-0 text-warning" />+ <span>{cut}.</span>+ </p>+ )}+ <ul className="list-disc space-y-0.5 pl-4">+ {CHARACTER_LIMITS.map((l) => (+ <li key={l}>{l}</li>+ ))}+ <li>Clips up to {CHARACTER_SWAP.maxBytes / 1024 / 1024} MB</li>+ </ul>+ {engine === "open" && maker?.h3 && (+ <p className="flex gap-1.5">+ <Cpu className="mt-0.5 size-3.5 shrink-0" />+ <span>+ {CHARACTER_GPU.tested}. {CHARACTER_GPU.advice}. {CHARACTER_GPU.weightsGb} GB of weights.+ </span>+ </p>+ )}+ {maker && (+ <p className="flex gap-1.5">+ <Scale className="mt-0.5 size-3.5 shrink-0" />+ <span>{characterLicenceLine(engine, maker.id)}. Your admin decides what runs (Settings → Models & licences).</span>+ </p>+ )}+ </div>+ );+}diff --git a/src/components/genjutsu/genjutsu-studio.tsx b/src/components/genjutsu/genjutsu-studio.tsxindex 29e73fff..9049074b 100644--- a/src/components/genjutsu/genjutsu-studio.tsx+++ b/src/components/genjutsu/genjutsu-studio.tsx@@ -1,12 +1,13 @@"use client";-import { Brush, Download, Loader2, RotateCcw, Sparkles, Undo2, Wand2 } from "lucide-react";+import { Brush, Download, Info, Loader2, RotateCcw, Sparkles, Undo2, Wand2 } from "lucide-react";import { useSearchParams } from "next/navigation";import { nanoid } from "nanoid";import { Suspense, useEffect, useMemo, useRef, useState } from "react";import { toast } from "sonner";import { Button } from "@/components/ui/button";import { Input } from "@/components/ui/input";+import { Switch } from "@/components/ui/switch";import { Textarea } from "@/components/ui/textarea";import { StepList, type StepRow } from "@/components/av/step-list";import { Panel, ToolHero, ToolShell } from "@/components/av/tool-shell";@@ -21,7 +22,8 @@ import { fileToList, MediaSlot, type SlotValue } from "@/components/studio/mediaimport { radioKeys, radioTab } from "@/components/studio/radio-keys";import { SketchEditor, type Stroke } from "@/components/studio/sketch-editor";import { VideoTrimmer, type TrimRange, type VideoTrimmerHandle } from "@/components/studio/video-trimmer";-import { useEngine, useGenerations, useStatus } from "@/lib/api";+import { useEngine, useGenerations } from "@/lib/api";+import { CHARACTER_SWAP, characterLicenceLine, cutsInPart, cutWarning, seedProblem, type CharacterOptions, type CharacterQuality } from "@/lib/catalog/character-swap";import {chooseMaker,decodeSetup,@@ -33,6 +35,7 @@ import {MODE_TARGETS,OPEN_TARGET_PROBLEM,resolutionWords,+ SOURCE_LABELS,TARGET_LABELS,type GenjutsuLook,type GenjutsuMode,@@ -43,12 +46,14 @@ import {type Maker,} from "@/lib/catalog/genjutsu";import { chainState } from "@/lib/catalog/shorts";-import type { PixelPoint } from "@/lib/catalog/types";+import type { Engine, PixelPoint } from "@/lib/catalog/types";import { downloadHref, downloadName } from "@/lib/library";import { cn } from "@/lib/utils";+import { CharacterControls, CharacterFacts } from "./character-panel";import { useGenjutsuEstimate, useGenjutsuRun, type GenjutsuBody } from "./hooks";import { LookPicker, type LookSource } from "./look-picker";import { SetupCode } from "./setup-code";+import { useClipCuts } from "./use-cuts";const LIMITS = `MP4, MOV or WebM · ${GENJUTSU.minSeconds}–${GENJUTSU.maxSeconds} s are used · ${GENJUTSU.maxBytes / 1024 / 1024} MB`;@@ -73,16 +78,18 @@ const isMode = (v: string | null): v is GenjutsuMode => !!v && GENJUTSU_MODES.soconst asSlot = (ref: string): SlotValue => ({ id: nanoid(8), ref, preview: ref, kind: "image" });const ready = (xs: SlotValue[]) => xs.filter((x) => !x.uploading).map((x) => x.ref);+/** A seed typed in the form (blank is random). */+const seedOf = (s: string): number | undefined => (s.trim() === "" ? undefined : Number(s));+/**- * Genjutsu: keep a clip's motion, camera and framing and change what is in it — Motion transfer, Object swap, Restyle- * or Insert. Pick the mode, add the clip (4–30 s, trimmed here) and your references, say what changes, see the price- * (or "Free" on your ComfyUI), get the result with a before / after wipe. Setups copy and paste as a short code.- * The plan: src/lib/catalog/genjutsu.ts; the server: src/server/genjutsu.ts.+ * Genjutsu: keep a clip's motion, camera and framing and change what is in it — Motion transfer, Character swap,+ * Object swap, Restyle or Insert. Pick the mode, add the clip (4–30 s, trimmed here; Character swap: a 5–15 s part)+ * and your references, say what changes, see the price (or "Free" on your ComfyUI), get the result with a before /+ * after wipe. Fuobe's Originals run by default on both engines; open weights and partners are labelled alternatives.+ * Setups copy and paste as a short code. The plan: src/lib/catalog/genjutsu.ts; the server: src/server/genjutsu.ts.*/export function GenjutsuStudio() {const [engine, setEngine, engineMode] = useEngine();- const status = useStatus().data;- const higgsfield = !!status?.providers.higgsfield?.configured;const [mode, setModeState] = useState<GenjutsuMode>("motion");const source = useSourceClip(GENJUTSU.maxBytes);const clip = source.clip;@@ -102,6 +109,11 @@ export function GenjutsuStudio() {const [points, setPoints] = useState<PixelPoint[]>([]);const [pointLabel, setPointLabel] = useState<"positive" | "negative">("positive");const [paint, setPaint] = useState<Paint | null>(null);+ // Character swap: its quality (H3's 480p / 768p), its settings, the seed, and a part longer than 15 s.+ const [charQuality, setCharQuality] = useState<CharacterQuality>(CHARACTER_SWAP.defaultQuality);+ const [character, setCharacter] = useState<CharacterOptions>({});+ const [seed, setSeed] = useState("");+ const [longPart, setLongPart] = useState(false);const [painting, setPainting] = useState(false);const [frame, setFrame] = useState<Frame | null>(null);const [frameError, setFrameError] = useState(false);@@ -118,11 +130,18 @@ export function GenjutsuStudio() {const duration = clipDuration(clip);const size = clipSize(clip);- // Higgsfield's looks run on the cloud engine only: the open engine shows the 44 looks (the tab stays where it was).- const lookSource: LookSource = engine === "open" && lookChoice === "higgsfield" ? "fuobe" : lookChoice;+ const lookSource: LookSource = lookChoice;+ const isCharacter = mode === "character";+ const partMax = isCharacter ? (longPart ? CHARACTER_SWAP.maxContinued : CHARACTER_SWAP.maxSeconds) : GENJUTSU.maxSeconds;+ const partMin = isCharacter ? CHARACTER_SWAP.minSeconds : GENJUTSU.minSeconds;const setMode = (m: GenjutsuMode) => {setModeState(m);+ // Character swap takes a 5–15 s part: a longer selection is cut back to its first 15 s.+ if (m === "character" && range && range.endTime - range.startTime > CHARACTER_SWAP.maxSeconds + 0.05) {+ setLongPart(false);+ setRange({ ...range, endTime: Math.round((range.startTime + CHARACTER_SWAP.maxSeconds) * 100) / 100 });+ }const url = new URL(window.location.href);url.searchParams.set("mode", m);window.history.replaceState(null, "", url);@@ -134,17 +153,23 @@ export function GenjutsuStudio() {? undefined: lookSource === "custom"? { kind: "custom", images: ready(custom), ...(words.trim() ? { words: words.trim() } : {}) }- : look && look.kind === (lookSource === "fuobe" ? "preset" : "higgsfield")+ : look && look.kind === (lookSource === "fuobe" ? "preset" : "soul")? look: undefined;- const lookKind = mode === "restyle" ? (lookSource === "higgsfield" ? "higgsfield" : "fuobe") : "";+ const lookKind = mode === "restyle" ? lookSource : "";const choiceKey = `${engine}:${mode}:${target ?? ""}:${lookKind}`;- const choice = chooseMaker({ engine, mode, target, tier, look: effLook ?? (mode === "restyle" ? lookPlaceholder(lookSource) : undefined), modelId: picked[choiceKey], higgsfield });+ const choice = chooseMaker({ engine, mode, target, tier, look: effLook ?? (mode === "restyle" ? lookPlaceholder(lookSource) : undefined), modelId: picked[choiceKey] });const maker: Maker | null = "maker" in choice ? choice.maker : null;- const options = makersFor(engine, mode, target, effLook ?? (mode === "restyle" ? lookPlaceholder(lookSource) : undefined));- const references = mode === "restyle" && lookSource !== "higgsfield" ? [] : ready(refs);- const showRefs = mode !== "restyle" || lookSource === "higgsfield";- const needsFrame = (mode === "swap" && (target === "click" || target === "paint")) || (mode === "insert" && target === "paint");+ const options = makersFor(engine, mode, target);+ const references = mode === "restyle" ? [] : ready(refs);+ const showRefs = mode !== "restyle";+ const maxRefs = isCharacter ? Math.max(1, maker?.refs.max ?? 1) : GENJUTSU.maxReferences;+ const needsFrame = ((mode === "swap" || isCharacter) && target === "click") || ((mode === "swap" || mode === "insert") && target === "paint");+ // Character swap: the clip's hard cuts (found in the browser), for the "one continuous shot" warning.+ const cuts = useClipCuts(clip?.preview, isCharacter && !!clip && !clip.error);+ const partCuts = isCharacter && range ? cutsInPart(cuts ?? undefined, { start: range.startTime, end: range.endTime }) : [];+ const cut = cutWarning(partCuts);+ const seedNumber = seedOf(seed);// The selection's first frame, grabbed by the browser: what points and paint are made on.const startAt = range ? Math.round(range.startTime * 100) / 100 : null;@@ -186,7 +211,10 @@ export function GenjutsuStudio() {const e = s.engine && engineMode === "both" ? s.engine : engine;if (s.engine && engineMode === "both") setEngine(s.engine);if (s.tier) setTier(s.tier);- if (s.quality) setQuality(s.quality);+ if (s.mode === "character") {+ if (s.quality === "480p" || s.quality === "768p") setCharQuality(s.quality);+ setCharacter(s.character ?? {});+ } else if (s.quality) setQuality(s.quality);const t = s.target ?? MODE_TARGETS[s.mode][0];if (s.target) setTargets((x) => ({ ...x, [s.mode]: s.target }));setSubject(s.subject ?? "");@@ -196,10 +224,11 @@ export function GenjutsuStudio() {setCustom(s.look.images.map(asSlot));setWords(s.look.words ?? "");} else if (s.look) {- setLookSource(s.look.kind === "preset" ? "fuobe" : "higgsfield");+ setLookSource(s.look.kind === "preset" ? "fuobe" : "soul");setLook(s.look);}- if (s.model) setPicked((x) => ({ ...x, [`${e}:${s.mode}:${t ?? ""}:${s.mode === "restyle" ? (s.look?.kind === "higgsfield" ? "higgsfield" : "fuobe") : ""}`]: s.model! }));+ const kind = s.mode === "restyle" ? (s.look?.kind === "custom" ? "custom" : s.look?.kind === "soul" ? "soul" : "fuobe") : "";+ if (s.model) setPicked((x) => ({ ...x, [`${e}:${s.mode}:${t ?? ""}:${kind}`]: s.model! }));if (s.references?.length) setRefs(s.references.map(asSlot));toast("Setup pasted", { description: clip ? "Check the references and press Generate." : "Add a clip to run it on." });};@@ -252,12 +281,13 @@ export function GenjutsuStudio() {engine,...(maker ? { model: maker.id } : {}),...(maker?.tier ? { tier: maker.tier } : {}),- quality,+ quality: isCharacter ? charQuality : quality,...(target ? { target } : {}),...(mode === "swap" && subject.trim() ? { subject: subject.trim() } : {}),...(prompt.trim() ? { prompt: prompt.trim() } : {}),...(effLook ? { look: effLook } : {}),...(references.length ? { references } : {}),+ ...(isCharacter && Object.keys(character).length ? { character } : {}),};function clearMarks() {@@ -295,6 +325,7 @@ export function GenjutsuStudio() {points: clicks,mask: !!paint,look: effLook,+ ...(isCharacter ? { seed: seedNumber } : {}),}): null;const body: GenjutsuBody | null =@@ -304,7 +335,7 @@ export function GenjutsuStudio() {mode,modelId: maker.id,...(maker.tier ? { tier: maker.tier } : {}),- quality,+ quality: isCharacter ? charQuality : quality,...(target ? { target } : {}),...(mode === "swap" && subject.trim() ? { subject: subject.trim() } : {}),...(prompt.trim() ? { prompt: prompt.trim() } : {}),@@ -315,6 +346,7 @@ export function GenjutsuStudio() {...(effLook ? { look: effLook } : {}),source: { url: clip.url!, name: clip.name, duration, fps: clip.info?.fps, width: size.width, height: size.height, hasAudio: clip.info?.hasAudio },range: { start: range.startTime, end: range.endTime },+ ...(isCharacter ? { character, ...(seedNumber !== undefined ? { seed: seedNumber } : {}), ...(cuts?.length ? { cuts } : {}) } : {}),}: null;const estimate = useGenjutsuEstimate(body);@@ -389,13 +421,34 @@ export function GenjutsuStudio() {src={clip.preview}value={range}onChange={setRange}- min={GENJUTSU.minSeconds}- max={GENJUTSU.maxSeconds}+ min={partMin}+ max={partMax}duration={clip.info?.duration}- label="Part of the clip to use"- hint={duration && duration > GENJUTSU.maxSeconds ? `Pick up to ${GENJUTSU.maxSeconds} s — only that part comes out` : `${GENJUTSU.minSeconds}–${GENJUTSU.maxSeconds} s; the whole clip, or just the part you need`}+ label={isCharacter ? "The part to swap" : "Part of the clip to use"}+ hint={+ isCharacter+ ? longPart+ ? `${CHARACTER_SWAP.minSeconds}–${CHARACTER_SWAP.maxContinued} s; past 15 s it continues window by window`+ : `${CHARACTER_SWAP.minSeconds}–${CHARACTER_SWAP.maxSeconds} s of one continuous shot, the person in its first frame`+ : duration && duration > GENJUTSU.maxSeconds+ ? `Pick up to ${GENJUTSU.maxSeconds} s — only that part comes out`+ : `${GENJUTSU.minSeconds}–${GENJUTSU.maxSeconds} s; the whole clip, or just the part you need`+ }onMeta={source.setBrowserMeta}/>+ {isCharacter && duration !== undefined && duration > CHARACTER_SWAP.maxSeconds && (+ <label className="flex items-center gap-2 text-[12px] text-muted-foreground">+ <Switch+ checked={longPart}+ onCheckedChange={(on) => {+ setLongPart(on);+ if (!on && range && range.endTime - range.startTime > CHARACTER_SWAP.maxSeconds) setRange({ ...range, endTime: Math.round((range.startTime + CHARACTER_SWAP.maxSeconds) * 100) / 100 });+ }}+ aria-label="A longer part, up to 30 seconds"+ />+ A longer part, up to {CHARACTER_SWAP.maxContinued} s (continued past 15 s; beyond H3's trained range)+ </label>+ )}</div></Panel>@@ -463,28 +516,17 @@ export function GenjutsuStudio() {{mode === "restyle" && (<Panel title="Look">- <LookPicker- look={look}- onLook={setLook}- source={lookSource}- onSource={setLookSource}- custom={custom}- onCustom={setCustom}- words={words}- onWords={setWords}- higgsfield={higgsfield}- engine={engine}- />+ <LookPicker look={look} onLook={setLook} source={lookSource} onSource={setLookSource} custom={custom} onCustom={setCustom} words={words} onWords={setWords} /></Panel>)}{showRefs && (- <Panel title={modeInfo.refs} aside={<span className="text-[12px] text-muted-foreground tabular-nums">{refs.length}/{GENJUTSU.maxReferences}</span>}>+ <Panel title={modeInfo.refs} aside={<span className="text-[12px] text-muted-foreground tabular-nums">{refs.length}/{maxRefs}</span>}><div className="flex flex-wrap gap-2">{refs.map((r) => (<MediaSlot key={r.id} label="Reference" kind="image" value={r} onChange={(v) => setRefs((xs) => (v ? xs.map((x) => (x.id === r.id ? { ...v, id: r.id } : x)) : xs.filter((x) => x.id !== r.id)))} size="lg" />))}- {refs.length < GENJUTSU.maxReferences && (+ {refs.length < maxRefs && (<MediaSlotlabel={refs.length ? "Add another" : REF_CTA[mode]}kind="image"@@ -492,13 +534,13 @@ export function GenjutsuStudio() {onChange={(v) => v && setRefs((xs) => [...xs, { ...v, id: v.id ?? nanoid(8) }])}onFile={(f) => fileToList(f, setRefs, "image")}size="lg"- required={mode !== "restyle"}+ required/>)}</div><p className="mt-2 text-[12px] text-muted-foreground">{REF_HINT[mode]}- {maker && maker.refs.max > 0 && ` ${maker.label} uses ${maker.refs.max === 1 ? "the first one" : `up to ${maker.refs.max}`}.`}+ {maker && maker.refs.max > 0 && maker.refs.max < maxRefs && ` ${maker.label} uses ${maker.refs.max === 1 ? "the first one" : `up to ${maker.refs.max}`}.`}</p></Panel>)}@@ -508,19 +550,19 @@ export function GenjutsuStudio() {<p className="text-[13px] text-pretty text-muted-foreground">{modeInfo.hint}</p>{MODE_TARGETS[mode].length > 0 && (- <Field label={mode === "insert" ? "Where does it go?" : "What gets swapped?"}>+ <Field label={TARGET_QUESTION[mode]}><Segmented- label={mode === "insert" ? "Where does it go?" : "What gets swapped?"}+ label={TARGET_QUESTION[mode]}value={target!}onChange={(t) => setTargets((x) => ({ ...x, [mode]: t }))}options={MODE_TARGETS[mode].map((t) => ({value: t,label: TARGET_LABELS[mode][t]!.label,disabled: !supported.includes(t),- title: supported.includes(t) ? TARGET_LABELS[mode][t]!.hint : "On the cloud engine",+ title: supported.includes(t) ? TARGET_LABELS[mode][t]!.hint : engine === "open" ? "On the cloud engine" : "On your GPU (the open engine)",}))}/>- {supported.length < MODE_TARGETS[mode].length && <p className="text-[12px] text-muted-foreground">{OPEN_TARGET_PROBLEM[mode]}.</p>}+ {supported.length < MODE_TARGETS[mode].length && <p className="text-[12px] text-muted-foreground">{engine === "open" ? OPEN_TARGET_PROBLEM[mode] : CLICK_ON_GPU}.</p>}</Field>)}@@ -537,14 +579,29 @@ export function GenjutsuStudio() {</Field>)}- {/* Fuobe's looks are words of their own; extra words go with Higgsfield's looks. */}- {(mode !== "restyle" || lookSource === "higgsfield") && (+ {isCharacter && (+ <CharacterControls+ engine={engine}+ maker={maker}+ target={target}+ value={character}+ onChange={setCharacter}+ quality={charQuality}+ onQuality={setCharQuality}+ seed={seed}+ onSeed={setSeed}+ seedProblem={seedProblem(seedNumber)}+ />+ )}++ {/* The looks are words of their own: Restyle takes no prompt. */}+ {mode !== "restyle" && (<Field label={PROMPT_LABEL[mode](target)} htmlFor="gj-prompt"><Textareaid="gj-prompt"value={prompt}onChange={(e) => setPrompts((x) => ({ ...x, [mode]: e.target.value }))}- maxLength={GENJUTSU.maxPromptChars}+ maxLength={isCharacter ? CHARACTER_SWAP.maxDirectionChars : GENJUTSU.maxPromptChars}rows={2}placeholder={PROMPT_PLACEHOLDER[mode]}className="resize-none text-[13px]"@@ -554,18 +611,17 @@ export function GenjutsuStudio() {{maker && options.length > 1 && (<Field label="Model">- <MakerList options={options} value={maker.pair && maker.tier === "high" ? maker.pair : maker.id} higgsfield={higgsfield} onChange={(id) => setPicked((p) => ({ ...p, [choiceKey]: id }))} />+ <MakerList options={options} value={maker.pair && maker.tier === "high" ? maker.pair : maker.id} engine={engine} character={isCharacter} onChange={(id) => setPicked((p) => ({ ...p, [choiceKey]: id }))} /></Field>)}{maker && options.length <= 1 && (<p className="text-[12px] text-muted-foreground">- <span className="font-medium text-foreground">{maker.label}</span> · {maker.note}- {maker.higgsfield && !higgsfield && " · needs a Higgsfield key (runs as a demo without one)"}+ <SourceBadge source={maker.source} /> <span className="font-medium text-foreground">{maker.label}</span> · {maker.note}</p>)}{maker?.pair && (- <Field label="Quality" hint={tier === "standard" ? "Genjutsu Lite — about a sixth of the price" : "Genjutsu — the full model"}>+ <Field label="Quality" hint={(maker.tier ?? tier) === "standard" ? "Lite — the cheaper, faster tier" : "The full Original"}><Segmentedlabel="Quality"value={maker.tier ?? tier}@@ -578,9 +634,15 @@ export function GenjutsuStudio() {</Field>)}- <Field label="Resolution" hint={maker ? upFirst(resolutionWords(maker, quality)) : undefined}>- <Segmented label="Resolution" value={quality} onChange={setQuality} options={GENJUTSU.qualities.map((q) => ({ value: q, label: q }))} />- </Field>+ {(!isCharacter || !maker?.h3) && (+ <Field label="Resolution" hint={maker ? upFirst(resolutionWords(maker, isCharacter ? charQuality : quality)) : undefined}>+ {isCharacter ? (+ <Segmented label="Resolution" value={charQuality} onChange={setCharQuality} options={CHARACTER_SWAP.qualities.map((q) => ({ value: q, label: q }))} />+ ) : (+ <Segmented label="Resolution" value={quality} onChange={setQuality} options={GENJUTSU.qualities.map((q) => ({ value: q, label: q }))} />+ )}+ </Field>+ )}<div className="space-y-3 border-t pt-3"><div className="flex items-center gap-2">@@ -615,6 +677,7 @@ export function GenjutsuStudio() {))}</ul>)}+ {isCharacter && <CharacterFacts engine={engine} maker={maker} cut={cut} />}</div></Panel></div>@@ -675,13 +738,18 @@ const friendly = (msg: string) => (/failed to fetch|networkerror|load failed/i.t/** Restyle before a look is picked: the kind of look the tab stands for (so the model list matches it). */function lookPlaceholder(s: LookSource): GenjutsuLook {- return s === "higgsfield" ? { kind: "higgsfield", id: "" } : s === "custom" ? { kind: "custom", images: [] } : { kind: "preset", id: "" };+ return s === "soul" ? { kind: "soul", id: "" } : s === "custom" ? { kind: "custom", images: [] } : { kind: "preset", id: "" };}-const REF_CTA: Record<GenjutsuMode, string> = { motion: "Add your character", swap: "Add what goes in", insert: "Add what to add", restyle: "Add a character" };+const CLICK_ON_GPU = "Clicking runs on your GPU (SAM 3.1 marks them) — on the cloud, pick who in words";++const TARGET_QUESTION: Record<GenjutsuMode, string> = { motion: "", restyle: "", character: "Who gets swapped?", swap: "What gets swapped?", insert: "Where does it go?" };++const REF_CTA: Record<GenjutsuMode, string> = { motion: "Add your character", character: "Add your character", swap: "Add what goes in", insert: "Add what to add", restyle: "Add a character" };const REF_HINT: Record<GenjutsuMode, string> = {motion: "A clear, full-body picture of the character who takes over the performance. More angles help Genjutsu.",+ character: "One clear picture of your character, head to toe, facing the camera — PNG, JPEG or WebP. They take the person's place.",swap: "The thing, person or outfit that goes in — cut out on a plain background works best.",insert: "The object or character to add — cut out on a plain background works best.",restyle: "Optional: characters who should appear in the look.",@@ -689,6 +757,7 @@ const REF_HINT: Record<GenjutsuMode, string> = {const PROMPT_LABEL: Record<GenjutsuMode, (t?: GenjutsuTarget) => string> = {motion: () => "Describe your character (optional)",+ character: () => "Direction (optional)",swap: () => "Describe the result (optional)",insert: (t) => (t === "type" ? "Where it goes" : "What appears there (optional)"),restyle: () => "Anything to keep (optional)",@@ -696,12 +765,14 @@ const PROMPT_LABEL: Record<GenjutsuMode, (t?: GenjutsuTarget) => string> = {const PROMPT_PLACEHOLDER: Record<GenjutsuMode, string> = {motion: "e.g. “a knight in silver armour, in a stone hall”",+ character: "e.g. “keep the hand on the railing; she smiles at the end”",swap: "e.g. “a white horse trotting at the same pace”",insert: "e.g. “on the table, next to the cup”",restyle: "e.g. “keep her pink hair the same in every shot”",};function frameHint(mode: GenjutsuMode, target: GenjutsuTarget | undefined, points: number, painted: boolean): string {+ if (target === "click" && mode === "character") return points ? "Add points on the same person, or mark someone to leave with Keep." : "Click the person to swap. Keyboard: arrows move the crosshair, Enter adds a point.";if (target === "click") return points ? "Add points on the same thing, or mark what stays with Keep." : "Click what to swap. Keyboard: arrows move the crosshair, Enter adds a point.";if (mode === "insert") return painted ? "Red is where it goes. It stays there for the whole shot." : "Paint where it should appear — it stays there for the whole shot, so a still camera works best.";return painted ? "Red is what gets swapped. Touch up the paint, or clear it." : "Paint over what to swap — it only needs to cover it on this frame.";@@ -737,8 +808,22 @@ function ModeTabsRow({ mode, onMode }: { mode: GenjutsuMode; onMode: (m: Genjuts);}-/** The models for this mode and engine, one line each (what it's good at, its limits). */-function MakerList({ options, value, higgsfield, onChange }: { options: Maker[]; value: string; higgsfield: boolean; onChange: (id: string) => void }) {+/** Where a model comes from, as a small badge: a Fuobe Original, open weights, or a partner's closed model. */+function SourceBadge({ source }: { source: Maker["source"] }) {+ return (+ <span+ className={cn(+ "inline-flex h-4 shrink-0 items-center rounded-[4px] px-1 align-[1px] text-[10px] font-medium",+ source === "original" ? "bg-brand-faint text-brand-text" : source === "open" ? "bg-success/15 text-success" : "bg-muted text-muted-foreground",+ )}+ >+ {SOURCE_LABELS[source]}+ </span>+ );+}++/** The models for this mode and engine, one line each (where it comes from, what it's good at, its limits, its licence). */+function MakerList({ options, value, engine, character, onChange }: { options: Maker[]; value: string; engine: Engine; character: boolean; onChange: (id: string) => void }) {return (<div role="radiogroup" aria-label="Model" onKeyDown={radioKeys} className="space-y-1.5">{options.map((m) => (@@ -756,11 +841,11 @@ function MakerList({ options, value, higgsfield, onChange }: { options: Maker[];><span className={cn("mt-1 size-3 shrink-0 rounded-full border-2", value === m.id ? "border-primary bg-primary" : "border-border-strong")} /><span className="min-w-0">- <span className="block text-[13px] font-medium">{m.label}</span>- <span className="block text-[12px] leading-snug text-muted-foreground">- {m.note}- {m.higgsfield && !higgsfield && " · needs a Higgsfield key (a demo without one)"}+ <span className="flex flex-wrap items-center gap-1.5 text-[13px] font-medium">+ {m.label} <SourceBadge source={m.source} /></span>+ <span className="block text-[12px] leading-snug text-muted-foreground">{m.note}</span>+ {character && <span className="mt-0.5 block text-[11px] leading-snug text-muted-foreground/90">{characterLicenceLine(engine, m.id)}</span>}</span></button>))}@@ -779,6 +864,8 @@ function RunPanel({ run, onAgain }: { run: Run; onAgain: () => void }) {});const state = chainState(rows.map((r) => ({ g: r.g, label: r.label })).sort((a, b) => (a.g?.id === run.final ? 1 : b.g?.id === run.final ? -1 : 0)));const out = final?.status === "succeeded" ? final.outputs.find((o) => o.kind === "video") : undefined;+ // A step that fell back (the first frame couldn't be made) says so on the result.+ const notices = [...new Set(rows.flatMap((r) => (r.g?.request.notice ? [r.g.request.notice] : [])))];return (<section className="mt-6" aria-labelledby="gj-run-title"><Panel@@ -800,6 +887,12 @@ function RunPanel({ run, onAgain }: { run: Run; onAgain: () => void }) {</div>}>+ {notices.length > 0 && (+ <p role="status" className="mb-3 flex gap-1.5 rounded-lg bg-muted p-2 text-[12px] text-muted-foreground">+ <Info className="mt-0.5 size-3.5 shrink-0" />+ <span>{notices.join(" · ")}.</span>+ </p>+ )}{out ? (<VideoCompare before={run.before} after={out.url} start={run.start} ratio={run.ratio} />) : (diff --git a/src/components/genjutsu/hooks.ts b/src/components/genjutsu/hooks.tsindex 3932620a..9688f767 100644--- a/src/components/genjutsu/hooks.ts+++ b/src/components/genjutsu/hooks.ts@@ -1,12 +1,13 @@"use client";import { keepPreviousData, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";-import type { GenjutsuLook, GenjutsuMode, GenjutsuTarget, GenjutsuTier } from "@/lib/catalog/genjutsu";+import type { CharacterOptions } from "@/lib/catalog/character-swap";+import type { GenjutsuLook, GenjutsuMode, GenjutsuTarget, GenjutsuTier, MakerSource } from "@/lib/catalog/genjutsu";import type { Engine, Generation, PixelPoint } from "@/lib/catalog/types";import { useDebounced } from "@/components/faceless/hooks";import { send } from "@/components/shorts/hooks";-/** React Query hooks for /api/genjutsu/** and Higgsfield's live Genjutsu looks. */+/** React Query hooks for /api/genjutsu/**. */export interface GenjutsuBody {engine: Engine;@@ -25,6 +26,10 @@ export interface GenjutsuBody {source: { url: string; name?: string; duration?: number; fps?: number; width?: number; height?: number; hasAudio?: boolean };range?: { start: number; end: number };seed?: number;+ /** Character swap's settings. */+ character?: CharacterOptions;+ /** Hard cuts the browser found in the clip (seconds): the server warns when the part has one. */+ cuts?: number[];/** Client nonce: a repeat of it gets the first answer (see useSubmitGuard). */requestId?: string;}@@ -34,13 +39,18 @@ export interface GenjutsuEstimate {demo: boolean;modelId: string;modelName: string;+ /** A Fuobe Original, other open weights, or a partner's model. */+ source: MakerSource;tier?: GenjutsuTier;quality?: string;pieces: number;seconds: number;steps: number;notes: string[];- higgsfield: boolean;+ /** Character swap: first frames made, the limits, and the GPU the open route was tested on. */+ anchors?: number;+ limits?: string[];+ gpu?: { weightsGb: number; tested: string; advice: string; speed: string };}/** The price and shape of a run for the current settings, asked for once typing pauses (300 ms). */@@ -66,19 +76,3 @@ export function useGenjutsuRun() {},});}--export interface HiggsfieldLook {- id: string;- name: string;- preview?: string;-}--/** Higgsfield's own Genjutsu looks (a key is needed; the list comes live from Higgsfield). */-export function useHiggsfieldLooks(enabled: boolean) {- return useQuery({- queryKey: ["provider-presets", "genjutsu-restyle"],- queryFn: async () => (await (await fetch("/api/providers/higgsfield/presets?source=genjutsu-restyle")).json()) as { items: HiggsfieldLook[]; error?: string },- enabled,- staleTime: 60 * 60 * 1000,- });-}diff --git a/src/components/genjutsu/look-picker.tsx b/src/components/genjutsu/look-picker.tsxindex 04935a68..a7714974 100644--- a/src/components/genjutsu/look-picker.tsx+++ b/src/components/genjutsu/look-picker.tsx@@ -1,23 +1,24 @@"use client";-import { Check, ImagePlus, Loader2, Search } from "lucide-react";+import { Search } from "lucide-react";import { nanoid } from "nanoid";import { useMemo, useState } from "react";import { Input } from "@/components/ui/input";+import { CuratedCover } from "@/components/moodboards/cards";+import { curatedLook } from "@/components/moodboards/logic";import { fileToList, MediaSlot, type SlotValue } from "@/components/studio/media-slot";import { LookCard } from "@/components/shorts/preset-card";import { tabKeys } from "@/components/shorts/ui";import { GENJUTSU, type GenjutsuLook } from "@/lib/catalog/genjutsu";import { SHORTS_PRESETS, shortsPreview } from "@/lib/catalog/shorts";-import type { Engine } from "@/lib/catalog/types";+import { SOUL_LOOK_CARDS } from "@/lib/catalog/soul-cards";import { cn } from "@/lib/utils";-import { useHiggsfieldLooks } from "./hooks";-export type LookSource = "fuobe" | "higgsfield" | "custom";+export type LookSource = "fuobe" | "soul" | "custom";/**- * Restyle's look: one of the 44 Shorts looks, one of Higgsfield's own Genjutsu looks (with a key, on the cloud engine),- * or your own look from up to 8 images and a few words.+ * Restyle's look: one of the 44 Shorts looks, one of Fuobe Soul's 139 looks (its words and LoRAs restyle the first+ * frame, every frame follows it), or your own look from up to 8 images and a few words. Every look runs on both engines.*/export function LookPicker({look,@@ -28,8 +29,6 @@ export function LookPicker({onCustom,words,onWords,- higgsfield,- engine,}: {look: GenjutsuLook | null;onLook: (l: GenjutsuLook) => void;@@ -39,21 +38,16 @@ export function LookPicker({onCustom: (update: (xs: SlotValue[]) => SlotValue[]) => void;words: string;onWords: (w: string) => void;- /** A Higgsfield key is set. */- higgsfield: boolean;- /** Higgsfield's looks run on the cloud engine only. */- engine: Engine;}) {const [q, setQ] = useState("");- const tabs: { id: LookSource; label: string; off?: string }[] = [+ const tabs: { id: LookSource; label: string }[] = [{ id: "fuobe", label: "Looks" },- { id: "higgsfield", label: "Higgsfield", ...(engine === "open" ? { off: "Higgsfield's looks run on the cloud engine" } : {}) },+ { id: "soul", label: "Soul looks" },{ id: "custom", label: "Your own" },];- const presets = useMemo(() => {- const t = q.trim().toLowerCase();- return t ? SHORTS_PRESETS.filter((p) => `${p.name} ${p.category} ${p.description}`.toLowerCase().includes(t)) : SHORTS_PRESETS;- }, [q]);+ const words_ = q.trim().toLowerCase();+ const presets = useMemo(() => (words_ ? SHORTS_PRESETS.filter((p) => `${p.name} ${p.category} ${p.description}`.toLowerCase().includes(words_)) : SHORTS_PRESETS), [words_]);+ const souls = useMemo(() => (words_ ? SOUL_LOOK_CARDS.filter((l) => `${l.name} ${l.description} ${l.categories.join(" ")}`.toLowerCase().includes(words_)) : SOUL_LOOK_CARDS), [words_]);return (<div className="space-y-3"><div role="tablist" aria-label="Where the look comes from" onKeyDown={tabKeys} className="flex w-full rounded-full bg-muted p-0.5">@@ -66,11 +60,9 @@ export function LookPicker({aria-selected={source === t.id}aria-controls={`look-panel-${t.id}`}tabIndex={source === t.id ? 0 : -1}- disabled={!!t.off}- title={t.off}onClick={() => onSource(t.id)}className={cn(- "flex h-8 min-w-0 flex-1 items-center justify-center rounded-full px-2 text-[13px] font-medium whitespace-nowrap text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",+ "flex h-8 min-w-0 flex-1 items-center justify-center rounded-full px-2 text-[13px] font-medium whitespace-nowrap text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring",source === t.id && "bg-background text-foreground shadow-soft",)}>@@ -79,34 +71,62 @@ export function LookPicker({))}</div>+ {source !== "custom" && (+ <div className="relative">+ <Search className="pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground" />+ <Input+ value={q}+ onChange={(e) => setQ(e.target.value)}+ placeholder={source === "soul" ? "Search 139 Soul looks — film, flash, editorial…" : "Search 44 looks — claymation, comic, watercolour…"}+ aria-label="Search looks"+ className="h-8 pl-8 text-[13px]"+ />+ </div>+ )}+{source === "fuobe" && (- <div role="tabpanel" id="look-panel-fuobe" aria-labelledby="look-tab-fuobe" className="space-y-2">- {engine === "open" && <p className="text-[12px] text-muted-foreground">Higgsfield's own looks run on the cloud engine; these 44 and Your own run on your ComfyUI.</p>}- <div className="relative">- <Search className="pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground" />- <Input value={q} onChange={(e) => setQ(e.target.value)} placeholder="Search 44 looks — claymation, comic, watercolour…" aria-label="Search looks" className="h-8 pl-8 text-[13px]" />- </div>- <div className="grid max-h-[460px] grid-cols-3 gap-1 overflow-y-auto pr-0.5 sm:grid-cols-4 xl:grid-cols-5">- {presets.map((p) => (- <LookCard- key={p.id}- id={p.id}- name={p.name}- description={p.description}- preview={shortsPreview(p)}- hue={p.hue}- selected={look?.kind === "preset" && look.id === p.id}- onSelect={(id) => onLook({ kind: "preset", id })}- />- ))}- {!presets.length && <p className="col-span-full py-6 text-center text-[13px] text-muted-foreground">No look matches “{q}”.</p>}- </div>+ <div role="tabpanel" id="look-panel-fuobe" aria-labelledby="look-tab-fuobe" className="grid max-h-[460px] grid-cols-3 gap-1 overflow-y-auto pr-0.5 sm:grid-cols-4 xl:grid-cols-5">+ {presets.map((p) => (+ <LookCard+ key={p.id}+ id={p.id}+ name={p.name}+ description={p.description}+ preview={shortsPreview(p)}+ hue={p.hue}+ selected={look?.kind === "preset" && look.id === p.id}+ onSelect={(id) => onLook({ kind: "preset", id })}+ />+ ))}+ {!presets.length && <p className="col-span-full py-6 text-center text-[13px] text-muted-foreground">No look matches “{q}”.</p>}</div>)}- {source === "higgsfield" && (- <div role="tabpanel" id="look-panel-higgsfield" aria-labelledby="look-tab-higgsfield">- <HiggsfieldLooks enabled={higgsfield} selected={look?.kind === "higgsfield" ? look.id : undefined} onPick={(id, name) => onLook({ kind: "higgsfield", id, name })} />+ {source === "soul" && (+ <div role="tabpanel" id="look-panel-soul" aria-labelledby="look-tab-soul" className="space-y-2">+ <p className="text-[12px] text-muted-foreground">Fuobe Soul's looks: their words and LoRAs restyle the first frame, and every frame follows it.</p>+ <div className="grid max-h-[460px] grid-cols-3 gap-1.5 overflow-y-auto pr-0.5 sm:grid-cols-4 xl:grid-cols-5">+ {souls.map((l) => {+ const on = look?.kind === "soul" && look.id === l.id;+ return (+ <button+ key={l.id}+ type="button"+ aria-pressed={on}+ title={l.description}+ onClick={() => onLook({ kind: "soul", id: l.id })}+ className={cn("group flex min-w-0 flex-col gap-1 rounded-xl p-1.5 text-left outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring", on && "bg-brand-faint hover:bg-brand-faint-hover")}+ >+ <span className={cn("relative aspect-[4/5] w-full overflow-hidden rounded-lg", on && "ring-2 ring-primary")}>+ <CuratedCover m={{ name: "", ...curatedLook(l.id) }} className="size-full" />+ </span>+ <span className="truncate px-0.5 text-[13px] font-medium">{l.name}</span>+ <span className="px-0.5 text-[11px] text-muted-foreground">{l.family === "v2" ? "Soul 2.0" : "Soul"}</span>+ </button>+ );+ })}+ {!souls.length && <p className="col-span-full py-6 text-center text-[13px] text-muted-foreground">No Soul look matches “{q}”.</p>}+ </div></div>)}@@ -127,47 +147,3 @@ export function LookPicker({</div>);}--function HiggsfieldLooks({ enabled, selected, onPick }: { enabled: boolean; selected?: string; onPick: (id: string, name: string) => void }) {- const list = useHiggsfieldLooks(enabled);- if (!enabled) {- return (- <p className="rounded-xl bg-muted/60 p-3 text-[13px] text-muted-foreground">- Higgsfield's own Genjutsu looks load live with a Higgsfield key (Settings → API keys). The 44 looks and Your own work without one.- </p>- );- }- if (list.isLoading) {- return (- <p className="flex items-center gap-2 py-6 text-[13px] text-muted-foreground">- <Loader2 className="size-4 animate-spin" /> Loading Higgsfield's looks…- </p>- );- }- const items = list.data?.items ?? [];- if (!items.length) return <p className="py-6 text-[13px] text-muted-foreground">{list.data?.error ?? "Higgsfield returned no looks — try again later, or pick one of the 44 looks."}</p>;- return (- <div className="grid max-h-[460px] grid-cols-3 gap-1.5 overflow-y-auto sm:grid-cols-4 xl:grid-cols-5">- {items.map((p) => (- <button- key={p.id}- type="button"- aria-pressed={selected === p.id}- onClick={() => onPick(p.id, p.name)}- className={cn("flex min-w-0 flex-col gap-1.5 rounded-xl p-1.5 text-left outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring", selected === p.id && "bg-brand-faint hover:bg-brand-faint-hover")}- >- <span className={cn("relative grid aspect-[4/5] w-full place-items-center overflow-hidden rounded-lg bg-muted", selected === p.id && "ring-2 ring-primary")}>- {/* eslint-disable-next-line @next/next/no-img-element */}- {p.preview ? <img src={p.preview} alt="" className="size-full object-cover" loading="lazy" /> : <ImagePlus className="size-5 text-muted-foreground" />}- {selected === p.id && (- <span className="absolute top-1.5 right-1.5 grid size-6 place-items-center rounded-full bg-primary text-primary-foreground">- <Check className="size-3.5" />- </span>- )}- </span>- <span className="truncate px-0.5 text-[13px] font-medium">{p.name}</span>- </button>- ))}- </div>- );-}diff --git a/src/components/genjutsu/use-cuts.ts b/src/components/genjutsu/use-cuts.tsnew file mode 100644index 00000000..89742093--- /dev/null+++ b/src/components/genjutsu/use-cuts.ts@@ -0,0 +1,37 @@+"use client";++import { useEffect, useState } from "react";+import { frameDiff, openVideo, releaseVideo, sampleFrames } from "@/components/av/frame-sampler";+import { detectCuts } from "@/lib/av/katana";++/**+ * The hard cuts in a clip, found in the browser (Katana's frame-difference pass: about 6 samples a second at 48 px,+ * at most 180 over the clip). Character swap warns when its part has one: H3 swaps one continuous shot. Null while+ * it reads (or when the browser can't read the clip's frames).+ */+export function useClipCuts(src: string | undefined, enabled: boolean): number[] | null {+ const [found, setFound] = useState<{ src: string; cuts: number[] } | null>(null);+ useEffect(() => {+ if (!enabled || !src || found?.src === src) return;+ const stop = new AbortController();+ void (async () => {+ let v: HTMLVideoElement | null = null;+ try {+ v = await openVideo(src);+ const duration = v.duration || 0;+ const fps = Math.min(6, 180 / Math.max(1, duration));+ const times = Array.from({ length: Math.max(2, Math.floor(duration * fps)) }, (_, i) => i / fps);+ const frames = await sampleFrames(v, times, { width: 48, signal: stop.signal });+ if (stop.signal.aborted) return;+ const diffs = frames.slice(1).map((f, i) => frameDiff(frames[i].data, f.data));+ setFound({ src, cuts: detectCuts(diffs, frames.map((f) => f.t)) });+ } catch {+ // The browser can't read this clip's frames: no warning rather than a wrong one.+ } finally {+ if (v) releaseVideo(v);+ }+ })();+ return () => stop.abort();+ }, [src, enabled, found?.src]);+ return found && found.src === src ? found.cuts : null;+}diff --git a/src/lib/studios.ts b/src/lib/studios.tsindex f1a30cac..cdf5fb9b 100644--- a/src/lib/studios.ts+++ b/src/lib/studios.ts@@ -360,7 +360,7 @@ export const MOTION_CONTROL_STUDIO: StudioConfig = {],defaultModels: { cloud: "kling-motion-control", open: "oss-wan22-animate" },promptOptional: true,- related: { href: "/genjutsu?mode=motion", label: "Up to 30 s and 8 character images with Genjutsu" },+ related: { href: "/genjutsu?mode=character", label: "Swap the person in a clip for your character with Genjutsu" },};export const VIDEO_EDIT_STUDIO: StudioConfig = {