Repository navigation
fix(parser): use Claude cwd for Windows project paths - #245
Merged
Merged
Conversation
Without this consolidation step, a Claude project containing both cwd-bearing and no-cwd session files ended up with two ProjectSummary entries sharing the same dirName: one keyed on the canonical cwd, one keyed on the slug. They later merged in parseAllSessions by p.project, and the projectPath of whichever entry was created first won. So a project with one alphabetically-early no-cwd session would silently keep the lossy slug-derived projectPath even though a clean canonical cwd was available on later sessions. Fold slug-keyed entries into the cwd-keyed entry sharing the same dirName during scanProjectDirs so canonical cwd always wins. Tests added: - mixed cwd / no-cwd in same slug -> canonical projectPath preserved - null / empty / whitespace / missing cwd -> slug-derived fallback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #228 (cross-fork PR by @ozymandiashh — original commit preserved as the first commit here, follow-up commit applies review fixes).
Summary
Closes #217. Claude Code stores project sessions under sanitized directory slugs that are lossy on Windows:
C:\AI_LAB\OPENCLAWbecomes a slug likec--AI-LAB-OPENCLAW, and the slug → path round-trip turns it intoc//AI/LAB/OPENCLAW(every-becomes/, eats underscores). Combined with drive-letter case differences and forward/backward slash variants in real cwds, one project ends up split into 3+ rows in CodeBurn output.This PR reads the canonical
cwdalready stored inside each Claude JSONL session, uses it asprojectPath, and groups sessions by a normalized path key (backslash → /, strip trailing /, lowercase).What changed (from #228)
cwdfrom each Claude JSONL session.projectPathfor Claude project rollups instead of the slug-derived reconstruction.C:\AI_LAB\OPENCLAW,c:\AI_LAB\OPENCLAW, andc:/AI_LAB/OPENCLAW/collapse into one project rollup.cwd.Review fix on top of #228
Adversarial probe found that when a slug contains both cwd-bearing and no-cwd sessions, scanProjectDirs created two ProjectSummary entries sharing the same dirName (one keyed on cwd, one keyed on slug). They later merged in
parseAllSessionsbyp.project, and whichever entry was created first setprojectPath. So a project with an alphabetically-early no-cwd session silently kept the lossy slug-derived projectPath even though a clean canonical cwd was available on later sessions in the same directory.Added a consolidation step at the end of
scanProjectDirsthat folds slug-keyed entries into the cwd-keyed entry sharing the same dirName, so canonical cwd always wins regardless of file iteration order.Tests
Two test cases added on top of the original two:
C:\AI_LAB\OPENCLAW. Asserts projectPath is the canonical Windows path, notc//AI/LAB/OPENCLAW.Validation
npx tsc --noEmitnpx vitest run— 36 files, 485 tests pass (was 483 in fix(parser): use Claude cwd for Windows project paths #228; +2 new)Related (not in scope)
Issue #217 also mentions Antigravity sessions surfacing as opaque ID-paths. That's a separate path-resolution concern in a different provider; this PR is scoped to Claude Code only and leaves Antigravity discovery untouched. Worth a follow-up issue.
What it does NOT touch
Token parsing, pricing, classification, date filtering, non-Claude providers, dashboard rendering. Only the project-rollup grouping logic in
scanProjectDirs.