From 52a2bfe016a3c9b9926ddbb3591929e3c8fac876 Mon Sep 17 00:00:00 2001 From: imagineer99 Date: Sun, 22 Feb 2026 02:39:56 +0000 Subject: [PATCH] fix: resolve image preview thumbnail not rendering before send --- .../components/assistant-ui/attachment.tsx | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/studio/frontend/src/components/assistant-ui/attachment.tsx b/studio/frontend/src/components/assistant-ui/attachment.tsx index 06c7d90d07..c53c134ea2 100644 --- a/studio/frontend/src/components/assistant-ui/attachment.tsx +++ b/studio/frontend/src/components/assistant-ui/attachment.tsx @@ -26,25 +26,22 @@ import { type FC, type PropsWithChildren, useEffect, - useMemo, useState, } from "react"; import { useShallow } from "zustand/shallow"; const useFileSrc = (file: File | undefined): string | undefined => { - const objectUrl = useMemo( - () => (file ? URL.createObjectURL(file) : undefined), - [file], - ); + const [objectUrl, setObjectUrl] = useState(undefined); useEffect(() => { - if (!objectUrl) { - return undefined; + if (!file) { + setObjectUrl(undefined); + return; } - return () => { - URL.revokeObjectURL(objectUrl); - }; - }, [objectUrl]); + const url = URL.createObjectURL(file); + setObjectUrl(url); + return () => URL.revokeObjectURL(url); + }, [file]); return objectUrl; };