From bc9ab83e29919fdd0f2665aa635b322b40a56142 Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Thu, 2 Jul 2026 12:42:15 -0700 Subject: [PATCH] Show live per-agent stats while running; drop inline row previews MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../src/components/workflow/workflowUi.tsx | 46 +++++++++---------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/apps/web/src/components/workflow/workflowUi.tsx b/apps/web/src/components/workflow/workflowUi.tsx index d47261a6a5..5fcb25b77b 100644 --- a/apps/web/src/components/workflow/workflowUi.tsx +++ b/apps/web/src/components/workflow/workflowUi.tsx @@ -88,19 +88,6 @@ export function agentDisplayLabel(agent: WorkflowRunAgent): string { return agent.label ?? agent.agentType ?? `agent ${agent.index}`; } -export function agentPreviewText(agent: WorkflowRunAgent): string | undefined { - switch (agent.status) { - case "error": - return agent.error ?? agent.resultPreview; - case "done": - return agent.resultPreview; - case "running": - return agent.lastToolSummary ?? agent.promptPreview; - default: - return agent.promptPreview; - } -} - function AgentMetaBadges({ agent }: { agent: WorkflowRunAgent }): ReactElement | null { const badges: string[] = []; if (agent.cached) { @@ -127,7 +114,10 @@ function AgentMetaBadges({ agent }: { agent: WorkflowRunAgent }): ReactElement | } /** "94.2k tok · 47 tools · 7m 03s" — cumulative per-agent stats from the - * SDK snapshot; duration is shown once the agent settles. */ + * SDK snapshot. Tokens and tool counts update on every progress tick; the + * duration is the reported total once the agent settles, and the elapsed + * time between start and the latest tick while it runs (tick-driven, so no + * client timer is needed). */ export function agentStatsLabel(agent: WorkflowRunAgent): string | undefined { const parts: string[] = []; if (agent.tokens !== undefined && agent.tokens > 0) { @@ -136,18 +126,23 @@ export function agentStatsLabel(agent: WorkflowRunAgent): string | undefined { if (agent.toolCalls !== undefined && agent.toolCalls > 0) { parts.push(`${agent.toolCalls} ${agent.toolCalls === 1 ? "tool" : "tools"}`); } - if ( - agent.durationMs !== undefined && - agent.durationMs > 0 && - (agent.status === "done" || agent.status === "error") - ) { + const settled = agent.status === "done" || agent.status === "error"; + if (settled && agent.durationMs !== undefined && agent.durationMs > 0) { parts.push(formatWorkflowDuration(agent.durationMs)); + } else if ( + !settled && + agent.startedAt !== undefined && + agent.lastProgressAt !== undefined && + agent.lastProgressAt > agent.startedAt + ) { + parts.push(formatWorkflowDuration(agent.lastProgressAt - agent.startedAt)); } return parts.length > 0 ? parts.join(" · ") : undefined; } -/** The shared inner content of an agent row: dot, label, badges, dimmed - * preview, right-aligned model + stats. */ +/** The shared inner content of an agent row: dot, label, badges, + * right-aligned model + stats. Error text is the only inline content — + * routine previews live in the expandable transcript, not the row. */ export function AgentRowContent({ agent, leading, @@ -155,8 +150,8 @@ export function AgentRowContent({ agent: WorkflowRunAgent; leading?: ReactNode; }): ReactElement { - const preview = agentPreviewText(agent); const stats = agentStatsLabel(agent); + const errorText = agent.status === "error" ? agent.error : undefined; return (
{leading} @@ -170,10 +165,11 @@ export function AgentRowContent({ {agentDisplayLabel(agent)} - {preview !== undefined && ( - {preview} + {errorText !== undefined ? ( + {errorText} + ) : ( + )} - {preview === undefined && } {agent.model !== undefined && ( {agent.model}