From f3ae76ce6815737a01c19bb00f3d37e1da3a3516 Mon Sep 17 00:00:00 2001 From: Ryan Chen Date: Thu, 9 Apr 2026 22:08:26 -0400 Subject: [PATCH] Fix mobile conversation launch resetting to homepage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the useEffect on selectedConversation.id that race-conditions with handleQuestionSubmit — it fetches the (still-empty) conversation and wipes messages, sending the user back to the empty state. Refresh conversation list after streaming completes instead to pick up the auto-generated title. Co-Authored-By: Claude Opus 4.6 --- raggr-frontend/src/components/ChatScreen.tsx | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/raggr-frontend/src/components/ChatScreen.tsx b/raggr-frontend/src/components/ChatScreen.tsx index 190410e..8febc36 100644 --- a/raggr-frontend/src/components/ChatScreen.tsx +++ b/raggr-frontend/src/components/ChatScreen.tsx @@ -120,20 +120,6 @@ export const ChatScreen = ({ setAuthenticated }: ChatScreenProps) => { scrollToBottom(); }, [messages]); - useEffect(() => { - const load = async () => { - if (!selectedConversation) return; - try { - const conv = await conversationService.getConversation(selectedConversation.id); - setSelectedConversation({ id: conv.id, title: conv.name }); - setMessages(conv.messages.map((m) => ({ text: m.text, speaker: m.speaker, image_key: m.image_key }))); - } catch (err) { - console.error("Failed to load messages:", err); - } - }; - load(); - }, [selectedConversation?.id]); - const handleQuestionSubmit = useCallback(async () => { if ((!query.trim() && !pendingImage) || isLoading) return; @@ -215,7 +201,10 @@ export const ChatScreen = ({ setAuthenticated }: ChatScreenProps) => { } } } finally { - if (isMountedRef.current) setIsLoading(false); + if (isMountedRef.current) { + setIsLoading(false); + loadConversations(); + } abortControllerRef.current = null; } }, [query, pendingImage, isLoading, selectedConversation, simbaMode, messages, setAuthenticated]); -- 2.49.1