Skip to content

Enhance tokenUsageSection in DiscoverView with time-scoped stats and richer breakdowns #604

Closed

Description

@haiphucnguyen

Context

tokenUsageSection in DiscoverView.kt currently renders a horizontal bar chart of
the top 5 models by all-time token usage, sourced directly from
TelemetryMetrics.llmTokensByInstance (a flat in-memory/file-backed map).

With Issue 1 landing (SQLite persistence + LlmUsageRepository), we can query
time-scoped data. This ticket covers enhancing the section to surface that richer data.

Current Behaviour

  • All-time total shown in section header (discover.tokens.total)
  • Top-5 bar chart with provider/model label, fill bar, abbreviated token count, and %
  • Empty state if totalTokensUsed == 0
  • "Open in new" icon navigates to System Diagnostics

Proposed Enhancements

1. Time-scope selector (This Month / This Week / All Time)

Add a compact segmented control or chip row below the section title to switch between:

  • This Month (default)
  • This Week
  • All Time
  1. Summary stat row above the bar chart
    Inside the Surface card, before the bar rows, add a compact 3-column stat strip:
    Tokens used. Calls made Avg tokens/call
    45.2K 38. 1.2K
    All values scoped to the active time period. Uses abbreviateTokens() (already exists) and LocalizationManager.formatNumber().

  2. tokenBarRow — add call count column
    Extend the existing tokenBarRow composable with an additional calls: Int column to the right of the % label, so each row shows:

[model/provider] [====bar====] [45.2K] [62%] [38 calls]

  1. Empty state - scope-aware copy
    Currently the empty state shows a single string (discover.tokens.empty). Update to show a scope-aware message, e.g.:
    "No token usage recorded this month"
    "No token usage recorded this week"
    "No token usage recorded yet"

Depends on #603

Activity

  1. added
    enhancement
    help wanted
    on Aug 5, 2026
  2. GurreXr commented on Aug 7, 2026

    @GurreXr
    Contributor

    I created PR #612 to set up the telemetry usage repository. I can continue working on this ticket.

  3. haiphucnguyen commented on Aug 7, 2026

    @haiphucnguyen
    CollaboratorAuthor

    Hi @GurreXr , thanks for the pull request and for volunteering on this ticket! I’ve assigned it to you now. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementhelp wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions