Skip to content

Fix token_count discovery for updated Codex sessions - #4

Open
k-shimura7617 wants to merge 1 commit into
xiangz19:mainfrom
k-shimura7617:codex/fix-session-mtime-discovery
Open

Fix token_count discovery for updated Codex sessions#4
k-shimura7617 wants to merge 1 commit into
xiangz19:mainfrom
k-shimura7617:codex/fix-session-mtime-discovery

Conversation

@k-shimura7617

Copy link
Copy Markdown

Summary

Fix token_count discovery when Codex continues writing to a session file under an older date directory.

Root Cause

The extension's fallback search only checked date directories from the previous seven calendar days. Codex can keep appending new events to an older session file, so a file can have a current mtime while its path date remains older than seven days.

When that happens, the extension skips the active session file and shows:

No token_count events found in session files

Changes

  • Build session search roots from the configured session path.
  • Recursively search rollout-*.jsonl under those roots.
  • Sort discovered files by mtime so recently updated sessions are checked first.
  • Include ~/.codex/archived_sessions for the default Codex session path.
  • Keep the existing fast path for today's recently modified session files.

Validation

  • Reproduced locally with a fixture where token_count exists under an older date directory while the file mtime is current.
  • Confirmed the old implementation returns No token_count events found in session files.
  • Confirmed the patched implementation discovers the same fixture file.
  • Ran npm run compile.

@k-shimura7617
k-shimura7617 marked this pull request as ready for review May 29, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant