@@ -4,6 +4,7 @@ import { useState, useEffect, useRef, useCallback } from "react";
44import { ProcessedEvent } from "@/components/ActivityTimeline" ;
55import { WelcomeScreen } from "@/components/WelcomeScreen" ;
66import { ChatMessagesView } from "@/components/ChatMessagesView" ;
7+ import { Button } from "@/components/ui/button" ;
78
89export default function App ( ) {
910 const [ processedEventsTimeline , setProcessedEventsTimeline ] = useState <
@@ -14,7 +15,8 @@ export default function App() {
1415 > ( { } ) ;
1516 const scrollAreaRef = useRef < HTMLDivElement > ( null ) ;
1617 const hasFinalizeEventOccurredRef = useRef ( false ) ;
17-
18+ const [ error , setError ] = useState < string | null > ( null ) ;
19+ console . log ( import . meta. env . DEV ) ;
1820 const thread = useStream < {
1921 messages : Message [ ] ;
2022 initial_search_query_count : number ;
@@ -54,9 +56,10 @@ export default function App() {
5456 title : "Reflection" ,
5557 data : event . reflection . is_sufficient
5658 ? "Search successful, generating final answer."
57- : `Need more information, searching for ${ event . reflection . follow_up_queries ?. join (
58- ", "
59- ) || "additional information" } `,
59+ : `Need more information, searching for ${
60+ event . reflection . follow_up_queries ?. join ( ", " ) ||
61+ "additional information"
62+ } `,
6063 } ;
6164 } else if ( event . finalize_answer ) {
6265 processedEvent = {
@@ -72,6 +75,9 @@ export default function App() {
7275 ] ) ;
7376 }
7477 } ,
78+ onError : ( error : any ) => {
79+ setError ( error . message ) ;
80+ } ,
7581 } ) ;
7682
7783 useEffect ( ( ) => {
@@ -166,6 +172,20 @@ export default function App() {
166172 isLoading = { thread . isLoading }
167173 onCancel = { handleCancel }
168174 />
175+ ) : error ? (
176+ < div className = "flex flex-col items-center justify-center h-full" >
177+ < div className = "flex flex-col items-center justify-center gap-4" >
178+ < h1 className = "text-2xl text-red-400 font-bold" > Error</ h1 >
179+ < p className = "text-red-400" > { JSON . stringify ( error ) } </ p >
180+
181+ < Button
182+ variant = "destructive"
183+ onClick = { ( ) => window . location . reload ( ) }
184+ >
185+ Retry
186+ </ Button >
187+ </ div >
188+ </ div >
169189 ) : (
170190 < ChatMessagesView
171191 messages = { thread . messages }
0 commit comments