Repository navigation
fix: checkpoint uncommitted work before restoring a checkpoint - #209
Merged
currentbits merged 1 commit intoAug 17, 2026
Merged
Conversation
restoreCheckpoint ran `git reset --hard` straight away, so any uncommitted work in the thread worktree — manual edits, or changes from a run whose best-effort post-turn checkpoint failed — was destroyed by one click on an older checkpoint. maybeCreateCheckpoint now runs first. It no-ops on a clean worktree, so the common restore is unchanged. The safety commit is off-HEAD after the reset and drops out of listCheckpoints; recovery is `git reflog` in the worktree. Co-Authored-By: Claude Opus 5 <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
currentbits
deleted the
coder/restorecheckpoint-hard-resets-the-worktr-ec44a0
branch
October 3, 2026 16:07
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.
Fixes #132.
Problem
restoreCheckpointinelectron/worktrees.jsrangit reset --hard <sha>as soon as the sha passed validation. Any uncommitted work in the thread worktree was destroyed by one click on an older checkpoint, with no way back:maybeCreateCheckpointalready existed and is exactly the right safety net — it just was not being called here.Change
await maybeCreateCheckpoint(store, threadId)immediately before the reset. It sits after the sha validation, so it cannot influence which checkpoint resolves.The fix is in the shared function, so it covers every restore entry point — the ThreadView undo bar and the AgentsPanel checkpoint list both route through it.
maybeCreateCheckpointno-ops on a clean worktree, so the ordinary restore (nothing uncommitted) behaves exactly as before.Known limitation
The safety commit is off-HEAD after the reset, so it drops out of
listCheckpointsand is not visible in the UI. Recovery isgit reflogin the worktree. That turns unrecoverable loss into recoverable loss, which is what the issue asked for; surfacing it in the checkpoint list is a separate change and is marked with aponytail:comment at the call site.Tests
Two cases added to
electron/test/checkpoints.test.js:electron/test/checkpoints.test.js12/12 andelectron/test/worktrees.test.js34/34 pass.