Repository navigation
fix(undo): restore originals after replacing moves - #2080
Conversation
Keep the staged Trash identity in move history instead of discarding it. Reuse the guarded restore pipeline after completed move batches settle, with one lookup for all originals and refreshed identities across redo. Extend the existing replacement QA scenario and customization fixture, and cover files, folders, conflicts, missing backups, durability, partial failure and cancellation. Refs #2077
Requiring every staged original before moving anything made one emptied Trash entry stop the whole undo. A failed undo stays on top of the history, so every later Ctrl+Z failed the same way and older entries were out of reach, where the move-back worked before. Look up a failed batch item by item, move everything back, restore what is still there and report the rest with the lookup's own message. Drop a_move_back_conflict_keeps_both_items_and_the_staged_original: its assertions are a subset of a_partial_replacing_move_undo_restores_only_completed_originals.
Only the QA scenario, which pull request CI skips, exercised this. Undo and redo each record what they replaced at their own end, and a replay that replaced nothing clears the identity it consumed.
The added Undo row lowered the file's code health from 8.26 to 8.22. Moving the conflict step tables to constants raises it to 8.52.
Review and cleanupMerged Review against the description and #2077. Confirmed: both items come back on Undo for files and folders, conflicts and failed flushes leave the original in Trash, cancellation restores only committed moves, a new arrival is never overwritten, redo refreshes the identity, and folder customizations are restored. Non-local destinations report no Trash identity, so they keep the plain move-back. There were no earlier review comments to reconcile. Fixes pushed
Tests removed or replaced
The comments the PR added each explain something the code does not show, so all were kept. Validation (on
Follow-ups outside this PR (from reading the code, not reproduced; none loses data)
CI: all required checks green on |
Description
Restore both items when undoing a Move with Replace. Move history now retains the staged original's Trash identity and reuses guarded restoration after completed move batches settle. Originals are looked up together, preserving flush batching rather than adding per-item scans or flushes. Redo refreshes the identity for the next Undo.
Covers file/folder restoration, conflicts, missing backups, partial failure, cancellation, failed flushes, redo, and folder customizations. Existing no-Trash fallback behavior is unchanged.
Validation exception: the owner explicitly authorized skipping CodeScene because it requires a paid service/token. That check was not run; other selected checks were completed. Detailed verification and benchmark record.
Benchmark
Three private QA-container sessions per version; 256 × 4 KiB files in each conflicting folder, Move → Replace → Undo. Medians:
Debug/software-rendered GUI measurements include driver overhead. Samples are noisy and the baseline omitted restoration work; no statistically established speedup or RAM reduction is claimed.
Visual evidence
strata-2077-fixed.mp4
How to test
a/note.txtandb/note.txtwith different contents.b/note.txt, paste it intoa, and choose Replace.Expected result: each Undo returns the moved item to
band restores the original ina, including its contents and folder customizations. A new arrival is never silently overwritten.Related issue
Closes #2077