Skip to content

Show host-owned usage history with provider charts - #33371

Open
gentslava wants to merge 23 commits into
stablyai:mainfrom
gentslava:feat/usage-history-and-quotas
Open

gentslava wants to merge 23 commits into
stablyai:mainfrom
gentslava:feat/usage-history-and-quotas

Conversation

@gentslava

@gentslava gentslava commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Read historical token usage from the selected host, filter it by provider/account/model/project/date, and compare daily provider trends.

What Changed

Reuses host-owned provider stores, recorded account attribution and existing RPC ownership to expose history and daily charts. Unknown identity, missing history and unavailable prices stay explicit; API-equivalent estimates are not subscription bills. This refresh preserves upstream daemon idle policy, tab-scoped provider rows, usage-limit RPCs and capability bundling.

Why

Current quota snapshots cannot explain historical usage. Recorded history must stay with the host that collected it and must not infer past account identity from the current login.

Linked Issue

Fixes #39518. Related: #23389 (history from SSH hosts) and #29676 (single overview period).

Visual Proof

Historical English component evidence; no new capture is claimed for this refresh.

Before: frozen upstream d58849a7d8d68929bd0e686571678d85e70740af. After: standalone 47bfa883da0d3e8898dbcb6f49c31c5288a9affb. Matched component pairs use identical synthetic data, dark theme and 1280×900 viewport.

Before: usage before desktop

Before: usage before desktop

After: usage after desktop

After: usage after desktop

After: usage after project history

After: usage after project history

After: usage after history account filter

After: usage after history account filter

Actual StatsPane and usage components with synthetic collector/account responses. Project/account/date filtering and unchanged account-wide quota values passed; this rendered proof does not establish real billing, collector scanning or remote compatibility. All final component runs had zero page errors and hidden, unfocused windows; captures ran on macOS through approved outside-sandbox execution. No private user screenshot is published and no image is committed to this PR. Full rendered evidence: gentslava#1.

Daily provider trends and comparative shares

Final chart refinement at af189a86ecd, with filter/zero-day regressions in 79dd6a8110d, compared with pre-chart 7ee4545332f, using synthetic fixture records:

Smooth solid provider curves and comparative shares

A day without recorded use reaches zero

Exact hover readout, with markers only during inspection

Provider curves use monotone smoothing without extra extrema, solid strokes and matching area fills. Days without recorded provider usage connect at zero; recorded usage with unknown prices remains explicitly unavailable in cost mode. Idle dots and guide lines stay hidden; hover and keyboard focus expose exact values. Historical totals remain ledger-derived.

The matched pre-chart capture, light theme are supplemental. Latest hidden CDP evidence exercises all four providers, 7/30/90/all periods, zero-day readout, hover, keyboard/day selection, metric switching, 420px layout and unchanged quota text. No live account or billing evidence is claimed.

Testing

Current head: 5b9b9eef657e3552eb4b5893b3d5898a194b96ad. Ordinary forward merge of upstream main 8a4dd3a7bb9bd7f96b68dec621433431d77dc8c1. Updated affected imports to their current owners.

All five desktop/runtime TypeScript projects pass with the supported tsrs compiler. The complete affected source test files pass 152 tests.

Normal commit hooks pass. Final changed-path gate: all non-unit checks passed; broad related-unit selection exceeded the one-minute limit and remains incomplete locally. No new installed-app/device, live-provider, SSH, Windows or Linux acceptance is claimed for this maintenance refresh.

Risk

Level: Medium

Attribution, cache identity and remote ownership are the main risks; errors could group usage under the wrong account or host. Existing unknown/unavailable states remain explicit. A plain revert removes the history surface and collector integration; recorded caches may remain on disk.

AI Disclosure

Implemented and checked with Codex assistance. The contributor owns the change and validation.

Review

Previously reported session-count fallback, ordering, token totals, filter labels and day-boundary issues remain fixed. The suggested local quota-watcher simplification was withdrawn because it could attach a stale account label to new quota data.

Agent skill upstream boundary

  • Not applicable; this change copies no upstream skill-installer implementation or documentation.

Notes

Source: 53f589d96e85efff6f46dfd3ac7c96d1d8e9b32b. Frozen upstream main: 18f674e69ff6708b634f53d668582d3943acb74d. Prepared from the exact published PR head with an ordinary forward merge. Local checks above are scoped to this atomic contribution.

Checklist

  • This PR is focused on the feature described above
  • What changed, why, risk and rollback are described
  • Earlier visual evidence or N/A reason is included
  • Self-reviewed for correctness, security and performance
  • Cross-platform, remote, folder-workspace, mobile and mixed-version impact considered
  • Full lint, typecheck, test and build gates pass at this head

