Skip to content

Show the reported usage total when some usage went unreported - #1908

Merged
DoodleBears merged 3 commits into
mainfrom
claude/project-thread-55eh0x-usage-known
Oct 15, 2026
Merged

DoodleBears merged 3 commits into
mainfrom
claude/project-thread-55eh0x-usage-known

Conversation

@DoodleBears

Copy link
Copy Markdown
Contributor

Requested by Vain · project thread

Why the change

On a Host upgraded from before usage completeness tracking, one old row with an unreported total turned the whole week's total and that day's bar into "Unknown", even though the Bots had millions of reported tokens (found in the #1899 simulator QA: Ada 4M and Bea 374.6K, headline and all bars "Unknown").

Refs #1896, #1899.

Special things to note

  • Merge risk: Host overviewUsage only; profileUsage and the other usage readers are unchanged. Each bucket is now the sum of what was reported, and is null only when nothing in it was reported (so a provider that never reports cache keeps cache null, as before). A row with an unreported total counts as the larger of its reported total and its reported parts, a lower bound. New partial: boolean on the totals, each day and each Bot row says some usage in it went unreported. Web shows the total as N+ with the existing partial note (copy updated). The Web parser accepts rows without partial, so an older Host still parses. No new bridge method; deepseekbot overview-usage returns the same JSON, documented in docs/bot-cli.md. Revert is a plain revert.
  • Verification:
    • Automated: new Host test counts reported usage beside an unreported total and marks the sum as partial inserts an upgraded-style row (unknown_total = 1, total 0, reported input/output) next to a reported turn and checks totals, the day, the Bot rows and partial; the existing "missing provider usage stays unknown" test still passes. New Web test checks 155+ and the partial note, and that a non-boolean partial is rejected. pnpm lint, pnpm format:check, pnpm typecheck pass; vitest run packages/core packages/client: 509 files pass, 1 fails (client-observer.test.ts, "Cannot bundle node:sqlite"), which fails the same way on main in this environment.
    • Runtime: isolated Host (scripts/dev-instance.mjs --build) with three usage_daily rows written into its database (Ada 4M reported, Bea 374.6K reported, an upgraded-style row with 360K reported parts and an unreported total). On main the Web Overview reads "Overall usage: Unknown tokens" and the bar for that day is missing; on this branch it reads "4,734,600+ tokens" and the bar is there.
    • Not run: the phone. Show the Host's 7-day token usage behind the Human's avatar on mobile #1899 (not merged yet) will read partial to show the same +.
  • CI test plan: affected.

Change outline

  • packages/core/src/usage/overview.ts: per bucket NULL only when nothing was reported; total uses MAX(total_tokens, reported parts) for rows with an unreported total; adds partial.
  • packages/client: loadOverviewUsage accepts an optional boolean partial; Overview total renders N+ and shows the partial note when totals.partial.
  • Docs: docs/bot-cli.md, docs/architecture/botharness-architecture.md.

Before (main) and after, Web Overview, last 7 days:

Before, light After, light

Before, dark After, dark

🤖 Generated with Claude Code

https://claude.ai/code/session_01U1JSurmR8K71uTv8K3rT4w


Generated by Claude Code

…totals

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U1JSurmR8K71uTv8K3rT4w
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U1JSurmR8K71uTv8K3rT4w
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 58 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3ba4e84e-02f3-434d-b426-102a5c3fe0c1
📥 Commits

Reviewing files that changed from the base of the PR and between 5e46c5e and 609fbc6.

⛔ Files ignored due to path filters: 4
  • .github/pr-screenshots/overview-usage-partial/after-dark.png is excluded by !**/*.png
  • .github/pr-screenshots/overview-usage-partial/after-light.png is excluded by !**/*.png
  • .github/pr-screenshots/overview-usage-partial/before-dark.png is excluded by !**/*.png
  • .github/pr-screenshots/overview-usage-partial/before-light.png is excluded by !**/*.png
📒 Files selected for processing: 9
  • changes/1908-usage-partial-total.md
  • docs/architecture/botharness-architecture.md
  • docs/bot-cli.md
  • packages/client/src/client/bridge.ts
  • packages/client/src/client/locale.ts
  • packages/client/src/client/overview-usage-view.tsx
  • packages/client/test/overview-usage-view.test.ts
  • packages/core/src/usage/overview.ts
  • packages/core/test/overview-usage.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U1JSurmR8K71uTv8K3rT4w
@DoodleBears
DoodleBears marked this pull request as ready for review October 15, 2026 15:47
@DoodleBears
DoodleBears merged commit b408325 into main Oct 15, 2026
9 checks passed
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