Skip to content

feat(desktop): add tps throughput, cache token counts, and output tokens to status bar / 底部信息栏新增 tps 吞吐、缓存 token 和输出 token 显示#6931

Open
HaoyueQin wants to merge 1 commit into
esengine:main-v2from
HaoyueQin:feat/status-bar-throughput-cache-tokens
Open

feat(desktop): add tps throughput, cache token counts, and output tokens to status bar / 底部信息栏新增 tps 吞吐、缓存 token 和输出 token 显示#6931
HaoyueQin wants to merge 1 commit into
esengine:main-v2from
HaoyueQin:feat/status-bar-throughput-cache-tokens

Conversation

@HaoyueQin

@HaoyueQin HaoyueQin commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds three new configurable status-bar display items and a streaming throughput readout in the composer run strip, addressing several unmet requests from the closed issue #5677.

New status bar items (persistent, bottom bar):

  • turn_tps — output token throughput (tokens/s), computed from (completionTokens + reasoningTokens) / (turn duration − wait time). Persists until the next turn completes.
  • turn_output_tokens — completion tokens from the most recent request, displayed as an exact integer ("out 1250").
  • turn_cache_tokens — prompt cache hit/miss token counts ("hit 12345 | miss 4567"), using i18n-aware labels.

All three are opt-in via Settings → Status Bar Items (drag-to-reorder, toggle visibility) and follow the existing | separator and metric-label/value layout conventions.

Streaming throughput in composer run strip (above the input box):

  • A live tokens/s estimate joins the existing ↓ N tokens readout: 来感觉了… 12s · 25 tokens/s · ↓ 850 tokens.
  • When the provider does not emit per-chunk usage events with token counts (common with some DeepSeek-compatible backends), the display falls back to a character-count estimate (chars ÷ 4), matching the approach used by MiMo-Code's sidebar TPS.
  • Tool-call argument streaming (write_file bodies, etc.) is included in the estimate so the readout stays meaningful during long tool dispatches.
  • A tooltip on hover explains that streaming values are estimates and final values may differ.

Additional changes:

  • The status bar now supports horizontal mouse-wheel panning when items overflow the window width (scrollbar hidden, no layout change).
  • Cache hit/miss sub-labels ("命中"/"未命中") use <span> (normal weight) + <b> (value only), matching the weight of every other status bar metric.
  • Three-language i18n (en / zh / zh-TW) for all new labels and tooltips.

Data model:

  • useController State gains turnDoneAt (recorded at turn_done), turnOutputTokens (accumulated from usage events: completionTokens + reasoningTokens), and turnTextChars (live text+reasoning character count for estimation).
  • lastTurnOutputTokens / lastTurnStartAt / lastTurnDoneAt / lastTurnWaitAccumMs preserve the previous turn's completed values so the status bar does not reset to "-" on the next turn.

Files changed (12):

File Change
desktop/frontend/src/lib/useController.ts Add turnDoneAt, turnOutputTokens, turnTextChars, lastTurn* fields; record in turn_done/usage/text handlers
desktop/frontend/src/lib/statusBarItems.ts Register turn_tps, turn_output_tokens, turn_cache_tokens
internal/config/config.go Add 3 items to defaultDesktopStatusBarItems
desktop/frontend/src/components/StatusBar.tsx New props, formatTps helper, 3 item renderers (Gauge/FileOutput/HardDrive icons), onWheel horizontal scroll
desktop/frontend/src/components/Composer.tsx turnOutputTokens + turnTextChars props; split runTicker into prefix/suffix with estimate tooltip; include turnArgChars in estimate
desktop/frontend/src/App.tsx Wire new state fields to Composer and StatusBar
desktop/frontend/src/components/SettingsPanel.tsx 3 new cases in statusBarItemLabel
desktop/frontend/src/locales/{en,zh,zh-TW}.ts 9 new i18n keys each
desktop/frontend/src/styles.css Horizontal scroll (hidden scrollbar) + .statusbar__cache-sep
desktop/frontend/src/__tests__/typography-overflow-contract.test.ts Update overflowoverflow-y assertion

