"use client";
import { useId, useState } from "react";
import type { UiStep } from "@/lib/gateway/transcript";
/** The collapsible "N steps" tool/reasoning trace on agent messages (§5b). */
export function StepTrace({ steps }: { steps: UiStep[] }) {
const [expanded, setExpanded] = useState(false);
const regionId = useId();
if (steps.length === 0) {
return null;
}
return (
{expanded && (
{steps.map((step) => (
-
{step.status === "ok" ? "✓" : step.status === "error" ? "✗" : "…"}{" "}
{step.tool}
{step.output != null && (
{JSON.stringify(step.output)}
)}
))}
)}
);
}