fix: update message handling in NewChatPage to conditionally set author_id based on chat visibility

This commit is contained in:
Anish Sarkar 2026-03-29 15:56:42 +05:30
parent 05030f6664
commit 7ed6e9c75f

View file

@ -218,13 +218,15 @@ export default function NewChatPage() {
return; return;
} }
const isSharedChat = currentThread?.visibility === "SEARCH_SPACE";
setMessages((prev) => { setMessages((prev) => {
if (syncedMessages.length < prev.length) { if (syncedMessages.length < prev.length) {
return prev; return prev;
} }
return syncedMessages.map((msg) => { return syncedMessages.map((msg) => {
const member = msg.author_id const member = isSharedChat && msg.author_id
? membersData?.find((m) => m.user_id === msg.author_id) ? membersData?.find((m) => m.user_id === msg.author_id)
: null; : null;
@ -239,7 +241,7 @@ export default function NewChatPage() {
thread_id: msg.thread_id, thread_id: msg.thread_id,
role: msg.role.toLowerCase() as "user" | "assistant" | "system", role: msg.role.toLowerCase() as "user" | "assistant" | "system",
content: msg.content, content: msg.content,
author_id: msg.author_id, author_id: isSharedChat ? msg.author_id : null,
created_at: msg.created_at, created_at: msg.created_at,
author_display_name: member?.user_display_name ?? existingAuthor?.displayName ?? null, author_display_name: member?.user_display_name ?? existingAuthor?.displayName ?? null,
author_avatar_url: member?.user_avatar_url ?? existingAuthor?.avatarUrl ?? 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); useMessagesSync(threadId, handleSyncedMessagesUpdate);