diff --git a/raggr-frontend/src/components/ChatScreen.tsx b/raggr-frontend/src/components/ChatScreen.tsx index 7d89439..c2c0931 100644 --- a/raggr-frontend/src/components/ChatScreen.tsx +++ b/raggr-frontend/src/components/ChatScreen.tsx @@ -94,7 +94,6 @@ export const ChatScreen = ({ setAuthenticated }: ChatScreenProps) => { const fetched = await conversationService.getAllConversations(); const parsed = fetched.map((c) => ({ id: c.id, title: c.name })); setConversations(parsed); - setSelectedConversation(parsed[0] ?? null); } catch (err) { console.error("Failed to load conversations:", err); } @@ -132,6 +131,14 @@ export const ChatScreen = ({ setAuthenticated }: ChatScreenProps) => { const handleQuestionSubmit = async () => { if (!query.trim() || isLoading) return; + let activeConversation = selectedConversation; + if (!activeConversation) { + const newConv = await conversationService.createConversation(); + activeConversation = { title: newConv.name, id: newConv.id }; + setSelectedConversation(activeConversation); + setConversations((prev) => [activeConversation!, ...prev]); + } + const currMessages = messages.concat([{ text: query, speaker: "user" }]); setMessages(currMessages); setQuery(""); @@ -150,7 +157,7 @@ export const ChatScreen = ({ setAuthenticated }: ChatScreenProps) => { try { await conversationService.streamQuery( query, - selectedConversation!.id, + activeConversation.id, (event) => { if (!isMountedRef.current) return; if (event.type === "tool_start") { @@ -309,21 +316,12 @@ export const ChatScreen = ({ setAuthenticated }: ChatScreenProps) => { - {/* Conversation title bar */} - {selectedConversation && ( -
- {selectedConversation.title || "Untitled Conversation"} -
-- Ask Simba anything -
+ {messages.map((msg, index) => { + if (msg.speaker === "tool") + return