Skip to content

feat(web): show Claude round usage metadata - #1655

Merged
tiann merged 1 commit into
tiann:mainfrom
junmo-kim:fix/claude-token-metadata
Aug 22, 2026
Merged

feat(web): show Claude round usage metadata#1655
tiann merged 1 commit into
tiann:mainfrom
junmo-kim:fix/claude-token-metadata

Conversation

@junmo-kim

Copy link
Copy Markdown
Contributor

Summary

This follows up on #637, which aggregated per-message metadata across a response group. Claude's final SDK result now lets the same surface show authoritative round-level usage, cost, duration, and turn count instead of deriving them from individual messages.

  • preserve the Claude Agent SDK's final result as authoritative metadata for the preceding response round
  • show models, processed tokens, cache-read share, API-rate estimate, elapsed round time, and internal turns in the message-details popover
  • keep existing metadata labels unchanged when a round result is unavailable

Details

Claude assistant messages expose per-message usage, while the SDK's final result contains the complete round-level usage, per-model breakdown, cost, duration, and turn count. The CLI now forwards that result through the existing system/turn_duration carrier without advancing the main or sidechain parent chain. The remote queue preserves visible system carriers and drains them before ready, while Web reconciliation retains late-arriving round summaries. The web app validates it at the normalization boundary, attaches it to the preceding contiguous assistant response group, and prefers it over derived per-message aggregates.

Malformed counters fail closed. Token and turn counts require non-negative safe integers, cost and duration require finite non-negative numbers, and a zero cost is omitted rather than presented as free usage.

Test plan

  • full CLI Vitest suite (2,439 passed, 1 skipped)
  • full Hub suite (1,205 passed, 3 skipped)
  • full Web Vitest suite (2,842 passed)
  • full Shared and Relay suites (294 and 80 passed)
  • CLI and Web typechecks
  • Web production build
  • isolated Hub + Vite + real Claude Haiku request + Playwright verification on desktop and iPhone 13, without a page reload

Screenshots

Desktop Mobile
Claude round usage metadata on desktop Claude round usage metadata on mobile

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • No findings.

Summary
Review mode: initial

No issues meeting the ≥80% confidence threshold were found in the added or modified lines. Residual risk: the change spans CLI message ordering and Web normalization/reconciliation, so correctness still depends on the full automated suite and representative Claude SDK result shapes.

Testing

  • Not run (automation); static review only. The diff adds coverage for result conversion, queue ordering, malformed-counter normalization, sidechain attachment, late reconciliation, tool-only grouping, and metadata formatting.

HAPI Bot

@tiann
tiann merged commit 661e9b4 into tiann:main Aug 22, 2026
4 checks passed
@junmo-kim
junmo-kim deleted the fix/claude-token-metadata branch August 22, 2026 10:09
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.

2 participants