Don't show stats for assistant messages with only tool calls

This commit is contained in:
Mario Zechner 2025-11-11 22:13:00 +01:00
parent ea8b8b7f54
commit 2d43b2f2e3
2 changed files with 13 additions and 4 deletions

View file

@ -10,8 +10,8 @@ The woodland creatures gazed in wonder as it flashed past them like a streak of
At the clearing's edge, there also dwelled an exceptionally lazy dog. At the clearing's edge, there also dwelled an exceptionally lazy dog.
This contented dog much preferred snoozing in the golden sunshine to any kind of adventure. This contented dog much preferred snoozing in the golden sunshine to any kind of adventure.
One day, the fox challenged the dog to a race across the meadow. One fateful morning, the fox challenged the dog to an epic race across the meadow.
The dog yawned and declined, saying "Why rush when you can rest?" The dog yawned deeply and declined, saying "Why rush around when you can rest peacefully?"
The fox laughed and zipped away, exploring distant hills and valleys. The fox laughed and zipped away, exploring distant hills and valleys.
The dog simply rolled over and continued its peaceful slumber. The dog simply rolled over and continued its peaceful slumber.

View file

@ -34,32 +34,41 @@ export class AssistantMessageComponent extends Container {
// Clear content container // Clear content container
this.contentContainer.clear(); this.contentContainer.clear();
// Check if there's any actual content (text or thinking)
let hasContent = false;
// Render content in order // Render content in order
for (const content of message.content) { for (const content of message.content) {
if (content.type === "text" && content.text.trim()) { if (content.type === "text" && content.text.trim()) {
// Assistant text messages with no background - trim the text // Assistant text messages with no background - trim the text
// Set paddingY=0 to avoid extra spacing before tool executions // Set paddingY=0 to avoid extra spacing before tool executions
this.contentContainer.addChild(new Markdown(content.text.trim(), undefined, undefined, undefined, 1, 0)); this.contentContainer.addChild(new Markdown(content.text.trim(), undefined, undefined, undefined, 1, 0));
hasContent = true;
} else if (content.type === "thinking" && content.thinking.trim()) { } else if (content.type === "thinking" && content.thinking.trim()) {
// Thinking traces in dark gray italic // Thinking traces in dark gray italic
// Apply styling to entire block so wrapping preserves it // Apply styling to entire block so wrapping preserves it
const thinkingText = chalk.gray.italic(content.thinking); const thinkingText = chalk.gray.italic(content.thinking);
this.contentContainer.addChild(new Text(thinkingText, 1, 0)); this.contentContainer.addChild(new Text(thinkingText, 1, 0));
this.contentContainer.addChild(new Spacer(1)); this.contentContainer.addChild(new Spacer(1));
hasContent = true;
} }
} }
// Check if aborted - show after partial content // Check if aborted - show after partial content
if (message.stopReason === "aborted") { if (message.stopReason === "aborted") {
this.contentContainer.addChild(new Text(chalk.red("Aborted"))); this.contentContainer.addChild(new Text(chalk.red("Aborted")));
hasContent = true;
} else if (message.stopReason === "error") { } else if (message.stopReason === "error") {
const errorMsg = message.errorMessage || "Unknown error"; const errorMsg = message.errorMessage || "Unknown error";
this.contentContainer.addChild(new Text(chalk.red(`Error: ${errorMsg}`))); this.contentContainer.addChild(new Text(chalk.red(`Error: ${errorMsg}`)));
hasContent = true;
} }
// Update stats // Only update stats if there's actual content (not just tool calls)
if (hasContent) {
this.updateStats(message.usage); this.updateStats(message.usage);
} }
}
updateStats(usage: any): void { updateStats(usage: any): void {
if (!usage) { if (!usage) {