@gentslava
gentslava marked this pull request as ready for review October 25, 2026 03:23
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
Walkthrough

The change adds account-aware, session-level usage history for Claude, Codex, OpenCode, and Muse. It exposes filtered history snapshots through runtime RPC and adds history charts, breakdowns, session details, and account quota views to the stats interface. Provider scanners persist account ownership and session identity in daily aggregates. Cache handling, session totals, and runtime startup are updated to support these paths.

Merge Risk: Low · previous review 0aa90

Local account quota cards may briefly disappear after a rate-limit refresh. The issue is bounded and does not prevent merging, but the watcher dependency should be corrected.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly summarizes the main change: host-owned usage history with provider charts.
Description check Passed The description is mostly complete. It covers the change, issue, visual proof, testing, risks, and rollback. Reviewer test steps and the alternatives considered could be clearer.
  • 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 8


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5632b3b4-3106-4ab3-a984-90e28e0f42ff
Commits

Reviewing files that changed from the base of the PR and between fd24040 and 47bfa88.

Files ignored due to path filters: 1
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
Files selected for processing: 112
  • config/scripts/orcad-entry-build.mjs
  • src/main/claude-accounts/claude-profile-installed-router.ts
  • src/main/claude-usage/claude-usage-report-aggregation.ts
  • src/main/claude-usage/claude-usage-session-rows.ts
  • src/main/claude-usage/persisted-source-cache.ts
  • src/main/claude-usage/persisted-usage-test-fixture.ts
  • src/main/claude-usage/scanner.ts
  • src/main/claude-usage/store.test.ts
  • src/main/claude-usage/store.ts
  • src/main/claude-usage/transcript-file-discovery.ts
  • src/main/claude-usage/transcript-projection-integrity.ts
  • src/main/claude-usage/transcript-resume-projection.ts
  • src/main/claude-usage/transcript-token-checkpoint.ts
  • src/main/claude-usage/transcript-usage-projection.ts
  • src/main/claude-usage/types.ts
  • src/main/claude-usage/usage-aggregation.ts
  • src/main/codex-usage/codex-rollout-file-parse.ts
  • src/main/codex-usage/codex-usage-provider.ts
  • src/main/codex-usage/codex-usage-rollup-projections.ts
  • src/main/codex-usage/codex-usage-session-rows.ts
  • src/main/codex-usage/scanner-file-generation.test.ts
  • src/main/codex-usage/scanner-file-identity.test.ts
  • src/main/codex-usage/scanner.ts
  • src/main/codex-usage/store-persistence.test.ts
  • src/main/codex-usage/store-test-harness.ts
  • src/main/codex-usage/store.ts
  • src/main/codex-usage/types.ts
  • src/main/codex/codex-account-home-discovery.ts
  • src/main/ipc/usage-provider-handlers-readiness.test.ts
  • src/main/ipc/usage-provider-handlers.ts
  • src/main/muse-usage/muse-usage-provider.ts
  • src/main/muse-usage/snapshot-rollups.ts
  • src/main/muse-usage/store.ts
  • src/main/opencode-usage/opencode-usage-account-roots.ts
  • src/main/opencode-usage/opencode-usage-provider.ts
  • src/main/opencode-usage/scanner.ts
  • src/main/opencode-usage/snapshot-rollups.ts
  • src/main/opencode-usage/store.test.ts
  • src/main/opencode-usage/store.ts
  • src/main/opencode-usage/types.ts
  • src/main/orcad/orcad-entry.ts
  • src/main/orcad/orcad-secret-store-startup.ts
  • src/main/orcad/orcad-usage-history.ts
  • src/main/runtime/construction/runtime-agent-provider-session-rows.ts
  • src/main/runtime/construction/runtime-host-services.ts
  • src/main/runtime/rpc/methods/index.ts
  • src/main/runtime/rpc/methods/usage-history.test.ts
  • src/main/runtime/rpc/methods/usage-history.ts
  • src/main/startup/main-process-ready-duplicate-pty-repair.test.ts
  • src/main/startup/main-process-runtime-service.ts
  • src/main/usage/usage-account-attribution.test.ts
  • src/main/usage/usage-account-attribution.ts
  • src/main/usage/usage-calendar-range.ts
  • src/main/usage/usage-event-aggregation.ts
  • src/main/usage/usage-history-projection.test.ts
  • src/main/usage/usage-history-projection.ts
  • src/main/usage/usage-provider-facade.ts
  • src/main/usage/usage-provider-store-initialization.test.ts
  • src/main/usage/usage-provider-store-lifecycle.test.ts
  • src/main/usage/usage-provider-store-lifecycle.ts
  • src/main/usage/usage-rollup-records.ts
  • src/main/usage/usage-scan-worker-entry.ts
  • src/main/usage/usage-scan-worker-event-loop.test.ts
  • src/main/usage/usage-scan-worker-protocol.ts
  • src/main/usage/usage-scan-worker-spawn.ts
  • src/main/usage/usage-session-selection.ts
  • src/main/usage/usage-source-cache-file.ts
  • src/preload/api/agent-usage-api.ts
  • src/preload/usage-provider-api.ts
  • src/renderer/src/components/settings/settings-interface-secondary-section-renderers.tsx
  • src/renderer/src/components/stats/ClaudeUsageDetails.tsx
  • src/renderer/src/components/stats/CodexUsageDailyChart.tsx
  • src/renderer/src/components/stats/CodexUsagePane.test.tsx
  • src/renderer/src/components/stats/GrokUsagePane.test.tsx
  • src/renderer/src/components/stats/OpenCodeUsageDetails.tsx
  • src/renderer/src/components/stats/StatsPane.tsx
  • src/renderer/src/components/stats/StatsPane.usage.test.tsx
  • src/renderer/src/components/stats/UsageAccountQuotas.test.tsx
  • src/renderer/src/components/stats/UsageAccountQuotas.tsx
  • src/renderer/src/components/stats/UsageHistoryDetails.tsx
  • src/renderer/src/components/stats/UsageHistoryFilter.tsx
  • src/renderer/src/components/stats/UsageHistoryFilters.tsx
  • src/renderer/src/components/stats/UsageOverviewPane.tsx
  • src/renderer/src/components/stats/UsageRecentSessionsTable.tsx
  • src/renderer/src/components/stats/usage-account-quota-rows.ts
  • src/renderer/src/components/stats/usage-formatters.test.ts
  • src/renderer/src/components/stats/usage-formatters.ts
  • src/renderer/src/components/stats/usage-history-accounts.ts
  • src/renderer/src/components/stats/usage-history-client.ts
  • src/renderer/src/components/stats/usage-history-model.test.ts
  • src/renderer/src/components/stats/usage-history-model.ts
  • src/renderer/src/components/stats/usage-overview-model.ts
  • src/renderer/src/components/stats/usage-overview-sections.tsx
  • src/renderer/src/components/stats/use-usage-history.test.ts
  • src/renderer/src/components/stats/use-usage-history.ts
  • src/renderer/src/components/status-bar/use-owner-usage-rate-limits.test.tsx
  • src/renderer/src/components/status-bar/use-owner-usage-rate-limits.ts
  • src/renderer/src/i18n/en-runtime-required.json
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/runtime/runtime-provider-accounts-client.ts
  • src/renderer/src/web/web-preload-api-usage-history.test.ts
  • src/shared/claude-usage-types.ts
  • src/shared/codex-usage-types.ts
  • src/shared/muse-usage-types.ts
  • src/shared/opencode-usage-types.ts
  • src/shared/orcad-artifacts.ts
  • src/shared/protocol-version.ts
  • src/shared/rpc-contract/usage-history-params.ts
  • src/shared/usage-history-aggregation.ts
  • src/shared/usage-history-range.ts
  • src/shared/usage-history-rpc.ts
  • src/shared/usage-history-types.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Comment thread src/shared/usage-history-range.ts Resolved
