fix(ccusage): extract session ID from filename instead of directory name#767
fix(ccusage): extract session ID from filename instead of directory name#767majiayu000 wants to merge 1 commit intoryoppippi:mainfrom
Conversation
The session ID was incorrectly extracted from the parent directory name
instead of the JSONL filename. This caused issues when project directories
had names starting with hyphens (e.g., -home-claude-user), where the
directory name was used as the session ID instead of the actual UUID.
Fixed by using path.basename(file, '.jsonl') to extract the session ID
from the filename, which matches the actual Claude Code file structure:
projects/{project}/{sessionId}.jsonl
Fixes ryoppippi#560
📝 WalkthroughWalkthroughThe data loader now extracts session IDs from JSONL filenames (removing the .jsonl extension) rather than inferring them from directory structures. A new helper function Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (7)apps/ccusage/src/**/*.ts📄 CodeRabbit inference engine (apps/ccusage/CLAUDE.md)
Files:
apps/ccusage/**/*.ts📄 CodeRabbit inference engine (apps/ccusage/CLAUDE.md)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.ts{,x}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/data-loader.ts📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ts,tsx,json}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (11)📓 Common learnings📚 Learning: 2025-09-18T16:06:37.474ZApplied to files:
📚 Learning: 2025-09-18T16:06:37.474ZApplied to files:
📚 Learning: 2025-11-25T14:42:34.734ZApplied to files:
📚 Learning: 2025-09-18T16:06:37.474ZApplied to files:
📚 Learning: 2025-09-18T16:06:37.474ZApplied to files:
📚 Learning: 2025-11-25T14:42:34.734ZApplied to files:
📚 Learning: 2025-09-18T16:06:37.474ZApplied to files:
📚 Learning: 2025-11-25T14:42:34.734ZApplied to files:
📚 Learning: 2025-09-17T18:29:15.764ZApplied to files:
📚 Learning: 2025-09-18T16:07:16.293ZApplied to files:
🔇 Additional comments (4)
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 |
Fixes session ID extraction when project directories start with hyphens (e.g., -home-claude-user). The session ID is now correctly extracted from the JSONL filename instead of the parent directory.
Fixes #560
Summary by CodeRabbit
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.