Skip to content

fix(server): count every provider instance on the Usage page - #7419

Open
MatthewFoxAF wants to merge 1 commit into
pingdotgg:mainfrom
MatthewFoxAF:fix/usage-scan-all-provider-instances
Open

fix(server): count every provider instance on the Usage page#7419
MatthewFoxAF wants to merge 1 commit into
pingdotgg:mainfrom
MatthewFoxAF:fix/usage-scan-all-provider-instances

Conversation

@MatthewFoxAF

@MatthewFoxAF MatthewFoxAF commented Aug 18, 2026

Copy link
Copy Markdown

What Changed

The usage scan now resolves one transcript directory per configured Claude and Codex provider instance instead of only the legacy default providers.<kind> homes. It walks the same merged instance map the provider registry hydrates from (deriveProviderInstanceConfigMap), so explicit providerInstances entries and the legacy mirrors are both covered, and dedupes by resolved directory so instances that share a home are not counted twice.

The resolution moved out of UsageService into usageTranscriptDirs.ts so it has focused tests (usageTranscriptDirs.test.ts): legacy-only, extra instances, nested .claude/projects probe, shared-home dedupe, and skipping non-transcript drivers / undecodable configs. One sentence added to docs/user/usage.md.

Why

A second Claude instance pointed at its own CLAUDE_CONFIG_DIR (or a second Codex home) writes transcripts there, not under ~/.claude/projects, so the Usage page silently under-reported that instance's spend as zero. Reported on a machine with a claude-second install: the page showed only the default account.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes (n/a — no UI change)
  • I included a video for animation/interaction changes (n/a)

Before

image

After

image

Note

Medium Risk
Changes which directories are scanned for billing-style usage totals; wrong paths could still under- or over-report, but behavior is aligned with the provider registry and covered by new unit tests.

Overview
Fixes under-reported Usage when multiple Claude or Codex installs use separate home directories. The scan no longer walks only the legacy default providers.<kind> homes.

Transcript directory resolution moves to usageTranscriptDirs.ts, which uses the same merged instance map as the provider registry (deriveProviderInstanceConfigMap). Each Claude/Codex instance gets its own transcript path (with the existing nested .claude/projects probe), deduped when two instances share a home, and skipped for non-transcript drivers or invalid configs. UsageService delegates to that helper and supplies FileSystem alongside Path for the existence probe. usageTranscriptDirs.test.ts covers legacy-only, extra instances, nesting, dedupe, and skip behavior; user docs note that every configured instance counts.

Reviewed by Cursor Bugbot for commit 893cdf9. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix Usage page to count every configured provider instance

  • Introduces usageTranscriptDirs.ts with resolveUsageTranscriptDirs, which derives transcript directories from all configured Claude and Codex provider instances (including legacy defaults), deduplicating by provider+directory.
  • Replaces the old inline resolveTranscriptDirs logic in UsageService.ts, which only scanned legacy/default homes, with a call to the new helper.
  • Claude resolution now probes for a nested .claude/projects directory under the configured home path before falling back to home/projects.
  • Behavioral Change: The Usage page now aggregates token usage across all configured instances rather than only the default home, so reported totals may increase for users with multiple provider instances configured.

Macroscope summarized 893cdf9.

The usage scan only read the default Claude and Codex homes from the legacy
`providers.<kind>` settings, so transcripts written by additional provider
instances (a second Claude install with its own CLAUDE_CONFIG_DIR, a second
Codex home) never showed up.

Resolve transcript directories from the same merged instance map the provider
registry hydrates from, one entry per distinct home, deduped so instances that
share a home are not counted twice.

Made with Claude Fable 5 in Claude Code.
@github-actions github-actions Bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Aug 18, 2026
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 064139ac-fb81-4c7a-ac07-81f6ff203671

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@github-actions github-actions Bot added the size:L 100-499 changed lines (additions + deletions). label Aug 18, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This PR changes runtime behavior by expanding usage tracking to scan ALL configured provider instances rather than just the default ones. This affects the user-visible Usage page metrics and warrants review to confirm the intended scope of the change.

You can add or adjust custom eligibility rules. Learn more.

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

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant