11import { useState } from 'react' ;
22import { useParams } from 'react-router-dom' ;
33import { useRun } from '../../hooks/use-runs' ;
4- import { useArtifactContent } from '../../hooks/use-artifacts' ;
54import {
65 Card ,
76 CardContent ,
@@ -10,13 +9,10 @@ import {
109 CardTitle ,
1110} from '../../components/ui/card' ;
1211import { Badge } from '../../components/ui/badge' ;
13- import { Button } from '../../components/ui/button' ;
1412import { Skeleton } from '../../components/ui/skeleton' ;
1513import { Tabs , TabsContent , TabsList , TabsTrigger } from '../../components/ui/tabs' ;
1614import { TraceTimeline } from '../../components/traces/trace-timeline' ;
17- import { ArtifactViewer } from '../../components/artifact-viewer' ;
1815import { formatDistanceToNow } from 'date-fns' ;
19- import { Eye } from 'lucide-react' ;
2016import type { Status } from '../../types' ;
2117
2218const STATUS_VARIANTS : Record < Status , 'default' | 'secondary' | 'success' | 'warning' | 'destructive' | 'unknown' | 'info' > = {
@@ -33,7 +29,6 @@ export function RunDetailPage() {
3329
3430 const { data : run , isLoading : runLoading , error : runError } = useRun ( id ! ) ;
3531
36- const [ dialogOpen , setDialogOpen ] = useState ( false ) ;
3732 const [ activeTab , setActiveTab ] = useState ( 'overview' ) ;
3833
3934 // Get metrics and traces from the nested run data
@@ -43,56 +38,6 @@ export function RunDetailPage() {
4338 const tracesLoading = runLoading ;
4439 const tracesError = runError ;
4540
46- // Check if execution result exists in metadata
47- const executionResult = run ?. meta ?. execution_result as any ;
48- const hasExecutionResult = executionResult ?. path && executionResult ?. file_name ;
49-
50- // Parse the path to extract the tag
51- let artifactTag = '' ;
52- if ( hasExecutionResult ) {
53- let tag = executionResult . path ;
54-
55- // If path contains ':', extract the part after the colon (the tag)
56- if ( tag . includes ( ':' ) ) {
57- tag = tag . split ( ':' ) [ 1 ] ;
58- }
59-
60- // If path contains '/', it's a full path, extract just the tag part
61- if ( tag . includes ( '/' ) ) {
62- const parts = tag . split ( '/' ) ;
63- tag = parts [ parts . length - 1 ] ;
64- if ( tag . includes ( ':' ) ) {
65- tag = tag . split ( ':' ) [ 1 ] ;
66- }
67- }
68-
69- artifactTag = tag ;
70- }
71-
72- // Use the cached artifact content hook
73- // Only fetch when dialog is open to avoid unnecessary requests
74- // Repository name is just 'execution' - the backend prepends teamId
75- const {
76- data : artifactContent ,
77- isLoading : loadingArtifact ,
78- error : artifactError
79- } = useArtifactContent (
80- run ?. teamId || '' ,
81- artifactTag ,
82- 'execution' ,
83- dialogOpen && hasExecutionResult // Only fetch when dialog is open
84- ) ;
85-
86- const handleViewArtifact = ( ) => {
87- if ( ! hasExecutionResult || ! run ) return ;
88- setDialogOpen ( true ) ;
89- } ;
90-
91- // Show error if artifact fetch fails
92- if ( artifactError && dialogOpen ) {
93- console . error ( 'Failed to load artifact:' , artifactError ) ;
94- }
95-
9641 if ( runLoading ) {
9742 return (
9843 < div className = "space-y-4" >
@@ -149,21 +94,6 @@ export function RunDetailPage() {
14994 < CardContent className = "p-4" >
15095 < h3 className = "text-base font-semibold mb-3" > Overview</ h3 >
15196 < dl className = "grid grid-cols-3 gap-3 text-sm" >
152- { hasExecutionResult && (
153- < div >
154- < dt className = "text-xs font-medium uppercase tracking-wide text-muted-foreground" > Execution Result</ dt >
155- < dd className = "mt-1.5 text-foreground text-sm" >
156- < button
157- onClick = { handleViewArtifact }
158- disabled = { loadingArtifact }
159- className = "inline-flex items-center gap-1.5 text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300 hover:underline"
160- >
161- < Eye className = "h-3.5 w-3.5" />
162- { executionResult . file_name }
163- </ button >
164- </ dd >
165- </ div >
166- ) }
16797 < div >
16898 < dt className = "text-xs font-medium uppercase tracking-wide text-muted-foreground" > Tokens</ dt >
16999 < dd className = "mt-1.5 text-foreground font-mono text-sm" >
@@ -272,18 +202,6 @@ export function RunDetailPage() {
272202 ) }
273203 </ TabsContent >
274204 </ Tabs >
275-
276- { /* Artifact Content Viewer */ }
277- < ArtifactViewer
278- open = { dialogOpen }
279- onOpenChange = { setDialogOpen }
280- artifactContent = { artifactContent }
281- isLoading = { loadingArtifact }
282- error = { artifactError }
283- title = "Artifact Content"
284- hideLineCount = { true }
285- hideCloseButton = { true }
286- />
287205 </ div >
288206 ) ;
289207}
0 commit comments