Skip to content

[Bug]: Usage drops all Claude history in ~/.claude once the default Claude instance is given a custom homePath #36717

Closed

Description

@Franciskid

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Use Claude in T3 Code with the default instance (claudeAgent, no homePath) for a while, so transcripts build up in ~/.claude/projects.
  2. Add Claude accounts: set the default claudeAgent instance's homePath to a new directory (for example ~/.claude-t3/a), and add a second Claude instance with its own homePath (~/.claude-t3/b).
  3. Keep working with both accounts.
  4. Open Usage → Cost for a range that covers both periods (for example the last 90 days).

Expected behavior

The Claude total should include all Claude transcripts on the machine that fall inside the range, including history recorded in ~/.claude before step 2. If T3 Code leaves a directory out on purpose, the Usage page should say so.

Proposed behavior, most important first:

  1. Always scan the default Claude home. Add the driver's default transcript directory (~/.claude, or the host's CLAUDE_CONFIG_DIR) as a history source even when an instance with the id claudeAgent has a custom homePath. The existing provider + realpath(dir) dedupe in resolveTranscriptDirs already prevents double counting when an instance still points at it. Apply the same rule to other drivers with a default home (~/.codex, etc.).
  2. Keep sources that were configured before. The scan cache already remembers past sources (sources in usage-scan-cache-v11.json) and still holds their records. Keep counting a source after its instance is reconfigured or removed, until its records age out of retention. Label it in the per-instance breakdown (for example "Claude: previous home ~/.claude") instead of dropping it.
  3. Never drop history silently. If a directory with transcripts in range is excluded, show a notice on the Usage page (for example "Claude history in ~/.claude (134 sessions) is not included because no Claude account uses it") with an action to include it. A setting for extra history directories, or a per-source include/exclude toggle, would also cover people who deliberately keep personal CLI usage in ~/.claude out of the totals.

Actual behavior

Only directories of instances in the current settings are scanned. usageInstances adds the implicit default instance only when settings.providerInstances has no entry with the driver's id:

if (!Object.hasOwn(settings.providerInstances, driver.driverKind)) {
  entries.push([ProviderInstanceId.make(driver.driverKind), {}, false]);
}

After step 2, the claudeAgent entry exists and points elsewhere, so ~/.claude is never resolved as a transcript directory. All Claude history from before the switch disappears from Usage. The page shows no warning, only the usual "N malformed or inconsistent usage record(s) were skipped".

Measured from my scan cache (usage-scan-cache-v11.json) for the displayed 90-day range:

Claude transcript dir Sessions in range Activity Counted
~/.claude-t3/a (instance claudeAgent) 32 Nov 6 → today yes
~/.claude-t3/b (second instance) 19 Nov 6 → today yes
~/.claude (former default home) 134 Aug 17 → Nov 6 no

The Usage page shows "Claude Code · 51 sessions" (32 + 19). The daily chart shows Claude at $0.00 on days with more than 1,000 usage records in ~/.claude (Aug 19: 1,363 records). The three directories share no dedupe keys, so dedupe does not explain the gap. Total Claude cost and its share of total cost are understated by everything before Nov 6.

The cache still lists claude ~/.claude/projects under sources, and its file records are still there, so the data was scanned at some point but is now filtered out.

Related, but not the same problem:

Impact

Minor bug or occasional failure

Version or commit

Desktop 0.1.7 (stable). Code path confirmed on main @ dafd053.

Environment

macOS 15 (arm64), desktop app 0.1.7, two Claude Code instances with separate homePaths, plus Codex.

Logs or stack traces

# usage-scan-cache-v11.json → "sources" (paths shortened)
claude ~/.claude-t3/b/projects
claude ~/.claude/projects        # still cached, not counted
claude ~/.claude-t3/a/projects
codex  ~/.codex/sessions

Workaround

Add a third Claude instance with homePath set to ~/.claude. usageInstances does not filter on enabled, so the instance can stay disabled and its history is counted again.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions