fix(messages): bulletproof dedup in appendMessage — check msg.id before adding
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Root cause: appendMessage() had no dedup check, so both send() and polling could add the same message. Now appendMessage() checks if msg.id already exists in state.messages[convId] before adding — guaranteed single display. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
720d7a2d7d
commit
643a9cd94a
@ -725,6 +725,11 @@
|
||||
appendMessage: function (msg) {
|
||||
var convId = msg.conversation_id;
|
||||
if (!state.messages[convId]) state.messages[convId] = [];
|
||||
|
||||
// Dedup: skip if message with this ID already exists
|
||||
if (msg.id && state.messages[convId].some(function(m) { return m.id === msg.id; })) {
|
||||
return; // Already displayed
|
||||
}
|
||||
state.messages[convId].push(msg);
|
||||
|
||||
if (convId !== state.currentConversationId) return;
|
||||
@ -1290,10 +1295,8 @@
|
||||
if (replyPreview) replyPreview.style.display = 'none';
|
||||
Composer.renderAttachments();
|
||||
|
||||
// Append the sent message and track it so polling doesn't duplicate
|
||||
// Append the sent message (dedup check inside appendMessage)
|
||||
ChatView.appendMessage(result);
|
||||
if (!state.messages[convId]) state.messages[convId] = [];
|
||||
state.messages[convId].push(result);
|
||||
|
||||
// Update conversation in list
|
||||
ConversationList.updateConversation(convId, {
|
||||
@ -1653,7 +1656,6 @@
|
||||
newMsgs.sort(function (a, b) { return a.id - b.id; });
|
||||
newMsgs.forEach(function (msg) {
|
||||
ChatView.appendMessage(msg);
|
||||
state.messages[convId].push(msg);
|
||||
});
|
||||
|
||||
// Update conversation list with the NEWEST message
|
||||
|
||||
Loading…
Reference in New Issue
Block a user