@gentslava gentslava changed the title Add account quotas and host-owned usage history Add account quotas and host-owned usage history with provider charts Oct 25, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments: 1
src/renderer/src/components/stats/StatsPane.usage.test.tsx: 1

293-293: Trivial · Functional Correctness · Quick win

Assert the no-history placeholder.

The not.toHaveTextContent('0.0k') assertion also passes when the total renders as 0 or 0 tokens. UsageOverviewPane explicitly renders — when no history rows exist, so assert the exact placeholder to catch this regression.

Suggested fix
-    expect(screen.getByTestId('usage-history-totals')).not.toHaveTextContent('0.0k')
+    expect(screen.getByTestId('usage-history-totals')).toHaveTextContent('—')

Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d343fdfc-5c6a-4712-a34e-253a1b4c670c
Commits

Reviewing files that changed from the base of the PR and between af189a8 and 79dd6a8.

Files selected for processing: 1
  • src/renderer/src/components/stats/StatsPane.usage.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@gentslava

Copy link
Copy Markdown
Contributor Author

Addressed the optional no-history assertion note in review 5641699842 in a8f84fd. The existing unavailable-history test now scopes to the Tokens card within usage-history-totals and asserts its displayed value matches /^—$/ exactly, replacing the negative 0.0k check. This rejects 0, 0 tokens, and 0.0k; an em dash in the Recorded days or estimate card cannot mask a false token total. No additional test or product behavior change was added.

