WIP: feat(saves): batched 6-slot Reorder mode with pre-flight safety checks and single SlotSwap backup #254

Draft
Jer9 wants to merge 2 commits from Jer9/LongshotLauncher:feat/saves-slot-reorder into main
First-time contributor

Players organizing saves across Slot 1–Slot 6 currently have no way to rearrange slot order without manually renaming folders on disk. Stacked cleanly on #253 (feat/saves-slot-previews-main), this adds an explicit Reorder mode on the Saves tab that arranges slot_00–slot_05 in memory and applies the full permutation atomically on disk with a single whole-save backup first (BackupKind.SlotSwap).

Opened as WIP because live in-game verification of slot reordering (including leaving slot_00 / slot_01 empty and confirming in-game Load screen sort order) is still required before merge.

Summary

  • Atomic 6-slot reorder engine (Core/SaveSlotOrder.cs, Core/SaveBackups.cs):
    • Strictly enforces ^slot_0[0-5]$ (SaveSlotOrder.IsGameSlot), rejecting slot_000, slot_06+, and path-traversal names before touching disk.
    • Pre-flight checks run before taking any backup: enforces whole-save Saves.RefuseLinks(save) before resolving Saves.Real(save) (refusing both a symlinked/junctioned save root and any linked slot/file inside it), verifies every source slot exists, checks for destination collisions against unmoved slots, refuses to overwrite/delete any orphaned .slot_NN.longshot-old left by an earlier failed reorder, and refuses while Longshot, Hookshot, or an emulator is running.
    • Takes a single slotswap-<stamp> whole-save backup (skipping hidden .slot_*.longshot-old / .slot_*.longshot-staging folders), listed in Restore from a backup as "Before slots were reordered" (BackupKind.SlotSwap).
    • Performs two-phase renames with explicit rollbackFailed tracking: reports "Nothing was changed" only when rollback fully succeeds, and accurately names stranded .slot_NN.longshot-old folders if rollback itself fails.
  • Saves tab Reorder UX (App/ViewModels/SavesViewModel.cs, App/Views/SavesView.axaml):
    • Clicking Reorder expands to all 6 in-game positions (Slot 1–Slot 6, showing empty positions as faint Slot N · Empty) with a sticky Cancel / Save order bar pinned above the scrollable list (c:Pad.Back="True" on Cancel), collapsing with zero layout spacing when not reordering.
    • Uses ObservableCollection<SlotRowViewModel>.Move on ▲/▼ to preserve keyboard and gamepad focus without recreating item containers.
    • Disables conflicting commands (Progress, Import, Hookshot, Export, Backups) while in Reorder mode, preserves any slot_06+ folders untouched with an explanatory note, and calls Reload() on failure so UI state always matches disk.
  • Tests & screenshots (tests/launcher_core/SaveSlotPreviewChecks.cs, tests/launcher_app/Program.cs, tools/screenshots/Program.cs):
    • Adds 17 core checks for SaveSlotOrder (strict regex, pre-flight collision, save-root and slot-level junction refusal, orphan guard, hidden temp skip during backup, clean rollback, failed rollback naming .slot_NN.longshot-old, BackupKind.SlotSwap listing, running-game refusal, 6-slot batch into empty slots, no-op), full app-level SaveSlotReorder tests, and a saves-reorder screenshot scene.

Screenshots & walkthrough

See the attached animated WebP walkthrough and screenshots in the first comment below.

Testing

