@@ -15,6 +15,7 @@ export function RunDetail() {
1515 const navigate = useNavigate ( ) , cache = useQueryClient ( ) ;
1616 const status = useQuery ( runStatusQuery ( runId ! ) ) ;
1717 const [ revision , setRevision ] = useState ( "" ) ;
18+ const [ tab , setTab ] = useState < "trace" | "context" | "settings" > ( "trace" ) ;
1819 const [ continuous , setContinuous ] = useState ( false ) ;
1920 const active = ! status . data || ! [ "succeeded" , "failed" , "stopped" ] . includes ( status . data . state ) || status . data . finalizing ;
2021 const finalizedSnapshot = useRef ( "" ) ;
@@ -51,16 +52,32 @@ export function RunDetail() {
5152 } , onSuccess : ( ) => cache . invalidateQueries ( { queryKey : [ "runs" , runId ] } ) } ) ;
5253 return < Page className = "max-w-6xl" >
5354 { status . isPending && < p role = "status" > Loading run…</ p > } { status . error && < p role = "alert" > { status . error . message } </ p > }
54- { status . data && < > < Link to = "/jobs/$jobId" params = { { jobId : status . data . job_id } } > { status . data . job_name } </ Link >
55+ < nav aria-label = "Breadcrumb" className = "flex min-w-0 flex-wrap items-center gap-2" > < Link to = "/jobs" search = { { q : "" } } > Jobs</ Link > { status . data && < > < span aria-hidden = "true" > →</ span > < Link className = "break-words min-w-0" to = "/jobs/$jobId" params = { { jobId : status . data . job_id } } > { status . data . job_name } </ Link > </ > } </ nav >
56+ { status . data && < >
5557 < h1 className = "mt-5 text-3xl font-semibold" > { status . data . run_name || "Run" } </ h1 > < p role = "status" className = "mb-4" > < Badge active = { active } > { status . data . state } </ Badge > { status . data . finalizing ? " · Finalizing trace and artifacts" : "" } </ p >
5658 < p className = "text-sm text-slate-600 dark:text-slate-400" > Created { new Date ( status . data . created_at ) . toLocaleString ( ) } · Started { status . data . started_at ? new Date ( status . data . started_at ) . toLocaleString ( ) : "Not yet" } </ p >
5759 { status . data . started_at && < p className = "mt-2 text-sm text-slate-600 dark:text-slate-400" > Queue time: { Math . max ( 0 , Math . round ( ( Date . parse ( status . data . started_at ) - Date . parse ( status . data . created_at ) ) / 1000 ) ) } s · Runtime: { Math . max ( 0 , Math . round ( ( ( active ? Date . now ( ) : Date . parse ( status . data . updated_at ) ) - Date . parse ( status . data . started_at ) ) / 1000 ) ) } s</ p > }
5860 { active && < p role = "status" > { trace . data ?. items . at ( - 1 ) ?. type === "reasoning" ? "Thinking…" : trace . data ?. items . at ( - 1 ) ?. title ? `Activity: ${ trace . data . items . at ( - 1 ) ! . title } ` : "Waiting for execution activity…" } </ p > }
5961 { status . data . destination_url && / ^ h t t p s ? : \/ \/ / . test ( status . data . destination_url ) && < a href = { status . data . destination_url } target = "_blank" rel = "noopener noreferrer" > Execution destination</ a > }
6062 { [ "starting" , "running" , "blocked" , "stopping" ] . includes ( status . data . state ) && < Button disabled = { stop . isPending || status . data . state === "stopping" } onClick = { ( ) => stop . mutate ( ) } > Stop run</ Button > }
6163 </ > }
62- < ExpandedRunDetail runId = { runId ! } /> { status . data && ! active && < ReplayTrace runId = { runId ! } /> }
6364 { stop . error && < p role = "alert" > { stop . error . message } </ p > }
65+ < div role = "tablist" aria-label = "Run details" className = "mt-6 flex gap-1 overflow-x-auto border-b border-stone-200 dark:border-slate-700" >
66+ { ( [ "trace" , "context" , "settings" ] as const ) . map ( ( name , index , tabs ) => < button key = { name } type = "button" role = "tab" id = { `run-tab-${ name } ` } aria-controls = { `run-panel-${ name } ` } aria-selected = { tab === name } tabIndex = { tab === name ? 0 : - 1 }
67+ className = { `min-h-11 shrink-0 border-b-2 px-4 py-3 text-sm capitalize ${ tab === name ? "border-factorize-500 font-semibold" : "border-transparent text-slate-600 hover:border-stone-300 dark:text-slate-400" } ` }
68+ onClick = { ( ) => setTab ( name ) } onKeyDown = { event => {
69+ const next = event . key === "ArrowRight" ? ( index + 1 ) % tabs . length : event . key === "ArrowLeft" ? ( index + tabs . length - 1 ) % tabs . length : event . key === "Home" ? 0 : event . key === "End" ? tabs . length - 1 : null ;
70+ if ( next === null ) return ;
71+ event . preventDefault ( ) ; setTab ( tabs [ next ] ) ; document . getElementById ( `run-tab-${ tabs [ next ] } ` ) ?. focus ( ) ;
72+ } } > { name [ 0 ] . toUpperCase ( ) + name . slice ( 1 ) } </ button > ) }
73+ </ div >
74+ < section role = "tabpanel" id = "run-panel-context" aria-labelledby = "run-tab-context" hidden = { tab !== "context" } tabIndex = { 0 } >
75+ < ExpandedRunDetail runId = { runId ! } />
76+ </ section >
77+ < section role = "tabpanel" id = "run-panel-settings" aria-labelledby = "run-tab-settings" hidden = { tab !== "settings" } tabIndex = { 0 } >
78+ { status . data && ! active ? < ReplayTrace runId = { runId ! } /> : < p className = "my-4" > Replay is available after the run finishes and trace finalization completes.</ p > }
79+ </ section >
80+ < section role = "tabpanel" id = "run-panel-trace" aria-labelledby = "run-tab-trace" hidden = { tab !== "trace" } tabIndex = { 0 } >
6481 < h2 className = "my-4 text-xl font-semibold" > Trace</ h2 >
6582 < Label > < Input type = "checkbox" checked = { continuous } onChange = { e => setContinuous ( e . target . checked ) } /> Continuous virtualized trace</ Label >
6683 { continuous && < ContinuousTrace key = { revision } runId = { runId ! } revision = { revision } active = { active } onReset = { next => { if ( next === revision ) return ; void cache . cancelQueries ( { queryKey : [ "runs" , runId , "continuous-trace" ] } ) ; cache . removeQueries ( { queryKey : [ "runs" , runId , "continuous-trace" ] } ) ; setRevision ( next ) ; cache . setQueryData ( runStatusQuery ( runId ! ) . queryKey , previous => previous ? { ...previous , trace_revision : next } : previous ) ; cache . removeQueries ( { queryKey : [ "runs" , runId , "continuous-tail" ] } ) ; } } /> }
@@ -76,5 +93,6 @@ export function RunDetail() {
7693 { trace . data . nextCursor !== null && < Link to = "/job-runs/$runId" params = { { runId : runId ! } } search = { { after : trace . data . nextCursor } } > Next trace page</ Link > }
7794 </ nav >
7895 </ > }
96+ </ section >
7997 </ Page > ;
8098}
0 commit comments