Skip to content

Commit 13f3107

Browse files
fix(web): closing a video preview no longer revokes the timeline's blob URL
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent c795004 commit 13f3107

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

‎apps/web/src/components/chat/ExpandedImageDialog.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,11 @@ export function ExpandedImageDialogHost({ threadKey }: { readonly threadKey: str
314314
const state = useAtomValue(expandedImagePreviewAtom);
315315
const preview = state?.threadKey === threadKey ? state.preview : null;
316316
const item = preview?.images[preview.index];
317-
const blobVideoSrc = item?.type === "video" && item.src?.startsWith("blob:") ? item.src : null;
317+
const ownedSrc = item?.ownsSrc === true ? item.src : null;
318318
useEffect(() => {
319-
if (blobVideoSrc === null) return;
320-
return () => URL.revokeObjectURL(blobVideoSrc);
321-
}, [blobVideoSrc]);
319+
if (ownedSrc === null) return;
320+
return () => URL.revokeObjectURL(ownedSrc);
321+
}, [ownedSrc]);
322322
// Leaving the thread (or the chat view) drops its preview.
323323
useEffect(() => () => closeExpandedImagePreviewFor(threadKey), [threadKey]);
324324
if (preview === null) return null;

‎apps/web/src/components/chat/ExpandedImagePreview.tsx‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export interface ExpandedImageItem {
2323
src: string | null;
2424
name: string;
2525
type?: "video";
26+
/** The preview created this object URL and must revoke it; other blob URLs belong to the timeline. */
27+
ownsSrc?: boolean;
2628
source?: SnapShotSource;
2729
autoPlay?: boolean;
2830
originalUrl?: string;
@@ -167,7 +169,14 @@ export function buildExpandedImagePreview(
167169
const selected = images.find((image) => image.id === selectedImageId);
168170
if (selected?.type === "file" && selected.file && isVideoAttachment(selected)) {
169171
return {
170-
images: [{ src: URL.createObjectURL(selected.file), name: selected.name, type: "video" }],
172+
images: [
173+
{
174+
src: URL.createObjectURL(selected.file),
175+
name: selected.name,
176+
type: "video",
177+
ownsSrc: true,
178+
},
179+
],
171180
index: 0,
172181
};
173182
}

0 commit comments

Comments
 (0)