From fe4e256cc410569604c4a8b62490aa8723aafee4 Mon Sep 17 00:00:00 2001 From: "juancarlos.cavero" Date: Thu, 27 Aug 2026 12:21:01 +0200 Subject: [PATCH] fix(thumbnail): byte-part references, public-figure fallback, frames effect race Browser run on a real video surfaced three defects: - references were one PIL Image shared by the worker threads; the SDK's encoder raced and every generation died. Now each reference is an immutable JPEG byte part. - Gemini's image model refuses recognisable public figures, by reference photo and by name alike (IMAGE_OTHER). The concept planner no longer writes real names or brands into scene prompts, and a blocked render is retried once without the person; the card says so. - the frames effect listed its own state as a dependency, so setting it re-ran the effect and the cleanup discarded the response in flight. --- dashboard/src/components/ThumbnailStudio.jsx | 22 +++++++---- thumbnail.py | 41 +++++++++++++++++--- 2 files changed, 51 insertions(+), 12 deletions(-) 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.

}