fix(saves): the Saves page and the save editor use the profile the game opens, not the first one found #193
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!193
Loading…
Reference in a new issue
No description provided.
Delete branch "mooki/LongshotLauncher:fix/editor-game-profile"
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: fix · Risk: low · Tested on: Linux (Arch, kernel 7.2.15), .NET SDK 10.0.113: the launcher's core tests, its release tests and a build of the whole solution; no Windows PC, no game · Needs: Windows
TL;DR
The Saves page lists the slots of the first profile folder it finds in Longshot's save folder, and the Progress view I added in #186 edits that same folder. The game opens only one profile. A stray profile beside it (a copy made by hand) sorts first, so the page showed, and Progress edited, a save the game never reads: the edit said done and the game showed the save as it was. Now both use the game's profile when it is there, and the first one found only when it is not.
Breakdown
savefolder (a Hookshot profile copied in by hand, a leftover), who use the Saves page or the Progress view (#186).LauncherService.SaveFolder()(what Progress edits, and the slots the Saves page lists) and the Saves page's own row tookSaves.Shared(env).Profiles[0], the first folder in ordinal order. The game opens onlySaves.ImportTarget(env)(5a3c9e1f...0001), and every import writes there. A stray profile with a lower id sorts first and was the one shown and edited.Saves.ShownProfile(env): the game's profile when it is in the save folder, else the first one found (as before), null when there is none.LauncherService.SaveFolder()and the Saves page's row use it.Why
#186 added the Progress view to the Saves page: it runs Longshot's save editor on the save the page lists (
LauncherService.SaveFolder(),App/LauncherService.cs:503on mainf2e40a0), which isset.Profiles[0].Path, the first profile folder found. When I reviewed the other saves PRs (#182 and #183) I saw the same line in #183'sSaveSlots.LongshotSaveand ran the case (#183 (comment)); it applies to my own PR too.Saves.ImportTargetsays why it matters: "Another profile folder in save\ (a stray one, a copy made by hand) is never read by the game, so an import never goes there" (Core/Saves.cs, from host/nn_applet.c's one user). With a stray profile0123...beside the game's5a3c9e1f...,Saves.Shared(env).Profiles[0]is the stray one. I ran it: the page's slots and Progress's folder were the stray profile's; the game's profile was never shown.The edit has a backup first and the editor reads back what it wrote, so nothing is lost; the harm is an edit of the wrong save, reported as done.
What changed
Core/Saves.cs(+7):ShownProfile(env).App/LauncherService.cs(-4 / +1):SaveFolder()isSaves.ShownProfile(SaveEnv).App/ViewModels/SavesViewModel.cs(1 line): the Saves page's own row showsSaves.ShownProfile(Env) ?? Env.SaveFolder(and the now unused local is gone).docs/saves.md(+1 / -1): Progress edits the profile the game opens.tests/launcher_core/ShownProfileChecks.cs(new) and one registration line intests/launcher_core/Program.cs.Unchanged on purpose:
Saves.Shared,Saves.ImportTarget,Saves.Pick(the Export picker still lists several profiles and asks); the other places that readProfiles[0]for an emulator's save; the editor's code and texts; no catalog change.How it was tested
Everything here was run by an AI agent (Claude Sonnet 5.5) working for me; the commands are given so anyone can rerun them. No Windows PC, no game, no GPU and no real save were used: every check is game-free, on Linux, on made-up saves in a temporary folder.
Environment: Arch Linux, kernel 7.2.15, .NET SDK 10.0.113 (the repository pins 10.0.404, which this PC does not have:
global.jsonwas changed in scratch copies for the runs and is not in the branch), 17 Nov 2026, basef2e40a0(launcher main), headf506942, load average 30 to 60 from other jobs on the PC (correctness checks only, nothing timed).f2e40a0; the neighbouring code the fix relies on; the existing checks for the area, to see what they do and do not cover.Appproject. In a made-up Longshot user folder on Linux makesave/0123456789abcdef0123456789abcdef(account.sav,slot_00) andsave/5a3c9e1f0b7d24680000000000000001(the game's:account.sav,slot_00,slot_01), and ask which profile the page shows. On main the page's code isSaves.Shared(env).Profiles[0]:Profiles[0]is01234567..., a stray profile the game never opens.bd1e513adds onlytests/launcher_core/ShownProfileChecks.csand its registration. It callsSaves.ShownProfile(env), which main does not have, so on main it stops at the build, not at a failing line (the choice lived in the App project, which the core tests do not compile; the next commit moves it into the core where they can reach it): Its assertions, which pass on the branch: no save gives null; the game's profile alone is shown; with a stray profile that sorts first the game's is shown (the check first asserts that the stray one does sort first, asSaves.Shared(env).Profiles[0]shows); with only a stray profile it is shown, as before.f506942is the fix:python -I tests/test_launcher_core.py --dotnet dotnetendslauncher core: 1,999 checks passed(main with the switch below: 1,994);dotnet build LongshotLauncher.slnx --configuration Releasebuilds the app with the new call sites with 0 warnings and 0 errors.f506942:Saves.ShownProfile(env)is5a3c9e1f..., the game's profile.python -I tests/test_release.py:Ran 37 tests ... OK, as on main.dotnet build LongshotLauncher.slnx --configuration Release(offline restore, the app and the screenshot tool): 0 warnings, 0 errors, as on main.fix/zip-import-aside,fix/zip-import-lock,fix/zip-damaged-entry,fix/zip-export-empty,fix/editor-game-profileandfix/edit-backups-label) into one scratch branch fromf2e40a0, one after the other: no conflict, 2,019 core checks pass (f2e40a0: 1,994; each branch adds its own), 37 release tests pass, the whole solution builds with 0 warnings.f2e40a0, and earlier mains) attests/launcher_core/BuildReportChecks.cs:69-70:The home folder taken out before a line is cut: no cut leaves part of the user's name.It is main's own check of the build report (not touched here), and the run aborts there, before the saves checks. I switched that one check off with anOperatingSystem.IsWindows()guard in scratch copies only (never committed, so the branch and this description are about code that has no such change), to let the rest of the suite run. With that switch main passes 1,994 checks, the number every count in this description is compared with.To rerun it:
python -I tests/test_launcher_core.py --dotnet dotnetandpython -I tests/test_release.pyin the checkout,dotnet build LongshotLauncher.slnx --configuration Release; to see the check fail first,git checkout bd1e513(the commit that adds only the check), run the first command, thengit checkout f506942.Risks
Saves.ShownProfilecompares the folder name with the game's id without case, as Windows file names are.Saves.Pick, which asks when several profiles are found; not changed here.Overlaps
Core/Saves.cs(one new method),App/LauncherService.cs,App/ViewModels/SavesViewModel.cs(one line of the Saves page's own row) anddocs/saves.md; the four zip branches editCore/SaveArchive.csand their own docs paragraphs, andfix/edit-backups-labeleditsCore/SaveBackups.csandWhatinSavesViewModel.cs, a different line. I merged all six: no conflict.SaveSlots.LongshotSavetakesProfiles[0]too, and could callSaves.ShownProfileonce this is on main (my review comment on #183: #183 (comment)).App/LauncherService.cs,App/ViewModels/SavesViewModel.csanddocs/saves.md, which this branch also edits, so the order does not matter to the conflict: #55 rebases either way. The intent agrees: #55'sSaveProfilePathisSaves.ImportTarget(SaveEnv)(App/LauncherService.cs:478on its head), the game's profile for the selected player, andSaves.ShownProfile(env)takes the environment of the player in use. I did not run #55.New on this forge; not opened on GitHub.