From d3a7fd745e9ee4680c66b82b634dce371c7baddb Mon Sep 17 00:00:00 2001 From: 7418 <7418@openclaw.ai> Date: Thu, 12 Feb 2026 02:12:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20file=20tree=20attachment=20bridge=20stal?= =?UTF-8?q?e=20closure=20=E2=80=94=20use=20ref=20for=20attachments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- src/components/chat/MessageInput.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/chat/MessageInput.tsx b/src/components/chat/MessageInput.tsx index 74524be..3b817fb 100644 --- a/src/components/chat/MessageInput.tsx +++ b/src/components/chat/MessageInput.tsx @@ -256,6 +256,11 @@ function AttachFileButton() { */ function FileTreeAttachmentBridge() { const attachments = usePromptInputAttachments(); + const attachmentsRef = useRef(attachments); + + useEffect(() => { + attachmentsRef.current = attachments; + }, [attachments]); useEffect(() => { const handler = async (e: Event) => { @@ -269,7 +274,7 @@ function FileTreeAttachmentBridge() { const blob = await res.blob(); const filename = filePath.split('/').pop() || 'file'; const file = new File([blob], filename, { type: blob.type || 'application/octet-stream' }); - attachments.add([file]); + attachmentsRef.current.add([file]); } catch { // Silently fail if file fetch fails } @@ -277,7 +282,7 @@ function FileTreeAttachmentBridge() { window.addEventListener('attach-file-to-chat', handler); return () => window.removeEventListener('attach-file-to-chat', handler); - }, [attachments]); + }, []); return null; }