Verification

  • gofmt -l . — clean (zero output)
  • npx tsc --noEmit (desktop/frontend) — zero errors
  • wails build — successful (Windows/amd64, 33 s)
  • Manual smoke-test with REASONIX_HOME=D:\reasonix-dev-isolated — streaming TPS, status bar items, persistence, i18n, and horizontal scroll all behave as expected
  • 131 CSS typography-overflow contract tests pass (updated assertion)

Relationship to #5677

Issue #5677 ("关于界面显示的一些建议") was closed as completed, but several items mentioned in the request body were not implemented at the time of closing:

  • Real-time token throughput speed (tok/s) — now added as both streaming estimate (run strip) and completed exact value (status bar)
  • Cache hit/miss token counts as persistent display items — now added
  • Per-request output token count — now added

The remaining suggestions in #5677 (circular context-gauge redesign, de-duplicating overview panel metrics) are out of scope for this PR.

Streaming estimation caveat

The run-strip TPS and ↓ N tokens values are character-count estimates (chars ÷ 4) when the provider does not report token counts in mid-stream usage events. This can diverge from the final exact values (sometimes by 30–50%), especially for code-heavy or mixed-language content. The final persistent values in the status bar are exact (from the API usage event). A hover tooltip on the run strip explains this to the user.

Cache impact

Cache-impact: none — the config.go change is a three-line addition to a default-item slice; it does not affect system-prompt construction, tool schema serialization, or any cache-sensitive path.

Cache-guard: existing go test ./internal/config/ covers config normalization; no new guard test needed.

System-prompt-review: self-reviewed (no prompt impact) — config.go change only appends three display-item IDs to defaultDesktopStatusBarItems; no system prompt, memory prefix, output style, or skill index construction is affected.


摘要

本 PR 新增了三个可自定义的底部状态栏显示项,并在输入框上方的 composer run strip 中添加了流式吞吐量读数,补全了已关闭的 Issue #5677 中尚未实现的若干需求。

新增状态栏项(底部持久显示):

  • turn_tps — 输出 token 吞吐速度(tokens/s),公式为 (completionTokens + reasoningTokens) / (轮次耗时 − 等待时间)。数值保留至下一轮完成才更新。
  • turn_output_tokens — 最近一次请求的 completion token 数,精确整数显示(如 "输出 1250")。
  • turn_cache_tokens — 请求级 prompt 缓存命中/未命中 token 数(如 "命中 12345 | 未命中 4567"),标签跟随界面语言切换。

所有三项均可通过「设置 → 状态栏项目」自由开关和拖拽排序,遵循现有的 | 分隔符和"标签+数值"布局规范。

输入框上方 run strip 中的流式吞吐量:

  • 在原有 ↓ 850 tokens 旁新增实时 tokens/s 估算,显示为 来感觉了… 12s · 25 tokens/s · ↓ 850 tokens
  • 当模型供应商不在流式传输中发送 usage 事件(token 计数)时,自动回退到字符数估算(chars ÷ 4),与 MiMo-Code 侧边栏 TPS 的算法一致。
  • 工具调用参数流(如 write_file 的文件体)已纳入估算,避免工具调用期间数值无意义下降。
  • 鼠标悬停时弹出提示,说明流式数值为估算值,与实际值可能存在偏差。

其他改进:

  • 状态栏支持鼠标滚轮横向平移(内容超出窗口宽度时自动可滚动,无滚动条,外观不变)。
  • 缓存命中/未命中的子标签("命中"/"未命中")使用普通字重 <span>,仅数值加粗,与其他状态栏项的字体粗细一致。
  • 三种语言 i18n(en / zh / zh-TW)均已适配。

