Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(usage): resolve transcript dirs from providerInstances #6312

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

What changed

UsageService.resolveTranscriptDirs only read the legacy settings.providers.codex / settings.providers.claudeAgent structs to find the Codex/Claude transcript directories to scan. The Settings UI, however, persists provider config to the newer settings.providerInstances map (packages/contracts/src/settings.ts). As a result, a Codex (or Claude) home configured via Settings was never scanned and usage reported zero.

This decodes enabled Codex/Claude entries from settings.providerInstances with the existing CodexSettings/ClaudeSettings schemas, resolves their transcript dirs with the same existing resolvers (resolveCodexHomeLayout / the Claude home probe), and merges the result with the legacy-derived dirs, deduplicating by (provider, dir) so a home configured both ways isn't scanned twice.

Fixes #6310.

Why

Users who configure a custom Codex/Claude home via the newer Settings provider-instances UI got silent zero usage, since the scanner never looked there.

No UI change — this is a server-side scan-directory fix.

Tests

Added apps/server/src/usage/UsageService.test.ts covering a custom Codex-instance home being included in the scan, and dedup when the same home is configured both legacily and via a provider instance. pnpm vitest run src/usage (39/39 passing) and tsgo --noEmit (clean) verified locally.

🤖 Generated with Claude Code

Note

Resolve transcript dirs from provider instances in UsageService

  • Introduces resolveTranscriptDirsForSettings in UsageService.ts that collects transcript directories from both base provider configs and enabled providerInstances for codex and claudeAgent.
  • Deduplicates results by provider+path using a Map, replacing the previous fixed pair of provider dirs.
  • resolveTranscriptDirs now delegates to the new helper, explicitly providing the FileSystem service.
  • Behavioral Change: transcript dir resolution now returns a variable-length deduplicated list instead of always returning exactly one dir per provider.
Macroscope summarized b908a84.
    1. 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: 31909698-3eb2-408b-8902-438c825f32cb

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

    3. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: b908a8456b

      ℹ️ 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".

      @@ -85,3 +88,18 @@
      8588 const ScanCacheJson = Schema.fromJsonString(Schema.Unknown as unknown as Schema.Codec<unknown>);
      8689 const decodeScanCacheFile = Schema.decodeUnknownEffect(ScanCacheJson);
      8790 const encodeScanCacheFile = Schema.encodeEffect(ScanCacheJson);
      91+const decodeCodexSettings = Schema.decodeUnknownOption(CodexSettings);
      92+const decodeClaudeSettings = Schema.decodeUnknownOption(ClaudeSettings);
      93+
      94+export const resolveTranscriptDirsForSettings = Effect.fn(
      95+ "UsageService.resolveTranscriptDirsForSettings",
      96+)(function* (settings: ServerSettingsConfig) {
      97+ const fileSystem = yield* FileSystem.FileSystem;
      98+ const path = yield* Path.Path;
      99+ const codexConfigs = [settings.providers.codex];
      100+ const claudeConfigs = [settings.providers.claudeAgent];
      101+
      102+ for (const instance of Object.values(settings.providerInstances)) {
      103+ if (instance.enabled === false) continue;
      104+ if (instance.driver === "codex") {
      105+ const config = decodeCodexSettings(instance.config ?? {});

      P2 Badge Resolve transcript homes from instance environments

      When an enabled instance sets CODEX_HOME or CLAUDE_CONFIG_DIR through providerInstances[id].environment while leaving config.homePath empty, this config-only decoding resolves the default home instead. The provider runtimes merge the envelope environment in CodexDriver.ts and ClaudeDriver.ts, so their transcripts are written elsewhere; usage then silently omits that instance and may report usage from the default account. Resolve each transcript directory using the same effective environment precedence as its provider runtime.

      AGENTS.md reference: AGENTS.md:L71-L71

      Useful? React with 👍 / 👎.

    4. Approvability

      Verdict: Needs human review

      This PR changes runtime behavior by scanning additional transcript directories from providerInstances, which were previously not included. While well-tested, this expands the scope of what the usage service scans and warrants verification that this behavioral change is intended.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. 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. It also covers default-slot precedence, provider home environment variables, shadow homes, and canonical path deduplication. The legacy-plus-instance deduplication case in this PR remains useful as a reference 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.