Skip to content

Commit a334991

Browse files
committed
formatCollapsedStats decouples content from presentation
1 parent ed785a0 commit a334991

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

spawn/renderer.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,19 @@ function wrapSpawnShell(lines: string[], width: number, theme: Theme | undefined
198198
];
199199
}
200200

201-
function formatCollapsedStats(details: SpawnResultDetails, color: (name: ThemeColor, text: string) => string): string | undefined {
201+
function formatCollapsedStats(details: SpawnResultDetails): { text: string; color: ThemeColor } | undefined {
202202
if (details.stats) {
203203
const s = details.stats;
204204
const cost = s.cost ?? 0;
205205
const costStr = cost >= COST_THRESHOLD_COMPACT ? cost.toFixed(0) : cost >= COST_THRESHOLD_DECIMAL ? cost.toFixed(2) : cost.toFixed(4);
206-
const truncated = details.truncated ? color("warning", " · trunc") : "";
207-
return color("dim", `tok ${s.inputTokens ?? "?"}/${s.outputTokens ?? "?"} · ${s.turns ?? "?"}t · $${costStr}${truncated}`);
206+
return {
207+
// Intentionally dim — truncated spawns are routine, not alarming
208+
text: `tok ${s.inputTokens ?? "?"}/${s.outputTokens ?? "?"} · ${s.turns ?? "?"}t · $${costStr}${details.truncated ? " · trunc" : ""}`,
209+
color: "dim",
210+
};
208211
}
209212
if (details.statsUnavailable) {
210-
return color("muted", "stats unavailable");
213+
return { text: "stats unavailable", color: "muted" };
211214
}
212215
return undefined;
213216
}
@@ -840,9 +843,9 @@ class NestedAgentSessionComponent extends Container implements SpawnFrameTarget
840843
}
841844
}
842845

843-
const statsLine = details ? formatCollapsedStats(details, color) : undefined;
846+
const statsLine = details ? formatCollapsedStats(details) : undefined;
844847
if (statsLine) {
845-
lines.push(truncateToWidth(statsLine, width));
848+
lines.push(truncateToWidth(color(statsLine.color, statsLine.text), width));
846849
}
847850

848851
return lines;

0 commit comments

Comments
 (0)