From 1c256994d02ec2e021ec22ce977c1c641aee9318 Mon Sep 17 00:00:00 2001
From: Soulter <905617992@qq.com>
Date: Wed, 14 Oct 2026 13:22:32 +0800
Subject: [PATCH] style: abbreviate trace token counts with k and M
---
changelogs/unreleased.md | 2 ++
dashboard/src/components/shared/TraceDisplayer.vue | 2 +-
dashboard/tests/traceTimelineGroups.test.mjs | 3 +++
docs/en/use/webui.md | 2 +-
docs/zh/use/webui.md | 2 +-
5 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/changelogs/unreleased.md b/changelogs/unreleased.md
index efdecd495..b014e3666 100644
--- a/changelogs/unreleased.md
+++ b/changelogs/unreleased.md
@@ -1,5 +1,7 @@
# Unreleased
+- Show the Tokens card total with two-decimal k/M notation while keeping precise counts in its tooltip.
+
- Add an Agent-only Tokens statistics card with input/output/cache breakdown, latest-snapshot deduplication, and an unavailable-state placeholder instead of a misleading zero.
- Add Type before UMO in the trace table, with independent blue Agent and green Command chips. Persist command flags in summaries and derive legacy flags for the current page; use explicit colors because the generic Vuetify color pack is disabled.
diff --git a/dashboard/src/components/shared/TraceDisplayer.vue b/dashboard/src/components/shared/TraceDisplayer.vue
index 09f24f234..187d2f4c1 100644
--- a/dashboard/src/components/shared/TraceDisplayer.vue
+++ b/dashboard/src/components/shared/TraceDisplayer.vue
@@ -953,7 +953,7 @@ onBeforeUnmount(() => {
{{ tm("responses") }}{{ selectedStats.responses }}
- {{ tm("tokens.title") }}{{ selectedTokenUsage ? selectedTokenUsage.total.toLocaleString() : "—" }}
+ {{ tm("tokens.title") }}{{ selectedTokenUsage ? selectedTokenUsage.total >= 1000000 ? (selectedTokenUsage.total / 1000000).toFixed(2) + " M" : (selectedTokenUsage.total / 1000).toFixed(2) + " k" : "—" }}
{{ selectedTokenUsage ? tm('tokens.breakdown', { input: selectedTokenUsage.input.toLocaleString(), output: selectedTokenUsage.output.toLocaleString(), cached: selectedTokenUsage.cached.toLocaleString() }) : tm('tokens.unavailable') }}
diff --git a/dashboard/tests/traceTimelineGroups.test.mjs b/dashboard/tests/traceTimelineGroups.test.mjs
index 2349f4ce7..35ba121ee 100644
--- a/dashboard/tests/traceTimelineGroups.test.mjs
+++ b/dashboard/tests/traceTimelineGroups.test.mjs
@@ -278,6 +278,9 @@ test("missing parents and cyclic span links cannot hang the timeline or hide unr
test("group template and stacked icon styles compile, and all locales include group labels", () => {
assert.equal(translations.compact.pluginHandler, "调用插件");
+ assert.match(descriptor.template.content, /selectedTokenUsage.total >= 1000000/);
+ assert.match(descriptor.template.content, /toFixed\(2\) \+ " M"/);
+ assert.match(descriptor.template.content, /toFixed\(2\) \+ " k"/);
assert.match(descriptor.template.content, /v-if="record.fields.handler_type && record.fields.handler_type !== 'AdapterMessageEvent'"/);
const template = compileTemplate({ source: descriptor.template.content, filename: "TraceDisplayer.vue", id: "trace-groups" });
assert.deepEqual(template.errors, []);
diff --git a/docs/en/use/webui.md b/docs/en/use/webui.md
index 2178a912f..bc31efd06 100644
--- a/docs/en/use/webui.md
+++ b/docs/en/use/webui.md
@@ -172,7 +172,7 @@ The toolbar contains search, fullscreen, font-size controls, and `Install Pip pa
### Trace
-Traces containing Agent calls add a borderless Tokens statistics card. Its total sums this execution's input (including cached input) and output; hover or focus to inspect input, output, and cached-input counts. Only the latest cumulative snapshot per Agent is used, and separate Agents are summed. Unavailable usage shows an em dash rather than a reported zero.
+Traces containing Agent calls add a borderless Tokens statistics card. Its total sums this execution's input (including cached input) and output, displayed with two-decimal k/M notation while the tooltip retains exact counts; hover or focus to inspect input, output, and cached-input counts. Only the latest cumulative snapshot per Agent is used, and separate Agents are summed. Unavailable usage shows an em dash rather than a reported zero.
The Type column precedes UMO. Blue Agent indicates an Agent call; green Command indicates a command-handler call. Both can appear independently on the same trace. Ordinary listeners and event hooks do not count as commands. Summaries provide these flags; legacy command flags are derived for the current page without opening each trace's details.
diff --git a/docs/zh/use/webui.md b/docs/zh/use/webui.md
index 3dd2d632d..4db0b6717 100644
--- a/docs/zh/use/webui.md
+++ b/docs/zh/use/webui.md
@@ -172,7 +172,7 @@ ChatUI 支持以下常用能力:
### 追踪
-包含 Agent 调用时,详情统计区增加无边框的 Tokens 卡片,展示本轮输入(含缓存输入)与输出的累计总量;悬停或键盘聚焦可查看输入、输出及缓存命中明细。同一 Agent 的累计快照只取最新一份,多个 Agent 分别累计。没有已上报用量时显示“—”,不按 0 处理。
+包含 Agent 调用时,详情统计区增加无边框的 Tokens 卡片,展示本轮输入(含缓存输入)与输出的累计总量,以两位小数的 k/M 格式显示,悬浮提示保留精确数量;悬停或键盘聚焦可查看输入、输出及缓存命中明细。同一 Agent 的累计快照只取最新一份,多个 Agent 分别累计。没有已上报用量时显示“—”,不按 0 处理。
UMO 前新增“类型”列:蓝色 Agent 表示 Agent 调用,绿色“指令”表示指令处理器调用。同一追踪可同时显示两个标签;普通监听器和事件钩子不算作指令。类型由追踪摘要提供,旧记录的指令标记按当前页数据推导,无需逐条打开详情。