diff --git a/dashboard/src/components/ThumbnailStudio.jsx b/dashboard/src/components/ThumbnailStudio.jsx index 7cc8141..ba45a18 100644 --- a/dashboard/src/components/ThumbnailStudio.jsx +++ b/dashboard/src/components/ThumbnailStudio.jsx @@ -101,6 +101,7 @@ export default function ThumbnailStudio({ geminiApiKey, uploadPostKey, uploadUse const [thumbnailCount, setThumbnailCount] = useState(3); const [burnText, setBurnText] = useState(true); // crisp PIL text vs model-rendered text const [frames, setFrames] = useState(null); // null = not fetched yet + const [framesLoading, setFramesLoading] = useState(false); const [selectedFrame, setSelectedFrame] = useState(null); const [isGenerating, setIsGenerating] = useState(false); const [generatedThumbnails, setGeneratedThumbnails] = useState([]); @@ -307,16 +308,21 @@ export default function ThumbnailStudio({ geminiApiKey, uploadPostKey, uploadUse // Frames with a big, sharp face from the uploaded video: one click replaces // the face upload nobody makes. Fetched once when the generate step opens. + // `frames` is deliberately not a dependency: setting it inside the effect + // would re-run it and the cleanup would discard the response in flight. + const framesRequestedFor = useRef(null); useEffect(() => { - if (step !== 2 || mode !== 'video' || !sessionId || frames !== null) return; - let cancelled = false; + if (step !== 2 || mode !== 'video' || !sessionId) return; + if (framesRequestedFor.current === sessionId) return; + framesRequestedFor.current = sessionId; setFrames([]); + setFramesLoading(true); apiFetch(`/api/thumbnail/frames/${sessionId}`) .then(res => (res.ok ? res.json() : { frames: [] })) - .then(data => { if (!cancelled) setFrames(data.frames || []); }) - .catch(() => { if (!cancelled) setFrames([]); }); - return () => { cancelled = true; }; - }, [step, mode, sessionId, frames]); + .then(data => setFrames(data.frames || [])) + .catch(() => setFrames([])) + .finally(() => setFramesLoading(false)); + }, [step, mode, sessionId]); const handleDownload = async (url) => { try { @@ -443,6 +449,7 @@ export default function ThumbnailStudio({ geminiApiKey, uploadPostKey, uploadUse setChatHistory([]); setFaceImage(null); setFrames(null); + framesRequestedFor.current = null; setSelectedFrame(null); setThumbnailTexts([]); setBgImage(null); @@ -753,7 +760,7 @@ export default function ThumbnailStudio({ geminiApiKey, uploadPostKey, uploadUse

YOUR FACE FROM THE VIDEO

{frames.length === 0 ? ( -

Looking for sharp frames with a face...

+

{framesLoading ? 'Looking for sharp frames with a face...' : 'No usable face found in the video.'}

) : ( <>
@@ -894,6 +901,7 @@ export default function ThumbnailStudio({ geminiApiKey, uploadPostKey, uploadUse )} {thumb.why &&

{thumb.why}

} + {thumb.fallback &&

Gemini refused to draw this person (public figures are blocked), so it was rendered without them.

}