@@ -13,9 +13,9 @@ export default function Home() {
1313 llama-ui to call the workflow. Customize this app with your own
1414 workflow and UI.
1515 </ div >
16- < div className = "flex flex-row gap-4 items-center justify-center w-full" >
16+ < div className = "flex flex-row gap-4 items-start justify-center w-full" >
1717 { taskId ? (
18- < HandlerOuput handlerId = { taskId } />
18+ < HandlerOutput handlerId = { taskId } />
1919 ) : (
2020 < Output >
2121 < span className = "text-black/60 dark:text-white/60" >
@@ -71,14 +71,35 @@ function RunButton({
7171 ) ;
7272}
7373
74- function HandlerOuput ( { handlerId } : { handlerId : string } ) {
74+ function HandlerOutput ( { handlerId } : { handlerId : string } ) {
75+ // stream events and result from the workflow
7576 const taskData = useWorkflowTask ( handlerId ) ;
7677
77- const result = taskData . events . find ( ( event ) =>
78+ // read workflow events here
79+ const pongs = taskData . events . filter ( ( event ) =>
7880 event . type . match ( / P o n g E v e n t $ / ) ,
79- ) as { type : string ; data : { message : string } } | undefined ;
81+ ) as { type : string ; data : { message : string } } [ ] ;
82+ const completed = taskData . events . find ( ( event ) =>
83+ event . type . match ( / W o r k f l o w C o m p l e t e d E v e n t $ / ) ,
84+ ) as { type : string ; data : { timestamp : string } } | undefined ;
8085
81- return < Output > { result ? result . data . message : "Running... " } </ Output > ;
86+ return (
87+ < div className = "flex flex-col gap-4 w-full min-h-60" >
88+ < Output > { completed ? completed . data . timestamp : "Running... " } </ Output >
89+ { pongs . map ( ( pong , index ) => (
90+ < span
91+ className = "text-black/60 dark:text-white/60 text-sm m-0"
92+ key = { pong . data . message }
93+ style = { {
94+ animation : "fade-in-left 80ms ease-out both" ,
95+ willChange : "opacity, transform" ,
96+ } }
97+ >
98+ { pong . data . message }
99+ </ span >
100+ ) ) }
101+ </ div >
102+ ) ;
82103}
83104
84105function Output ( { children } : { children : React . ReactNode } ) {
0 commit comments