From fe6ec467c6c6aac3cbce5555bf00ef4dbf866d90 Mon Sep 17 00:00:00 2001 From: Kagamine Rin Date: Fri, 29 May 2026 22:57:14 -0400 Subject: [PATCH] fix: SuggestionsModal now fetches fresh suggestions every time Bug: SuggestionsModal only fetched on first open because it checked if suggestions.length === 0 before fetching. This meant changing the prompt and re-opening the modal showed stale suggestions. Fix: useEffect now: - Clears suggestions and error on every open - Always fetches fresh suggestions when isOpen changes - Also re-fetches when userInput changes while modal is open - Dependency array: [isOpen, userInput] Result: Every click of 'Get Suggestions' generates new, relevant suggestions based on the current prompt. --- frontend/src/components/SuggestionsModal.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/SuggestionsModal.tsx b/frontend/src/components/SuggestionsModal.tsx index 50a639b..358a6af 100644 --- a/frontend/src/components/SuggestionsModal.tsx +++ b/frontend/src/components/SuggestionsModal.tsx @@ -35,12 +35,14 @@ export default function SuggestionsModal({ isOpen, onClose, onSelect, userInput } } - // Auto-fetch when opened + // Auto-fetch when opened — always fetch fresh suggestions useEffect(() => { - if (isOpen && suggestions.length === 0 && !loading && !error) { + if (isOpen) { + setSuggestions([]) + setError('') fetchSuggestions() } - }, [isOpen]) + }, [isOpen, userInput]) if (!isOpen) return null