Skip to content

Commit 8e437fd

Browse files
committed
Use canonical run status for agentic trace badge
1 parent 29aab55 commit 8e437fd

2 files changed

Lines changed: 23 additions & 7 deletions

File tree

apps/frontend/src/App.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,10 @@ function hydrateConversationMessages(
857857
}
858858
hydrated[index] = {
859859
...message,
860+
metadata: {
861+
...(message.metadata ?? {}),
862+
runStatus: run.status,
863+
},
860864
toolCalls: toolTrace.map((entry, traceIndex) =>
861865
normalizeToolTraceEntry(entry as Record<string, unknown>, traceIndex),
862866
),
@@ -1944,6 +1948,7 @@ function messageToThreadMessage(
19441948
toolCalls: message.toolCalls,
19451949
runId: typeof message.metadata?.runId === "string" ? message.metadata.runId : null,
19461950
sessionId: message.sessionId,
1951+
runStatus: typeof message.metadata?.runStatus === "string" ? message.metadata.runStatus : null,
19471952
experimentProposal:
19481953
message.metadata?.experimentProposal && typeof message.metadata.experimentProposal === "object"
19491954
? message.metadata.experimentProposal

apps/frontend/src/components/assistant-ui/thread.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,13 @@ const AssistantMessage: FC = () => {
726726
: null;
727727
return typeof custom?.sessionId === "string" ? custom.sessionId : null;
728728
});
729+
const runStatus = useAuiState((state) => {
730+
const metadata = state.message.metadata;
731+
const custom = metadata && typeof metadata === "object" && "custom" in metadata
732+
? metadata.custom as Record<string, unknown>
733+
: null;
734+
return typeof custom?.runStatus === "string" ? custom.runStatus : null;
735+
});
729736
const hasPlanToolTrace = phase === "plan" && planToolTrace.length > 0;
730737

731738
if (phase === "progress") {
@@ -741,7 +748,7 @@ const AssistantMessage: FC = () => {
741748
>
742749
<div className="aui-assistant-message-content wrap-break-word px-2 text-foreground leading-relaxed">
743750
<MessagePrimitive.Parts components={TOOL_PART_COMPONENTS} />
744-
{hasPlanToolTrace ? <PlanToolTraceCard trace={planToolTrace} isRunning={isRunning} runId={runId} sessionId={sessionId} /> : null}
751+
{hasPlanToolTrace ? <PlanToolTraceCard trace={planToolTrace} isRunning={isRunning} runId={runId} sessionId={sessionId} runStatus={runStatus} /> : null}
745752
{experimentProposal ? <ExperimentApprovalCard proposal={experimentProposal} disabled={isRunning} /> : null}
746753
<MessageError />
747754
</div>
@@ -814,17 +821,20 @@ const PlanToolTraceCard: FC<{
814821
isRunning: boolean;
815822
sessionId: string | null;
816823
runId: string | null;
817-
}> = ({ trace, isRunning, sessionId, runId }) => {
824+
runStatus: string | null;
825+
}> = ({ trace, isRunning, sessionId, runId, runStatus }) => {
818826
const [collapsed, setCollapsed] = useState(false);
819827
const lines = useMemo(
820828
() => trace.map((entry) => summarizePlanToolLine(entry)).filter((line) => line),
821829
[trace],
822830
);
823-
const statusLabel = trace.some((entry) => entry.state === "error" || entry.isError)
824-
? "Failed"
825-
: isRunning || trace.some((entry) => entry.state === "running")
826-
? "In Progress"
827-
: "Completed";
831+
const statusLabel =
832+
runStatus === "failed" ? "Failed"
833+
: runStatus === "cancelled" ? "Cancelled"
834+
: runStatus === "completed" ? "Completed"
835+
: runStatus === "queued" || runStatus === "running" || isRunning || trace.some((entry) => entry.state === "running")
836+
? "In Progress"
837+
: "Completed";
828838

829839
return (
830840
<section className="aui-agentic-trace" aria-label="Agentic Search run">
@@ -841,6 +851,7 @@ const PlanToolTraceCard: FC<{
841851
<span className={cn(
842852
"aui-agentic-trace-status",
843853
statusLabel === "Failed" && "is-error",
854+
statusLabel === "Cancelled" && "is-error",
844855
statusLabel === "Completed" && "is-complete",
845856
)}
846857
>

0 commit comments

Comments
 (0)