You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(chat): preserve Claude rewind context after rollback - #31231
Rolling Orca back after rewinding a Claude chat could bring discarded turns back into the model’s context while the chat displayed the shortened history. The rewind now saves the kept context before reporting success.
What Changed
Save a Claude fork through the SDK’s session-fork API, then commit its conversation handle and shortened journal in the same database transaction. Keep the original transcript intact, support rewinding again while the agent is stopped, and retain compatibility with older deferred-fork records. Add failure/recovery tests and a real-CLI test that resumes the saved fork using the ordinary session ID before another send.
Why
Older builds already understand the persisted conversation handle. Saving the actual fork and advancing that handle avoids depending on a new optional field that those builds ignore. The SDK handles branching and message-ID remapping; existing durable-write and journal-receipt code handles persistence.
N/A — changes persisted provider context and crash recovery; no rendered UI or controls change. The real-CLI test proves that a normal resume remembers the kept turn and forgets the discarded turn.
Testing
Verified locally on macOS against scan base 8a4ef49a4db6, with ORCA_BACKGROUND_LAUNCH=1 on every test command:
153 regression tests passed across transcript persistence, fork rewinds, failed commits and recovery, rewinds after clear, rewinds at rest, pending-rewind compatibility, account routing, journal recovery, and the real-agent-home write guard.
ORCA_REAL_CLAUDE_CLI_TEST=1 pnpm test src/main/claude/claude-structured-real-cli-rewind.test.ts passed. It resumes the durable fork by session ID and checks that discarded context stays absent.
pnpm tc:node and pnpm run check:code-quality:changed passed.
Manual packaged-app testing
Automated tests added/updated
Linux, Windows, SSH, and an actual packaged downgrade were not runtime-tested. Full build and remaining checks are for CI.
Review
Self-reviewed the commit ordering, source-account paths, empty-history rewind, failed writes, and compatibility with older records. No remote protocol opcode or dependency changes.
Agent skill upstream boundary
Not applicable; no upstream skill-installer source is copied or translated.
Notes
The separate stale-assertion fix is in #31229. The combined workspace passed all 16 real-Claude tests. This PR does not replace the release checklist’s packaged-update and live-network verification.
Checklist
This PR is small and focused
Explained what changed and why
Visual proof marked N/A with reason
Self-reviewed correctness, security, and performance
Cross-platform, SSH, and compatibility impact considered
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
📝 Walkthrough
Claude rewinds now materialize transcript forks through the selected entry and track resume state. Structured rewind completion updates provider-handle chains and journal epochs, with receipt handling and recovery for materialized forks. Tests cover transcript contents, fork persistence, failure rollback, and recovery. The real-agent home write guard permits opted-in Claude transcript writes while continuing to block Codex and Orca removals.
Priority: ➖ Normal
Merge Risk:⚪ Minimal · up to 839e5
The investigated rewind paths do not show a remaining issue that should block merging after normal checks.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 16 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title clearly identifies the main change: preserving Claude rewind context after rollback.
Description check
The description includes all required sections, explains the user impact and implementation, links the issue, documents testing and limitations, and marks visual proof as not applicable. Some checks r…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description includes all required sections, explains the user impact and implementation, links the issue, documents testing and limitations, and marks visual proof as not applicable. Some checks remain pending CI or were not tested locally, but the description is complete and relevant.
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Rolling Orca back after rewinding a Claude chat could bring discarded turns back into the model’s context while the chat displayed the shortened history. The rewind now saves the kept context before reporting success.
What Changed
Save a Claude fork through the SDK’s session-fork API, then commit its conversation handle and shortened journal in the same database transaction. Keep the original transcript intact, support rewinding again while the agent is stopped, and retain compatibility with older deferred-fork records. Add failure/recovery tests and a real-CLI test that resumes the saved fork using the ordinary session ID before another send.
Why
Older builds already understand the persisted conversation handle. Saving the actual fork and advancing that handle avoids depending on a new optional field that those builds ignore. The SDK handles branching and message-ID remapping; existing durable-write and journal-receipt code handles persistence.
Linked Issue
Fixes STA-11420.
Visual Proof
N/A — changes persisted provider context and crash recovery; no rendered UI or controls change. The real-CLI test proves that a normal resume remembers the kept turn and forgets the discarded turn.
Testing
Verified locally on macOS against scan base
8a4ef49a4db6, withORCA_BACKGROUND_LAUNCH=1on every test command:ORCA_REAL_CLAUDE_CLI_TEST=1 pnpm test src/main/claude/claude-structured-real-cli-rewind.test.tspassed. It resumes the durable fork by session ID and checks that discarded context stays absent.pnpm tc:nodeandpnpm run check:code-quality:changedpassed.Linux, Windows, SSH, and an actual packaged downgrade were not runtime-tested. Full build and remaining checks are for CI.
Review
Self-reviewed the commit ordering, source-account paths, empty-history rewind, failed writes, and compatibility with older records. No remote protocol opcode or dependency changes.
Agent skill upstream boundary
Notes
The separate stale-assertion fix is in #31229. The combined workspace passed all 16 real-Claude tests. This PR does not replace the release checklist’s packaged-update and live-network verification.
Checklist