From 18108267d1be639fcd54000de4257186e4ffa054 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Fri, 24 Apr 2026 20:58:39 +0200 Subject: [PATCH] Defer clearing pending chat screenshots until send commits --- .../[search_space_id]/new-chat/[[...chat_id]]/page.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx index fe23cb2c7..da134c4cf 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx @@ -499,7 +499,6 @@ export default function NewChatPage() { } const urlsSnapshot = [...pendingUserImageUrls]; - setPendingUserImageUrls([]); const { userQuery, userImages } = extractUserTurnForNewChatApi(message, urlsSnapshot); if (!userQuery.trim() && userImages.length === 0) return; @@ -544,6 +543,10 @@ export default function NewChatPage() { } } + if (urlsSnapshot.length > 0) { + setPendingUserImageUrls((prev) => prev.filter((u) => !urlsSnapshot.includes(u))); + } + // Add user message to state const userMsgId = `msg-user-${Date.now()}`;