Skip to content

fix(resume): keep a restored Claude conversation until its pane reports - #306

Merged
amirlehmam merged 1 commit into
amirlehmam:masterfrom
clemrdh:fix/claude-resume-keep-unreported
Oct 19, 2026
Merged

amirlehmam merged 1 commit into
amirlehmam:masterfrom
clemrdh:fix/claude-resume-keep-unreported

Conversation

@clemrdh

@clemrdh clemrdh commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Restarting wmux twice loses every Claude conversation in a tab you did not open in between. The save-time stamp asked agent-state for each terminal's Claude id and read silence as "exited", so a pane whose claude --resume had not reported yet, or whose tab had never been shown (no PTY at all), lost its claudeSessionId on the first 30 s autosave. Codex and OpenCode never had this: their lookup already told silence (keep) from a release or another provider's report (clear).

A second path erased the rest at quit. Claude's SessionEnd hook calls pane.release_agent as wmux kills its PTY, and unlike the Codex and OpenCode releases it was not refused while quitting, so a plain quit could drop the conversations that were open.

Changes:

  • Claude goes through the same provider lookup as Codex and OpenCode: its own report wins, another provider's report or a release clears the id, silence keeps it.
  • stampClaudeSessionIds treats an undefined lookup as "no opinion" and keeps the id.
  • pane.release_agent is refused while isQuitting, like pane.release_codex_session and pane.release_opencode_session. Claude exiting because wmux killed it is not the user closing the conversation.

Exiting Claude yourself still clears the tab: SessionEnd releases it, and wasAgentReleased makes the lookup return null. A test covers this.

Seen in practice on 2.28.1: one workspace came back with five bare shells. Its Claude ids were in an earlier session backup and had been dropped by later autosaves.

Validation:

  • New tests/unit/agent-session-persistence.test.ts: a silent pane keeps its restored id; a pane that reports state without a session keeps it; a new report replaces it; a release and a PTY exit each clear it; a Codex report takes the tab. Plus a "no opinion" case in claude-resume.test.ts.
  • Typecheck passes; ESLint is clean on the changed files.
  • Full suite with --maxWorkers=2: 4,759 passed, 4 failed, 14 skipped. The 4 failures are timing assertions in pipe-client-latency and orchestrator-final-reap, run while the machine was busy; both files pass in isolation (25/25).

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-19T10:06:22.096241Z b1907ce PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

The save-time stamp asked agent-state for each terminal's Claude id and read
silence as "exited": a pane whose `claude --resume` had not reported yet, or
whose tab had never been shown (no PTY at all), had its id removed by the
first 30 s autosave. Restart wmux twice and every Claude tab you had not
opened in between came back as a bare shell. Codex and OpenCode never had
this — their lookup already distinguished silence (keep) from a release or
another provider's report (clear).

- Claude now uses the same provider lookup: its own report wins, another
  provider's report or a release clears the id, silence keeps it.
- `stampClaudeSessionIds` treats an `undefined` lookup as "no opinion".
- `pane.release_agent` (Claude's SessionEnd hook) is refused while wmux is
  quitting, like the Codex and OpenCode releases: Claude exiting because
  wmux killed its PTY is not the user closing the conversation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@clemrdh
clemrdh force-pushed the fix/claude-resume-keep-unreported branch from b1907ce to 99ee6bd Compare October 19, 2026 11:10
@clemrdh

clemrdh commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto 2.29.0 (2b9511d), no changes to the patch. It still merges cleanly next to #303.

@amirlehmam
amirlehmam merged commit b95603a into amirlehmam:master Oct 19, 2026
@amirlehmam

Copy link
Copy Markdown
Owner

Merged, thank you @clemrdh. Bringing Claude onto the same provider lookup as Codex and OpenCode, and refusing release_agent while quitting, closes both of the ways a restore was losing conversations. Ships in 2.30.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants