feat(saves): a Progress view per slot shows what a save has and is missing, and edits it with a backup first #186
No reviewers
Labels
No labels
area/build
area/install
area/saves
area/tooling
area/ui
area/updates
ci: approved
good first issue
gpu/amd
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
platform/linux
platform/steam-deck
platform/windows
priority
critical
priority
high
priority
low
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/LongshotLauncher!186
Loading…
Reference in a new issue
No description provided.
Delete branch "mooki/LongshotLauncher:saves-editor"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type: feat · Risk: medium · Tested on: Linux (Arch, kernel 7.2.15), .NET SDK 10.0.113, Python 3.14.8: the launcher's core and release tests, a build of the whole solution, and the launcher's code and view models against the real save editor on made-up saves; no Windows PC, no real game or save · Needs: Windows (a real save), and a Longshot release whose tools carry the save editor (MagicBeanDev/Longshot#1401 merged)
TL;DR
Finishing a save, setting one up for a test or fixing a mistake means leaving the launcher for the command line, and the launcher cannot say what a save is missing, because it reads nothing inside one. I added a Progress button to each slot of the Saves page: it shows what the slot has and is missing, by name and area, and makes the usual edits with a backup first, refused while a game runs. It runs Longshot's own save editor from the build's tools (MagicBeanDev/Longshot#1401), so the launcher carries no second copy of its rules. I checked it with the real editor on made-up saves and the launcher's tests; nothing ran on Windows.
Breakdown
--jsonfrom the build's own tools (Core/SaveEditor.cs,SaveEditorAnswer.cs,SaveEditorReport.cs).builds.json, settings, releases, the build; no package; copying, importing and exporting saves still need no Python; nothing runs until a player presses Progress. #55's preview code (SavePreview,SaveProgress, the Home card) is not touched.0e96947: the core tests 1,890 checks passed (main: 1,752; one check that fails on Linux on main itself is skipped in both runs, see How it was tested), the release tests 37 OK, the whole solution builds with 0 warnings and 0 errors, and the editor's real answers equal the fixtures the launcher is tested on. The launcher's code and its Progress view models were driven against the real editor on a made-up game and made-up saves (36 checks), and the nine screenshots below were drawn headless and looked at.Why
Players who finish a save, set one up for a test or put right something that went wrong can only do it from Longshot's command line or the game's Debug tools, and the launcher cannot even say what a save is missing because it reads nothing inside one. I added a Progress button to each slot of the Saves page that shows what the slot has and is missing, by name and area, and makes the usual edits, with a backup first and refused while a game runs. It does that by running Longshot's own offline save editor from the build's tools, not by carrying a second copy of the editor's rules: what a save can hold, and where, needs the game's own lists (names, chests, Gold Skulltulas, dungeons, quests), which only the editor reads.
Depends on MagicBeanDev/Longshot#1401, builds on #55
Depends on MagicBeanDev/Longshot#1401, the pull request that adds
scripts/longshot_save_editor.py, its guide and its tests. It was open and mergeable on 17 Nov 2026 with head6c45402bf, which is the editor I tested against. I need it with--jsonon every command, schema 1, and its reason codes, as that head has them. Merge it first. This change only works for a build made from a Longshot release that carries the script in its tools (the builders copyscripts/, so a release after the merge has it). Until then every version shows Progress switched off with the reason "This version has no save editor yet", and nothing else changes.Builds on #55 (Anarkkie, player profiles and progress previews, open, head
5d9e9d1). #55 gives each player a save of their own and a read-only picture of what it holds: slot pictures, a save card on Home, a grouped list of the items. As I read its code it cannot say what is missing (SaveProgressreads the table of values and not the key table at the end ofprogress.sav, where chests, Gold Skulltulas, heart pieces and bosses are), and it never edits ("Previews are read-only"). This is the other half: what is missing, by name and area, and the edits. I opened it on main, not on #55's branch (the forge opens a pull request onto main only, and #55 is large and still under review), so it works alone. After #55 the editor follows the selected player with one line, and its button sits in #55's slot detail; both are in Overlaps below. This pull request does not touch #55's preview code.What changed
Core/SaveEditor.cs,Core/SaveEditorReport.cs,Core/SaveEditorAnswer.cs(new, 556 lines): run the editor the wayPerfReportsrunsperf_report.py: the default build's own version's pinned Python, isolated (-I -B), in the game's environment, with the build's game folder (romfsholds the lists the editor reads), the save folder the Saves page lists, and the launcher's own backup folder. Every command is run with--jsonand its answer read (the editor's guide, "For programs":schema,command,ok): the report into records, the item and place lists, and each edit's lines, files, backup and read-back. A refusal isok: falsewith a reason code (SaveFailure.Code). For a game running, NX2navi waiting, a link, a backup folder inside the save, a failed write, a file that could not be read or written, game files or zstd the editor cannot use, another game version, a damaged file, a slot that is gone, a copy over a slot, the same slot and an area that needs Link's age, the launcher says it in its own words. For the rest (a count the game does not allow, the bag to give first, a name that fits two items, an unknown target or place) and for any code a newer editor adds, the editor's own words stay, because they hold what only it knows. An answer with a newerschemathan 1 says the launcher is older. A build with no save, no build, no game files, no tools, or tools from before the editor gets a reason instead. A slot is always passed asslot_NN: the Saves page counts from 1 (slot_00is Slot 1), and the editor's3would meanslot_03.Saves.Running, which leaves the launcher itself out). The editor checks again, backs the whole save folder up first, writes each file whole beside its place, reads it back and puts it back if that fails. The launcher never passes--force.App/ViewModels/SaveEditorViewModel.cs,SaveEditDialogs.cs,App/Views/SaveEditorView.axaml,SaveEditAskView.axaml,SaveEditConfirmView.axaml(new): the slot's page (place, hearts, rupees, the game's clock, a percentage that never says 100 while one thing is missing; every category with how many the slot has of how many; for the picked one its areas with every missing entry by name; Set all, Take all away, Set and Take away per area, Set per entry, Give…, Start place…, Copy slot…) and two dialogs. Give takes an item (counted ones an amount, within what the bags Link has hold), hearts, rupees or a dungeon's small keys. Start place takes one of the game's named places and, where the area has both, Link's age. Copy slot takes another slot or the next free one. Every edit is confirmed first with what the editor says it would change (its own--dry-run, which writes nothing), where the backup goes, and that the game must be closed; the page reads the files again after it.App/ViewModels/SavesViewModel.cs,App/Views/SavesView.axaml,App/LauncherService.cs: a Progress button on each slot row (off, with the reason in its tooltip and a line under the list, when there is no editor or the slot has noprogress.sav);SaveFolder()is now the one place the Saves page and the editor take the save folder from.Core/Saves.cs:SaveFailuregets the editor's reason code (Code), nothing else of it changes.tests/launcher_core/SaveEditorChecks.cs,tests/fixtures/save-editor/*,tests/save_editor_fixtures.py,tests/test_launcher_core.py: see How it was tested. The fixtures are the editor's real JSON on the made-up game and made-up saves of Longshot's own tests, kept as text; the launcher's repository holds no save and no game file.docs/saves.md,README.md,tools/screenshots/*: the guide's "Progress and edits", the README paragraph, and nine screenshot scenes drawn from a report authored with invented names (tools/screenshots/save-editor-report.json).Core/andApp/, and 619 are tests and tools.What it does not do:
language.txtto the editor's--languagebelongs in the editor.How it was tested
Environment. Linux (Arch), kernel 7.2.15, .NET SDK 10.0.113 (the repository pins 10.0.404; I changed
global.jsonin my own copy only and did not commit it), Python 3.14.8 (it runs the editor and the fixture check), 17 Nov 2026. Headsaves-editor@e68a815(three commits) on launcher main @0e96947. The editor is the head of MagicBeanDev/Longshot#1401,6c45402bf. Headless: no window, no display, no GPU, no game. A made-up game and made-up saves in temporary folders only; no real game file or save was read. The PC was busy with other jobs (load average between about 30 and 170 while these ran), so every test, build and throwaway-program run waited for and ran in the idle priority class through the workbench's test gate (https://github.com/mooki000/ls-workbench, its harness folder), which only changes how long it waits.Step by step:
f31b555. Main moved 16 commits and I rebased onto7a4a61e(two conflicts, both kept on both sides:tests/test_launcher_core.py, my newcheck_save_editorbeside #118's two new checks, andtools/screenshots/Program.cs, my nine scenes and their helpers next to #168's threesaves-confirm-*scenes and theirs). While I was checking that head, main moved again (#171, #179, #180 and #181 merged), so I rebased once more onto0e96947: the first two commits applied by themselves, and the docs commit conflicted in three places, again kept on both sides:README.md(the Saves row now names the .zip of #181 and Progress),docs/saves.md(the Tests list holds #181'sSaveArchiveChecks.csbullet and this branch'sSaveEditorChecks.csbullet) andtools/screenshots/Program.cs(#181's scene helpers, then this branch's).git range-diffof the three commits against the ones on7a4a61eshows only context differences. The merged hunks ofApp/LauncherService.cs,App/ViewModels/SavesViewModel.csandCore/Saves.csare in different places from main's changes (#166, #168, #175, #176, #181). #164's privacy rule (LauncherLog.AddandBugReport.Makescrub the user's name) already covers the page's log line and its "Copy for a bug report", which go through them; #169 changedSaves.Running, which the edit's refusal calls, and its tests pass here. Every check below was run on the final head (e68a815); the first-rebase headd4acbcepassed the same ones with 1,763 and 1,625 checks.python -I -B tests/test_launcher_core.py --dotnet dotnet(it buildstests/launcher_core, which compilesCore/, and runs the checks on fixtures and scratch folders): 1,890 checks passed on the head, and the same again with--longshotat agit archivesnapshot of the editor's head, with the contract check running. The same runner on main @0e96947passes 1,752, so this branch adds 138 checks, all inSaveEditorChecks.cs. They parse the editor's real report and check every category and area of it, the damaged slot, the lists, each edit's answer and every refusal with its code (the editor's own words kept for a hearts count over the game's, a bag that is not there and an unknown target; the launcher's words for a copy over a slot, a running game with the games named, another game version, a damaged file, a slot that is gone, a write that failed after the backup with the files put back, and every other code it says itself), a newer schema, a wrong command's answer, anokanswer from a command that exited 1, an answer that is not JSON, argparse's and Python's own last lines, the command the launcher builds (arguments, environment, UTF-8, no window, no--force), which build gets which reason, the plans (a slot isslot_NN, nothing that could read as an option), the refusal while a game runs (the editor is never started), and the real process code over a stand-in for the tools' Python (arguments with spaces and non-ASCII reach it as they are, its output is read as UTF-8, itserror:line and exit code become the refusal).tests/launcher_core/BuildReportChecks.cs:70("The home folder taken out before a line is cut: no cut leaves part of the user's name") fails on Linux and stops the whole run there, so no later check runs: I got the same failure at the same line on main and on the head (on7a4a61e, which I ran unpatched, and the line is unchanged on0e96947). It looks like a Windows-only expectation in #164. The check puts 290xcharacters before the home folder, and on Linux the home folder is replaced by~only where a path starts, not after other characters, so the line keeps the home folder's path with<user>in place of the name, cut at 300 (it ends<use), where the check expects it to end~/x.bars. The 1,890 and 1,752 above are from scratch copies of the head and of main in which I made that one check Windows-only and print the line's end instead (the same local change in both; it is not in the branch). I did not touch it here; it is #164's.python -I -B tests/test_release.py: 37 tests OK on the head and on main.tests/save_editor_fixtures.py --longshot <checkout>runs the editor on the made-up game and made-up saves that Longshot's own tests build and fails when its answer differs fromtests/fixtures/save-editor. At the editor's head it passes. To see it fail as it should, I renamed one reason code in a copy of the fixtures (damagedtodamaged_file): exit 1, "tests/fixtures/save-editor/error-damaged.json is not what Longshot's save editor prints now: the interface the launcher reads changed", with how to regenerate it. Against the Longshot commit thattests/longshot.refpins it says the checkout has noscripts/longshot_save_editor.pyand skips, so the pinned CI run skips it until the pin moves to a commit that has the editor. The editor's two scripts at6c45402bfare byte for byte the ones the fixtures were made from (687244f5d).Core/and drivesSaveEditingthrough the real process runner, with a small Python wrapper that answers only the editor's running-game check "none" (other jobs were running games on this PC; the editor refuses every edit there otherwise, which is the safety working). The made-up game and saves come from the editor's own test helpers (make_game,make_save_folder): slots 1, 2 and 4 and a damaged slot 3 (slot_02, 22 bytes). It printed: the report of four slots (three with 38 missing, one "slot_02/progress.sav is 22 bytes: not a save file"); 12 items with the dungeon's small keys and the hearts range 1 to 5; 5 places with their ages (one that cannot be loaded); a dry run (set skulltulas/TestArea: 2 of 2 changed, no backup); the refusal while a game runs (Running, coderunning, no process started); a real edit with the files written (slot_00/progress.sav,slot_00/caption.sav) and a backup of the whole save folder (account.sav,option.savand every slot); the same edit again (nothing to change, no second backup); the editor's refusals with their codes (damaged,out_of_range,needs_bag,would_overwrite,unknown_target); give, start and copy into a new slot; and the report after each.dotnet build LongshotLauncher.slnx --configuration Release --no-incremental: 0 warnings, 0 errors on the head (13 s), and no package added (the one project file this branch touches is the screenshots tool's, which copies its report JSON next to it). The repository's CI form, with-p:RestoreLockedMode=true, does not run on this PC: restore stops with four NU1004 errors (App/andCore/: "The package references have changed for net10.0" and "The project's runtime identifiers have changed"), because the lock files were made with SDK 10.0.404 and this one is 10.0.113. Main @0e96947stops with the same four, so it says nothing about this branch, which changes no lock file (the same four on the head before the first rebase). The plain build rewrites the twopackages.lock.jsonfiles; I built in scratch copies, so none is in the branch.python -I scripts/translations.pyprints no placeholder fault, only that each catalog lacks texts (the head: 185 of 819,es183; main: 65 of 699,es63), so it exits 1 on both; the 120 extra are this change's English-only texts. The core tests print the same as advice and do not fail on it.dotnet run --project tools/screenshots -c Release -- <folder> saves-progress saves-progress-off save-editor save-editor-skulltulas save-editor-confirm save-editor-running save-editor-give save-editor-start save-editor-failed, headless at 960 x 600, drawn again on the final head. Nothing is run to draw them: the report behind them is authored with invented names and numbers, and the editor's answers are the few lines of text an edit says. Three of the nine are pixel for pixel the ones I drew on the first rebase; the two Saves pages differ in about 4,400 pixels (#181 added ".zip" to two descriptions on that page and the clock follows the time), and the other four in a few hundred pixels at most. I looked at every one of the nine.pulls/N/files), fetched the heads of those that share a file with this branch and trial-merged each (git merge-tree --write-tree) against main and against this branch; a conflict that appears only with this branch is an overlap. The result and the hunks are under Overlaps.Rebased from main
f31b555onto0e96947; heade68a815. Patch: five hand-merged hunks over the two rebases (above), nothing else. Carried: nothing; every check above was rerun on the final head. Windows: not run. Game: not run, there is none involved.To rerun it:
python -I -B tests/test_launcher_core.py --dotnet dotnet --longshot <a checkout of MagicBeanDev/Longshot#1401's head>andpython -I -B tests/test_release.pyfrom the repository (the first stops at theBuildReportChecks.cs:70failure on Linux, on main too),dotnet build LongshotLauncher.slnx --configuration Release,python -I scripts/translations.py, and the screenshots command above. I can attach the two throwaway programs if a reviewer wants to run them.Not tested:
CreateNoWindow, the environment, paths) followsPerfReports, which ships.zstandard): only this PC's Python 3.14 ran the editor.mise run ci:smoke: not run, the tools it pins (dotnet 10.0.404, shellcheck, gitleaks, pre-commit) are not installed here. Its build step was run directly (above); its lint coversscripts/package.shand secrets, and its release testsscripts/release.py, none of which this change touches. The repository's own locked restore (-p:RestoreLockedMode=true) cannot run on this SDK. CircleCI has not run on this branch.Must be tested:
%LOCALAPPDATA%\Longshot\oot-save-backups\edit-<player>-<date>-<time>) and that the game loads the slot; start the game and try an edit (it must be refused, nothing written). Someone with a Windows PC and a real save: me by hand, or any Windows tester.Screenshots
Launcher screenshots only (CONTRIBUTING: no game files, no saves). The report behind them is authored with invented names and numbers.
Risk and rollback
What could break: Nothing runs until a player presses Progress. The Saves page's slot rows change (a button added;
SaveSlots()now takes its folder from the newSaveFolder(), the same folder as before). An edit writes a save, but only through the editor, after the confirmation, with the whole save backed up first, refused while a game runs, and put back if the write or the read-back fails. The editor's own rules are the main risk: a "set" writes what the game's lists name and nothing more, which the page's guide section says. A slot of another game version, a damaged file and a save folder holding a link are refused by the editor and shown in its words.Turning it off: revert the pull request: the Saves page is as before, and every backup an edit made stays in the backup folder (
edit-<player>-<date>-<time>;$XDG_DATA_HOME/longshot/save-backupon Linux,%LOCALAPPDATA%\Longshot\oot-save-backupson Windows) with the saves it kept.Compatibility: no change to the save files' format,
builds.json, settings, releases or the build; no package. The launcher still needs no Python for copying, importing or exporting saves; Python is used only by Progress, from the build's own tools, and in the optional--longshotcontract check.Overlaps
I read the open launcher pull requests' file lists on 17 Nov 2026 (13 of them at first, 11 later, after main moved), fetched the heads of the ones that share a file with this branch, and trial-merged each against main (now
0e96947) and against this branch (git merge-tree --write-tree --name-only), then read the hunks. #181 (export to one .zip), #179, #180 and #171 merged while I worked. #181 conflicted with this branch inREADME.md,docs/saves.mdand the screenshot scenes; I resolved those in the second rebase, keeping both sides (the README's Saves row now names the .zip and Progress; both test bullets are in the guide; both groups of scene helpers are in the tool). Of the open ones, only #55, #182, #183 (with #184 and #185) and #49 conflict with this branch in a file where they do not already conflict with main.5d9e9d1, still on an older main,c5e27ee, so it already conflicts with main today in the same files as with this branch:App/LauncherService.cs,App/ViewModels/SavesViewModel.cs,App/Views/SavesView.axaml,docs/saves.md,README.md, the test dispatcher and others). The hunks that are this branch's, read against the first rebase:App/LauncherService.cs(1: #55'sSaveSlots()withProfileProblemagainst this branch'sSaveFolder()andSaveEditor()),App/ViewModels/SavesViewModel.cs(1: where the slot list is built),App/Views/SavesView.axaml(2: the slot row, and the line under the list),docs/saves.md(1: the Tests list),README.mdand the test dispatcher. The resolution I would make: after #55,SaveFolder()returnsProfileProblem == null ? SaveProfilePath : null, so the editor edits the selected player's save and nothing else changes, and the Progress button goes into the slot detail that #55 adds (its slot list is a selectable list with a detail, not rows). Whoever merges second rebases these.7c78639andbe68020), and #184, #185 (rename instances' folders; Open saves folder and Open builds folder buttons), whose conflict lists with main and with this branch are the same as #182's and #183's, so I take them to be stacked on that series (not checked further). They already conflict with main inSavesViewModel.cs, the Lang catalogs,README.md,docs/saves.md, the test dispatcher and the screenshot scenes (their base is older than #181), and with this branch also inApp/MainWindow.axaml,App/Views/Views.cs(one template line and one view line each) andApp/Views/SavesView.axaml(the slot row, and the line under the list). In substance two things need a decision: #183 makes each slot row selectable with its own actions (Export, Copy to another slot, Delete) under the selected row, where this branch puts a Progress button at the right of the row; and #183's "Copy to another slot…" does what this branch's "Copy slot…" does (through the editor'scopy, which copies a slot'sprogress.savandcaption.sav). Also, #182 lists the backups folder by name (<command>-<name>-<stamp>) and an edit's backup here isedit-<player id>-<stamp>: reading its code, it would list it with the kind "Other" and could restore it (the backup is a whole save folder). I did not run that.App/MainWindow.axaml(one template line) is new with this branch;README.md,HomeView.axamlandMakeGameCommand.csconflict with main already.7a4a61e) #59 merged cleanly with this branch, and #151, #130, #50 and #42 conflicted with it only in the files where they conflicted with main already.fix/saves-shared-link, head8670cb0on main7a4a61e: a build started on its own reads the shared saves through a link): it merges cleanly with this branch (also after the second rebase). It sharesCore/Saves.cs,App/LauncherService.cs,README.mdanddocs/saves.mdwith it, but in other places: it addsLinkSavesand its checks toCore/Saves.cs, and a line toPlayFolder()and toGatherSaves(), while this branch adds aCodetoSaveFailureandSaveFolder()andSaveEditor()at the end ofLauncherService. The link it makes is in a build's own folder (user\save), not in the shared save folder the editor edits, which the editor does not read.Questions for you
AI-assisted: I wrote this with Claude Sonnet 5.5; the commits carry its trailers.
New on this forge; not opened on GitHub.