fix(codex-integration): context row now persists#76
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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), sosession.claudeSessionIDis nil and the views fell back to scanningEventStorefor a matching event to find the stats key.EventStoreprunes tomaxEventsTotal=100/maxEventsPerSession=5, so once enough newer events arrive the CodexStopevent 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:
TranscriptRef { sessionID, path }andPanelNav.transcriptRefByPID: [Int: TranscriptRef]— a stable per-agent-PID handle to a transcript, held onnav(survives panel navigation and event pruning).refreshTranscriptStats), keyed by agent PID.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.Sessions.swiftandCompactView.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
claudeSessionIDpath first).Testing
swift build— clean../build.sh— full app builds.Related issues
None.