fix(codex): include archived sessions in usage stats - #210
Conversation
Scan active and archived Codex session directories so archived usage remains visible. Preserve canonical message identities across moves and deduplicate temporary copies. Signed-off-by: jimyag <git@jimyag.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughCodex CLI analysis now watches active and archived session directories, canonicalizes archived files to active-session identities, deduplicates discovered sources, and produces stable message hashes across session archiving. ChangesCodex archived session support
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant CodexCliAnalyzer
participant SessionDirectories
participant JSONLSourceDiscovery
participant MessageParser
CodexCliAnalyzer->>SessionDirectories: inspect active and archived paths
SessionDirectories->>JSONLSourceDiscovery: provide JSONL files
JSONLSourceDiscovery->>JSONLSourceDiscovery: canonicalize and deduplicate session paths
JSONLSourceDiscovery-->>CodexCliAnalyzer: return unique sources
CodexCliAnalyzer->>MessageParser: parse a session file
MessageParser->>MessageParser: hash messages using canonical session path
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/analyzers/tests/codex_cli.rs (1)
11-23: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExercise direct assistant-message hash stability.
The fixture emits only a user message and token usage, so the changed direct-assistant branch in
src/analyzers/codex_cli.rsLines 492-502 is untested. Add an assistantresponse_itembefore the token event and retain the active/archive hash assertions.Also applies to: 69-89
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/analyzers/tests/codex_cli.rs` around lines 11 - 23, Add an assistant `response_item` record to the fixture produced by `write_test_session`, placing it before the existing token-count event and using the format expected by the direct-assistant branch in `codex_cli.rs`. Keep the existing active/archive hash assertions unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/analyzers/codex_cli.rs`:
- Around line 183-186: Update is_valid_data_path to require the path to be
located under at least one directory returned by Self::data_dirs(), in addition
to being a file with a .jsonl extension. Add regression coverage proving paths
inside watched roots are accepted and unrelated .jsonl paths outside those roots
are rejected.
---
Nitpick comments:
In `@src/analyzers/tests/codex_cli.rs`:
- Around line 11-23: Add an assistant `response_item` record to the fixture
produced by `write_test_session`, placing it before the existing token-count
event and using the format expected by the direct-assistant branch in
`codex_cli.rs`. Keep the existing active/archive hash assertions unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 554cc2c1-aab7-4f50-a7b6-8e198a0407a0
📒 Files selected for processing (2)
src/analyzers/codex_cli.rssrc/analyzers/tests/codex_cli.rs
Reject JSONL files outside Codex data roots and cover direct assistant hash stability across archival moves. Signed-off-by: jimyag <git@jimyag.com>
Summary
Motivation
Codex moves completed sessions from
~/.codex/sessionsto~/.codex/archived_sessions. Splitrail only scanned the active directory, so usage disappeared from local statistics after a session was archived.Validation
cargo build --quietcargo test --quiet(397 passed)cargo clippy --quiet -- -D warningscargo doc --quietcargo fmt --all --quietsplitrail statsverification against active and archived Codex dataSummary by CodeRabbit
New Features
Bug Fixes