Skip to content

fix(server): keep Claude rewind when fork history length changes - #11954

Merged
maria-rcks merged 3 commits into
mainfrom
fix/claude-rewind-fork-boundaries
Sep 16, 2026
Merged

maria-rcks merged 3 commits into
mainfrom
fix/claude-rewind-fork-boundaries

Conversation

@maria-rcks

@maria-rcks maria-rcks commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

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.

before: last-turn rewind, tools and 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.

after: verified last-turn rewind, tools and queued follow-up, multi-turn rewind, and reset-all

reviewed and updated with gpt-6-astra in codex.

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>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Sep 15, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 3f9057d

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.

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Sep 15, 2026
@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 13.6 KiB 13.6 KiB +29 B (+0.2%) 15.1 KiB
Codex Thread snapshot wire 7.1 KiB 7.1 KiB −6 B (−0.1%) 7.3 KiB
Codex Live turn WebSocket wire 6.5 KiB 6.6 KiB +35 B (+0.5%) 7.8 KiB
Codex Live turn WebSocket decoded 57.0 KiB 57.1 KiB +44 B (+0.1%) 66.4 KiB
Codex Live turn messages 9 10 +1 (+11.1%) 21
Claude Total thread wire 13.6 KiB 13.6 KiB −12 B (−0.1%) 15.1 KiB
Claude Thread snapshot wire 7.1 KiB 7.1 KiB +1 B (+0.0%) 7.3 KiB
Claude Live turn WebSocket wire 6.6 KiB 6.6 KiB −13 B (−0.2%) 7.8 KiB
Claude Live turn WebSocket decoded 57.9 KiB 57.9 KiB 0 B (0.0%) 66.4 KiB
Claude Live turn messages 10 10 0 (0.0%) 21

Baseline: 3efdcc5 · PR result: 3f9057d · Source CI: success

Scenario and decoded snapshot size

10 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.

  • Codex decoded thread snapshot: 113.9 KiB
  • Claude decoded thread snapshot: 114.6 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: c8f52527-6b6c-458f-80b4-eb8d13b12fbb

📥 Commits

Reviewing files that changed from the base of the PR and between 8e2e05a and 3f9057d.

📒 Files selected for processing (1)
  • apps/server/src/provider/Layers/ClaudeAdapter.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/server/src/provider/Layers/ClaudeAdapter.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

Claude 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.

Changes

Claude rollback handling

Layer / File(s) Summary
Fork boundary remapping
apps/server/src/provider/Layers/ClaudeAdapter.ts
Validates conversation offsets, retained message types, and message bodies before remapping fork message IDs. Rollback uses this validated alignment and preserves the existing error when boundaries cannot be preserved.
Rollback validation
apps/server/src/provider/Layers/ClaudeAdapter.ts, apps/server/src/provider/Layers/ClaudeAdapter.test.ts
Adds tests for omitted or extra system messages, compacted prefixes, tool results, steering, multi-turn rewinds, full resets, missing retained turns, inserted messages, and changed assistant content.

Priority: ⬇️ Low

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 3f905

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the primary change: preserving Claude rewind when fork history length changes.
Description check ✅ Passed The description explains what changed, why it was needed, test coverage, live verification, and UI evidence. It does not use the template headings or include the checklist, but it contains the require…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/claude-rewind-fork-boundaries

Comment @coderabbitai help to get the list of available commands.

@macroscopeapp
macroscopeapp Bot dismissed their stale review September 16, 2026 01:43

Dismissing prior approval to re-evaluate 8e2e05a

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Sep 16, 2026
@macroscopeapp
macroscopeapp Bot dismissed their stale review September 16, 2026 01:53

Dismissing prior approval to re-evaluate 3f9057d

@maria-rcks
maria-rcks merged commit eed974c into main Sep 16, 2026
22 checks passed
@maria-rcks
maria-rcks deleted the fix/claude-rewind-fork-boundaries branch September 16, 2026 02:41
sheehanmunim added a commit to munimtechnologies/mtcode that referenced this pull request Sep 16, 2026
- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant