Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

Rebuild media viewer (no flicker, 2026 look) + strip all create time estimates

purple1d38f2df108d
diff --git a/src/api/comfyui.ts b/src/api/comfyui.ts
index d505f507..a70521c2 100644
--- a/src/api/comfyui.ts
+++ b/src/api/comfyui.ts
@@ -864,8 +864,16 @@ export async function uploadImage(file: File): Promise<string> {
return data.name // ComfyUI returns { name, subfolder, type }
}
-export function getImageUrl(filename: string, subfolder: string = '', type: string = 'output'): string {
- return comfyuiUrl(`/view?filename=${encodeURIComponent(filename)}&subfolder=${encodeURIComponent(subfolder)}&type=${type}&t=${Date.now()}`)
+export function getImageUrl(filename: string, subfolder: string = '', type: string = 'output', cacheBust?: string | number): string {
+ const path = `/view?filename=${encodeURIComponent(filename)}&subfolder=${encodeURIComponent(subfolder)}&type=${type}`
+ // A cache-buster is appended ONLY when an explicit, STABLE token is supplied
+ // (e.g. a gallery item's immutable `createdAt`). We must never mint a fresh
+ // `Date.now()` per call: that returned a different URL on every React
+ // re-render, forcing the <img>/<video> to refetch mid-render — which is
+ // exactly what made the media viewer flicker while zooming/panning/loading.
+ // ComfyUI output filenames are unique per generation, so a per-item token is
+ // sufficient to defeat any rare filename-reuse cache collision.
+ return comfyuiUrl(cacheBust != null ? `${path}&t=${cacheBust}` : path)
}
// ─── Validate params ───
diff --git a/src/components/create/CreateView.tsx b/src/components/create/CreateView.tsx
index 155d2857..d165b486 100644
--- a/src/components/create/CreateView.tsx
+++ b/src/components/create/CreateView.tsx
@@ -303,11 +303,10 @@ export function CreateView() {
return () => clearInterval(id)
}, [loadingStartedAt])
+ // nowTick (1s interval) is kept only to re-evaluate the 60s "taking too
+ // long" threshold below — no elapsed-seconds is shown to the user anymore.
const loadingElapsedMs = loadingStartedAt ? nowTick - loadingStartedAt : 0
const loadingTooLong = loadingElapsedMs > 60_000
- const loadingElapsedLabel = loadingStartedAt
- ? `${Math.floor(loadingElapsedMs / 1000)}s`
- : ''
const killStuckComfyui = async () => {
setKilling(true)
@@ -563,7 +562,7 @@ export function CreateView() {
{isStarting && !connected && !loadingTooLong && (
<div className="flex items-center gap-2 px-4 py-2 bg-white/5 border-b border-white/5 text-gray-400 text-xs">
<Loader2 size={12} className="animate-spin" />
- <span>ComfyUI loading{loadingElapsedLabel ? ` (${loadingElapsedLabel})` : '...'}</span>
+ <span>ComfyUI loading...</span>
</div>
)}
{isStarting && !connected && loadingTooLong && (
@@ -573,7 +572,7 @@ export function CreateView() {
<div className="flex items-start gap-2 text-orange-300">
<AlertTriangle size={14} className="shrink-0 mt-0.5" />
<div className="space-y-1">
- <p className="font-medium">ComfyUI is taking unusually long ({loadingElapsedLabel})</p>
+ <p className="font-medium">ComfyUI is taking unusually long</p>
<p className="text-[10px] text-orange-200/70 leading-relaxed">
The process is alive but its web server hasn't responded. This usually means a CUDA / PyTorch wheel mismatch, an out-of-memory crash, or a custom-node import error. Check the startup logs below before restarting — they often name the failing module.
</p>
diff --git a/src/components/create/Gallery.tsx b/src/components/create/Gallery.tsx
index 086500f1..242df975 100644
--- a/src/components/create/Gallery.tsx
+++ b/src/components/create/Gallery.tsx
@@ -12,7 +12,6 @@ export function Gallery() {
const { gallery, removeFromGallery, clearGallery } = useCreateStore()
const [expanded, setExpanded] = useState(true)
const [page, setPage] = useState(0)
- const [selected, setSelected] = useState<GalleryItem | null>(null)
const [viewerIndex, setViewerIndex] = useState<number | null>(null)
if (gallery.length === 0) {
@@ -65,21 +64,17 @@ export function Gallery() {
>
<div className="flex gap-2 overflow-x-auto scrollbar-thin px-4 pb-3">
{visible.map((item, i) => {
- const url = getImageUrl(item.filename, item.subfolder)
+ // Stable URL (item's createdAt token) → no per-render refetch.
+ const url = getImageUrl(item.filename, item.subfolder, 'output', item.createdAt)
return (
<motion.div
key={item.id}
- className={`relative group shrink-0 cursor-pointer rounded-lg overflow-hidden border-2 transition-colors ${
- selected?.id === item.id ? 'border-purple-500' : 'border-transparent'
- }`}
+ className="relative group shrink-0 cursor-pointer rounded-lg overflow-hidden border border-transparent hover:border-[rgba(160,148,248,0.6)] transition-colors"
initial={{ opacity: 0, scale: 0.9 }}
animate={{ opacity: 1, scale: 1 }}
transition={{ delay: i * 0.02 }}
- onClick={() => {
- setSelected(selected?.id === item.id ? null : item)
- // Double-click opens viewer (single click selects)
- }}
- onDoubleClick={() => setViewerIndex(page * PAGE_SIZE + i)}
+ onClick={() => setViewerIndex(page * PAGE_SIZE + i)}
+ title="Open"
>
{item.type === 'video' ? (
<video
@@ -139,15 +134,6 @@ export function Gallery() {
</div>
)}
- {/* Selected item info */}
- {selected && (
- <div className="px-4 pb-2 flex items-center gap-2 text-xs text-gray-400">
- <span className="truncate flex-1">{selected.prompt}</span>
- <span>{selected.width}x{selected.height}</span>
- <span>Seed: {selected.seed}</span>
- <span>{selected.sampler}/{selected.scheduler}</span>
- </div>
- )}
</motion.div>
)}
</AnimatePresence>
diff --git a/src/components/create/MediaViewer.tsx b/src/components/create/MediaViewer.tsx
index c661532b..edd521ec 100644
--- a/src/components/create/MediaViewer.tsx
+++ b/src/components/create/MediaViewer.tsx
@@ -1,4 +1,5 @@
import { useState, useEffect, useRef, useCallback } from 'react'
+import { createPortal } from 'react-dom'
import { motion, AnimatePresence } from 'framer-motion'
import { X, Download, ChevronLeft, ChevronRight, ZoomIn, ZoomOut, Info } from 'lucide-react'
import { getImageUrl } from '../../api/comfyui'
@@ -11,208 +12,273 @@ interface Props {
onClose: () => void
}
+const MIN_ZOOM = 1
+const MAX_ZOOM = 5
+
+// Small round icon button used across the viewer chrome.
+function IconBtn({
+ children, title, onClick, active = false,
+}: { children: React.ReactNode; title: string; onClick: () => void; active?: boolean }) {
+ return (
+ <button
+ onClick={onClick}
+ title={title}
+ aria-label={title}
+ className={`p-2 rounded-full backdrop-blur transition-colors ${
+ active
+ ? 'bg-[rgba(160,148,248,0.28)] text-white ring-1 ring-[rgba(160,148,248,0.5)]'
+ : 'bg-white/10 text-white/90 hover:bg-white/20'
+ }`}
+ >
+ {children}
+ </button>
+ )
+}
+
+function NavBtn({ side, onClick }: { side: 'left' | 'right'; onClick: () => void }) {
+ return (
+ <button
+ onClick={(e) => { e.stopPropagation(); onClick() }}
+ aria-label={side === 'left' ? 'Previous' : 'Next'}
+ className={`absolute ${side === 'left' ? 'left-3' : 'right-3'} top-1/2 -translate-y-1/2 z-20 p-3 rounded-full bg-black/40 text-white/90 hover:bg-black/70 backdrop-blur transition-colors`}
+ >
+ {side === 'left' ? <ChevronLeft size={24} /> : <ChevronRight size={24} />}
+ </button>
+ )
+}
+
+function Meta({ k, v, wide = false }: { k: string; v: string; wide?: boolean }) {
+ return (
+ <span className={wide ? 'w-full sm:w-auto sm:max-w-[40ch] truncate' : ''}>
+ <b className="text-white/80 font-medium">{k}:</b> {v}
+ </span>
+ )
+}
+
export function MediaViewer({ gallery, initialIndex, onClose }: Props) {
const [index, setIndex] = useState(initialIndex)
const [zoom, setZoom] = useState(1)
const [pan, setPan] = useState({ x: 0, y: 0 })
const [dragging, setDragging] = useState(false)
const [showInfo, setShowInfo] = useState(false)
+ const [closing, setClosing] = useState(false)
+ // The URL whose media has finished loading. `ready` compares it to the
+ // current url synchronously, so a freshly-navigated item is at opacity 0
+ // from its very first render until it decodes (no flash of an empty frame).
+ const [loadedUrl, setLoadedUrl] = useState('')
const dragStart = useRef({ x: 0, y: 0 })
const panStart = useRef({ x: 0, y: 0 })
+ const stageRef = useRef<HTMLDivElement>(null)
- const item = gallery[index]
- if (!item) return null
+ // Clamp so a deleted item (gallery shrank under us) never indexes out of range.
+ const safeIndex = Math.max(0, Math.min(index, gallery.length - 1))
+ const item = gallery[safeIndex] as GalleryItem | undefined
+ const isVideo = item?.type === 'video'
- const url = getImageUrl(item.filename, item.subfolder)
+ // Stable URL: keyed on the item's immutable createdAt, so the string is
+ // identical across every re-render (zoom/pan/mouse-move) → no refetch, no
+ // flicker. Empty when the gallery has emptied out.
+ const url = item ? getImageUrl(item.filename, item.subfolder, 'output', item.createdAt) : ''
+ const ready = !!url && loadedUrl === url
- const resetView = () => { setZoom(1); setPan({ x: 0, y: 0 }) }
+ const resetView = useCallback(() => { setZoom(1); setPan({ x: 0, y: 0 }) }, [])
+
+ // Fade out first, then unmount via onClose (gives a smooth close without
+ // relying on a parent <AnimatePresence>, which the old code mis-used).
+ const requestClose = useCallback(() => setClosing(true), [])
const navigate = useCallback((dir: 1 | -1) => {
- const next = index + dir
- if (next >= 0 && next < gallery.length) {
- setIndex(next)
- resetView()
- }
- }, [index, gallery.length])
+ setIndex((i) => {
+ const next = i + dir
+ if (next < 0 || next > gallery.length - 1) return i
+ return next
+ })
+ resetView()
+ }, [gallery.length, resetView])
- // Keyboard handlers
+ // If the gallery empties while open, close cleanly.
+ useEffect(() => { if (!item && !closing) requestClose() }, [item, closing, requestClose])
+
+ // Keyboard navigation + zoom.
useEffect(() => {
const handler = (e: KeyboardEvent) => {
switch (e.key) {
- case 'Escape': onClose(); break
+ case 'Escape': requestClose(); break
case 'ArrowLeft': navigate(-1); break
case 'ArrowRight': navigate(1); break
- case '+': case '=': setZoom(z => Math.min(z + 0.5, 5)); break
- case '-': setZoom(z => Math.max(z - 0.5, 1)); if (zoom <= 1.5) setPan({ x: 0, y: 0 }); break
+ case '+': case '=': setZoom((z) => Math.min(z + 0.5, MAX_ZOOM)); break
+ case '-': case '_':
+ setZoom((z) => {
+ const n = Math.max(z - 0.5, MIN_ZOOM)
+ if (n <= 1) setPan({ x: 0, y: 0 })
+ return n
+ })
+ break
+ case '0': resetView(); break
}
}
window.addEventListener('keydown', handler)
return () => window.removeEventListener('keydown', handler)
- }, [onClose, navigate, zoom])
+ }, [navigate, requestClose, resetView])
- // Mouse wheel zoom
- const handleWheel = (e: React.WheelEvent) => {
- e.preventDefault()
- const delta = e.deltaY > 0 ? -0.2 : 0.2
- setZoom(z => {
- const next = Math.max(1, Math.min(5, z + delta))
- if (next <= 1) setPan({ x: 0, y: 0 })
- return next
- })
- }
+ // Wheel zoom via a non-passive native listener so preventDefault actually
+ // works (React's synthetic onWheel is passive → preventDefault is a no-op +
+ // console error). The overlay is fixed full-screen, so we suppress the
+ // underlying scroll entirely.
+ useEffect(() => {
+ const el = stageRef.current
+ if (!el) return
+ const onWheel = (e: WheelEvent) => {
+ e.preventDefault()
+ const delta = e.deltaY > 0 ? -0.25 : 0.25
+ setZoom((z) => {
+ const n = Math.max(MIN_ZOOM, Math.min(MAX_ZOOM, z + delta))
+ if (n <= 1) setPan({ x: 0, y: 0 })
+ return n
+ })
+ }
+ el.addEventListener('wheel', onWheel, { passive: false })
+ return () => el.removeEventListener('wheel', onWheel)
+ }, [])
- // Pan (drag) handlers
- const handleMouseDown = (e: React.MouseEvent) => {
+ // Pan (only meaningful while zoomed in).
+ const onMouseDown = (e: React.MouseEvent) => {
if (zoom <= 1) return
e.preventDefault()
setDragging(true)
dragStart.current = { x: e.clientX, y: e.clientY }
panStart.current = { ...pan }
}
-
- const handleMouseMove = (e: React.MouseEvent) => {
+ const onMouseMove = (e: React.MouseEvent) => {
if (!dragging) return
setPan({
x: panStart.current.x + (e.clientX - dragStart.current.x),
y: panStart.current.y + (e.clientY - dragStart.current.y),
})
}
+ const endDrag = () => setDragging(false)
- const handleMouseUp = () => setDragging(false)
-
- const handleDownload = () => downloadComfyFile(item.filename, item.subfolder)
+ const content = (
+ <motion.div
+ initial={{ opacity: 0 }}
+ animate={{ opacity: closing ? 0 : 1 }}
+ transition={{ duration: 0.18, ease: 'easeOut' }}
+ onAnimationComplete={() => { if (closing) onClose() }}
+ className="fixed inset-0 z-[100] flex flex-col bg-[#0b0b0e]/95 backdrop-blur-md"
+ onMouseMove={onMouseMove}
+ onMouseUp={endDrag}
+ onMouseLeave={endDrag}
+ >
+ {/* Top scrim keeps the controls readable over bright images. */}
+ <div className="absolute inset-x-0 top-0 h-24 bg-gradient-to-b from-black/55 to-transparent pointer-events-none z-10" />
- return (
- <AnimatePresence>
- <motion.div
- initial={{ opacity: 0 }}
- animate={{ opacity: 1 }}
- exit={{ opacity: 0 }}
- className="fixed inset-0 z-50 bg-black/95 flex flex-col"
- onMouseMove={handleMouseMove}
- onMouseUp={handleMouseUp}
- onMouseLeave={handleMouseUp}
- >
- {/* Top bar */}
- <div className="flex items-center justify-between px-4 py-3 z-10">
- <div className="text-white/60 text-sm">
- {index + 1} / {gallery.length}
- </div>
- <div className="flex items-center gap-2">
- <button
- onClick={() => setZoom(z => Math.max(1, z - 0.5))}
- className="p-2 rounded-full bg-white/10 text-white hover:bg-white/20 transition-colors"
- title="Zoom out (-)"
- >
- <ZoomOut size={18} />
- </button>
- <span className="text-white/60 text-xs w-12 text-center">{Math.round(zoom * 100)}%</span>
- <button
- onClick={() => setZoom(z => Math.min(5, z + 0.5))}
- className="p-2 rounded-full bg-white/10 text-white hover:bg-white/20 transition-colors"
- title="Zoom in (+)"
- >
- <ZoomIn size={18} />
- </button>
- <button
- onClick={() => setShowInfo(!showInfo)}
- className={`p-2 rounded-full transition-colors ${showInfo ? 'bg-white/25 text-white' : 'bg-white/10 text-white hover:bg-white/20'}`}
- title="Info"
- >
- <Info size={18} />
- </button>
- <button
- onClick={handleDownload}
- className="p-2 rounded-full bg-white/10 text-white hover:bg-white/20 transition-colors"
- title="Download"
- >
- <Download size={18} />
- </button>
- <button
- onClick={onClose}
- className="p-2 rounded-full bg-white/10 text-white hover:bg-white/20 transition-colors"
- title="Close (Esc)"
- >
- <X size={18} />
- </button>
- </div>
- </div>
-
- {/* Main content */}
- <div
- className="flex-1 flex items-center justify-center overflow-hidden relative"
- onWheel={handleWheel}
- >
- {/* Nav arrows */}
- {index > 0 && (
- <button
- onClick={(e) => { e.stopPropagation(); navigate(-1) }}
- className="absolute left-4 z-10 p-3 rounded-full bg-black/50 text-white hover:bg-black/70 transition-colors"
- >
- <ChevronLeft size={24} />
- </button>
- )}
- {index < gallery.length - 1 && (
- <button
- onClick={(e) => { e.stopPropagation(); navigate(1) }}
- className="absolute right-4 z-10 p-3 rounded-full bg-black/50 text-white hover:bg-black/70 transition-colors"
- >
- <ChevronRight size={24} />
- </button>
+ {/* Top bar */}
+ <div className="relative flex items-center justify-between px-4 py-3 z-20">
+ <div className="flex items-center gap-2 text-white/70 text-xs">
+ <span className="tabular-nums">{safeIndex + 1} / {gallery.length}</span>
+ {isVideo && (
+ <span className="px-1.5 py-0.5 rounded bg-white/10 text-[10px] uppercase tracking-wider text-white/60">Video</span>
)}
-
- {/* Media */}
- {item.type === 'video' ? (
- <video
- key={item.id}
- src={url}
- controls
- autoPlay
- loop
- className="max-w-[90vw] max-h-[80vh]"
- onClick={(e) => e.stopPropagation()}
- />
- ) : (
- <img
- key={item.id}
- src={url}
- alt={item.prompt}
- className="max-w-[90vw] max-h-[80vh] object-contain select-none"
- style={{
- transform: `scale(${zoom}) translate(${pan.x / zoom}px, ${pan.y / zoom}px)`,
- cursor: zoom > 1 ? (dragging ? 'grabbing' : 'grab') : 'default',
- transition: dragging ? 'none' : 'transform 0.15s ease-out',
- }}
- onMouseDown={handleMouseDown}
- draggable={false}
- />
+ </div>
+ <div className="flex items-center gap-1.5">
+ {!isVideo && (
+ <>
+ <IconBtn title="Zoom out (−)" onClick={() => setZoom((z) => {
+ const n = Math.max(MIN_ZOOM, z - 0.5)
+ if (n <= 1) setPan({ x: 0, y: 0 })
+ return n
+ })}>
+ <ZoomOut size={17} />
+ </IconBtn>
+ <span className="text-white/55 text-xs w-11 text-center tabular-nums">{Math.round(zoom * 100)}%</span>
+ <IconBtn title="Zoom in (+)" onClick={() => setZoom((z) => Math.min(MAX_ZOOM, z + 0.5))}>
+ <ZoomIn size={17} />
+ </IconBtn>
+ <div className="w-px h-5 bg-white/15 mx-1" />
+ </>
)}
+ <IconBtn title="Info" active={showInfo} onClick={() => setShowInfo((s) => !s)}>
+ <Info size={17} />
+ </IconBtn>
+ <IconBtn title="Download" onClick={() => item && downloadComfyFile(item.filename, item.subfolder)}>
+ <Download size={17} />
+ </IconBtn>
+ <IconBtn title="Close (Esc)" onClick={requestClose}>
+ <X size={17} />
+ </IconBtn>
</div>
+ </div>
- {/* Info panel */}
- <AnimatePresence>
- {showInfo && (
- <motion.div
- initial={{ height: 0, opacity: 0 }}
- animate={{ height: 'auto', opacity: 1 }}
- exit={{ height: 0, opacity: 0 }}
- className="overflow-hidden border-t border-white/10"
- >
- <div className="px-6 py-3 flex flex-wrap gap-x-6 gap-y-1 text-xs text-white/60">
- <span><b className="text-white/80">Prompt:</b> {item.prompt}</span>
- {item.negativePrompt && <span><b className="text-white/80">Negative:</b> {item.negativePrompt}</span>}
- <span><b className="text-white/80">Model:</b> {item.model}</span>
- <span><b className="text-white/80">Size:</b> {item.width}x{item.height}</span>
- <span><b className="text-white/80">Steps:</b> {item.steps}</span>
- <span><b className="text-white/80">CFG:</b> {item.cfgScale}</span>
- <span><b className="text-white/80">Sampler:</b> {item.sampler}/{item.scheduler}</span>
- <span><b className="text-white/80">Seed:</b> {item.seed}</span>
- {item.builderUsed && <span><b className="text-white/80">Builder:</b> {item.builderUsed}</span>}
- </div>
- </motion.div>
- )}
- </AnimatePresence>
- </motion.div>
- </AnimatePresence>
+ {/* Stage */}
+ <div
+ ref={stageRef}
+ className="flex-1 flex items-center justify-center overflow-hidden relative select-none"
+ onClick={(e) => { if (e.target === e.currentTarget) requestClose() }}
+ >
+ {safeIndex > 0 && <NavBtn side="left" onClick={() => navigate(-1)} />}
+ {safeIndex < gallery.length - 1 && <NavBtn side="right" onClick={() => navigate(1)} />}
+
+ {item && (isVideo ? (
+ <video
+ key={item.id}
+ src={url}
+ controls
+ autoPlay
+ loop
+ playsInline
+ className="max-w-[92vw] max-h-[82vh] rounded-lg shadow-2xl bg-black"
+ onLoadedData={() => setLoadedUrl(url)}
+ onClick={(e) => e.stopPropagation()}
+ style={{ opacity: ready ? 1 : 0, transition: 'opacity 0.2s ease-out' }}
+ />
+ ) : (
+ <img
+ key={item.id}
+ src={url}
+ alt={item.prompt}
+ onLoad={() => setLoadedUrl(url)}
+ draggable={false}
+ onMouseDown={onMouseDown}
+ className="max-w-[92vw] max-h-[82vh] object-contain rounded-lg shadow-2xl"
+ style={{
+ transform: `scale(${zoom}) translate(${pan.x / zoom}px, ${pan.y / zoom}px)`,
+ transition: dragging ? 'none' : 'transform 0.16s ease-out, opacity 0.2s ease-out',
+ opacity: ready ? 1 : 0,
+ cursor: zoom > 1 ? (dragging ? 'grabbing' : 'grab') : 'default',
+ }}
+ />
+ ))}
+ </div>
+
+ {/* Info panel */}
+ <AnimatePresence>
+ {showInfo && item && (
+ <motion.div
+ initial={{ height: 0, opacity: 0 }}
+ animate={{ height: 'auto', opacity: 1 }}
+ exit={{ height: 0, opacity: 0 }}
+ transition={{ duration: 0.18 }}
+ className="relative z-20 overflow-hidden border-t border-white/10 bg-black/40 backdrop-blur"
+ >
+ <div className="px-6 py-3 flex flex-wrap gap-x-6 gap-y-1.5 text-xs text-white/55">
+ <Meta k="Prompt" v={item.prompt} wide />
+ {item.negativePrompt && <Meta k="Negative" v={item.negativePrompt} wide />}
+ <Meta k="Model" v={item.model} />
+ <Meta k="Size" v={`${item.width}×${item.height}`} />
+ <Meta k="Steps" v={String(item.steps)} />
+ <Meta k="CFG" v={String(item.cfgScale)} />
+ <Meta k="Sampler" v={`${item.sampler}/${item.scheduler}`} />
+ <Meta k="Seed" v={String(item.seed)} />
+ {item.builderUsed && <Meta k="Builder" v={item.builderUsed} />}
+ </div>
+ </motion.div>
+ )}
+ </AnimatePresence>
+ </motion.div>
)
+
+ // Render into <body> so no ancestor transform/zoom/overflow (e.g. the +25%
+ // sidebar zoom, or a framer-motion scale animation) can break the fixed
+ // overlay's sizing/position.
+ return createPortal(content, document.body)
}
diff --git a/src/components/create/OutputDisplay.tsx b/src/components/create/OutputDisplay.tsx
index c9ab483b..f8b13212 100644
--- a/src/components/create/OutputDisplay.tsx
+++ b/src/components/create/OutputDisplay.tsx
@@ -7,9 +7,13 @@ import { useCreateStore, type GalleryItem } from '../../stores/createStore'
import { MediaViewer } from './MediaViewer'
export function OutputDisplay() {
- const { isGenerating, progress, progressText, progressPhase, gallery, lastGenTime } = useCreateStore()
+ const { isGenerating, progress, progressText, progressPhase, gallery } = useCreateStore()
const [viewerIndex, setViewerIndex] = useState<number | null>(null)
const [copiedSeed, setCopiedSeed] = useState(false)
+ // Gate the result media's fade-in on its own load so a freshly-finished
+ // generation never shows a half-painted frame. Keyed by item id so it
+ // auto-resets when a new result arrives.
+ const [loadedId, setLoadedId] = useState<string | null>(null)
const latest = gallery[0]
const handleDownload = (item: GalleryItem) => {
@@ -98,11 +102,12 @@ export function OutputDisplay() {
)}
</div>
<p className="text-gray-500 text-xs tracking-wide">{progressText || 'Generating...'}</p>
- {/* Progress bar for sampling */}
- {progressPhase === 'sampling' && progress > 0 && (
- <div className="w-48 h-1 bg-gray-200 dark:bg-white/10 rounded-full overflow-hidden">
+ {/* Progress bar — shown for the whole run (loading → sampling →
+ decoding). Steps live in progressText above. No time estimates. */}
+ {progress > 0 && (
+ <div className="w-56 h-1 bg-gray-200 dark:bg-white/10 rounded-full overflow-hidden">
<motion.div
- className="h-full bg-green-400 rounded-full"
+ className="h-full rounded-full bg-[rgb(160,148,248)]"
initial={{ width: 0 }}
animate={{ width: `${Math.min(progress, 100)}%` }}
transition={{ duration: 0.3 }}
@@ -129,8 +134,10 @@ export function OutputDisplay() {
)
}
- // Show latest result
- const url = getImageUrl(latest.filename, latest.subfolder)
+ // Show latest result — stable URL (item's createdAt as cache token) so the
+ // element never refetches across re-renders.
+ const url = getImageUrl(latest.filename, latest.subfolder, 'output', latest.createdAt)
+ const ready = loadedId === latest.id
return (
<>
@@ -142,18 +149,25 @@ export function OutputDisplay() {
>
{latest.type === 'video' ? (
<video
+ key={latest.id}
src={url}
controls
autoPlay
loop
- className="max-w-full max-h-full rounded-xl border border-gray-200 dark:border-white/10 object-contain cursor-pointer"
+ playsInline
+ onLoadedData={() => setLoadedId(latest.id)}
+ className="max-w-full max-h-full rounded-xl border border-gray-200 dark:border-white/10 object-contain cursor-pointer bg-black"
+ style={{ opacity: ready ? 1 : 0, transition: 'opacity 0.25s ease-out' }}
onClick={() => setViewerIndex(0)}
/>
) : (
<img
+ key={latest.id}
src={url}
alt={latest.prompt}
+ onLoad={() => setLoadedId(latest.id)}
className="max-w-full max-h-full rounded-xl border border-gray-200 dark:border-white/10 object-contain cursor-pointer"
+ style={{ opacity: ready ? 1 : 0, transition: 'opacity 0.25s ease-out' }}
onClick={() => setViewerIndex(0)}
/>
)}
diff --git a/src/components/create/ParamPanel.tsx b/src/components/create/ParamPanel.tsx
index 02f79b4b..d1c38d4a 100644
--- a/src/components/create/ParamPanel.tsx
+++ b/src/components/create/ParamPanel.tsx
@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react'
import { useCreateStore } from '../../stores/createStore'
import { SliderControl } from '../settings/SliderControl'
import { WorkflowFinder } from './WorkflowFinder'
-import { Dice5, Info, AlertTriangle, Film, ImageIcon, ImagePlus } from 'lucide-react'
+import { Dice5, AlertTriangle, Film, ImageIcon, ImagePlus } from 'lucide-react'
import type { ClassifiedModel, ModelType } from '../../api/comfyui'
import { snapToVideoGrid, isI2VModel, getLoraModels, getVAEModels } from '../../api/comfyui'
@@ -97,7 +97,6 @@ export function ParamPanel({ imageModels, videoModels, samplerList, schedulerLis
}
const activeModel = isVideo ? store.videoModel : store.imageModel
- const videoDuration = isVideo ? (store.frames / store.fps).toFixed(1) : null
return (
<div className="space-y-3">
@@ -292,10 +291,6 @@ export function ParamPanel({ imageModels, videoModels, samplerList, schedulerLis
<SliderControl label="Frames" value={store.frames} min={1} max={81} step={4} onChange={store.setFrames} />
<SliderControl label="FPS" value={store.fps} min={4} max={30} step={1} onChange={store.setFps} />
</div>
- <div className="flex items-center gap-1 text-[10px] text-gray-500">
- <Info size={10} />
- ~{videoDuration}s ({store.frames}f @ {store.fps}fps)
- </div>
{(store.width % 16 !== 0 || store.height % 16 !== 0) && (
<button
onClick={() => { const s = snapToVideoGrid(store.width, store.height); store.setSize(s.width, s.height) }}
diff --git a/src/hooks/useCreate.ts b/src/hooks/useCreate.ts
index cac800a1..59adc55b 100644
--- a/src/hooks/useCreate.ts
+++ b/src/hooks/useCreate.ts
@@ -28,7 +28,7 @@ import { buildDynamicWorkflow, WorkflowUnavailableError, checkVideoOutputCapabil
import { getAllNodeInfo } from '../api/comfyui-nodes'
import { installCustomNodes } from '../api/discover'
import { backendCall } from '../api/backend'
-import { useCreateStore, type GalleryItem } from '../stores/createStore'
+import { useCreateStore } from '../stores/createStore'
import { useSettingsStore } from '../stores/settingsStore'
import { useWorkflowStore } from '../stores/workflowStore'
import { injectParameters } from '../api/workflows'
@@ -454,7 +454,6 @@ export function useCreate() {
if (useWS) {
// ── WebSocket-driven progress ──
await new Promise<void>((resolve, reject) => {
- const startTime = Date.now()
const store = useCreateStore.getState()
store.setProgressPhase('queued')
setProgress(10, 'Queued...')
@@ -481,13 +480,7 @@ export function useCreate() {
cleanup()
useCreateStore.getState().setProgressPhase('complete')
setProgress(95, 'Fetching results...')
- const messages: [string, any][] = history.status?.messages ?? []
- const startMsg = messages.find(([t]: [string, any]) => t === 'execution_start')
- const endMsg = messages.find(([t]: [string, any]) => t === 'execution_success')
- const comfyTime = startMsg?.[1]?.timestamp && endMsg?.[1]?.timestamp
- ? ((endMsg[1].timestamp - startMsg[1].timestamp) / 1000).toFixed(1) : null
setProgress(100, 'Complete!')
- useCreateStore.getState().setLastGenTime(comfyTime ? `${comfyTime}s` : null)
const outputs = history.outputs ?? {}
let found = false
for (const nodeId of Object.keys(outputs)) {
@@ -534,7 +527,6 @@ export function useCreate() {
// Only handle events for our prompt
if ('prompt_id' in event.data && event.data.prompt_id !== promptId) return
- const elapsed = Math.round((Date.now() - startTime) / 1000)
const st = useCreateStore.getState()
switch (event.type) {
@@ -547,19 +539,19 @@ export function useCreate() {
const classType = nodeClassMap.get(nodeId) || ''
if (LOADER_NODES.has(classType)) {
st.setProgressPhase('loading-model')
- setProgress(15, `Loading model... ${elapsed}s`)
+ setProgress(15, 'Loading model...')
} else if (CLIP_LOADER_NODES.has(classType)) {
st.setProgressPhase('loading-clip')
- setProgress(25, `Loading text encoder... ${elapsed}s`)
+ setProgress(25, 'Loading text encoder...')
} else if (VAE_LOADER_NODES.has(classType)) {
st.setProgressPhase('loading-vae')
- setProgress(30, `Loading VAE... ${elapsed}s`)
+ setProgress(30, 'Loading VAE...')
} else if (SAMPLER_NODES.has(classType)) {
st.setProgressPhase('sampling')
- setProgress(35, `Sampling... ${elapsed}s`)
+ setProgress(35, 'Sampling...')
} else if (DECODE_NODES.has(classType)) {
st.setProgressPhase('decoding')
- setProgress(90, `Decoding... ${elapsed}s`)
+ setProgress(90, 'Decoding...')
}
break
}
@@ -567,7 +559,7 @@ export function useCreate() {
const { value, max } = event.data
const stepPct = 35 + (value / max) * 55 // 35% to 90%
st.setProgressPhase('sampling')
- setProgress(Math.round(stepPct), `Sampling step ${value}/${max}... ${elapsed}s`)
+ setProgress(Math.round(stepPct), `Sampling step ${value}/${max}`)
break
}
case 'execution_complete': {
@@ -579,13 +571,7 @@ export function useCreate() {
// Fetch history to get output files
getHistory(promptId).then(history => {
if (!history) { setError('No history found after completion.'); resolve(); return }
- const messages: [string, any][] = history.status?.messages ?? []
- const startMsg = messages.find(([t]) => t === 'execution_start')
- const endMsg = messages.find(([t]) => t === 'execution_success')
- const comfyTime = startMsg?.[1]?.timestamp && endMsg?.[1]?.timestamp
- ? ((endMsg[1].timestamp - startMsg[1].timestamp) / 1000).toFixed(1) : null
setProgress(100, 'Complete!')
- useCreateStore.getState().setLastGenTime(comfyTime ? `${comfyTime}s` : null)
const outputs = history.outputs ?? {}
let found = false
for (const nodeId of Object.keys(outputs)) {
@@ -661,24 +647,17 @@ export function useCreate() {
}
}
- const elapsedSec = Math.round(elapsed / 1000)
const expectedSteps = mode === 'video' ? steps * frames * 0.5 : steps * 2
const pct = Math.min(10 + (attempts / expectedSteps * 85), 95)
try {
const history = await getHistory(promptId)
- setProgress(pct, `Generating... ${elapsedSec}s elapsed`)
+ setProgress(pct, 'Generating...')
if (!history) return
if (history.status?.completed) {
if (pollRef.current) clearInterval(pollRef.current)
- const messages: [string, any][] = history.status?.messages ?? []
- const startMsg = messages.find(([t]) => t === 'execution_start')
- const endMsg = messages.find(([t]) => t === 'execution_success')
- const comfyTime = startMsg?.[1]?.timestamp && endMsg?.[1]?.timestamp
- ? ((endMsg[1].timestamp - startMsg[1].timestamp) / 1000).toFixed(1) : null
setProgress(100, 'Complete!')
- useCreateStore.getState().setLastGenTime(comfyTime ? `${comfyTime}s` : null)
const outputs = history.outputs ?? {}
let found = false
for (const nodeId of Object.keys(outputs)) {