Skip to content

Commit 9f92857

Browse files
authored
Reuse stable empty message array in SME chat (#371)
- Avoid allocating a new empty array when no conversation messages are present - Keep the selected store slice stable for empty states
1 parent f7ef73d commit 9f92857

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

apps/web/src/components/sme/SmeChatWorkspace.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { useSmeStore } from "~/smeStore";
66

77
import { SmeMessageBubble } from "./SmeMessageBubble";
88

9+
const EMPTY_MESSAGES: SmeMessage[] = [];
10+
911
interface SmeChatWorkspaceProps {
1012
conversationId: string | null;
1113
onToggleKnowledge: () => void;
@@ -18,7 +20,7 @@ export function SmeChatWorkspace({
1820
knowledgePanelOpen,
1921
}: SmeChatWorkspaceProps) {
2022
const messages = useSmeStore((s) =>
21-
conversationId ? (s.messagesByConversation[conversationId] ?? []) : [],
23+
conversationId ? (s.messagesByConversation[conversationId] ?? EMPTY_MESSAGES) : EMPTY_MESSAGES,
2224
);
2325
const streamingMessageId = useSmeStore((s) => s.streamingMessageId);
2426
const streamingText = useSmeStore((s) => s.streamingText);

0 commit comments

Comments
 (0)