Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

fix: resolve image preview thumbnail not rendering before send

imagineer9952a2bfe016a3
diff --git a/studio/frontend/src/components/assistant-ui/attachment.tsx b/studio/frontend/src/components/assistant-ui/attachment.tsx
index 06c7d90d071..c53c134ea2c 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<string | undefined>(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;
};