Skip to content

feat: undo and redo reversible file operations - #155

Merged
nextestudios merged 2 commits into
mainfrom
feature/22-undo-redo
Sep 27, 2026
Merged

nextestudios merged 2 commits into
mainfrom
feature/22-undo-redo

Conversation

@nextestudios

Copy link
Copy Markdown
Owner

Summary

  • Inverses (session undo/redo stacks, built from the finished operation and its history entry):
    • rename → rename back;
    • move → move each top-level item back (and restore its name if it was kept as "x (2)");
    • copy → remove the copy only if its fingerprint (size + mtime per file, tree listing for folders; links inside → not undoable) is unchanged and the original still exists; removal goes to the Recycle Bin when the drive has one;
    • Recycle Bin delete → restore via IRecycleBin (same original path, deleted during the operation's time window).
  • Refusal first: every step is checked before anything changes (current item missing, old name/place taken, parent folder gone, copy edited, original gone, item no longer in the bin). If any fails, nothing is done and the reasons are shown; the entry leaves the undo list. Undo never overwrites (conflicts during a move-back are skipped).
  • Never offered: permanent deletes, operations with replaced items, folder merges, anything that didn't finish cleanly, retry-of-failed runs.
  • Engine: OperationResult.Placed lists top-level items that arrived as new items (merged folders and replacements are excluded), so undo never treats a merged user folder as our copy.
  • UI: Menu → Desfazer: … / Refazer: … (after Operações), and Desfazer in the copy/move result dialog. Undo confirmation starts on Cancel. Redo repeats the original request (new copy/move/recycle, or rename).

Tests

CI (Windows):

  • UndoJourneyTests: rename undo restores the old name and redo renames again; move undo brings a folder and a file back, and is refused with a reason (nothing changed) when the original name is taken; copy undo refuses an edited copy and removes only an unchanged "kept both" copy, leaving the original and the edited copy; permanent delete never offers undo; Recycle Bin undo restores (fake bin), redo recycles again, and undo is refused when the name is taken again.
  • FileOperationServiceTests: a folder merged into an existing one is never reported as placed; a kept-both folder is.

Manual (docs/TESTING.md): real Windows Recycle Bin restore, cross-drive folder move-back, copy undo on a USB drive.

Closes #22

🤖 Generated with Claude Code

Rename goes back, a move goes back, an unchanged copy is removed while
the original still exists, and Recycle Bin deletes are restored. Every
item is checked before anything changes; if the disk changed since the
operation, nothing is done and the reason is shown. Permanent deletes,
replacements and folder merges are never offered. The engine now reports
top-level placed items so merges can never be mistaken for our copies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nextestudios
nextestudios merged commit ace624a into main Sep 27, 2026
1 check passed
@nextestudios
nextestudios deleted the feature/22-undo-redo branch September 27, 2026 06:02
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.

feat: undo and redo reversible file operations

1 participant