[Bug]: Usage page never scans Codex archived_sessions/, so archived sessions' usage silently disappears
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 23k
- Forks
- 5.9k
- Avg merge
- 11h 14m
- Merged PRs (30d)
- 357
Description
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
- Use Codex interactively, then archive some sessions (rollouts move from
~/.codex/sessions/to~/.codex/archived_sessions/). - Open the Usage page for a window covering that work.
- Compare the reported Codex tokens/cost against the transcripts actually on disk.
Observed behavior
UsageService.resolveTranscriptDirs resolves only <codexHome>/sessions for the Codex provider, so rollouts in archived_sessions/ are never scanned — even though the Codex shadow-home layout elsewhere in the codebase treats archived_sessions as a known shared directory alongside sessions.
On my machine the effect is dramatic:
~/.codex/archived_sessions/holds 2.7 GB, with 148 files modified inside the 30-day window, containing ~6,700gpt-5.6-solturn-context records — this is where nearly all of my real interactive Codex work lives.- The scanned
~/.codex/sessions/retains only ~300gpt-5.6-solrecords; the rest of it is dominated bycodex-auto-reviewtraffic (~31,000 model records). - The Usage page therefore reports 177M priced Codex tokens ($131.09) for the window; the true interactive figure is several times that.
Compounding it, codex-auto-review has no LiteLLM rate, so the 885M tokens that are scanned price at $0.00 (the display side of that is tracked in #5799). Net result: Codex usage is doubly understated — most real usage is invisible, and most visible usage is unpriced.
Expected behavior
Usage should cover archived sessions: scan archived_sessions/ alongside sessions/. Transcripts are append-only and the existing mtime filter + (size, mtime) scan cache already bound the cost of the extra walk. At minimum, the page should disclose that archived sessions are excluded from the totals.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at UsageService.resolveTranscriptDirs in apps/server and inspect the Codex shadow-home layout elsewhere in the codebase, especially how sessions and archived_sessions are treated. Reproduce the Usage page comparison for a window containing archived work. Done means archived_sessions is scanned alongside sessions and archived transcripts contribute to the reported totals without bypassing the existing mtime and scan-cache behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100