Repository navigation
fix(codex): keep session capture through a restore burst; never save an empty thread - #309
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…an empty thread Restoring a session starts every saved Codex at once, and about half of them ran without session capture: wmux lost track of those tabs, so a `/new` or a quit there was never recorded. Seen with 9 restored Codex tabs: 5 relayed, 4 native, interleaved within 11 s. Each launch hung on two tight limits, and failing either one silently meant "restore off": - `pane.codex_restore_config` got one 2 s pipe request; - `codex --help` got 5 s, run once per pane, so the burst of probes was itself what ran out of time. - Pipe requests are now asked again while wmux is merely busy: no reply, a dropped connection, EBUSY/ECONNRESET/EPIPE/ETIMEDOUT. Each attempt is longer, within a budget: config 45 s, session reports 60 s, release 10 s. An absent wmux (ENOENT), "outside wmux" or an error reply from an older wmux still answers at once. The pane says when it waits, and when it finally starts without restore. - The `--help` probe gets 30 s. Its "yes" is remembered per executable (path, size, mtime: an update invalidates it), so a restore probes once. A probe that timed out is retried, and silence is no longer reported as "this Codex is too old". A tab opened on Codex and left empty saved an id that no restart could reopen. The relay reported a thread at `thread/start`, but Codex writes a conversation only once it has content, so `codex resume` answered "no rollout found" on every restore. Nothing released it either: the pane never reported, and silence keeps a restored id. - A started thread is now reported at its first content: `turn/start`, `review/start`, `thread/shellCommand` or `thread/inject_items`. Resumed and forked threads are reported at once, as before. - When the conversation a launch was asked to resume gets that exact answer, the launcher sends `pane.codex_session_missing`, and the next save drops that id, and only that id, from that tab. A later report in the tab wins over it. The saved id is not checked against rollout files: Codex 0.163 migrated history into SQLite (`legacy_to_paginated_v1`), so most valid threads have no rollout file left. The missing-thread signal comes from Codex itself, verified against codex 0.163 app-server: a migrated thread resumes; a never-written one answers -32600 "no rollout found for thread id <id>". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ad1a9c0 to
68b1b1c
Compare
|
Merged, thank you. Retrying the pipe through a restore burst, caching the |
Restoring a session starts every saved Codex at once, and about half of them ran without session capture. This was seen on 2.28.1 with 10 restored Codex tabs:
codex resumefailed there on every restart.A natively started Codex still shows its conversation, but wmux no longer follows that tab: a
/newor a quit there is never recorded.1. The restore burst (
wmux-codex.ts)Each launch hung on two tight limits, and failing either one silently meant "restore off":
pane.codex_restore_configgot one 2 s pipe request. Requests are now asked again while wmux is merely busy: no reply, a dropped connection,EBUSY,ECONNRESET,EPIPEorETIMEDOUT. Each attempt is longer than the last, within a budget: config 45 s, session reports 60 s, release 10 s. An absent wmux (ENOENT), "outside wmux" or an error reply from an older wmux still answers at once, as before. The pane prints a line when it waits, and another if it finally starts without restore.codex --helpgot 5 s, once per pane, so the burst of probes was itself what ran out of time. The probe now gets 30 s. Its "yes" is remembered per executable (path, size and mtime, so an update invalidates it), which means a restore probes once. A probe that timed out is retried, and silence is no longer reported as "this Codex version cannot record sessions".2. Empty threads (
codex-session-tracker.ts,agent-state.ts)The relay reported a thread at
thread/start, but Codex writes a conversation only once it has content. A tab opened on Codex and left empty therefore saved an id thatcodex resumeanswers with-32600 "no rollout found for thread id <id>". Nothing ever released it: the pane never reported, and silence keeps a restored id (by design, so that slow restores keep their handle).turn/start,review/start,thread/shellCommandorthread/inject_items, all of which requirethreadIdin the v2 protocol schema. Resumed and forked threads are reported at once, as before.pane.codex_session_missing. The next save drops that id, and only that id, from that tab. A later report in the tab wins over it.I first tried pruning saved ids that had no rollout file, as Claude's prune does, and abandoned it. Codex 0.163 migrated history into SQLite (
legacy_to_paginated_v1): here 648 of 700 threads have no rollout file and still resume. The missing-thread signal therefore comes from Codex's own answer.Verified live (Codex 0.163, Windows 11)
codex app-server. The empty thread from the incident triggeredonMissingwith its id; a migrated thread with no rollout file resumed and triggeredonSession.turn/start,review/start,thread/shellCommandandthread/inject_itemswere checked againstcodex app-server generate-json-schema.Tests
codex --helpis cached per executable and invalidated by an update;resumeTargetparses the arguments correctly.thread/start" and now send the first turn.npm run typecheckandnpm run verify:resourcespass (resources/cliregenerated), and ESLint is clean on the changed files.--maxWorkers=2: 4,838 passed, 1 failed, 14 skipped. The one failure ispipe-client-latency's 45 ms wall-clock budget (188 ms on a busy machine), which test: stop timing-dependent failures on a loaded Windows machine #308 replaces with a deterministic check.🤖 Generated with Claude Code