Codex Desktop startup rescans archived_sessions instead of incrementally updating session_index.jsonl

Resolved 💬 1 comment Opened May 14, 2026 by nanlis Closed May 14, 2026

Problem

Codex appears to rebuild session_index.jsonl by scanning files under archived_sessions during startup. On machines with large archived histories, this makes startup much slower than necessary.

Observed case:

  • archived_sessions contained about 2.2GB of JSON session data.
  • Codex startup rescanned archived files to rebuild the session index.
  • Archived sessions were rescanned even when they had already been indexed and had not changed.
  • Environment: Windows 11, Microsoft Store Codex App 26.506.3741.0, codex-cli 0.130.0.

Related issues

  • #20864 reports Desktop lag from scanning the hot sessions tree.
  • #18693 reports broad Desktop performance collapse with very large local histories.
  • This issue is the archived-history variant: even files already moved to archived_sessions can remain on the startup indexing hot path.

Expected behavior

Codex should treat the session index as a persistent cache and update it incrementally:

  • Load the existing index immediately on startup.
  • Only scan metadata for archived session files.
  • Only parse JSON for new or modified files.
  • Update the index when a session is archived, instead of waiting for the next startup.
  • Provide an explicit rebuild command for repair/migration cases.

Suggested design

Add a v2 index with a manifest/state file:

session_index_v2/
  meta.json
  records.jsonl
  state.json
  journal.jsonl

Use per-file fingerprints in state.json:

{
  "source_path": "archived_sessions/2026/05/session.jsonl",
  "size": 123456,
  "mtime_ms": 1778760000000,
  "head_hash": "sha256:...",
  "tail_hash": "sha256:..."
}

Startup flow:

  1. Load records.jsonl.
  2. Display known sessions immediately.
  3. Start a background reconcile job.
  4. Reconcile compares file metadata against state.json.
  5. Parse only changed or new files.
  6. Write updates through an append-only journal and compact later.

Acceptance criteria

  • If no archived files changed, startup does not parse archived JSON files.
  • Adding one archived file causes only that file to be parsed.
  • Modifying one archived file causes only that file to be reparsed.
  • Deleting an archived file writes a tombstone or removes the index entry.
  • Corrupt index/journal rows do not block startup.
  • A manual rebuild-session-index command exists for repair.

Workaround

Move cold archived sessions out of archived_sessions so Codex does not see them during startup. This avoids the startup slowdown but does not fix the underlying indexing design.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