@@ -3,6 +3,35 @@ import { ChevronDown, ChevronRight, RotateCcw, GitFork } from "lucide-react";
33import { RunStatusBadge } from "@/components/runs/RunStatusBadge" ;
44import { cn , formatDuration , formatCost } from "@/lib/utils" ;
55
6+ function extractText ( value : unknown ) : string | null {
7+ if ( typeof value === "string" ) return value ;
8+ if ( value && typeof value === "object" && ! Array . isArray ( value ) ) {
9+ const obj = value as Record < string , unknown > ;
10+ // Unwrap single-key objects like {"result": "..."}
11+ const keys = Object . keys ( obj ) ;
12+ if ( keys . length === 1 && typeof obj [ keys [ 0 ] ] === "string" ) {
13+ return obj [ keys [ 0 ] ] as string ;
14+ }
15+ }
16+ return null ;
17+ }
18+
19+ function OutputBlock ( { value } : { value : unknown } ) {
20+ const text = extractText ( value ) ;
21+ if ( text ) {
22+ return (
23+ < div className = "max-h-96 overflow-auto rounded-md bg-background p-3 text-sm text-foreground whitespace-pre-wrap break-words leading-relaxed" >
24+ { text }
25+ </ div >
26+ ) ;
27+ }
28+ return (
29+ < pre className = "max-h-64 overflow-auto rounded-md bg-background p-3 font-mono text-xs text-foreground whitespace-pre-wrap break-words" >
30+ { JSON . stringify ( value , null , 2 ) }
31+ </ pre >
32+ ) ;
33+ }
34+
635interface StepCardProps {
736 stepId : string ;
837 status : string ;
@@ -72,9 +101,7 @@ export function StepCard({
72101 { output != null && (
73102 < div >
74103 < p className = "mb-1 text-xs font-medium text-muted" > Output</ p >
75- < pre className = "max-h-64 overflow-auto rounded-md bg-background p-3 font-mono text-xs text-foreground" >
76- { typeof output === "string" ? output : JSON . stringify ( output , null , 2 ) }
77- </ pre >
104+ < OutputBlock value = { output } />
78105 </ div >
79106 ) }
80107
0 commit comments