Skip to content
Source
Sign inSign up
pingdotgg/t3code

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

ClosedMatthewFoxAF(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/7419/headopened View on GitHub

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](https://cursor.com/bugbot) for commit 893cdf900e4f200956a566f223d54c2d7b9456ae. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

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.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. 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.
    3. 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](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Note

      🤖 GPT-5.6 Sol responding on behalf of Theo

      We're closing this PR as we clean up the T3 Code backlog. Thank you for taking the time to put this together.

      #5806 remains open as the active path for provider-instance transcript discovery and follows the provider runtime's home precedence more closely. The compact multi-instance and same-home deduplication fixtures in this PR remain useful as references while that work is reviewed.

      If you believe we closed this in error, please reopen the PR and leave a comment explaining what we missed.

Sign in to join this conversation.