Repository navigation
refactor(native-chat): share the catch-up open runner across agents - #31622
Conversation
The Codex catch-up's agent-neutral parts move to one module: the open-time envelope (its own deadline and cancellation, never gating the open), the bounded staged batch, the single settlement commit that re-checks the journal before writing, and the "Continued outside this chat." divider. Codex keeps only how it reads its saved turns and what the chat already holds. No behavior change; the other agents' catch-up builds on this instead of copying it.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
… when the agent asks
…ommit to be written A journal write barrier that never settled after the import was admitted held the provider's open past the catch-up deadline. The wait now ends with the deadline or the open's cancellation, like every other step.
|
Codex chats need to pick up turns completed outside Orca when they resume. The existing cancellation, bounded staging and checked history commit now live in one shared runner, preserving Codex’s ordering, divider and duplicate prevention. Optional preparation and final-write waits now end at the deadline or cancellation; adapters can also complete an eligible saved item only while its saved identity, revision and read dependencies still match. The full review completed through round 4, followed by an independent check of the final main merge at Full CI passed on this exact head (run 39723995800): static analysis/typecheck, all five full test shards, relay integration, cross-version compatibility and macOS/Windows packaging. Real Codex 0.162.1 QA passed on macOS using the same thread and cold copy of main-created data: an initial native reply, a real outside CLI resume, one ordered outside pair under one divider, Session History close/reopen without duplicates, then two final-head native sends/replies across a real app restart. Saved options and tab identity/order were retained. The two imported rows and divider remained single after restart. No changed Codex flow was skipped or waived. Owned test processes were stopped and the QA ticket released. Baseline observations were preserved for separate triage: the configured default shell command was absent on main (existing STA-10870), and old Setup output/port count did not survive the stopped-rig restart on either build. Import-time timestamps and several neighboring UI/status details were the same on main; no new branch-specific chat regression was found. Other platforms, remote transport, folder-workspace UI and large-history performance were not runtime-tested by this macOS run. The deadline failure contracts were covered by targeted tests rather than a simulated app failure. The deliberate differences from the common pattern are the required incremental continuation of an existing conversation, its saved-item compare-and-commit checks, and the accepted optional-wait deadline. No new saved fields, wire operations, send predicate, settings or user notice were added. The existing journal owns admitted writes. A durable-write failure can still fail the current sink and require reopen; the asynchronous deadline does not preempt synchronous work or all provider I/O. These inherited limits were traced and kept explicit. For Brennan’s review Same main-created state and outside input, after the ordinary resumed Send:
History retained after reopening, with a real further reply; branch also went through a full app restart:
|




Problem and user-facing change
Codex chats already import turns written outside the chat when the provider resumes. Other agent integrations need the same cancellation, bounded staging and checked journal commit; copying the implementation would let these rules drift. Completing an existing saved item also needs one shared check that its saved identity and revision have not changed before the completion is written.
This extracts the existing handling into one shared runner, preserving Codex’s history selection, order, divider and duplicate prevention. It also closes a deadline gap: if preparation or the final write wait never settles, optional catch-up stops waiting at its deadline or when opening is cancelled. An already admitted write remains owned by the existing journal queue.
Implementation
runHistoryCatchUpowns the initial write barrier, cancellation/deadline, current-session checks and one checked commit. Agents supply their saved-history view and history preparation.createHistoryCatchUpBatchkeeps the 1,024-operation / 16 MiB budget. It now supports completing a saved item and recording saved items read during planning. The commit checks every expected canonical identity and revision before writing any of the batch. Journal code assigns the written revision; no new saved field or wire format is introduced.The shared extraction is useful alone through the current Codex caller. Other agent integrations land separately; no visible feature in this PR depends on one of them landing first.
Review classification: full path
Validation
62efd405b66, including the real-journal saved-item contract flow and stalled preparation/final-write regressions. The normal pre-commit hook passed.62efd405b66, including static analysis/typecheck, full unit shards, cross-version checks and macOS/Windows packaging.62efd405b66: main-created chat state carried through restart/upgrade, real outside same-thread CLI continuation, import once under the existing divider, duplicate-free Session History reopen and two real native replies across app restart. Main/branch screenshots and detailed evidence are attached in the review status comment. QA observed the existing default-tab issue STA-10870 and baseline Setup-output/port-count loss on both builds; those are outside this PR.Related work
Tracked in the chat/terminal switching lane. Pi #31618, Claude #31615 and OpenCode/Grok #31616 consume the shared runner in their integrations.