Tested (Windows 11, .NET SDK 10.0.404):

  • dotnet build LongshotLauncher.slnx -c Release -p:RestoreLockedMode=true: 0 warnings, 0 errors; LauncherCoreTests.csproj: 0 warnings, 0 errors; zero packages.lock.json changes.
  • dotnet format Core/LongshotLauncher.Core.csproj --verify-no-changes --include Core/SaveSlotPreview.cs Core/SaveSlotOrder.cs: PASS (exit 0).
  • dotnet run --project tests/launcher_app/LauncherAppTests.csproj -c Release -p:RestoreLockedMode=true: PASS (includes SaveSlotPreviews + SaveSlotReorder).
  • Core checks on compiled LauncherCoreTests.dll: SaveSlotPreviewChecks (incl. SaveSlotOrder) 39/39 passed, plus SaveArchiveChecks (78/78), SaveBackupsChecks (30/30), PadChecks, IconChecks, TranslationChecks, and ShownProfileChecks all PASS.
  • scripts/translations.py: 0 new faults (only the 4 pre-existing leftover #244 keys on main).
  • Headless screenshots (saves-backups-listed, saves-reorder) and interactive animated walkthrough frames: rendered and visually inspected — zero alignment shift in normal mode and clean sticky Reorder bar with disabled right-side actions in Reorder mode.

Still to test (required before removing WIP / merging):

  • Live in-game verification of reordered slots: test loading Longshot after moving saves into new slot numbers — including leaving slot_00 / slot_01 empty — to confirm both that the game loads those slots cleanly and whether the in-game Load screen orders slots by slot_NN folder number or by caption.sav's internal header timestamp.
  • Linux / Steam Deck gamepad focus check during ▲/▼ moves and full Linux CI run.

Risks

  • Medium-low. Writes only when the player clicks Save order, refuses while any game/emulator is running, refuses links/orphans/collisions pre-flight, takes one whole-save backup first (restorable via Restore from a backup), and rolls back two-phase renames on fault. Kept WIP: until in-game verification confirms slot loading with leading empty gaps.

Assisted-by: Antigravity

Players organizing saves across Slot 1–Slot 6 currently have no way to rearrange slot order without manually renaming folders on disk. Stacked cleanly on #253 (`feat/saves-slot-previews-main`), this adds an explicit **Reorder** mode on the Saves tab that arranges `slot_00`–`slot_05` in memory and applies the full permutation atomically on disk with a single whole-save backup first (`BackupKind.SlotSwap`). > Opened as **WIP** because **live in-game verification of slot reordering (including leaving `slot_00` / `slot_01` empty and confirming in-game Load screen sort order) is still required before merge**. ## Summary - **Atomic 6-slot reorder engine (`Core/SaveSlotOrder.cs`, `Core/SaveBackups.cs`):** - Strictly enforces `^slot_0[0-5]$` (`SaveSlotOrder.IsGameSlot`), rejecting `slot_000`, `slot_06+`, and path-traversal names before touching disk. - Pre-flight checks run **before** taking any backup: enforces whole-save `Saves.RefuseLinks(save)` before resolving `Saves.Real(save)` (refusing both a symlinked/junctioned save root and any linked slot/file inside it), verifies every source slot exists, checks for destination collisions against unmoved slots, refuses to overwrite/delete any orphaned `.slot_NN.longshot-old` left by an earlier failed reorder, and refuses while Longshot, Hookshot, or an emulator is running. - Takes a single `slotswap-<stamp>` whole-save backup (skipping hidden `.slot_*.longshot-old` / `.slot_*.longshot-staging` folders), listed in Restore from a backup as *"Before slots were reordered"* (`BackupKind.SlotSwap`). - Performs two-phase renames with explicit `rollbackFailed` tracking: reports *"Nothing was changed"* only when rollback fully succeeds, and accurately names stranded `.slot_NN.longshot-old` folders if rollback itself fails. - **Saves tab Reorder UX (`App/ViewModels/SavesViewModel.cs`, `App/Views/SavesView.axaml`):** - Clicking **Reorder** expands to all 6 in-game positions (`Slot 1`–`Slot 6`, showing empty positions as faint `Slot N · Empty`) with a sticky **Cancel / Save order** bar pinned above the scrollable list (`c:Pad.Back="True"` on **Cancel**), collapsing with zero layout spacing when not reordering. - Uses `ObservableCollection<SlotRowViewModel>.Move` on `▲`/`▼` to preserve keyboard and gamepad focus without recreating item containers. - Disables conflicting commands (`Progress`, `Import`, `Hookshot`, `Export`, `Backups`) while in Reorder mode, preserves any `slot_06+` folders untouched with an explanatory note, and calls `Reload()` on failure so UI state always matches disk. - **Tests & screenshots (`tests/launcher_core/SaveSlotPreviewChecks.cs`, `tests/launcher_app/Program.cs`, `tools/screenshots/Program.cs`):** - Adds 17 core checks for `SaveSlotOrder` (strict regex, pre-flight collision, save-root and slot-level junction refusal, orphan guard, hidden temp skip during backup, clean rollback, failed rollback naming `.slot_NN.longshot-old`, `BackupKind.SlotSwap` listing, running-game refusal, 6-slot batch into empty slots, no-op), full app-level `SaveSlotReorder` tests, and a `saves-reorder` screenshot scene. ## Screenshots & walkthrough See the attached animated WebP walkthrough and screenshots in the first comment below. ## Testing **Tested** (Windows 11, .NET SDK `10.0.404`): - `dotnet build LongshotLauncher.slnx -c Release -p:RestoreLockedMode=true`: **0 warnings, 0 errors**; `LauncherCoreTests.csproj`: **0 warnings, 0 errors**; zero `packages.lock.json` changes. - `dotnet format Core/LongshotLauncher.Core.csproj --verify-no-changes --include Core/SaveSlotPreview.cs Core/SaveSlotOrder.cs`: **PASS (exit 0)**. - `dotnet run --project tests/launcher_app/LauncherAppTests.csproj -c Release -p:RestoreLockedMode=true`: **PASS** (includes `SaveSlotPreviews` + `SaveSlotReorder`). - Core checks on compiled `LauncherCoreTests.dll`: `SaveSlotPreviewChecks` (incl. `SaveSlotOrder`) **39/39 passed**, plus `SaveArchiveChecks` (78/78), `SaveBackupsChecks` (30/30), `PadChecks`, `IconChecks`, `TranslationChecks`, and `ShownProfileChecks` all **PASS**. - `scripts/translations.py`: **0 new faults** (only the 4 pre-existing leftover #244 keys on `main`). - Headless screenshots (`saves-backups-listed`, `saves-reorder`) and interactive animated walkthrough frames: rendered and visually inspected — zero alignment shift in normal mode and clean sticky Reorder bar with disabled right-side actions in Reorder mode. **Still to test (required before removing WIP / merging):** - **Live in-game verification of reordered slots:** test loading Longshot after moving saves into new slot numbers — including leaving `slot_00` / `slot_01` empty — to confirm both that the game loads those slots cleanly and whether the in-game Load screen orders slots by `slot_NN` folder number or by `caption.sav`'s internal header timestamp. - Linux / Steam Deck gamepad focus check during `▲`/`▼` moves and full Linux CI run. ## Risks - **Medium-low.** Writes only when the player clicks **Save order**, refuses while any game/emulator is running, refuses links/orphans/collisions pre-flight, takes one whole-save backup first (restorable via **Restore from a backup**), and rolls back two-phase renames on fault. Kept `WIP:` until in-game verification confirms slot loading with leading empty gaps. Assisted-by: Antigravity
feat(saves): show read-only per-slot thumbnails, location, era, progress stats, and full date/time
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Compile and test (pull_request) Blocked by required conditions
84f94a3ea5
Adds a strictly read-only, bounded parser (Core/SaveSlotPreview.cs) for caption.sav (area name via SaveEditorText.Humanize, Child/Adult era, and bounded JPEG thumbnail) and progress.sav (hearts, rupees, 3 Spiritual Stones, 6 Sage Medallions, Gold Skulltulas, and main-quest progress), plus Durations.WhenFull for full date+time on the Saves tab.

- Core/SaveSlotPreview.cs: refuses symlinks/junctions via LinkTarget and FileAttributes.ReparsePoint on both the slot directory and leaf files, bounds file sizes and JPEG SOF dimensions before decoding, ignores duplicate field IDs and out-of-range values, handles trailing bytes, and degrades cleanly to the slot-number badge.
- Core/MakeGameRun.cs: adds Durations.WhenFull using Tr.F("{0}, {1}", Date(t, now), time) without changing Durations.When or SavesConfirmViewModel timestamps.
- App/ViewModels/SavesViewModel.cs & App/Views/SavesView.axaml: displays 16:9 thumbnail with fallback, Grid-based Title + Era badge (no badge clipping on truncation), Tr.P pluralized rupees/skulltulas, Launcher's <c:Bar> with clarified Main quest X/9 (Y%) label, and IDisposable cleanup of previous row Bitmaps on Reload().
- docs/saves.md, tests/launcher_core/SaveSlotPreviewChecks.cs, tests/launcher_app/Program.cs, tools/screenshots/Program.cs: reconciled docs, 21 core checks (trailing bytes, duplicate IDs, out-of-range values, directory/file link refusal, WhenFull), app ViewModel checks, and synthetic gradient JPEGs for headless screenshots.

Field hashes adapted from Traiver/OOT-SW2SE (MIT) and Anarkkie's LongshotLauncher#55 layout.

Assisted-by: Antigravity
feat(saves): batched 6-slot Reorder mode with pre-flight safety checks and single SlotSwap backup
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Compile and test (pull_request) Blocked by required conditions
895584a421
Stacks cleanly on read-only slot previews so players can arrange Slot 1..Slot 6 (including moving saves into empty slots) in memory and apply the full permutation atomically on disk with a single whole-save backup first (BackupKind.SlotSwap).

- Core/SaveSlotOrder.cs: enforces strict ^slot_0[0-5]$ (rejecting slot_000/slot_06+), runs pre-flight destination collision checks, orphaned .slot_NN.longshot-old guards (never deleting stranded folders on retry), and whole-save Saves.RefuseLinks before taking any backup; skips hidden .slot_*.longshot-old/.longshot-staging during backup copy; tracks rollbackFailed explicitly and names stranded .slot_NN.longshot-old folders accurately on partial rollback.
- Core/SaveBackups.cs & App/ViewModels/SavesViewModel.cs: adds BackupKind.SlotSwap ('Before slots were reordered'); uses ObservableCollection<SlotRowViewModel>.Move to preserve keyboard/gamepad focus during up/down moves; disables Progress/Import/Export/Hookshot/Backups commands during Reorder mode; preserves slot_06+ untouched with an explanatory note; calls Reload() on failure.
- App/Views/SavesView.axaml: adds Reorder header trigger, sticky top Cancel (with c:Pad.Back='True') / Save order bar, and per-row up/down buttons.
- tests/launcher_core/SaveSlotPreviewChecks.cs & tests/launcher_app/Program.cs: adds 16 core checks (strict regex, pre-flight collision, link refusal, orphan guard, backup skip, clean rollback, failed rollback naming .slot_NN.longshot-old, SlotSwap listing, 6-slot batch) and full app-level Reorder tests.

Assisted-by: Antigravity
Author
First-time contributor

Walkthrough & Screenshots

Animated walkthrough (entering Reorder mode on real local saves read-only, moving a slot down into empty slots with live renumbering and Save order enabling, then cancelling with zero disk writes):

Animated walkthrough of batched 6-slot Reorder mode

6-slot Reorder mode (real thumbnails, sticky Cancel / Save order bar, right-side actions disabled):

6-slot Reorder mode with real thumbnails and sticky top bar

Synthetic fixture (tools/screenshots saves-reorder scene):

6-slot Reorder mode synthetic fixture

### Walkthrough & Screenshots **Animated walkthrough (entering Reorder mode on real local saves read-only, moving a slot down into empty slots with live renumbering and `Save order` enabling, then cancelling with zero disk writes):** ![Animated walkthrough of batched 6-slot Reorder mode](https://git.magicbean.dev/attachments/892c7cf3-b41c-4682-9b1c-4d248479b124) **6-slot Reorder mode (real thumbnails, sticky Cancel / Save order bar, right-side actions disabled):** ![6-slot Reorder mode with real thumbnails and sticky top bar](https://git.magicbean.dev/attachments/b272a9cb-4f4a-41fd-af62-dbd052b847db) **Synthetic fixture (`tools/screenshots` `saves-reorder` scene):** ![6-slot Reorder mode synthetic fixture](https://git.magicbean.dev/attachments/73d341d7-6f5e-4de8-a9c1-0aea9709ecbc)
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Compile and test (pull_request) Blocked by required conditions
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'feat/saves-slot-reorder:Jer9-feat/saves-slot-reorder'
git switch 'Jer9-feat/saves-slot-reorder'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/LongshotLauncher!254
No description provided.