fix(usage): only show enabled providers - #6094
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
| { provider: "claude" as const, dir: claudeDir }, | ||
| { provider: "codex" as const, dir: path.join(codexLayout.sharedHomePath, "sessions") }, | ||
| ]; | ||
| if (enabledProviders.has("claude")) { |
There was a problem hiding this comment.
🟠 High usage/UsageService.ts:221
resolveTranscriptDirs enables a provider when any custom instance is enabled (via selectEnabledUsageProviders), but then resolves the transcript directory from the legacy settings.providers.claudeAgent / settings.providers.codex config — not from the enabled instance's own config. When an enabled custom instance has a different homePath and the legacy provider is disabled or points elsewhere, the scan reads the wrong home directory: it omits the enabled instance's transcripts and may include transcripts from a differently configured or disabled home. The directory resolution needs to iterate over each enabled instance's config rather than collapsing enabled instances to a single provider-level boolean.
Also found in 1 other location(s)
apps/server/src/usage/usageProviderSelection.ts:23
isDriverEnabledtreats any enabled custom instance as enabling the provider, butUsageService.resolveTranscriptDirsstill resolves exactly one directory fromsettings.providers.<driver>rather than that enabled instance'sconfig. For example, an enabledcodex_workinstance withconfig.homePath = "~/.codex-work"and a disabled legacy/default Codex config causes the scan to read the disabled default's sessions and omit the enabled instance's sessions. The selection needs to preserve enabled instance configs/directories (and potentially scan each distinct home), rather than collapsing them to a provider boolean.
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/server/src/usage/UsageService.ts around line 221:
`resolveTranscriptDirs` enables a provider when any custom instance is enabled (via `selectEnabledUsageProviders`), but then resolves the transcript directory from the legacy `settings.providers.claudeAgent` / `settings.providers.codex` config — not from the enabled instance's own `config`. When an enabled custom instance has a different `homePath` and the legacy provider is disabled or points elsewhere, the scan reads the wrong home directory: it omits the enabled instance's transcripts and may include transcripts from a differently configured or disabled home. The directory resolution needs to iterate over each enabled instance's config rather than collapsing enabled instances to a single provider-level boolean.
Also found in 1 other location(s):
- apps/server/src/usage/usageProviderSelection.ts:23 -- `isDriverEnabled` treats any enabled custom instance as enabling the provider, but `UsageService.resolveTranscriptDirs` still resolves exactly one directory from `settings.providers.<driver>` rather than that enabled instance's `config`. For example, an enabled `codex_work` instance with `config.homePath = "~/.codex-work"` and a disabled legacy/default Codex config causes the scan to read the disabled default's sessions and omit the enabled instance's sessions. The selection needs to preserve enabled instance configs/directories (and potentially scan each distinct home), rather than collapsing them to a provider boolean.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3233f39bf1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (const source of environment.summary.sources) { | ||
| providersInScope.add(source.fingerprint.provider); |
There was a problem hiding this comment.
Version the new provider-scope semantics
When a current web or desktop client connects to an environment running a server from before this commit, that server still returns both Claude and Codex sources with contractVersion: 3; this new inference therefore treats both providers as enabled, and the existing version check accepts and merges their historical usage instead of marking the environment stale. Bump USAGE_CONTRACT_VERSION or add an explicitly versioned scope field before interpreting sources this way, otherwise the fix silently fails for mixed-version remote environments.
AGENTS.md reference: AGENTS.md:L72-L74
Useful? React with 👍 / 👎.
ApprovabilityVerdict: Needs human review 1 blocking correctness issue found. This PR changes which usage providers get scanned and displayed based on enabled state, introducing new selection logic. A high-severity finding identifies that custom instance configurations may cause scanning wrong directories. The behavioral changes and unresolved bug warrant human review. You can customize Macroscope's approvability policy. Learn more. |
The Usage page scanned and rendered both Claude Code and Codex even when one was disabled, so disabled providers could contribute historical transcripts and appear in charts and tables.
Usage scans now follow effective provider enablement, including legacy settings and explicit provider instances. The merged view carries the provider scope across environments, and web charts, legends, tooltips, and daily columns render only providers in that scope. External CLI sessions remain included for enabled providers.
Fixes #5997
Testing
vp run -r testvp run --filter t3 --filter @t3tools/web --filter @t3tools/shared typecheckMade with GPT-5.6-sol in T3 Code through the Codex harness.
Note
Low Risk
Scoped usage scanning and display logic with unit tests; no auth, billing, or data-deletion behavior.
Overview
Usage no longer always scans Claude and Codex transcripts or shows both in the UI when a provider is disabled.
Server: New
selectEnabledUsageProviderspicks which providers to scan from legacyproviders.*.enabled, per-instanceenabled, andconfig.enabled, with explicit default instances overriding legacy flags.UsageServiceonly resolves transcript directories for providers in that set.Merge + UI:
mergeUsageaddsprovidersInScope(union of scan sources across environments, including providers with zero usage). The Usage page filters chart legend, series, tooltips, and daily breakdown columns to that scope instead of a fixed provider list.Docs: User docs note that disabled providers are omitted from scans without deleting session files.
Reviewed by Cursor Bugbot for commit 3233f39. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Filter usage page charts, legends, and tables to only show enabled providers
UsageService.makenow resolves transcript directories only for providers enabled inServerSettings, skipping Claude or Codex paths when the respective provider is disabled.mergeUsagecomputes aprovidersInScopefield by unioning provider kinds across current environments, andUsagePageuses this to derivevisibleProviders.UsagePageiterate overvisibleProvidersinstead of the globalPROVIDER_ORDER, so disabled providers are fully hidden.selectEnabledUsageProviders(new util) determines enablement by checking provider instances; an explicit default instance overrides legacysettings.providers[driver].enabledfallback.📊 Macroscope summarized 3233f39. 6 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
🗂️ Filtered Issues
No issues evaluated.