fix(server): keep Claude rewind when fork history length changes - #11954
Conversation
Claude forks rewrite UUIDs and rebuild the parent chain, so system notices and compact metadata can change getSessionMessages length without dropping retained turns. Align those user/assistant turns from the truncated end instead of requiring equal transcript lengths. Co-authored-by: Cursor <cursoragent@cursor.com>
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a localized Claude rollback bug fix with comprehensive tests, preserving valid rewinds while rejecting forks that do not preserve retained conversation content. It does not alter schemas, defaults, deployment configuration, or security-sensitive behavior. You can add or adjust custom eligibility rules. Learn more. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughClaude rollback now aligns retained conversation messages across fork histories with different system-message layouts. It validates message types and bodies before remapping boundaries. Tests cover supported histories, rewinds, resets, tool results, steering, and invalid forks. ChangesClaude rollback handling
Priority: ⬇️ Low Estimated code review effort: 4 (Complex) | ~45 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The rollback update preserves valid forked conversations and safely rejects incompatible fork histories, with focused tests covering supported and rejected history variants. No actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Dismissing prior approval to re-evaluate 8e2e05a
Dismissing prior approval to re-evaluate 3f9057d
- ClaudeAdapter: took upstream's extracted `isClaudeHumanTurnStart` predicate (pingdotgg#11954) while keeping the fork's empty-history behaviour, which rolls back retained turns in memory instead of failing the request. - App.tsx: upstream's `shouldHandleAppLink` deep-link filter (pingdotgg#12002) alongside the fork's branded URL schemes. - package.json version/license stamps stay on the fork's values (0.0.56, Apache-2.0); upstream's v0.0.41 prep does not apply here. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
claude rewind could reject a valid fork when system notices or compaction metadata changed the transcript's raw length. this aligns retained user/assistant messages from the truncated end and remaps native turn ids. it verifies retained message bodies before accepting that alignment, so restored steering messages or changed replies cannot silently shift a turn boundary.
verification: 137 claude adapter tests and server typechecking passed on blacksmith. coverage includes omitted/extra system messages, compact prefixes, tool results, steering, single/multi-turn rewind, reset-all, and invalid retained history. the two new mismatch cases failed on the original pr head and pass with the body validation.
live claude sonnet 5 verification through the web client covered repeated last-turn rewind, tool calls with a queued follow-up, multi-turn rewind, reset-all, and subsequent messages. ordinary cases passed before and after. the specific metadata-length failure was not reproduced organically; its variants are covered by adapter tests. desktop/mobile use this server adapter but were not separately exercised.
before: original adapter at
3efdcc5296, including last-turn rewind, tools/queued follow-up, multi-turn rewind, and reset-all.after: the same interaction categories with retained-history validation. the multi-turn examples remove different numbers of turns; these are functional checks, not timing benchmarks.
reviewed and updated with
gpt-6-astrain codex.