From 7bdec6491a20621cbc87549a0244a78a648379a2 Mon Sep 17 00:00:00 2001 From: dengmik-commits <270912164+dengmik-commits@users.noreply.github.com> Date: Wed, 20 May 2026 17:50:43 +0800 Subject: [PATCH] feat: show cumulative session tokens and request count in status line Replace activeTokens (latest response only) with cumulative total_tokens from entry.usage and total_reqs from entry.usagePerModel, formatted as "tokens: 12.3k / 5 reqs". --- src/ui/App.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ui/App.tsx b/src/ui/App.tsx index 75d6689..ba1e187 100644 --- a/src/ui/App.tsx +++ b/src/ui/App.tsx @@ -760,11 +760,22 @@ function isCurrentSessionEmpty(sessionManager: SessionManager): boolean { return !activeSessionId || !sessionManager.getSession(activeSessionId); } +function formatTokenCount(n: number): string { + if (n < 1000) return String(n); + if (n < 10000) return `${(n / 1000).toFixed(1)}k`; + return `${Math.round(n / 1000)}k`; +} + function buildStatusLine(entry: SessionEntry): string { const parts: string[] = []; parts.push(`status: ${entry.status}`); - if (typeof entry.activeTokens === "number" && entry.activeTokens > 0) { - parts.push(`tokens: ${entry.activeTokens}`); + const totalTokens = entry.usage?.total_tokens ?? 0; + const totalReqs = + entry.usagePerModel != null + ? Object.values(entry.usagePerModel).reduce((sum, m) => sum + (m.total_reqs ?? 0), 0) + : 0; + if (totalTokens > 0) { + parts.push(`tokens: ${formatTokenCount(totalTokens)}${totalReqs > 0 ? ` / ${totalReqs} reqs` : ""}`); } if (entry.failReason) { parts.push(`fail: ${entry.failReason}`);