Repository navigation
fix(session-history): keep a legacy Codex conversation's branch current after Codex updates it - #26563
fix(session-history): keep a legacy Codex conversation's branch current after Codex updates it#26563brennanb2025 wants to merge 2 commits into
Conversation
…er its metadata updates Since #26336 the Codex history scanner reads only a rollout's first session record, so a fork's copy of its parent's record cannot take over the fork's row. Codex also re-appends a thread's own first session record, same id, when it updates the thread's git metadata on an older (non-paginated) history, and the scanner ignored those too: the row kept the branch the thread started on. A later record with the thread's own id now moves the branch; identity, history mode, non-user classification, title and folder stay with the first record, and records with another id stay ignored. The session_meta handling moves into its own module so the parser stays under its line limit.
… clears it Clearing a thread's branch re-appends its session record with an empty git object, which the branch refresh treated like a missing one and so kept the old branch. A record with a git object now sets the branch as written; only a record with no git (a memory_mode update) keeps it. The fork test also puts the parent's record after the fork's own update, so a refresh that took any later id would fail it.
Review summary (head 63cd74d)Problem. #26336 made the Codex history scanner read only a conversation's first info record ( What changes for you. A Codex conversation in the older format shows its current branch in Session History search, and as its place label when nothing else can place it. If Codex clears the branch, the row clears it too. Forks still show only their own info. Nothing else changes: no transcript writes, no change to which session owns a conversation, no change to fork or resume, no UI. Fixed.
Readiness checklist: pass, no P0/P1.
Deferred (P2 / nits).
Verified.
Not verified.
Author: @BrennanKB5 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughCodex session parsing now delegates Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The inspected rescan paths support branch updates, and no actionable merge-blocking issue remains after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ELI5
Orca's Agent Session History lists your past Codex conversations and remembers which git branch each one was on. When Codex moves a conversation to a new branch, it writes a small "here is this conversation's info again" record into the conversation's file. A recent change (#26336) made Orca read only the first such record, so it stopped noticing those updates and kept showing the branch the conversation started on. This PR makes Orca accept a later record when it belongs to the same conversation, and only for the branch.
What Changed
The problem. #26336 ("Resume in New CLI") fixed a real bug: when Codex forks an older-format conversation, the fork's file starts with the fork's own info record and then contains a copy of the parent's, which has the parent's conversation id. Orca used to let that copied record overwrite the fork's row, so the fork looked like the parent. #26336 fixed that by reading only the first info record. But Codex also appends a later info record with the same conversation id whenever it updates the conversation's git info (for example, when the Codex terminal app notices a reply created a branch). Orca now ignored those too, so the history row kept a stale branch.
What you see.
The mechanism. All handling of Codex's info records (
session_meta) now lives in one function,consumeCodexSessionMetainsession-scanner-codex-session-meta.ts:gitobject, the branch is set to exactly what it says, so an empty object clears it. If it has nogitat all (Codex's memory-setting update writes it that way), the branch stays.The function moved out of
session-scanner-codex-parser.tsbecause that file was already at its 300-line lint limit.Scope. Display metadata only. No change to how transcripts are written, which session owns a conversation, forks, resume, or UI.
Why
Codex's own metadata reader uses the same rule: it applies later records with the conversation's own id and skips ones with another id. The writer copies the conversation's first record, changes only its git info (and memory setting), refuses to write if the ids differ, and appends it. Matching on id rather than position fixes both directions. Reading only the first record broke updates, and reading every record (the behavior before #26336) broke forks.
Not refreshed on purpose:
The alternative of keeping the first-only check and adding a branch exception beside it was rejected: it would leave two checks that decide which record speaks for the conversation. Here one rule decides it.
Linked Issue
N/A (maintainer follow-up to #26336, found in its post-merge audit)
Visual Proof
N/A. This is a parser-only fix with no UI change: the history row renders
branchexactly as before, and only the value the scanner produces changes. The parser tests below show the before/after values. Two of them fail onmain(the branch staysmain/fork-branch) and pass with this change.Testing
New tests in
session-scanner-codex-parser.test.ts:gitkeeps the branch; one with an emptygitobject clears it.Targeted vitest: the 8 Codex scanner test files (78 tests) pass.
tc:nodeandorca-ci-checks(lint, code quality, localization) pass locally at the pushed commit.Codex writer behavior was read first-hand from Codex's source (the metadata update path, the reader that copies the first record, the git info serialization, and Codex's own reader). It was not observed with a live Codex run.
Not run: the app. The scanner is platform-neutral; local, SSH and paired-host scans all go through this parser.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Reviewed by a fresh reviewer and an architecture challenger, who first sketched a fix from the problem statement alone. Both independently found one more case: a branch Codex clears was kept, which was also true before #26336. It is fixed in the second commit. Deferred nits: no test for a first record without an id (the id then comes from the file name, which Codex sets to the conversation id); no scanner-level append-and-rescan test. Also, a history row saved by a build that includes #26336 keeps its stale branch until the conversation file changes again. #26336 is not in any release yet.
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Author: @BrennanKB5