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
Save as element popover keeps focus; stream catch-up only after a reconnect; list thumbnails
Claudea9b29c4e8062
diff --git a/src/components/studio/result-actions.tsx b/src/components/studio/result-actions.tsxindex 2eca3d61..85d3a5fb 100644--- a/src/components/studio/result-actions.tsx+++ b/src/components/studio/result-actions.tsx@@ -27,7 +27,7 @@ import {} from "lucide-react";import Link from "next/link";import { useRouter } from "next/navigation";-import { useMemo, useState, useSyncExternalStore } from "react";+import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";import { toast } from "sonner";import {DropdownMenu,@@ -161,6 +161,12 @@ export function SaveElementForm({ g, o, onDone }: { g: Generation; o: OutputFileconst router = useRouter();const [name, setName] = useState(() => characterName(g.request.prompt));const [kind, setKind] = useState<ElementKind>("character");+ const nameRef = useRef<HTMLInputElement>(null);+ // Focus once the menu that opened this has finished moving focus around.+ useEffect(() => {+ const t = setTimeout(() => nameRef.current?.select(), 60);+ return () => clearTimeout(t);+ }, []);const submit = () =>save.mutate({ name: name.trim() || "New character", kind, references: [o.url] },@@ -187,7 +193,7 @@ export function SaveElementForm({ g, o, onDone }: { g: Generation; o: OutputFile</label><inputid={`el-name-${g.id}`}- autoFocus+ ref={nameRef}value={name}onChange={(e) => setName(e.target.value)}maxLength={60}@@ -268,7 +274,8 @@ export function TileActions({const popover = saving && (<Popover open onOpenChange={(v) => !v && setSaving(false)}><PopoverAnchor className="absolute right-2 bottom-2" />- <PopoverContent align="end" collisionPadding={12} className="w-72" onClick={stop}>+ {/* Opened from a closing menu, which moves focus around: only a click outside or Esc closes it. */}+ <PopoverContent align="end" collisionPadding={12} className="w-72" onClick={stop} onFocusOutside={(e) => e.preventDefault()}><SaveElementForm g={g} o={g.outputs[index]} onDone={() => setSaving(false)} /></PopoverContent></Popover>diff --git a/src/lib/api.ts b/src/lib/api.tsindex f95813a2..4ca9c7fe 100644--- a/src/lib/api.ts+++ b/src/lib/api.ts@@ -78,6 +78,7 @@ const patched = (g: Generation, patch: Partial<Generation>): Generation => ({ ..const live = {connected: false,+ everConnected: false,subscribers: 0,listeners: new Set<() => void>(),abort: null as AbortController | null,@@ -112,8 +113,12 @@ async function connect() {}live.attempt = 0;setLive(true);- // Catch up on whatever changed while we were away.- void live.client.invalidateQueries({ queryKey: ["generations"] });+ // Back after a drop: catch up on whatever changed while we were away.+ if (live.everConnected) {+ void live.client.invalidateQueries({ queryKey: ["generations"] });+ void live.client.invalidateQueries({ queryKey: ["library"] });+ }+ live.everConnected = true;const reader = res.body.pipeThrough(new TextDecoderStream()).getReader();let buf = "";for (;;) {