fix(cli): restore source file when reverting a move across folders - #9758
Merged
Conversation
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Incremental Review NoteA large upstream merge landed on this branch since the previous review (
Files Reviewed (3 files)
Reviewed by claude-4.6-sonnet-20260217 · 674,187 tokens Review guidance: REVIEW.md from base branch |
lambertjosh
force-pushed
the
sleepy-stoplight
branch
2 times, most recently
from
May 1, 2026 18:15
0eb5256 to
dda8f9c
Compare
Git's default rename detection in 'diff --cached --name-only' collapses a file move (A/foo -> B/foo) into a single destination entry. The snapshot revert iterates this list and deletes files that aren't in the pre-step tree — so B/foo was removed but A/foo was never restored, losing data. Pass --no-renames so both the source and destination paths appear in the patch, matching diffFull()'s behavior. Revert now deletes the new location and restores the original. Fixes #9741
lambertjosh
force-pushed
the
sleepy-stoplight
branch
from
May 1, 2026 18:23
dda8f9c to
b92677a
Compare
marius-kilocode
approved these changes
May 8, 2026
marius-kilocode
approved these changes
May 8, 2026
Contributor
|
To stay organized pull requests are automatically closed after 30 days of inactivity. If the pull request is still relevant please reopen it or create a fresh new one. |
Collaborator
|
@lambertjosh do you want to go ahead with this? Did you test it and is it ready to merge? |
Contributor
Author
t7tran
pushed a commit
to t7tran/kilocode
that referenced
this pull request
Aug 14, 2026
fix(cli): restore source file when reverting a move across folders
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.




Summary
Fixes #9741. When the agent moved a file between folders during a task, clicking Revert would delete the file from its new location without restoring the original — resulting in data loss.
Root cause:
patch()insnapshot/index.tscomputed the file list viagit diff --cached --name-onlywithout--no-renames. Git's default rename detection collapsed a move (A/foo→B/foo) into a single destination entry, so the source path never entered the revert list.Fix: Pass
--no-renames, matchingdiffFull()'s behavior. Both source and destination now appear, so revert deletes the new location and restores the original.Changes
patch()to add--no-renamestest/kilocode/snapshot-revert-move.test.tscovering folder-to-folder moves and in-folder renamescheckpoints.mdandwhats-new.md(the limitation note now documents expected behavior; kept in case there are edge cases we haven't surfaced)