fix(server): recover provider sessions when resume history is missing - #5433
chrisdeeming wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
ApprovabilityVerdict: Needs human review This PR introduces new session recovery capabilities across 6 provider adapters, including automatic session restart and prompt replay logic. The significant runtime behavior changes and an unresolved review comment about potential incorrect transcript handling warrant human review. You can customize Macroscope's approvability policy. Learn more. |
c06135c to
60a70c3
Compare
7929c7f to
031d5ad
Compare
031d5ad to
063bdc0
Compare
063bdc0 to
00bcdcd
Compare
00bcdcd to
d1e07ac
Compare
d1e07ac to
324c388
Compare
324c388 to
3a428e3
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3a428e31114d09e9c12460d0c2d66d8801a6d98a. Configure here.
3a428e3 to
a905f33
Compare
|
Closing as part of the open-PR backlog sweep (wave 1). Reason: Aug conflicted resume-history recovery; provider adapters have moved a long way. Reopen if this is still wanted and you’re willing to rebase onto current |

What Changed
Every provider adapter now recovers when a thread's resume target no longer exists, instead of failing identically on every subsequent message.
Path "..." does not exist), the adapter restarts once and replays the pending prompt, keeping the resume cursor so conversation history survives. One retry only, guarded by a flag.session/loadin the shared ACP runtime falls back tosession/newand rewrites the resume cursor. Timeouts are excluded: a hung agent surfaces as an error rather than silently discarding history.logWarning; they now tell the user.Transcript inspection is best-effort throughout — if it fails for any reason, the session starts as though nothing was found.
Why
A thread can be pinned to a git worktree that something else later deletes — another agent, another thread, or the user. The consequences were provider-specific and mostly bad:
EnterWorktree. Delete that worktree and the transcript is stranded: resume fails withNo conversation found with session ID: <id>even though the file still exists. The cursor was never cleared, so every later message retried the same doomed resume and the thread stayed permanently wedged.session/loadcall that had no fallback and never rewrote the cursor, so an unloadable session id wedged the thread the same way. Their failures also arrive as defects rather than typed errors, so recovery handles the cause rather than the error channel while still re-raising transport timeouts.Checklist
I included before/after screenshots for any UI changes— no UI changes; the only user-visible addition is a standard warning rowI included a video for animation/interaction changes— no animation or interaction changesNote
Medium Risk
Touches session start, resume cursors, and mid-turn restart across all provider adapters; mistakes could drop history or double-run turns, though behavior is heavily covered by new tests.
Overview
Provider adapters no longer stay wedged when a thread’s resume target is gone (e.g. deleted git worktree). Users get
runtime.warningwhen history can’t be resumed instead of silent fresh sessions or repeated failures.Claude adds
recoverClaudeSession, which finds orphaned.jsonltranscripts under Claude’sprojects/tree (when the recordedcwdis missing) and copies the newest match into the current workspace before start. If recovery ismissing, start drops the resume cursor and warns. On CLIPath "..." does not exist, the adapter restarts once, keeps the resume id, replays the last prompt, and injects a workspace-moved notice.Cursor / Grok (ACP) treat recoverable
session/loadfailures assession/newwithresumeFallback; transport/timeouts still fail. Codex and OpenCode already fell back but now emit the same user-visible warning pattern.Reviewed by Cursor Bugbot for commit a905f33. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Recover provider sessions when resume history is missing by rehoming orphaned transcripts
recoverClaudeSessionin ClaudeSessionRecovery.ts that scans Claude's projects directory for orphaned transcripts matching the session ID, copies the most recently modified one into the current workspace, and returns'available' | 'rehomed' | 'missing'.makeClaudeAdapterin ClaudeAdapter.ts to call session recovery on start, suppress resume when history is missing, and automatically restart and replay the last prompt when the CLI reports a missing resume path.session/loadfails recoverably, returning aresumeFallbackflag to callers.runtime.warningevent when they start a fresh session due to an unresumable prior session.ClaudeAdaptersilently retries once; if the restarted session also fails, the turn completes as failed and asession.exitedwithexitKind: 'error'is emitted.Macroscope summarized a905f33.