Skip to content

fix(snapshot): make /redo targeted to only restore files from reverted turn#15611

Open
Br1an67 wants to merge 1 commit intoanomalyco:devfrom
Br1an67:fix/issue-15391-redo-targeted
Open

fix(snapshot): make /redo targeted to only restore files from reverted turn#15611
Br1an67 wants to merge 1 commit intoanomalyco:devfrom
Br1an67:fix/issue-15391-redo-targeted

Conversation

@Br1an67
Copy link

@Br1an67 Br1an67 commented Mar 1, 2026

Issue for this PR

Closes #15391

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

/redo (unrevert) was using checkout-index -a -f which writes every tracked file from the snapshot tree, updating mtimes on all files — even those untouched by the reverted turn. This triggers editor reload prompts and confuses file watchers.

The fix stores the file list collected from patches during /undo into session.revert.files, then passes it to restore() during /redo. When a file list is present, restore() does per-file git checkout <hash> -- <file> (the same pattern revert() already uses) with the ls-tree fallback for files that were created and need deletion. When no file list is available (backward compat), it falls back to the existing blanket restore.

Three files changed:

  • session/index.ts — added optional files field to the revert schema
  • session/revert.ts — collect unique file paths from patches, pass them through unrevert
  • snapshot/index.tsrestore() accepts optional file list for targeted checkout

How did you verify your code works?

Read through the existing revert() function to confirm the targeted checkout pattern is identical. The new restore() path mirrors revert() exactly — same git flags, same ls-tree fallback, same fs.unlink cleanup.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…erted turn

/redo used checkout-index -a -f which writes every file from the
snapshot, updating modification timestamps on unchanged files and
triggering editor reload prompts.

Store the file list from patches during /undo, pass it through to
/redo, and use per-file checkout (same pattern as revert) when a file
list is available. Falls back to blanket restore for backward
compatibility.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(snapshot): /redo touches all files unnecessarily, destroying date modified metadata and triggering editor reload prompts

1 participant