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
Photo apps: ask before a run or a new pack, and Fuobe Soul leads to a character
Adarsh34f0849f876f
diff --git a/src/components/fashion/character-sheet.tsx b/src/components/fashion/character-sheet.tsxindex 6e482090..f1ca28ba 100644--- a/src/components/fashion/character-sheet.tsx+++ b/src/components/fashion/character-sheet.tsx@@ -13,6 +13,7 @@ import { Textarea } from "@/components/ui/textarea";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 { useAskFirst } from "@/components/photodump/ask-first";import { usePhotoCharacters, useRun, useRunPreview, useSaveCharacter } from "@/components/photodump/hooks";import { ResultsGrid } from "@/components/photodump/results";import { RunLine } from "@/components/photodump/steps";@@ -195,6 +196,9 @@ export function CharacterSheetView({ fields, defaults }: { fields: CastFieldData// A guest is asked to sign up before choosing photos, and an account with neither its own GPU nor its own key to// connect one.const askFirst = useAskBeforeUpload();+ // The sheet itself: a guest gets the sign-up card and an account with nothing to run on "Connect your GPU" before it is+ // sent (a press before the page knows who is looking waits for that).+ const askRun = useAskFirst();const [mode, setMode] = useState<Mode>("reference");const [photos, setPhotos] = useState<SlotValue[]>([]);const [details, setDetails] = useState("");@@ -232,15 +236,16 @@ export function CharacterSheetView({ fields, defaults }: { fields: CastFieldDatasetMode("reference");setPhotos((xs) => (xs.some((x) => x.ref === url) ? xs : [{ ref: url, preview: url, kind: "image" as const, id: nanoid(8) }, ...xs].slice(0, SHEET_MAX_REFS)));}, []);- const create = () => {- if (mode === "reference" && !photos.length) return toast("Upload at least 1 image");- if (!body) return toast(mode === "describe" ? "Describe your character first" : "Wait for the uploads to finish");- run.mutate(body, {- // The run line already says which model runs and why (its notes), so no toast here.- onSuccess: (r) => setIds((xs) => [...r.items.map((g) => g.id), ...xs]),- onError: (e) => toastError(e, "Failed to create character sheet"),- });- };+ const create = () =>+ askRun(() => {+ if (mode === "reference" && !photos.length) return toast("Upload at least 1 image");+ if (!body) return toast(mode === "describe" ? "Describe your character first" : "Wait for the uploads to finish");+ run.mutate(body, {+ // The run line already says which model runs and why (its notes), so no toast here.+ onSuccess: (r) => setIds((xs) => [...r.items.map((g) => g.id), ...xs]),+ onError: (e) => toastError(e, "Failed to create character sheet"),+ });+ }, "run");return (<PageShell wide>diff --git a/src/components/influencer/influencer-builder.tsx b/src/components/influencer/influencer-builder.tsxindex 90fb4063..c3a722e8 100644--- a/src/components/influencer/influencer-builder.tsx+++ b/src/components/influencer/influencer-builder.tsx@@ -6,6 +6,7 @@ import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from "reacimport { toast } from "sonner";import { SaveCharacter } from "@/components/fashion/character-sheet";import { PageHeader, PageShell } from "@/components/page-shell";+import { useAskFirst } from "@/components/photodump/ask-first";import { useRun, useRunPreview, type RunPreview } from "@/components/photodump/hooks";import { ResultsGrid } from "@/components/photodump/results";import { UploadBox } from "@/components/photodump/upload-box";@@ -122,6 +123,9 @@ export function InfluencerBuilder() {// A guest is asked to sign up before choosing photos, and an account with neither its own GPU nor its own key to// connect one.const askFirst = useAskBeforeUpload();+ // The sheet itself: a guest gets the sign-up card and an account with nothing to run on "Connect your GPU" before it is+ // sent (a press before the page knows who is looking waits for that).+ const askRun = useAskFirst();const wide = useWide();const [state, setState] = useState<InfluencerState>(INFLUENCER_START);const [active, setActive] = useState("tier");@@ -192,14 +196,15 @@ export function InfluencerBuilder() {if (clothing.length + list.length > MAX_CLOTHING) toast("You can add up to three clothing references");list.slice(0, MAX_CLOTHING - clothing.length).forEach((f) => fileToList(f, setClothing, "image"));};- const create = () => {- if (blocker) return toast(blocker);- if (!body) return toast("Wait for the uploads to finish");- run.mutate(body, {- onSuccess: (r) => setIds((xs) => [...r.items.map((g) => g.id), ...xs]),- onError: (e) => toastError(e, "Couldn't start the sheet"),- });- };+ const create = () =>+ askRun(() => {+ if (blocker) return toast(blocker);+ if (!body) return toast("Wait for the uploads to finish");+ run.mutate(body, {+ onSuccess: (r) => setIds((xs) => [...r.items.map((g) => g.id), ...xs]),+ onError: (e) => toastError(e, "Couldn't start the sheet"),+ });+ }, "run");return (<PageShell wide>diff --git a/src/components/photodump/ask-first.ts b/src/components/photodump/ask-first.tsnew file mode 100644index 00000000..e6287be3--- /dev/null+++ b/src/components/photodump/ask-first.ts@@ -0,0 +1,41 @@+"use client";++import { useCallback, useEffect, useRef } from "react";+import { useAskBeforeUpload, useStatus, useViewer, type RefusalAction } from "@/lib/api";++/** Whether who is looking is known well enough to ask first: a guest, the owner, or an account with its GPU and keys read. */+export function viewerKnown(v: { owner: boolean; account?: unknown } | undefined, viewerFailed: boolean, statusRead: boolean): boolean {+ if (viewerFailed) return true;+ if (!v) return false;+ return v.owner || !v.account || statusRead;+}++/**+ * Ask first, then act: a guest gets "Create a free account" and an account with neither its own GPU nor its own key+ * "Connect your GPU" (useAskBeforeUpload), anyone else `then`. A press made before the page knows who is looking waits+ * for that (a guest's early press opens the sign-up card, never the form), then goes the same way. Only for actions a+ * browser lets run a moment later (a dialog, a run), not a file chooser.+ */+export function useAskFirst(): (then: () => void, action?: RefusalAction) => void {+ const ask = useAskBeforeUpload();+ const viewer = useViewer();+ const status = useStatus();+ const known = viewerKnown(viewer.data, viewer.isError, !!status.data || status.isError);+ const waiting = useRef<{ then: () => void; action: RefusalAction } | null>(null);+ useEffect(() => {+ const w = waiting.current;+ if (!known || !w) return;+ waiting.current = null;+ if (!ask(w.action)) w.then();+ }, [known, ask]);+ return useCallback(+ (then: () => void, action: RefusalAction = "upload") => {+ if (!known) {+ waiting.current = { then, action };+ return;+ }+ if (!ask(action)) then();+ },+ [known, ask],+ );+}diff --git a/src/components/photodump/photodump-view.tsx b/src/components/photodump/photodump-view.tsxindex a16fcaa2..c35a327b 100644--- a/src/components/photodump/photodump-view.tsx+++ b/src/components/photodump/photodump-view.tsx@@ -11,7 +11,7 @@ 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 { useAskBeforeUpload, useEngine, useGenerations, useModelAccess } from "@/lib/api";+import { useEngine, useGenerations, useModelAccess } from "@/lib/api";import { keepOffered, offered } from "@/lib/model-access";import { customPack, DEFAULT_ASPECT, MAX_PACK_REFS, MAX_SELFIE_MB, PACKS, PHOTODUMP_ASPECTS, PHOTODUMP_MODELS, PHOTODUMP_SOUL, soulIdOf, type Pack } from "@/lib/catalog/packs";import type { Generation } from "@/lib/catalog/types";@@ -20,8 +20,9 @@ import { cn } from "@/lib/utils";import { onAttr, TAB_PILL, TabRow } from "@/components/ui/tab-row";import { linkTab, TabFromLink } from "@/components/nav/tab-from-link";import { toastError } from "@/lib/refusals";+import { useAskFirst } from "./ask-first";import { PackCover } from "./covers";-import { usePhotoCharacters, useRun, useRunPreview, usePackActions, useUserPacks } from "./hooks";+import { useOwnsElements, usePhotoCharacters, useRun, useRunPreview, usePackActions, useUserPacks } from "./hooks";import { DownloadAll, ResultsGrid, runState } from "./results";import { RunLine, Steps } from "./steps";import { CharacterPicker } from "./subject";@@ -157,7 +158,7 @@ export function PhotodumpView() {const [engine, setEngine] = useEngine();// A pack of your own is made of photos you upload: a guest is asked to sign up first, and an account with neither its// own GPU nor its own key to connect one (as before any upload). An account's packs and runs are its own.- const askFirst = useAskBeforeUpload();+ const askFirst = useAskFirst();const [step, setStep] = useState(0);const [reached, setReached] = useState(0);const [tab, setTab] = useState<PackTab>("all");@@ -200,9 +201,14 @@ export function PhotodumpView() {// Models switched off in Settings → Models & licences leave the choices (Auto picks among the ones on).const access = useModelAccess();const choices: (string | undefined)[] = [undefined, ...keepOffered(PHOTODUMP_MODELS[engine], (m) => offered(access, m, engine))];+ // The owner trains a character's Soul ID (Elements) for Fuobe Soul. A visitor's characters are its own photos: Fuobe+ // Soul stays a choice, its press opens "My character" (pick one, or make one there), and the run line says which model+ // makes the set from that character's photo.+ const owner = useOwnsElements();const unavailable = (m?: string): string | null => {if (m !== PHOTODUMP_SOUL) return null;if (pack?.custom) return "Your own packs recreate each reference photo with an edit model";+ if (!owner) return null;if (!character) return "Pick a trained character";return soulIdOf({ kind: "element", handle: character.handle, name: character.name, references: character.references, loras: character.loras }, engine) ? null : `${character.name} isn't trained yet`;};@@ -267,7 +273,7 @@ export function PhotodumpView() {<div className="grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-5"><buttontype="button"- onClick={() => askFirst() || setCreatingPack(true)}+ onClick={() => askFirst(() => setCreatingPack(true))}className="flex aspect-[3/4] flex-col items-center justify-center gap-2 rounded-xl border border-dashed p-4 text-center text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"><Plus className="size-6" />@@ -412,7 +418,11 @@ export function PhotodumpView() {disabled={!!why}title={why ?? undefined}aria-label={why ? `${m ? MODEL_NAMES[m] : "Auto"} — ${why}` : undefined}- onClick={() => setModelPick(m)}+ onClick={() => {+ setModelPick(m);+ // A visitor's Fuobe Soul starts from a character of its own: "My character" picks one or makes one.+ if (m === PHOTODUMP_SOUL && !owner && !pack.custom) setSubjectMode("character");+ }}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",diff --git a/src/components/photodump/subject.tsx b/src/components/photodump/subject.tsxindex 3d21b7f3..b0d0e1d4 100644--- a/src/components/photodump/subject.tsx+++ b/src/components/photodump/subject.tsx@@ -9,7 +9,7 @@ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, Dimport { Input } from "@/components/ui/input";import { Skeleton } from "@/components/ui/skeleton";import { fileToList, type SlotValue } from "@/components/studio/media-slot";-import { useAskBeforeUpload } from "@/lib/api";+import { useAskFirst } from "./ask-first";import type { StudioElement } from "@/lib/catalog/elements";import { SOUL_ID_COPY, SOUL_ID_PHOTOS } from "@/lib/catalog/training";import { cn } from "@/lib/utils";@@ -132,14 +132,14 @@ export function CharacterPicker({ value, onChange }: { value?: string; onChange:const { data, isLoading } = usePhotoCharacters();const [creating, setCreating] = useState(false);// A guest is asked to sign up first, and an account with neither its own GPU nor its own key to connect one.- const askFirst = useAskBeforeUpload();+ const askFirst = useAskFirst();const characters = (data ?? []).filter((e) => e.kind === "character");return (<><div className="grid grid-cols-3 gap-2 sm:grid-cols-4 lg:grid-cols-6"><buttontype="button"- onClick={() => askFirst() || setCreating(true)}+ onClick={() => askFirst(() => setCreating(true))}className="flex aspect-[3/4] flex-col items-center justify-center gap-1.5 rounded-xl border border-dashed text-[12.5px] font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"><Plus className="size-5" /> New characterdiff --git a/src/lib/catalog/packs.ts b/src/lib/catalog/packs.tsindex 6c7c0770..5c30e1b4 100644--- a/src/lib/catalog/packs.ts+++ b/src/lib/catalog/packs.ts@@ -416,7 +416,10 @@ export function photodumpModel(subject: PhotoSubject, engine: Engine, _caps: Placonst note =pick === PHOTODUMP_SOUL && custom? `Your own packs recreate each reference photo — ${name} runs them`- : pick === PHOTODUMP_SOUL && subject.kind === "selfie"+ : pick === PHOTODUMP_SOUL && subject.kind === "selfie" && subject.name+ ? // An account's own character (its photos, no Soul ID): the edit model keeps its face from its photo.+ `${name} makes ${subject.name}'s photos from their saved photo, keeping their face`+ : pick === PHOTODUMP_SOUL && subject.kind === "selfie"? `Fuobe Soul needs a character with a trained Soul ID — ${name} works from your photo`: pick === PHOTODUMP_SOUL || (engine === "open" && subject.kind === "element" && !trained && !custom)? `No Soul ID yet — ${name} works from the character's photos (train them for Fuobe Soul on the Elements page)`diff --git a/tests/image-studios.test.ts b/tests/image-studios.test.tsindex ec2981ea..e1e856c5 100644--- a/tests/image-studios.test.ts+++ b/tests/image-studios.test.ts@@ -589,6 +589,11 @@ describe("Photodump: model choice and retries", () => {expect(photodumpModel(selfie, "cloud", {}).modelId).toBe("qwen-image-edit-2511-cloud");expect(photodumpModel(selfie, "open", {}, "fuobe-soul", true).note).toMatch(/Your own packs recreate each reference photo/);expect(photodumpModel(selfie, "open", {}).note).toBeUndefined();+ // An account's own character (its photo, no Soul ID) picked with Fuobe Soul: the run says what makes its photos,+ // with no step it couldn't take.+ const mine: PhotoSubject = { kind: "selfie", url: "/api/files/accounts/a/maya.png", name: "Maya" };+ expect(photodumpModel(mine, "cloud", {}, "fuobe-soul")).toEqual({ modelId: "qwen-image-edit-2511-cloud", note: "Qwen-Image-Edit 2511 makes Maya's photos from their saved photo, keeping their face" });+ expect(photodumpModel(mine, "open", {}, "fuobe-soul").note).not.toMatch(/Elements|trained|train/);// A demo training's stand-in isn't a Soul ID.const demo: PhotoSubject = { kind: "element", handle: "Maya", name: "Maya", references: ["/a.png"], loras: [{ engine: "cloud", modelId: "fuobe-soul", family: "z-image-turbo", file: "fuobe/x.safetensors", trigger: "t", demo: true }] };expect(photodumpModel(demo, "open", {}).modelId).toBe("oss-qwen-image-21");diff --git a/tests/photo-apps-ask-first.test.ts b/tests/photo-apps-ask-first.test.tsnew file mode 100644index 00000000..5cd27f9d--- /dev/null+++ b/tests/photo-apps-ask-first.test.ts@@ -0,0 +1,97 @@+import { beforeEach, describe, expect, it, vi } from "vitest";++// Photodump's "Create pack" and "New character", and the Character Sheet's and AI Influencer's run, ask first: a guest+// gets the sign-up card, an account with nothing to run on "Connect your GPU", before the dialog opens or the run is+// sent. A press made before the page knows who is looking waits for that, never opening the dialog for a guest.++const state = vi.hoisted(() => ({+ viewer: undefined as undefined | { owner: boolean; account?: { email: string }; signedIn: boolean; publicSignup: boolean },+ viewerError: false,+ status: undefined as unknown,+ asked: [] as string[],+ refusing: false,+ refs: [] as { current: unknown }[],+ ref: 0,+ effects: [] as (() => void)[],+}));++// One hook harness, outside React: refs keep their value between renders, effects run after each render.+vi.mock("react", async (importOriginal) => ({+ ...(await importOriginal<typeof import("react")>()),+ useCallback: <T,>(f: T) => f,+ useRef: (init: unknown) => (state.refs[state.ref] ??= { current: init }, state.refs[state.ref++]),+ useEffect: (f: () => void) => void state.effects.push(f),+}));+vi.mock("@/lib/api", () => ({+ useViewer: () => ({ data: state.viewer, isError: state.viewerError }),+ useStatus: () => ({ data: state.status, isError: false }),+ // The real ask: true (and the card opens) for a guest or an account with nothing to run on.+ useAskBeforeUpload: () => (action: string) => (state.refusing ? (state.asked.push(action), true) : false),+}));++const { useAskFirst, viewerKnown } = await import("@/components/photodump/ask-first");++// One render of the hook (outside React, by the mocks above).+function render() {+ state.ref = 0;+ state.effects = [];+ // eslint-disable-next-line react-hooks/rules-of-hooks+ const ask = useAskFirst();+ for (const f of state.effects) f();+ return ask;+}++beforeEach(() => {+ Object.assign(state, { viewer: undefined, viewerError: false, status: undefined, asked: [], refusing: false, refs: [], ref: 0, effects: [] });+});++describe("asking first on the photo apps", () => {+ it("knows who is looking once the viewer is read (and, for an account, its GPU and keys)", () => {+ expect(viewerKnown(undefined, false, false)).toBe(false);+ expect(viewerKnown(undefined, true, false)).toBe(true);+ expect(viewerKnown({ owner: false }, false, false)).toBe(true);+ expect(viewerKnown({ owner: true }, false, false)).toBe(true);+ expect(viewerKnown({ owner: false, account: { email: "[email protected]" } }, false, false)).toBe(false);+ expect(viewerKnown({ owner: false, account: { email: "[email protected]" } }, false, true)).toBe(true);+ });++ it("a guest's press before the viewer loads waits, then opens the sign-up card, never the dialog", () => {+ const opened: string[] = [];+ render()(() => opened.push("dialog"));+ expect(opened).toEqual([]);+ expect(state.asked).toEqual([]);+ // The viewer arrives: a guest.+ state.viewer = { owner: false, signedIn: false, publicSignup: true };+ state.refusing = true;+ render();+ expect(state.asked).toEqual(["upload"]);+ expect(opened).toEqual([]);+ // Rendering again doesn't ask twice.+ render();+ expect(state.asked).toEqual(["upload"]);+ });++ it("an account's early press waits for its GPU and keys, then goes on when it has one", () => {+ const opened: string[] = [];+ state.viewer = { owner: false, account: { email: "[email protected]" }, signedIn: true, publicSignup: true };+ render()(() => opened.push("run"), "run");+ expect(opened).toEqual([]);+ state.status = { viewer: { kind: "account", gpu: { connected: true } } };+ render();+ expect(opened).toEqual(["run"]);+ expect(state.asked).toEqual([]);+ });++ it("once known, asks at the press: the card for a refusal, else the action", () => {+ state.viewer = { owner: false, signedIn: false, publicSignup: true };+ state.refusing = true;+ const opened: string[] = [];+ render()(() => opened.push("run"), "run");+ expect(state.asked).toEqual(["run"]);+ expect(opened).toEqual([]);+ state.refusing = false;+ state.viewer = { owner: true, signedIn: true, publicSignup: true };+ render()(() => opened.push("dialog"));+ expect(opened).toEqual(["dialog"]);+ });+});