From ef183dfdc072cf9450f1c9338b48f4b5c4be2198 Mon Sep 17 00:00:00 2001 From: Val Alexander Date: Thu, 9 Apr 2026 00:03:42 -0500 Subject: [PATCH] Reuse stable empty message array in SME chat - Avoid allocating a new empty array when no conversation messages are present - Keep the selected store slice stable for empty states --- apps/web/src/components/sme/SmeChatWorkspace.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/sme/SmeChatWorkspace.tsx b/apps/web/src/components/sme/SmeChatWorkspace.tsx index c24cc5c75..01fa7dd2d 100644 --- a/apps/web/src/components/sme/SmeChatWorkspace.tsx +++ b/apps/web/src/components/sme/SmeChatWorkspace.tsx @@ -6,6 +6,8 @@ import { useSmeStore } from "~/smeStore"; import { SmeMessageBubble } from "./SmeMessageBubble"; +const EMPTY_MESSAGES: SmeMessage[] = []; + interface SmeChatWorkspaceProps { conversationId: string | null; onToggleKnowledge: () => void; @@ -18,7 +20,7 @@ export function SmeChatWorkspace({ knowledgePanelOpen, }: SmeChatWorkspaceProps) { const messages = useSmeStore((s) => - conversationId ? (s.messagesByConversation[conversationId] ?? []) : [], + conversationId ? (s.messagesByConversation[conversationId] ?? EMPTY_MESSAGES) : EMPTY_MESSAGES, ); const streamingMessageId = useSmeStore((s) => s.streamingMessageId); const streamingText = useSmeStore((s) => s.streamingText);