Skip to content

Commit 7bdec64

Browse files
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".
1 parent abde38c commit 7bdec64

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/ui/App.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,11 +760,22 @@ function isCurrentSessionEmpty(sessionManager: SessionManager): boolean {
760760
return !activeSessionId || !sessionManager.getSession(activeSessionId);
761761
}
762762

763+
function formatTokenCount(n: number): string {
764+
if (n < 1000) return String(n);
765+
if (n < 10000) return `${(n / 1000).toFixed(1)}k`;
766+
return `${Math.round(n / 1000)}k`;
767+
}
768+
763769
function buildStatusLine(entry: SessionEntry): string {
764770
const parts: string[] = [];
765771
parts.push(`status: ${entry.status}`);
766-
if (typeof entry.activeTokens === "number" && entry.activeTokens > 0) {
767-
parts.push(`tokens: ${entry.activeTokens}`);
772+
const totalTokens = entry.usage?.total_tokens ?? 0;
773+
const totalReqs =
774+
entry.usagePerModel != null
775+
? Object.values(entry.usagePerModel).reduce((sum, m) => sum + (m.total_reqs ?? 0), 0)
776+
: 0;
777+
if (totalTokens > 0) {
778+
parts.push(`tokens: ${formatTokenCount(totalTokens)}${totalReqs > 0 ? ` / ${totalReqs} reqs` : ""}`);
768779
}
769780
if (entry.failReason) {
770781
parts.push(`fail: ${entry.failReason}`);

0 commit comments

Comments
 (0)