Skip to content

Commit bc9ab83

Browse files
t3dotggclaude
andcommitted
Show live per-agent stats while running; drop inline row previews
The SDK emits tokens/toolCalls on every progress tick (verified against the bundled runtime), so agent rows now show them live; elapsed time for a running agent derives from lastProgressAt - startedAt, which advances tick-by-tick without a client timer. Settled agents keep the reported total duration. Agent rows no longer render the routine inline preview text (result and last-tool snippets) — the expandable transcript owns that detail. Error text stays inline since it explains a red row at a glance. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent 93cd36a commit bc9ab83

1 file changed

Lines changed: 21 additions & 25 deletions

File tree

‎apps/web/src/components/workflow/workflowUi.tsx‎

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,6 @@ export function agentDisplayLabel(agent: WorkflowRunAgent): string {
8888
return agent.label ?? agent.agentType ?? `agent ${agent.index}`;
8989
}
9090

91-
export function agentPreviewText(agent: WorkflowRunAgent): string | undefined {
92-
switch (agent.status) {
93-
case "error":
94-
return agent.error ?? agent.resultPreview;
95-
case "done":
96-
return agent.resultPreview;
97-
case "running":
98-
return agent.lastToolSummary ?? agent.promptPreview;
99-
default:
100-
return agent.promptPreview;
101-
}
102-
}
103-
10491
function AgentMetaBadges({ agent }: { agent: WorkflowRunAgent }): ReactElement | null {
10592
const badges: string[] = [];
10693
if (agent.cached) {
@@ -127,7 +114,10 @@ function AgentMetaBadges({ agent }: { agent: WorkflowRunAgent }): ReactElement |
127114
}
128115

129116
/** "94.2k tok · 47 tools · 7m 03s" — cumulative per-agent stats from the
130-
* SDK snapshot; duration is shown once the agent settles. */
117+
* SDK snapshot. Tokens and tool counts update on every progress tick; the
118+
* duration is the reported total once the agent settles, and the elapsed
119+
* time between start and the latest tick while it runs (tick-driven, so no
120+
* client timer is needed). */
131121
export function agentStatsLabel(agent: WorkflowRunAgent): string | undefined {
132122
const parts: string[] = [];
133123
if (agent.tokens !== undefined && agent.tokens > 0) {
@@ -136,27 +126,32 @@ export function agentStatsLabel(agent: WorkflowRunAgent): string | undefined {
136126
if (agent.toolCalls !== undefined && agent.toolCalls > 0) {
137127
parts.push(`${agent.toolCalls} ${agent.toolCalls === 1 ? "tool" : "tools"}`);
138128
}
139-
if (
140-
agent.durationMs !== undefined &&
141-
agent.durationMs > 0 &&
142-
(agent.status === "done" || agent.status === "error")
143-
) {
129+
const settled = agent.status === "done" || agent.status === "error";
130+
if (settled && agent.durationMs !== undefined && agent.durationMs > 0) {
144131
parts.push(formatWorkflowDuration(agent.durationMs));
132+
} else if (
133+
!settled &&
134+
agent.startedAt !== undefined &&
135+
agent.lastProgressAt !== undefined &&
136+
agent.lastProgressAt > agent.startedAt
137+
) {
138+
parts.push(formatWorkflowDuration(agent.lastProgressAt - agent.startedAt));
145139
}
146140
return parts.length > 0 ? parts.join(" · ") : undefined;
147141
}
148142

149-
/** The shared inner content of an agent row: dot, label, badges, dimmed
150-
* preview, right-aligned model + stats. */
143+
/** The shared inner content of an agent row: dot, label, badges,
144+
* right-aligned model + stats. Error text is the only inline content —
145+
* routine previews live in the expandable transcript, not the row. */
151146
export function AgentRowContent({
152147
agent,
153148
leading,
154149
}: {
155150
agent: WorkflowRunAgent;
156151
leading?: ReactNode;
157152
}): ReactElement {
158-
const preview = agentPreviewText(agent);
159153
const stats = agentStatsLabel(agent);
154+
const errorText = agent.status === "error" ? agent.error : undefined;
160155
return (
161156
<div className="flex min-w-0 items-center gap-1.5 text-[12px] leading-5">
162157
{leading}
@@ -170,10 +165,11 @@ export function AgentRowContent({
170165
{agentDisplayLabel(agent)}
171166
</span>
172167
<AgentMetaBadges agent={agent} />
173-
{preview !== undefined && (
174-
<span className="min-w-0 flex-1 truncate text-muted-foreground/70">{preview}</span>
168+
{errorText !== undefined ? (
169+
<span className="min-w-0 flex-1 truncate text-destructive/70">{errorText}</span>
170+
) : (
171+
<span className="min-w-0 flex-1" />
175172
)}
176-
{preview === undefined && <span className="min-w-0 flex-1" />}
177173
{agent.model !== undefined && (
178174
<span className="hidden shrink-0 text-[11px] text-muted-foreground/55 sm:inline">
179175
{agent.model}

0 commit comments

Comments
 (0)