@@ -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,7 @@ 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 ) ;
1819 const thread = useStream < {
1920 messages : Message [ ] ;
2021 initial_search_query_count : number ;
@@ -26,15 +27,12 @@ export default function App() {
2627 : "http://localhost:8123" ,
2728 assistantId : "agent" ,
2829 messagesKey : "messages" ,
29- onFinish : ( event : any ) => {
30- console . log ( event ) ;
31- } ,
3230 onUpdateEvent : ( event : any ) => {
3331 let processedEvent : ProcessedEvent | null = null ;
3432 if ( event . generate_query ) {
3533 processedEvent = {
3634 title : "Generating Search Queries" ,
37- data : event . generate_query . query_list . join ( ", " ) ,
35+ data : event . generate_query ?. search_query ? .join ( ", " ) || "" ,
3836 } ;
3937 } else if ( event . web_research ) {
4038 const sources = event . web_research . sources_gathered || [ ] ;
@@ -52,11 +50,7 @@ export default function App() {
5250 } else if ( event . reflection ) {
5351 processedEvent = {
5452 title : "Reflection" ,
55- data : event . reflection . is_sufficient
56- ? "Search successful, generating final answer."
57- : `Need more information, searching for ${ event . reflection . follow_up_queries . join (
58- ", "
59- ) } `,
53+ data : "Analysing Web Research Results" ,
6054 } ;
6155 } else if ( event . finalize_answer ) {
6256 processedEvent = {
@@ -72,6 +66,9 @@ export default function App() {
7266 ] ) ;
7367 }
7468 } ,
69+ onError : ( error : any ) => {
70+ setError ( error . message ) ;
71+ } ,
7572 } ) ;
7673
7774 useEffect ( ( ) => {
@@ -161,6 +158,20 @@ export default function App() {
161158 isLoading = { thread . isLoading }
162159 onCancel = { handleCancel }
163160 />
161+ ) : error ? (
162+ < div className = "flex flex-col items-center justify-center h-full" >
163+ < div className = "flex flex-col items-center justify-center gap-4" >
164+ < h1 className = "text-2xl text-red-400 font-bold" > Error</ h1 >
165+ < p className = "text-red-400" > { JSON . stringify ( error ) } </ p >
166+
167+ < Button
168+ variant = "destructive"
169+ onClick = { ( ) => window . location . reload ( ) }
170+ >
171+ Retry
172+ </ Button >
173+ </ div >
174+ </ div >
164175 ) : (
165176 < ChatMessagesView
166177 messages = { thread . messages }
0 commit comments