数据模型:

  • useController State 新增 turnDoneAt(在 turn_done 事件中记录)、turnOutputTokens(从 usage 事件累加 completionTokens + reasoningTokens)、turnTextChars(流式文本+推理字符总数,用于估算)。
  • lastTurnOutputTokens / lastTurnStartAt / lastTurnDoneAt / lastTurnWaitAccumMs 保存上一轮完成时的精确值,确保状态栏不会在新一轮开始时变成 "-"。

修改文件(12 个):(同上表,略)

#5677 的关系

Issue #5677("关于界面显示的一些建议")已被标记为已关闭,但其中部分需求在关闭时并未实现:

  • 实时 token 吞吐速度(tok/s)— 现已实现(流式估算 + 完成精确值)
  • 缓存命中/未命中 token 数的持久显示 — 现已实现
  • 单次请求输出 token 数显示 — 现已实现

#5677 中的其余建议(上下文圆形进度条改为横向、概览窗口去重等)不在本 PR 范围内。

流式估算误差说明

当模型供应商不在流式过程中报告 token 计数时,run strip 的 TPS 和 ↓ N tokens 均基于字符数估算(chars ÷ 4),与精确值之间可能存在 30–50% 的偏差(尤其在代码或混合语言场景下)。底部状态栏中的持久值为 API 返回的精确值。run strip 上的悬浮提示已向用户说明这一点。

缓存影响

Cache-impact: none — config.go 仅往默认项切片追加了三行字符串,不影响系统提示词构建、工具 schema 序列化或任何缓存敏感路径。

Cache-guard: 现有 go test ./internal/config/ 已覆盖配置标准化逻辑,无需新增守护测试。

System-prompt-review: N/A — 未改动 provider 可见的系统提示词、记忆前缀、输出风格或技能索引行为。


效果展示

屏幕截图 2026-07-25 135114 屏幕截图 2026-07-25 135132 屏幕截图 2026-07-25 135151

@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) config Configuration & setup (internal/config) labels Jul 25, 2026
@HaoyueQin
HaoyueQin force-pushed the feat/status-bar-throughput-cache-tokens branch 2 times, most recently from 0ece3d8 to 8ed2cc0 Compare July 26, 2026 11:57
@HaoyueQin HaoyueQin changed the title feat(desktop): add tok/s throughput, cache token counts, and output tokens to status bar / 底部信息栏新增 tok/s 吞吐、缓存 token 和输出 token 显示 feat(desktop): add tps throughput, cache token counts, and output tokens to status bar / 底部信息栏新增 tps 吞吐、缓存 token 和输出 token 显示 Jul 26, 2026
@HaoyueQin

Copy link
Copy Markdown
Contributor Author

After the initial submission, the status-bar label for token throughput was updated for localization consistency:

English: "tok/s" → "tps" (matching the ctx-style abbreviation convention)
Simplified Chinese: "tok/s" → "吞吐速度"
Traditional Chinese: "tok/s" → "吞吐速度"
The corresponding PR title and body text should be updated accordingly.


PR 初始提交后,token 吞吐量的状态栏标签进行了本地化调整:

英文:"tok/s" → "tps"(与 ctx 等缩写风格一致)
简体中文:"tok/s" → "吞吐速度"
繁体中文:"tok/s" → "吞吐速度"

…okens to status bar and composer run strip

- StatusBar: new turn_tps, turn_output_tokens, turn_cache_tokens items with i18n
- Composer run strip: streaming TPS estimate (chars/4) with tool-arg support
- Text-based token estimation as fallback when provider omits streaming usage events
- Completed TPS persists across turns via lastTurn* state fields
- StatusBar horizontal mouse-wheel scroll with hidden scrollbar
- Three-language i18n (en/zh/zh-TW) for all new labels and tooltips
@HaoyueQin
HaoyueQin force-pushed the feat/status-bar-throughput-cache-tokens branch from c0c9cc8 to d1bb80f Compare July 26, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration & setup (internal/config) desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant