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
AI Influencer builder: polish from the browser check
Claude9658f2720bd8
diff --git a/src/components/influencer/influencer-builder.tsx b/src/components/influencer/influencer-builder.tsxindex 39090126..ed890da3 100644--- a/src/components/influencer/influencer-builder.tsx+++ b/src/components/influencer/influencer-builder.tsx@@ -13,6 +13,7 @@ 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 { Button } from "@/components/ui/button";+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";import { Textarea } from "@/components/ui/textarea";import { useEngine, useGenerations, useStatus } from "@/lib/api";import {@@ -113,10 +114,17 @@ export function InfluencerBuilder() {const [modelId, setModelId] = useState("auto");const [ids, setIds] = useState<string[]>([]);const clothingInput = useRef<HTMLInputElement>(null);+ const model = CLOUD_MODELS.find((m) => m.id === modelId) ?? CLOUD_MODELS[0];const categories = useMemo(() => categoriesFor(state.tier), [state.tier]);const category = categories.find((c) => c.id === active);const tab = category ? category.id : "tier";+ // The rail scrolls sideways on phones: keep the open category in view (a summary chip can open any).+ const railMoved = useRef(false);+ useEffect(() => {+ if (!railMoved.current) return void (railMoved.current = true);+ document.getElementById(`ib-tab-${tab}`)?.scrollIntoView({ block: "nearest", inline: "nearest" });+ }, [tab]);const summary = describeInfluencer(state);const rows = summaryRows(state);const tierLabel = HUMAN_TIERS.find((t) => t.id === state.tier)?.label ?? CREATURE_TYPES.find((c) => c.id === state.tier)?.label ?? "";@@ -174,7 +182,7 @@ export function InfluencerBuilder() {<EngineSwitch value={engine} onChange={setEngine} /></PageHeader>- <div className="grid gap-4 lg:grid-cols-[184px_minmax(0,1fr)] xl:grid-cols-[184px_minmax(0,1fr)_360px]">+ <div className="grid gap-4 lg:grid-cols-[212px_minmax(0,1fr)] xl:grid-cols-[212px_minmax(0,1fr)_340px]">{/* The rail: Character type, then the categories this type shows. Phones scroll it sideways inside itself. */}<divrole="tablist"@@ -271,7 +279,7 @@ export function InfluencerBuilder() {</div><div className="space-y-3 rounded-2xl border bg-background p-4">- <div role="radiogroup" aria-label="How to start" onKeyDown={radioKeys} className="scrollbar-none flex max-w-full overflow-x-auto rounded-full bg-muted p-0.5">+ <div role="radiogroup" aria-label="How to start" onKeyDown={radioKeys} className="grid grid-cols-3 rounded-2xl bg-muted p-0.5">{STARTS.map(([id, label]) => (<buttonkey={id}@@ -280,7 +288,7 @@ export function InfluencerBuilder() {aria-checked={start === id}tabIndex={radioTab(start === id)}onClick={() => setStart(id)}- className={cn("h-8 flex-1 shrink-0 rounded-full px-3 text-[12.5px] font-medium whitespace-nowrap text-muted-foreground transition outline-none focus-visible:ring-2 focus-visible:ring-ring", start === id && "bg-background text-foreground shadow-soft")}+ className={cn("min-h-8 rounded-[14px] px-1.5 py-1 text-[12.5px] leading-tight font-medium text-muted-foreground transition outline-none focus-visible:ring-2 focus-visible:ring-ring", start === id && "bg-background text-foreground shadow-soft")}>{label}</button>@@ -347,30 +355,26 @@ export function InfluencerBuilder() {<div className="space-y-3 rounded-2xl border bg-background p-4">{engine === "cloud" ? (- <div role="radiogroup" aria-label="Model" onKeyDown={radioKeys} className="space-y-1.5">- {CLOUD_MODELS.map((m) => (- <button- key={m.id}- type="button"- role="radio"- aria-checked={modelId === m.id}- tabIndex={radioTab(modelId === m.id)}- onClick={() => setModelId(m.id)}- className={cn(- "flex w-full min-w-0 items-start gap-2.5 rounded-xl border px-3 py-2 text-left transition-colors outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring",- modelId === m.id && "border-primary bg-brand-faint hover:bg-brand-faint-hover",- )}- >- <span className={cn("mt-1 size-3 shrink-0 rounded-full border-2", modelId === 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"}- </span>- </span>- </button>- ))}+ <div className="space-y-1.5">+ <label htmlFor="ib-model" className="text-[13px] font-medium">+ Model+ </label>+ <Select value={modelId} onValueChange={setModelId}>+ <SelectTrigger id="ib-model" className="w-full" aria-describedby="ib-model-note">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {CLOUD_MODELS.map((m) => (+ <SelectItem key={m.id} value={m.id}>+ {m.label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ <p id="ib-model-note" className="text-[12px] leading-snug text-muted-foreground">+ {model.note}+ {model.higgsfield && !higgsfield && " · needs a Higgsfield key"}+ </p></div>) : (<p className="text-[12.5px] text-muted-foreground">@@ -399,7 +403,7 @@ export function InfluencerBuilder() {<ResultsGriditems={mine}ratio={2}- className="sm:grid-cols-1 lg:grid-cols-2"+ className="grid-cols-1 sm:grid-cols-1 lg:grid-cols-2"onRetried={(from, to) => setIds((xs) => (xs.length ? xs.flatMap((id) => (id === from ? to : [id])) : xs))}/>{latest && <SaveCharacter key={latest.id} item={latest} extra={start === "face" && photo && !photo.uploading ? [photo.ref] : []} defaultName={influencerName(state)} />}diff --git a/src/components/influencer/option-panel.tsx b/src/components/influencer/option-panel.tsxindex d7796510..d778e15b 100644--- a/src/components/influencer/option-panel.tsx+++ b/src/components/influencer/option-panel.tsx@@ -126,7 +126,7 @@ export function TierPanel({ state, onTier, onSpecies, onBodyColor }: { state: In</span><span className="min-w-0"><span className="block text-[13px] font-medium">{label}</span>- <span className="block truncate text-[12px] text-muted-foreground">{hint}</span>+ <span className="block text-[12px] leading-snug text-muted-foreground">{hint}</span></span></button>);@@ -140,7 +140,7 @@ export function TierPanel({ state, onTier, onSpecies, onBodyColor }: { state: In</div><div className="space-y-2"><p className="text-[12px] font-medium text-muted-foreground">Creature</p>- <div className="grid grid-cols-2 gap-2 sm:grid-cols-3">{CREATURE_TYPES.map((c) => tile(c.id, c.label, `Anthropomorphic ${c.label.toLowerCase()}`))}</div>+ <div className="grid grid-cols-2 gap-2 sm:grid-cols-3">{CREATURE_TYPES.map((c) => tile(c.id, c.label, `${c.species.length} species`))}</div></div></div>{creature && (@@ -197,7 +197,7 @@ export function OptionTiles({ category, state, onPick }: { category: InfluencerCconst Icon = CATEGORY_ICON[category.id] ?? Sparkles;const colour = category.kind === "color";return (- <div role="group" aria-label={category.label} className={cn("grid gap-2", colour ? "grid-cols-2 sm:grid-cols-3 xl:grid-cols-4" : "grid-cols-2 sm:grid-cols-3 xl:grid-cols-4")}>+ <div role="group" aria-label={category.label} className="grid grid-cols-2 gap-2 sm:grid-cols-3">{category.options.map((o) => {const on = picked.includes(o.id);const conflict = on ? null : conflictFor(state, category.id, o.id);diff --git a/src/lib/influencer.ts b/src/lib/influencer.tsindex 6d6f64a7..034685df 100644--- a/src/lib/influencer.ts+++ b/src/lib/influencer.ts@@ -135,18 +135,23 @@ export function togglePick(state: InfluencerState, category: string, id: string)return { state: { ...state, picks }, ...(was && { note: `${c.label}: up to ${c.max} — ${was} was replaced` }) };}-/** Switch the character type: picks the new tier doesn't show are dropped (named in `dropped`), and so are new conflicts. */+/**+ * Switch the character type: picks the new tier doesn't show are dropped, and so are new conflicts.+ * `dropped` names them: the option, or the category when the new type doesn't show it at all.+ */export function setTier(state: InfluencerState, tier: InfluencerTier): { state: InfluencerState; dropped: string[] } {if (tier === state.tier) return { state, dropped: [] };const dropped: string[] = [];const picks: Record<string, string[]> = {};+ const shown = new Set(categoriesFor(tier).map((c) => c.id));for (const [cat, ids] of Object.entries(state.picks)) {const c = CATEGORY.get(cat);if (!c) continue;const keep = ids.filter((id) => {const o = c.options.find((x) => x.id === id);const ok = !!o && optionVisible(o, tier, cat);- if (!ok && o) dropped.push(o.label);+ // A whole category the new type doesn't have is named once ("Skin color"), else the option ("Hair horns").+ if (!ok && o) dropped.push(shown.has(cat) ? o.label : c.label);return ok;});if (keep.length) picks[cat] = keep;@@ -160,11 +165,10 @@ export function setTier(state: InfluencerState, tier: InfluencerTier): { state:picks[cat] = (picks[cat] ?? []).filter((x) => !ids.includes(x));if (!picks[cat].length) delete picks[cat];}- const creature = isCreature(tier);- const sameType = creature && state.tier === tier;+ // A species belongs to its type; a body colour carries over to another creature.return {- state: { tier, picks, locked: state.locked, ...(sameType && state.species && { species: state.species }), ...(creature && state.bodyColor && { bodyColor: state.bodyColor }) },- dropped,+ state: { tier, picks, locked: state.locked, ...(isCreature(tier) && state.bodyColor && { bodyColor: state.bodyColor }) },+ dropped: [...new Set(dropped)],};}@@ -628,7 +632,9 @@ export function describeInfluencer(state: InfluencerState): string {].filter((x): x is string => !!x);const accessories = state.picks.accessory ?? [];const parts = [subject(state), ...body];- if (pick1(state, "facial_hair") === "fh_none") parts.push("clean-shaven");+ // "Clean" is what Shuffle gives everyone but men and trans men: said only where it means something.+ const g = pick1(state, "gender");+ if (pick1(state, "facial_hair") === "fh_none" && (g === "male" || g === "trans_man" || !g)) parts.push("clean-shaven");if (withs.length) parts.push(`with ${list(withs)}`);const outfit = phrases(state, "aesthetic")[0];if (outfit) parts.push(`wearing ${outfit}`);@@ -839,7 +845,7 @@ export function planInfluencer(run: InfluencerRun, caps: PlanCaps): InfluencerPlnotes.push(photo ? (start === "face" ? "Two steps: Z-Image Turbo draws the sheet, then Qwen-Image-Edit 2511 puts your face on it" : "Two steps: Z-Image Turbo draws the sheet, then Qwen-Image-Edit 2511 matches it to your reference") : "Two steps: Z-Image Turbo draws the sheet, then Qwen-Image-Edit 2511 dresses it in your clothing");return {steps: [- { ...sheet, request: { ...sheet.request, feature: `${FEATURE}-step`, title: `${title} · sheet` } },+ { ...sheet, request: { ...sheet.request, feature: `${FEATURE}-step`, title: `${title} · sheet`, step: { label: "Drawing the sheet", index: 0, of: 2 } } },{key: "dress",after: "sheet",@@ -852,6 +858,7 @@ export function planInfluencer(run: InfluencerRun, caps: PlanCaps): InfluencerPlinputs: { images: [...(photo ? [photo] : []), ...used] },params: { numOutputs: 1 },title,+ step: { label: start === "face" ? "With your face" : start === "reference" ? "Matched to your reference" : "Dressed", index: 1, of: 2 },},},],diff --git a/src/server/influencer.ts b/src/server/influencer.tsindex f8e5e611..d4d8dc78 100644--- a/src/server/influencer.ts+++ b/src/server/influencer.ts@@ -3,6 +3,7 @@ import { getModel } from "@/lib/catalog";import type { Engine } from "@/lib/catalog/types";import { cleanState, planInfluencer, type InfluencerRun, type InfluencerStart } from "@/lib/influencer";import { createPipeline } from "./chains";+import { createGenerations } from "./generations";import { planCaps, previewRun, runEngine } from "./photodump";/**@@ -46,8 +47,13 @@ export function previewInfluencer(body: InfluencerBody) {export function createInfluencer(body: InfluencerBody) {const p = plan(body);- const title = p.steps[p.steps.length - 1].request.title ?? "AI Influencer";+ const last = p.steps[p.steps.length - 1];+ const title = last.request.title ?? "AI Influencer";+ if (p.steps.length === 1) {+ // One job: no "Step 1 of 1" on its tile.+ const items = createGenerations({ ...last.request, batchTitle: title });+ return { batchId: items[0]?.batchId ?? items[0]?.id, items, sheet: items[items.length - 1], notes: p.notes, modelId: p.modelId };+ }const { batchId, items, byKey } = createPipeline(p.steps.map((s) => ({ ...s, request: { ...s.request, batchTitle: title } })));- const last = p.steps[p.steps.length - 1].key;- return { batchId, items, sheet: byKey[last], notes: p.notes, modelId: p.modelId };+ return { batchId, items, sheet: byKey[last.key], notes: p.notes, modelId: p.modelId };}diff --git a/tests/influencer-api.test.ts b/tests/influencer-api.test.tsindex a576bb5e..f1b8df23 100644--- a/tests/influencer-api.test.ts+++ b/tests/influencer-api.test.ts@@ -71,6 +71,7 @@ describe("/api/influencer", () => {]);expect(run.items[0].prompt).toBe(compileCastPrompt({ state: state as never, direction: "A potter from Porto" }));expect(run.sheet.id).toBe(run.items[1].id);+ expect(run.items.map((g: { request: { step?: { label: string } } }) => g.request.step?.label)).toEqual(["Drawing the sheet", "With your face"]);expect(new Set(run.items.map((g: { batchId: string }) => g.batchId))).toEqual(new Set([run.batchId]));const done = await settle(run.sheet.id);expect(done.status).toBe("succeeded");@@ -97,7 +98,9 @@ describe("/api/influencer", () => {expect(redone.request.inputs?.images).toHaveLength(2);const one = await (await post({ engine: "cloud", state, start: "scratch" })).json();await gens.cancelGeneration(one.items[0].id);- expect(retryPhoto(one.items[0].id)[0]).toMatchObject({ feature: "influencer", batchId: one.batchId });+ expect(one.items).toHaveLength(1);+ expect(one.items[0].request.step).toBeUndefined();+ expect(retryPhoto(one.items[0].id)[0]).toMatchObject({ feature: "influencer", batchId: one.items[0].batchId });}, 60_000);it("follows the engine mode", async () => {diff --git a/tests/influencer.test.ts b/tests/influencer.test.tsindex efebd1d7..45d21eb9 100644--- a/tests/influencer.test.ts+++ b/tests/influencer.test.ts@@ -193,12 +193,12 @@ describe("switching the character type", () => {expect(r.dropped).toEqual(["Short legs"]);});- it("keeps the species within its type and the body colour for creatures", () => {+ it("drops the species of the old type, and keeps the body colour for creatures", () => {const cat = S("cats", { gender: ["male"] }, { species: "persian", bodyColor: "#ff8800" });expect(setTier(cat, "dogs").state).toMatchObject({ tier: "dogs", bodyColor: "#ff8800", picks: { gender: ["male"] } });expect(setTier(cat, "dogs").state.species).toBeUndefined();expect(setTier(cat, "normal").state.bodyColor).toBeUndefined();- expect(setTier(S("normal", { skin_tone: ["st_fair"] }), "cats").dropped).toEqual(["Fair"]);+ expect(setTier(S("normal", { skin_tone: ["st_fair"], freak_face: ["fn_freckles", "fn_dimples"], gender: ["male"] }), "cats").dropped).toEqual(["Skin color", "Features"]);});it("Reset all clears the picks and locks but keeps the type", () => {@@ -312,7 +312,8 @@ describe("the prompt compiler", () => {expect(describeInfluencer(S("normal", { hair: ["hair_afro"] }))).toBe("A person, with an afro.");expect(describeInfluencer(S("normal", { hair: ["hair_long"], hair_colour: ["hc_platinum"] }))).toContain("long platinum blonde hair");expect(describeInfluencer(S("normal", { hair: ["hair_bald"], hair_colour: ["hc_red"] }))).toContain("a bald head");- expect(describeInfluencer(S("normal", { gender: ["female"], facial_hair: ["fh_none"], accessory: ["acc_none"] }))).toBe("A woman, clean-shaven, no accessories.");+ expect(describeInfluencer(S("normal", { gender: ["female"], facial_hair: ["fh_none"], accessory: ["acc_none"] }))).toBe("A woman, no accessories.");+ expect(describeInfluencer(S("normal", { gender: ["male"], facial_hair: ["fh_none"] }))).toBe("A man, clean-shaven.");});it("words the tier: realistic, bold caricature, extreme caricature, anthropomorphic {species}", () => {