Repository navigation
feat: revert a thread to just after a message - #116
Merged
Merged
Conversation
Edit from here rewinds to before a prompt and returns it to the composer. Revert to here keeps the prompt and its reply and drops every later run (an automation wake, an unwanted compaction, a stray prompt) from the thread and the provider's history, using the same checkpoint rollback. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…summary Claude's resume re-applies a compaction written later in the transcript, even past resumeSessionAt, so a rollback to before /compact kept the summary in context. When the transcript compacts after the target, fork the session up to it and alias earlier turn cursors to the fork's uuids. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…liasing them Review findings on the compaction fork: - the rollback returns the kept turns with their cursors moved to the fork, and CheckpointRollbackService writes them, so no new stored field is needed and a code revert cannot strand a forked thread - rewinding to a compaction run keeps that compaction (no fork) - a fork missing a kept cursor fails the rollback instead of dangling - an unreadable transcript is logged Co-Authored-By: Claude Opus 5.5 <[email protected]>
…turns Co-Authored-By: Claude Opus 5.5 <[email protected]>
akiva-quickvett
marked this pull request as ready for review
November 26, 2026 00:47
akiva-quickvett
added a commit
that referenced
this pull request
Nov 26, 2026
…r-tip Merged onto the upstream-synced tip. Upstream pingdotgg#41276 dropped providerTurns from thread snapshots, so rollbackThread now returns ProviderAdapterV2RollbackThreadResult, which carries the moved turns; the compaction fork drops forkSession's dir (upstream pingdotgg#22836). Co-Authored-By: Claude Opus 5.5 <[email protected]>
akiva-quickvett
added a commit
that referenced
this pull request
Nov 26, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds Revert to here beneath a sent message. It keeps that message and its reply and drops every later turn from the chat and from the agent's context: an automation's wake, a prompt that sent the agent off course, or a compaction that came too early. Unlike Edit from here, the prompt stays put and nothing returns to the composer. The existing confirm dialog asks whether to revert files too.
Problem
The only way back was Edit from here, which rewinds to before a prompt and moves it into the composer. To drop a cron turn or a stray message after a good exchange, you had to resend the good prompt. Reverting a Claude thread to before a
/compactalso kept the compaction summary in context: Claude's resume re-applies a compaction written anywhere later in the transcript, even pastresumeSessionAt.Fix
deriveRevertTurnCountByUserMessageIdreturnseditandkeeptargets.keepis the prompt's own run checkpoint, offered only when a later visible run exists and the provider can roll back to it. The row shows a history-icon button, and the dialog andrewindToMessagetake a mode, so keep leaves the composer alone.ClaudeAdapterV2.rollbackThread): when the transcript has acompact_boundaryafter the target cursor, fork the session up to that cursor (SDKforkSession) and point the provider thread at the fork. The rollback returns the kept turns with their cursors moved to the fork's uuids, read from theforkedFromthe SDK writes on each copied message.CheckpointRollbackServicenow writes any turns an adapter returns asprovider-turn.updated(every adapter returned[]before), so later rollbacks and forks resolve inside the fork with no new stored field./compact) keeps that compaction: no fork, as before.Evidence
/compact. Revert to here on BANANA forked the session, the run becamerolled_back, and Haiku quoted both messages and said its context held no compaction summary (before the fix it said it was reading a summary). A second revert, to APPLE, made no new fork, resumed at the aliased cursor, and Haiku listed only APPLE./compact, CHERRY.forkSessioncut after an existing compaction copied every earlier line withforkedFromon each (checked during review).ClaudeAdapterV2.test.ts: the compaction case fails on the old adapter, and the compaction-target case fails on the first version of this fix.CheckpointRollbackService.test.ts: the moved-turns case fails on main's service. Thesession-logic.test.tskeep targets cover wake runs, unavailable checkpoints and steers.vp run check:changedpasses.Surfaces
akiva/server-tip.Upstream
A candidate. It is branched from
mainand has no tip dependencies.Review
Tier 1 (5 points, R1). The general reviewer raised two highs and two meds. All are fixed:
/compactdropped the compaction. The fork is skipped when the target is the compaction run. A test covers it.forkedFromon every line.Lows left as they are: every Claude rollback with a cursor reads its transcript file(s) to look for a compaction. The old session file stays on disk after a fork.
Fixed after the last review: everything above. No re-check was due (R1, under 8 points, and each fix has a test that fails without it).
Deferred decisions
assetsbranch that earlier PRs used is gone, so the screenshots (row with both buttons, the dialog, the reverted thread) are not embedded. Recreate the branch, or say where they should go.🤖 Generated with Claude Code