fix(chat): preserve messages array during chat update
All checks were successful
continuous-integration/drone/push Build is passing

Object.assign was overwriting the existing messages array before the
ternary fallback could reference it. Capture the reference beforehand.
This commit is contained in:
2026-04-28 23:34:46 -04:00
parent 91d4202874
commit 5d5f10b2d8

View File

@@ -152,10 +152,13 @@ Alpine.data('chatManager', () => ({
chat = { ...chunk.chat, messages: chunk.chat.messages || [] };
this.chats.unshift(chat);
} else {
// Preserve Messages - Object.assign would overwrite the existing
// messages array before we can check whether the chunk has any.
const existingMessages = chat.messages;
Object.assign(chat, chunk.chat);
chat.messages = chunk.chat.messages?.length
? chunk.chat.messages
: chat.messages;
: existingMessages;
}
this.selectedChatID = chunk.chat.id;
this.updateHash(chunk.chat.id);