From 7ed6e9c75f1c6ef9c9fc997c53bea8dc0e7dcb69 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Sun, 29 Mar 2026 15:56:42 +0530 Subject: [PATCH] fix: update message handling in NewChatPage to conditionally set author_id based on chat visibility --- .../[search_space_id]/new-chat/[[...chat_id]]/page.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 9809c9b2e..1f9074793 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 @@ -218,13 +218,15 @@ export default function NewChatPage() { return; } + const isSharedChat = currentThread?.visibility === "SEARCH_SPACE"; + setMessages((prev) => { if (syncedMessages.length < prev.length) { return prev; } return syncedMessages.map((msg) => { - const member = msg.author_id + const member = isSharedChat && msg.author_id ? membersData?.find((m) => m.user_id === msg.author_id) : null; @@ -239,7 +241,7 @@ export default function NewChatPage() { thread_id: msg.thread_id, role: msg.role.toLowerCase() as "user" | "assistant" | "system", content: msg.content, - author_id: msg.author_id, + author_id: isSharedChat ? msg.author_id : null, created_at: msg.created_at, author_display_name: member?.user_display_name ?? existingAuthor?.displayName ?? null, author_avatar_url: member?.user_avatar_url ?? existingAuthor?.avatarUrl ?? null, @@ -247,7 +249,7 @@ export default function NewChatPage() { }); }); }, - [isRunning, membersData] + [isRunning, membersData, currentThread?.visibility] ); useMessagesSync(threadId, handleSyncedMessagesUpdate);