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
Home: a guest's Image, Video and Edit drafts are kept apart, each under its studio
Adarsh09c5cead4c41
diff --git a/src/components/home/home-studio-composer.tsx b/src/components/home/home-studio-composer.tsxindex a969b548..da4db83a 100644--- a/src/components/home/home-studio-composer.tsx+++ b/src/components/home/home-studio-composer.tsx@@ -6,6 +6,7 @@ import { useEffect, useMemo, useRef } from "react";import { CatalogProvider, useCatalog } from "@/components/studio/catalog";import { Composer } from "@/components/studio/composer";import { initialDraft } from "@/components/studio/draft";+import { GuestDraftPathCtx } from "@/components/studio/guest-draft";import { HoldFilesForGuests } from "@/components/studio/hold-files";import { StudioProvider, useStudio, type StudioConfig } from "@/components/studio/studio-context";import { CREATE_GENERATION_KEY, useEngine } from "@/lib/api";@@ -66,9 +67,12 @@ function StudioDraftBox({ mode, prompt, onPrompt }: { mode: HomeStudioMode; prom<StudioProvider config={config} initial={initial}><PromptReport onPrompt={onPrompt} /><OpenStudioOnRun mode={mode} />- <HoldFilesForGuests>- <Composer docked={false} />- </HoldFilesForGuests>+ {/* A guest's draft is kept as its studio keeps it, so Image, Video and Edit never share one. */}+ <GuestDraftPathCtx.Provider value={STUDIOS[mode].href}>+ <HoldFilesForGuests>+ <Composer docked={false} />+ </HoldFilesForGuests>+ </GuestDraftPathCtx.Provider></StudioProvider>);}diff --git a/src/components/studio/guest-draft.ts b/src/components/studio/guest-draft.tsindex 22420513..5533d6e9 100644--- a/src/components/studio/guest-draft.ts+++ b/src/components/studio/guest-draft.ts@@ -1,6 +1,6 @@"use client";-import { useCallback, useEffect, useRef, useState } from "react";+import { createContext, useCallback, useContext, useEffect, useRef, useState } from "react";import { clearDraft, readDraft, restoredDraft, restoredPrompt, sameDraft, saveDraft, savePendingRun, takePendingRun, type PendingRun, type ShownPrice } from "@/lib/guest-draft";import type { OwnSetup } from "@/lib/own-setup";import { replaceAttachment } from "@/lib/composer";@@ -24,6 +24,12 @@ export function uploadKept(held: SlotValue[], up: (v: SlotValue) => Promise<Slot).then(() => undefined);}+/**+ * The page a composer's guest draft is kept under, when it isn't the address: Home's composer keeps each mode's draft+ * as its studio does (`/video`), so the modes never share one.+ */+export const GuestDraftPathCtx = createContext<string | null>(null);+/*** A guest's whole draft through sign-up (hosted runs on; src/lib/guest-draft.ts), for the studio composer:* - a guest whose files are kept in this browser (`hold`) has the draft saved for this page as it changes;@@ -34,10 +40,11 @@ export function uploadKept(held: SlotValue[], up: (v: SlotValue) => Promise<Slot* Nothing happens for the owner, nor for a guest with hosted runs off (nothing is saved for them).*/export function useGuestDraft({ hold, viewer, draft, setDraft }: { hold: boolean; viewer: "guest" | "account" | undefined; draft: Draft; setDraft: (patch: Partial<Draft> | ((d: Draft) => Partial<Draft>)) => void }) {+ const named = useContext(GuestDraftPathCtx);const path = useRef<string | null>(null);useEffect(() => {- path.current = window.location.pathname;- }, []);+ path.current = named ?? window.location.pathname;+ }, [named]);const [pending, setPending] = useState<(PendingRun & { same: boolean }) | null>(null);const [lost, setLost] = useState(false);