From 5ba77d8952a7cfe46589c33a820f6ad712f34491 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Wed, 25 Feb 2026 20:41:43 -0600 Subject: [PATCH] fix(web): add random suffix to fallback assistant message IDs to prevent collisions Message IDs generated in the fallback path used only Date.now() which caused ID collisions in rapid-send scenarios (multiple sends within the same millisecond). Adding the same Math.random() suffix used by userMessage IDs ensures uniqueness. Co-Authored-By: Claude Opus 4.6 --- apps/web/src/hooks/useChat.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/web/src/hooks/useChat.ts b/apps/web/src/hooks/useChat.ts index 8f0cfe0..7283ee5 100644 --- a/apps/web/src/hooks/useChat.ts +++ b/apps/web/src/hooks/useChat.ts @@ -294,7 +294,7 @@ export function useChat(options: UseChatOptions = {}): UseChatReturn { const response = await sendChatMessage(request); const assistantMessage: Message = { - id: `assistant-${Date.now().toString()}`, + id: `assistant-${Date.now().toString()}-${Math.random().toString(36).slice(2, 8)}`, role: "assistant", content: response.message.content, createdAt: new Date().toISOString(), @@ -328,7 +328,7 @@ export function useChat(options: UseChatOptions = {}): UseChatReturn { }); const errorMessage: Message = { - id: `error-${String(Date.now())}`, + id: `error-${String(Date.now())}-${Math.random().toString(36).slice(2, 8)}`, role: "assistant", content: "Something went wrong. Please try again.", createdAt: new Date().toISOString(),