fix: prevent data loss in checkpoint restoration (fixes #6209) #6210
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.
Summary
This PR fixes a critical data loss issue where users were losing their entire codebase when restoring checkpoints. The issue was caused by the use of
git clean -d -fwhich aggressively removes ALL untracked files.Problem
The user reported in #6209 that when they clicked on checkpoint restore, it deleted almost all their codebase. This happened when switching between different tools (Copilot and Roo Code) and was causing complete data loss.
Root Cause
The
restoreCheckpointmethod inShadowCheckpointService.tswas using:This command forcefully removes ALL untracked files and directories, which is extremely dangerous and was causing the reported data loss.
Solution
git cleancommand - We no longer usegit clean -d -fwhich was the primary cause of data lossgit reset --hardwhich restores tracked files while preserving untracked fileslistStashes()- List available stashesrecoverFromStash()- Recover from a specific stashTesting
git cleanis never called during restorationImpact
This fix prevents catastrophic data loss that users were experiencing when restoring checkpoints. Untracked files are now preserved during checkpoint restoration, making the feature much safer to use.
Fixes #6209
Important
Fixes critical data loss issue by removing
git clean -d -ffrom checkpoint restoration, adding validation checks, and introducing recovery methods.git clean -d -ffromrestoreCheckpointinShadowCheckpointService.tsto prevent data loss.git reset --hardto restore tracked files while preserving untracked files.listStashes()andrecoverFromStash()for emergencies.ShadowCheckpointService.spec.tsto verify new behavior and ensuregit cleanis not called.This description was created by
for 58f9492. You can customize this summary. It will automatically update as commits are pushed.