Skip to content

Commit 96f2cb1

Browse files
author
Tomas Pflanzer
committed
fix: render step output as readable text instead of raw JSON on one line
Extract text from single-key objects like {result: "..."}, display with whitespace-pre-wrap for proper line breaks and word wrapping.
1 parent 19fcc57 commit 96f2cb1

1 file changed

Lines changed: 30 additions & 3 deletions

File tree

dashboard/src/components/runs/StepCard.tsx

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,35 @@ import { ChevronDown, ChevronRight, RotateCcw, GitFork } from "lucide-react";
33
import { RunStatusBadge } from "@/components/runs/RunStatusBadge";
44
import { 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+
635
interface 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

Comments
 (0)