Skip to content

fix(audit): keep token usage when media input is present - #934

Open
buddhism5080 wants to merge 2 commits into
chenyme:mainfrom
buddhism5080:fix/audit-media-keep-tokens
Open

fix(audit): keep token usage when media input is present#934
buddhism5080 wants to merge 2 commits into
chenyme:mainfrom
buddhism5080:fix/audit-media-keep-tokens

Conversation

@buddhism5080

Copy link
Copy Markdown
Contributor

Summary

  • Audit list rows with media input no longer replace the token grid.

  • Media Input / output stay on the first row; 输入 / 输出 / 缓存 / 推理 stay below.

  • Missing token usage (usageSource === "none") shows ; reported zeros still show 0.

  • 带 media 输入的审计行不再整块换成 Media Usage。

  • 第一行保留 Media Input / output;下面仍显示 输入 / 输出 / 缓存 / 推理

  • 未上报 token(usageSource === "none")用 占位;已上报的 0 仍显示数字。

Context

Chat/image/video rows with mediaInputImages > 0 previously swapped the whole usage cell to MediaUsage, so token counts disappeared even when the backend already stored them.

只要 mediaInputImages > 0(带图 chat 也会中招),UsageDetails 会整块换成 MediaUsage,后端已有的 token 用量在列表里看不见。

Test plan

  • node --experimental-strip-types --test frontend/src/features/audits/audit-usage.test.ts (6/6)

  • Sabotage run: dropping token items on media rows fails the new tests; restore passes

  • pnpm exec tsc -b

  • UI: media chat row shows 3×2 grid (Media Input/output, then token four-pack)

  • UI: missing token usage shows ; reported 0 still shows 0

  • UI: plain chat without media stays 2×2

  • 视图模型单测 6/6 通过

  • 破坏验证:有 media 时去掉 token 四格会红;恢复后转绿

  • tsc -b 通过

  • 界面:带图 chat 显示 3 行 2 列

  • 界面:缺 token 显示 ;已上报的 0 仍是数字

  • 界面:无 media 的普通 chat 仍是 2×2

Media-bearing chat/image/video rows replaced the 输入/缓存/输出/推理
grid with Media Input counts. Show both, and use an em dash when
token usage was not reported.
Keep the media row distinct from the token 输出 cell.
realotz pushed a commit to realotz/grok2api that referenced this pull request Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant