From a4828c4d45e78825ebb45540ec7265e266e1abe8 Mon Sep 17 00:00:00 2001 From: Rodrigo Verdiani Date: Sat, 4 Jul 2026 18:17:25 -0300 Subject: [PATCH] fix(chat): hide mutation suggestion cards when no session is selected Skip pendingSuggestions in mergedMessages and previousMutationSuggestions rendering when activeSessionId is null. Also fix empty state check to not consider API suggestions as content when no session is active. --- src/features/binary/AIChatPanel.tsx | 55 ++++++++++++++++------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/src/features/binary/AIChatPanel.tsx b/src/features/binary/AIChatPanel.tsx index c1321b8..efb0b0b 100644 --- a/src/features/binary/AIChatPanel.tsx +++ b/src/features/binary/AIChatPanel.tsx @@ -168,9 +168,11 @@ export function AIChatPanel({ | { kind: "suggestion"; data: MutationSuggestionResponse } > = messages.map((m) => ({ kind: "message" as const, data: m })); - for (const s of pendingSuggestions ?? []) { - if (!s.createdAt) continue; - items.push({ kind: "suggestion" as const, data: s }); + if (activeSessionId) { + for (const s of pendingSuggestions ?? []) { + if (!s.createdAt) continue; + items.push({ kind: "suggestion" as const, data: s }); + } } items.sort((a, b) => { @@ -180,7 +182,7 @@ export function AIChatPanel({ }); return items; - }, [messages, pendingSuggestions]); + }, [messages, pendingSuggestions, activeSessionId]); // Track manual scroll to respect user reading position useEffect(() => { @@ -319,7 +321,9 @@ export function AIChatPanel({ ref={scrollContainerRef} className="flex min-h-0 flex-1 flex-col overflow-x-hidden overflow-y-auto" > - {messages.length === 0 && !pendingSuggestions?.length && !isStreaming ? ( + {messages.length === 0 && + !(activeSessionId && pendingSuggestions?.length) && + !isStreaming ? (

AI Analysis Assistant

@@ -432,26 +436,27 @@ export function AIChatPanel({ })} )} - {previousMutationSuggestions - .filter( - (s, i, arr) => - !pendingIds.has(s.mutationId) && - !resolvedIds.has(s.mutationId) && - arr.findIndex((x) => x.mutationId === s.mutationId) === i - ) - .map((s) => ( - - ))} + {activeSessionId && + previousMutationSuggestions + .filter( + (s, i, arr) => + !pendingIds.has(s.mutationId) && + !resolvedIds.has(s.mutationId) && + arr.findIndex((x) => x.mutationId === s.mutationId) === i + ) + .map((s) => ( + + ))} {isStreaming && ( <>