fix(usage): do not scan ~/projects when Claude transcripts are missing #7177
main fromrefs/pull/7177/head·opened View on GitHubSummary#
Fixes #7088.
When Claude has never been used, a missing ~/.claude/projects no longer falls back to walking the entire ~/projects tree. The default missing dir is reported as a missing source. Custom claudeAgent.homePath / CLAUDE_CONFIG_DIR still uses <home>/projects when the nested path is absent.
Test plan#
- Usage page with no
~/.claude/projectsreturns quickly and does not walk~/projects - Custom Claude home still finds
<home>/projectstranscripts - Codex usage unchanged
Note
Low Risk Localized usage transcript path resolution with pure helpers and tests; no auth, data migration, or API contract changes beyond correct scan roots.
Overview
Fixes incorrect Claude usage scanning when the default transcript folder is absent. Previously, a missing ~/.claude/projects caused the scanner to fall back to ~/projects, which could walk a huge tree and skew or slow usage reads.
Now path choice lives in usageClaudeTranscriptDir.ts: default installs always target ~/.claude/projects (missing dir → missing source, no ~/projects fallback). A non-empty configured claudeAgent.homePath still uses <home>/projects only when nested .claude/projects does not exist; whitespace-only config counts as default.
UsageService passes whether the home is an explicit override into that resolver after probing the nested directory on disk. Unit tests cover default, custom home, and override detection.
Note
Fix Claude transcript resolution to avoid scanning ~/projects when no explicit home override is set#
Previously, the Claude transcript directory resolver would fall back to <home>/projects when <home>/.claude/projects did not exist, even for default (non-overridden) home paths. This caused unintended directory scanning.
- Adds
isClaudeHomeExplicitOverrideto classify a configuredhomePathas explicit only when non-empty after trimming. - Adds
resolveClaudeTranscriptDirPathas a pure utility that skips the<home>/projectsfallback unless the home path is an explicit override. - Updates
UsageServiceto pass the override flag when resolving transcript directories. - Behavioral Change: default Claude home paths no longer fall back to
~/projects; only explicit home overrides may use the<override>/projectsfallback.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Approvability#
Verdict: Approved 9695da9
This is a straightforward bug fix that prevents unintended directory scanning by ensuring the code doesn't fall back to ~/projects when Claude transcripts are missing. The change is conservative, well-tested with unit tests, and self-contained.
You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Note
This comment is posted by Julius' dot
Closing for missing verification results. The new tests cover default and custom Claude transcript paths, but the PR provides only an unchecked test plan and no executed checks or observed results. Run the focused path tests and report their command and result, including the missing default directory and custom home cases, then request reconsideration.
juliusmarminge closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
028e6cc4-dfcb-43c1-95a0-4b304951d422You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.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.
❤️ Share