Local validation on Node 24.22.0 with ORCA_BACKGROUND_LAUNCH=1: all 6 tests in StatsPane.usage.test.tsx passed, pnpm tc:web passed, the changed-line quality gate against 79dd6a8 passed, and normal commit hooks passed. No app/GUI, provider, or remote integration run was performed; these results do not assert CI or review approval.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8fbe62d5-9cd9-4bda-a420-76358ee32ee5
Commits

Reviewing files that changed from the base of the PR and between a8f84fd and 0aa90af.

Files ignored due to path filters: 2
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
Files selected for processing: 30
  • package.json
  • src/main/codex-usage/codex-rollout-file-parse.ts
  • src/main/codex-usage/codex-usage-provider.ts
  • src/main/codex-usage/store-persistence.test.ts
  • src/main/codex-usage/types.ts
  • src/main/opencode-usage/opencode-usage-provider.ts
  • src/main/opencode-usage/scanner.ts
  • src/main/opencode-usage/types.ts
  • src/main/orcad/orcad-entry.ts
  • src/main/orcad/orcad-secret-store-startup.ts
  • src/main/runtime/construction/runtime-agent-provider-session-rows.ts
  • src/main/runtime/construction/runtime-host-services.ts
  • src/main/runtime/rpc/methods/index.ts
  • src/main/startup/main-process-runtime-service.ts
  • src/main/usage/usage-event-aggregation.ts
  • src/main/usage/usage-rollup-records.ts
  • src/main/usage/usage-scan-worker-entry.ts
  • src/main/usage/usage-scan-worker-event-loop.test.ts
  • src/main/usage/usage-scan-worker-protocol.ts
  • src/main/usage/usage-scan-worker-spawn.ts
  • src/main/usage/usage-source-cache-file.ts
  • src/renderer/src/assets/main.css
  • src/renderer/src/components/stats/CodexUsageDailyChart.tsx
  • src/renderer/src/components/stats/StatsPane.tsx
  • src/renderer/src/components/stats/usage-overview-sections.tsx
  • src/renderer/src/components/status-bar/use-owner-usage-rate-limits.ts
  • src/renderer/src/i18n/en-runtime-required.json
  • src/renderer/src/i18n/locales/en.json
  • src/shared/orcad-artifacts.ts
  • src/shared/protocol-version.ts
Files skipped from review as they are similar to previous changes: 3
  • src/renderer/src/assets/main.css
  • src/renderer/src/components/stats/usage-overview-sections.tsx
  • src/renderer/src/i18n/locales/en.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@gentslava
gentslava requested a review from Jinwoo-H as a code owner October 26, 2026 00:53
gentslava added a commit to gentslava/orca that referenced this pull request Oct 26, 2026
gentslava added a commit to gentslava/orca that referenced this pull request Oct 26, 2026
gentslava added a commit to gentslava/orca that referenced this pull request Oct 26, 2026
gentslava added a commit to gentslava/orca that referenced this pull request Oct 26, 2026
gentslava added a commit to gentslava/orca that referenced this pull request Oct 27, 2026
gentslava added a commit to gentslava/orca that referenced this pull request Oct 27, 2026
gentslava added a commit to gentslava/orca that referenced this pull request Oct 27, 2026
gentslava added a commit to gentslava/orca that referenced this pull request Oct 27, 2026
gentslava added a commit to gentslava/orca that referenced this pull request Oct 28, 2026
gentslava added a commit to gentslava/orca that referenced this pull request Oct 28, 2026
@gentslava
gentslava force-pushed the feat/usage-history-and-quotas branch from fc5dd9e to 38e07c0 Compare October 28, 2026 09:27
@gentslava gentslava changed the title Add account quotas and host-owned usage history with provider charts Show host-owned usage history with provider charts Oct 28, 2026
gentslava added a commit to gentslava/orca that referenced this pull request Oct 30, 2026
gentslava pushed a commit to gentslava/orca that referenced this pull request Oct 31, 2026
gentslava added a commit to gentslava/orca that referenced this pull request Oct 31, 2026
gentslava pushed a commit to gentslava/orca that referenced this pull request Oct 31, 2026
gentslava pushed a commit to gentslava/orca that referenced this pull request Oct 31, 2026

This branch has not been deployed

No deployments
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.

[Feature]: Break down usage history by account, model, project and day

1 participant