diff --git a/packages/ui/src/components/message-stream-v2.tsx b/packages/ui/src/components/message-stream-v2.tsx index e5abc7c7..c5485596 100644 --- a/packages/ui/src/components/message-stream-v2.tsx +++ b/packages/ui/src/components/message-stream-v2.tsx @@ -958,7 +958,9 @@ function MessageBlock(props: MessageBlockProps) { partVersion={toolItem.partVersion} instanceId={props.instanceId} sessionId={props.sessionId} + onContentRendered={props.onContentRendered} /> + ) })()} @@ -1059,34 +1061,28 @@ function StepCard(props: StepCardProps) { const finishStyle = () => (props.borderColor ? { "border-left-color": props.borderColor } : undefined) - const renderUsageChips = (usage: NonNullable>) => ( -
-
- Input - {formatTokenTotal(usage.input)} + const renderUsageChips = (usage: NonNullable>) => { + const entries = [ + { label: "Input", value: usage.input, formatter: formatTokenTotal, show: usage.input > 0 }, + { label: "Output", value: usage.output, formatter: formatTokenTotal, show: usage.output > 0 }, + { label: "Reasoning", value: usage.reasoning, formatter: formatTokenTotal, show: usage.reasoning > 0 }, + { label: "Cache Read", value: usage.cacheRead, formatter: formatTokenTotal, show: usage.cacheRead > 0 }, + { label: "Cache Write", value: usage.cacheWrite, formatter: formatTokenTotal, show: usage.cacheWrite > 0 }, + { label: "Cost", value: usage.cost, formatter: formatCostValue, show: true }, + ].filter((entry) => entry.show) + + return ( +
+ + {(entry) => ( + + {entry.formatter(entry.value)} + + )} +
-
- Output - {formatTokenTotal(usage.output)} -
-
- Reasoning - {formatTokenTotal(usage.reasoning)} -
-
- Cache Read - {formatTokenTotal(usage.cacheRead)} -
-
- Cache Write - {formatTokenTotal(usage.cacheWrite)} -
-
- Cost - {formatCostValue(usage.cost)} -
-
- ) + ) + } if (props.kind === "finish") { const usage = usageStats() diff --git a/packages/ui/src/components/tool-call.tsx b/packages/ui/src/components/tool-call.tsx index 81242406..4b641e22 100644 --- a/packages/ui/src/components/tool-call.tsx +++ b/packages/ui/src/components/tool-call.tsx @@ -56,7 +56,9 @@ interface ToolCallProps { partVersion?: number instanceId: string sessionId: string -} + onContentRendered?: () => void + } + function getToolIcon(tool: string): string { switch (tool) { @@ -761,8 +763,10 @@ export default function ToolCall(props: ToolCallProps) { if (!options?.disableScrollTracking) { handleScrollRendered() } + props.onContentRendered?.() } + return (
{ markdownCache.set(markdownPart.renderCache) handleScrollRendered() + props.onContentRendered?.() } + return (