Skip to content

fix(codex-integration): context row now persists#76

Merged
StuBehan merged 1 commit into
mainfrom
fix/codex-context-row-persistence
Jun 8, 2026
Merged

fix(codex-integration): context row now persists#76
StuBehan merged 1 commit into
mainfrom
fix/codex-context-row-persistence

Conversation

@StuBehan

@StuBehan StuBehan commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

The Codex context-usage row in the Sessions tab (and the compact pill) disappeared after navigating away and back, or once enough new events accumulated. This makes it persist: Codex now resolves its context stats through a stable per-PID transcript handle that the poll re-reads, instead of the prunable event list — matching how Claude already behaves.

Changes

Root cause: Codex has no per-pid session sidecar like Claude (~/.claude/sessions/<pid>.json), so session.claudeSessionID is nil and the views fell back to scanning EventStore for a matching event to find the stats key. EventStore prunes to maxEventsTotal=100 / maxEventsPerSession=5, so once enough newer events arrive the Codex Stop event ages out and the lookup returns nil → the row vanishes. The compact pill had no event fallback at all, so Codex never showed context there.

Fix:

  • Add TranscriptRef { sessionID, path } and PanelNav.transcriptRefByPID: [Int: TranscriptRef] — a stable per-agent-PID handle to a transcript, held on nav (survives panel navigation and event pruning).
  • Populate the cache from each Codex hook event (refreshTranscriptStats), keyed by agent PID.
  • Add a Codex branch to the poll refresh (refreshAllClaudeStats): for active non-Claude sessions with a cached ref, re-read the transcript path so stats stay live and repopulate — mirroring Claude's sidecar-driven refresh.
  • Resolve Codex stats via the PID cache in both Sessions.swift and CompactView.swift (the pill previously had no fallback).

Resulting behavior: the PID→path binding persists; stats are re-read from the live rollout file on each poll while the session is active; a transient read failure keeps the last value rather than blanking. Claude is unaffected (it still hits its claudeSessionID path first).

Testing

  • swift build — clean.
  • ./build.sh — full app builds.
  • Not exercisable in CI (panel/AX + live transcript). Manually verified on macOS: with a live Codex session, the context row now persists across tab navigation and panel close/reopen (previously it disappeared once the source event was pruned).

Related issues

None.

@StuBehan StuBehan merged commit 04e48cf into main Jun 8, 2026
5 checks passed
@StuBehan StuBehan deleted the fix/codex-context-row-persistence branch June 8, 2026 19:23
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