Repository navigation
Keep a woken Codex terminal's saved session when its workspace sleeps again - #42864
Conversation
Status: ready for reviewFix: a finished Codex terminal agent whose workspace is slept, woken (the tab resumes and is left idle) and slept again no longer loses its saved session. Before, its tab reopened as a bare shell and the conversation was gone. Regression from #41793. Cause: the "agent exited" note recorded at the first sleep survived the wake. A resumed Codex sends nothing until its next turn, so the second sleep read the old note as a real exit and deleted the saved session. The fix forgets that note when the sleeping pane's process restarts ( Review: fresh Claude Opus and Codex reviewers both approve with no findings (every wake route, pane-key aliases, restart persistence, SSH and mobile wake traced). The #41793 owner agreed the fix. CI: green, 28 checks, CLEAN. QA (M4Air, real Codex v0.169.0 + Claude Opus 5.5):
Older bugs QA saw, the same with and without this PR (not fixed here):
|


A finished Codex terminal loses its saved conversation when its workspace sleeps, wakes with the Codex tab resumed, and sleeps again before another prompt. The tab then reopens as a bare shell.
Sleep records the old process's exit while preserving the finished pane.
Wake retires the sleeping pane, but its provider-session-only launch row cannot supersede that exit without a hook.
The next Sleep reads the retained exit and deletes the saved session.
Forget the old exit through the server's existing alias-aware path only when spawn retires a sleeping pane. Ordinary exits remain authoritative; the presence check and sleep capture probe are unchanged.
Test: extend the existing server-pane-sleep fixture through the real presence, capture, and apply paths for idle Codex resume, Claude's new-process hook, failed resume into a bare shell, and an ordinary exit. On main, the idle Codex and failed-resume cases delete the saved record.
Validation: git diff --check passed. No dependencies installed, builds, typechecks, tests, or pnpm check:changed run locally, per this task's machine restriction. The normal commit and push completed without bypassing hooks.
Regression from #41793
Plan: CI and an admitted QA machine run the targeted test, typechecks, required checks, and the Sleep → wake idle Codex → Sleep repro before review.