From da9b52dda162761b4c1f1b7a5fea5057834b9aa9 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 11 Mar 2026 09:47:37 -0400 Subject: [PATCH] Add Claude.ai-style homepage with centered empty state Show centered cat icon + "Ask me anything" + input when no messages exist. Transition to scrollable messages + bottom input once chat starts. Auto-create a conversation on first message if none selected. Co-Authored-By: Claude Sonnet 4.6 --- raggr-frontend/src/components/ChatScreen.tsx | 131 +++++++++++-------- 1 file changed, 75 insertions(+), 56 deletions(-) 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"} -

-
- )} - - {/* Messages */} -
-
+ {messages.length === 0 ? ( + /* ── Empty / homepage state ── */ +
{/* Mobile conversation drawer */} {showConversations && ( -
+
{ />
)} +
+
+ Simba +
+

+ Ask me anything +

+
+ +
+
+ ) : ( + /* ── Active chat state ── */ + <> +
+
+ {/* Mobile conversation drawer */} + {showConversations && ( +
+ +
+ )} - {/* Empty state */} - {messages.length === 0 && !isLoading && ( -
-
-
- Simba -
-

- Ask Simba anything -

+ {messages.map((msg, index) => { + if (msg.speaker === "tool") + return ; + if (msg.speaker === "simba") + return ; + return ; + })} + + {isLoading && } +
- )} +
- {messages.map((msg, index) => { - if (msg.speaker === "tool") - return ; - if (msg.speaker === "simba") - return ; - return ; - })} - - {isLoading && } -
-
-
- - {/* Input */} -
-
- -
-
+ + + )}
);