Skip to content

fix(codex): discover archived sessions - #55

Open
solkennedy wants to merge 2 commits into
skillsynchq:mainfrom
solkennedy:fix/codex-discover-archived-sessions
Open

solkennedy wants to merge 2 commits into
skillsynchq:mainfrom
solkennedy:fix/codex-discover-archived-sessions

Conversation

@solkennedy

Copy link
Copy Markdown
Contributor

Fixes #54.

What changed

CodexStore::discover() only walked sessions_dir (~/.codex/sessions or $CODEX_HOME/sessions). Codex's own /archive (TUI) and codex archive/codex unarchive (CLI) move a rollout out of that dated YYYY/MM/DD tree into a flat sibling directory, archived_sessions, which discover() never looked at. An archived Codex session was invisible to txcript list --from codex / view / MCP list_sessions until it was unarchived back into sessions/.

CodexStore gets an optional archived_sessions_dir, set by default_root() to the sibling archived_sessions directory. discover() walks it alongside sessions_dir and merges the results. new() keeps its existing single-argument shape — it's also used to construct a store for writing a new session (see src/local.rs's codex::CodexStore::new factory reference), which should always land in sessions_dir, never archived_sessions_dir.

Testing

  • Added discover_includes_archived_sessions (active + archived rollouts both surface) and discover_without_archived_dir_only_finds_active_sessions (a hand-built store with no archived dir is unaffected) to tests/integration/codex.rs.
  • cargo test -p txcript --lib (60 passed), cargo test -p txcript --test integration (205 passed), cargo clippy -p txcript --lib --all-features (clean).
  • Verified on a real machine: txcript list --from codex went from 671 to 1202 sessions (+531), matching the file count in ~/.codex/archived_sessions exactly, with no duplicate IDs and correct metadata (titles, cwd, timestamps) on the newly-surfaced rows going back to the very first session.

Note: this is unrelated to #52/#53 (the ChatGPT-cloud harness's own separate is_archived bug) — see the correction comment on #52.

CodexStore::discover() only walked sessions_dir. Codex's own
/archive (TUI) and codex archive / codex unarchive (CLI) move a
rollout out of that dated tree into a flat sibling directory,
archived_sessions, which discover() never looked at. An archived
Codex session was therefore invisible to txcript list --from codex
/ view / MCP list_sessions until it was unarchived.

Give CodexStore an optional archived_sessions_dir, set by
default_root() to the sibling archived_sessions directory, and walk
it alongside sessions_dir in discover(). new() keeps its existing
single-argument shape since it's also used to construct a store for
writing a new session, which should always land in sessions_dir.

Verified on a real machine: `txcript list --from codex` went from
671 to 1202 sessions (+531), matching the file count in
~/.codex/archived_sessions exactly.

Fixes skillsynchq#54.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@NishantJoshi00
NishantJoshi00 self-requested a review September 17, 2026 21:21
@NishantJoshi00

Copy link
Copy Markdown
Collaborator

Thanks for tracking this down! Could you also make delete() work for archived sessions while keeping the existing path checks? Discovery now finds sessions that deletion rejects. Please cover archived deletion, a missing active directory, and rejection of paths outside both directories in tests.

One release detail for us: the new public field breaks callers using CodexStore { sessions_dir: ... } directly. CodexStore::new() still works, but we'll need to account for that API change.

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.

Local Codex discovery never looks at archived_sessions/

2 participants