fix(saves): the Saves page and the save editor use the profile the game opens, not the first one found #193

Merged
HumanBean merged 2 commits from mooki/LongshotLauncher:fix/editor-game-profile into main 2026-11-17 22:59:02 +00:00
Member

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

  • Who it helps: players with a second profile folder in Longshot's save folder (a Hookshot profile copied in by hand, a leftover), who use the Saves page or the Progress view (#186).
  • What was wrong: LauncherService.SaveFolder() (what Progress edits, and the slots the Saves page lists) and the Saves page's own row took Saves.Shared(env).Profiles[0], the first folder in ordinal order. The game opens only Saves.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.
  • What changes: a new 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.
  • What does not change: a save with only the game's profile, or only one other profile (the same folder as before); imports, exports, backups and restores (they already used the game's profile); the editor itself; every text on screen.
  • How it was checked: a check written first (it needs the new method, so on main it stops at the build; the choice used to live in the App project, which the core tests do not compile), passing here (1,999 checks; main 1,994), release tests, the whole solution builds with 0 warnings, and a throwaway program that asks which profile is shown with a stray and the game's profile, on main and on the branch.
  • What is still open: a Windows run; the Progress view itself needs a build whose tools carry the save editor (Longshot#1401's release), which I did not have, so the editing was not run through this change.
  • Risk: low. It only changes which of several profiles is shown; with one profile nothing changes. For a player who had a stray profile first, the page now lists the game's slots, which is what the game shows.

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:503 on main f2e40a0), which is set.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's SaveSlots.LongshotSave and ran the case (#183 (comment)); it applies to my own PR too.

Saves.ImportTarget says 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 profile 0123... beside the game's 5a3c9e1f..., 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() is Saves.ShownProfile(SaveEnv).
  • App/ViewModels/SavesViewModel.cs (1 line): the Saves page's own row shows Saves.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 in tests/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 read Profiles[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.json was changed in scratch copies for the runs and is not in the branch), 17 Nov 2026, base f2e40a0 (launcher main), head f506942, load average 30 to 60 from other jobs on the PC (correctness checks only, nothing timed).

  1. Reading first. The merged pull request this follows (#186) and its comments and review threads, and the code it changed, at launcher main f2e40a0; the neighbouring code the fix relies on; the existing checks for the area, to see what they do and do not cover.
  2. The bug on main, by hand. A throwaway program (not in the branch) that references the launcher's App project. In a made-up Longshot user folder on Linux make save/0123456789abcdef0123456789abcdef (account.sav, slot_00) and save/5a3c9e1f0b7d24680000000000000001 (the game's: account.sav, slot_00, slot_01), and ask which profile the page shows. On main the page's code is Saves.Shared(env).Profiles[0]: Profiles[0] is 01234567..., a stray profile the game never opens.
  3. The check first. Commit bd1e513 adds only tests/launcher_core/ShownProfileChecks.cs and its registration. It calls Saves.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):
    error CS0117: 'Saves' does not contain a definition for 'ShownProfile'
    
    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, as Saves.Shared(env).Profiles[0] shows); with only a stray profile it is shown, as before.
  4. The fix and the same check. Commit f506942 is the fix: python -I tests/test_launcher_core.py --dotnet dotnet ends launcher core: 1,999 checks passed (main with the switch below: 1,994); dotnet build LongshotLauncher.slnx --configuration Release builds the app with the new call sites with 0 warnings and 0 errors.
  5. The same steps on the branch. The same program on f506942: Saves.ShownProfile(env) is 5a3c9e1f..., the game's profile.
  6. The release tests and the whole solution. 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.
  7. The six branches together. I merged the six branches (fix/zip-import-aside, fix/zip-import-lock, fix/zip-damaged-entry, fix/zip-export-empty, fix/editor-game-profile and fix/edit-backups-label) into one scratch branch from f2e40a0, 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.
  8. The one inherited Linux check. On this PC the core suite stops on plain main (f2e40a0, and earlier mains) at tests/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 an OperatingSystem.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.
  9. Not run: a Windows PC (NTFS renames, junctions, Explorer's and 7-Zip's zips, the Save As dialog), the game, a real save, a click-through of the window, the GPU, and CI's compile-and-test (it is started by hand on this forge, and was not started). The Progress view and the editor themselves (they need a build whose tools carry Longshot#1401's script; I ran only which folder they are given), and a Windows save folder (the game's id is compared without case there).

To rerun it: python -I tests/test_launcher_core.py --dotnet dotnet and python -I tests/test_release.py in 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, then git checkout f506942.

Risks

  • The Saves page lists a different profile than before for a player who had a stray profile first; that is the one the game opens.
  • Saves.ShownProfile compares the folder name with the game's id without case, as Windows file names are.
  • The Export picker still goes through Saves.Pick, which asks when several profiles are found; not changed here.

Overlaps

  • The other five branches (my small fixes for the saves stack, opened together): it touches Core/Saves.cs (one new method), App/LauncherService.cs, App/ViewModels/SavesViewModel.cs (one line of the Saves page's own row) and docs/saves.md; the four zip branches edit Core/SaveArchive.cs and their own docs paragraphs, and fix/edit-backups-label edits Core/SaveBackups.cs and What in SavesViewModel.cs, a different line. I merged all six: no conflict.
  • #183 (one slot at a time, WIP, on hold): replaying #183's two own commits on top of this branch conflicts in the same files as on plain main, and in nothing new. It is the same problem #183's review has: SaveSlots.LongshotSave takes Profiles[0] too, and could call Saves.ShownProfile once this is on main (my review comment on #183: #183 (comment)).
  • #55 (player profiles and progress previews, open): it already conflicts with main in App/LauncherService.cs, App/ViewModels/SavesViewModel.cs and docs/saves.md, which this branch also edits, so the order does not matter to the conflict: #55 rebases either way. The intent agrees: #55's SaveProfilePath is Saves.ImportTarget(SaveEnv) (App/LauncherService.cs:478 on its head), the game's profile for the selected player, and Saves.ShownProfile(env) takes the environment of the player in use. I did not run #55.

New on this forge; not opened on GitHub.

**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 - **Who it helps:** players with a second profile folder in Longshot's `save` folder (a Hookshot profile copied in by hand, a leftover), who use the Saves page or the Progress view ([#186](https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/186)). - **What was wrong:** `LauncherService.SaveFolder()` (what Progress edits, and the slots the Saves page lists) and the Saves page's own row took `Saves.Shared(env).Profiles[0]`, the first folder in ordinal order. The game opens only `Saves.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. - **What changes:** a new `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. - **What does not change:** a save with only the game's profile, or only one other profile (the same folder as before); imports, exports, backups and restores (they already used the game's profile); the editor itself; every text on screen. - **How it was checked:** a check written first (it needs the new method, so on main it stops at the build; the choice used to live in the App project, which the core tests do not compile), passing here (1,999 checks; main 1,994), release tests, the whole solution builds with 0 warnings, and a throwaway program that asks which profile is shown with a stray and the game's profile, on main and on the branch. - **What is still open:** a Windows run; the Progress view itself needs a build whose tools carry the save editor (Longshot#1401's release), which I did not have, so the editing was not run through this change. - **Risk:** low. It only changes which of several profiles is shown; with one profile nothing changes. For a player who had a stray profile first, the page now lists the game's slots, which is what the game shows. ## Why [#186](https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/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:503` on main `f2e40a0`), which is `set.Profiles[0].Path`, the first profile folder found. When I reviewed the other saves PRs ([#182](https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/182) and [#183](https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/183)) I saw the same line in #183's `SaveSlots.LongshotSave` and ran the case (https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/183#issuecomment-45978); it applies to my own PR too. `Saves.ImportTarget` says 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 profile `0123...` beside the game's `5a3c9e1f...`, `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()` is `Saves.ShownProfile(SaveEnv)`. - `App/ViewModels/SavesViewModel.cs` (1 line): the Saves page's own row shows `Saves.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 in `tests/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 read `Profiles[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.json` was changed in scratch copies for the runs and is not in the branch), 17 Nov 2026, base `f2e40a0` (launcher main), head `f506942`, load average 30 to 60 from other jobs on the PC (correctness checks only, nothing timed). 1. **Reading first.** The merged pull request this follows ([#186](https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/186)) and its comments and review threads, and the code it changed, at launcher main `f2e40a0`; the neighbouring code the fix relies on; the existing checks for the area, to see what they do and do not cover. 2. **The bug on main, by hand.** A throwaway program (not in the branch) that references the launcher's `App` project. In a made-up Longshot user folder on Linux make `save/0123456789abcdef0123456789abcdef` (`account.sav`, `slot_00`) and `save/5a3c9e1f0b7d24680000000000000001` (the game's: `account.sav`, `slot_00`, `slot_01`), and ask which profile the page shows. On main the page's code is `Saves.Shared(env).Profiles[0]`: `Profiles[0]` is `01234567...`, a stray profile the game never opens. 3. **The check first.** Commit `bd1e513` adds only `tests/launcher_core/ShownProfileChecks.cs` and its registration. It calls `Saves.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): ``` error CS0117: 'Saves' does not contain a definition for 'ShownProfile' ``` 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, as `Saves.Shared(env).Profiles[0]` shows); with only a stray profile it is shown, as before. 4. **The fix and the same check.** Commit `f506942` is the fix: `python -I tests/test_launcher_core.py --dotnet dotnet` ends `launcher core: 1,999 checks passed` (main with the switch below: 1,994); `dotnet build LongshotLauncher.slnx --configuration Release` builds the app with the new call sites with 0 warnings and 0 errors. 5. **The same steps on the branch.** The same program on `f506942`: `Saves.ShownProfile(env)` is `5a3c9e1f...`, the game's profile. 6. **The release tests and the whole solution.** `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. 7. **The six branches together.** I merged the six branches (`fix/zip-import-aside`, `fix/zip-import-lock`, `fix/zip-damaged-entry`, `fix/zip-export-empty`, `fix/editor-game-profile` and `fix/edit-backups-label`) into one scratch branch from `f2e40a0`, 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. 8. **The one inherited Linux check.** On this PC the core suite stops on plain main (`f2e40a0`, and earlier mains) at `tests/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 an `OperatingSystem.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. 9. **Not run:** a Windows PC (NTFS renames, junctions, Explorer's and 7-Zip's zips, the Save As dialog), the game, a real save, a click-through of the window, the GPU, and CI's compile-and-test (it is started by hand on this forge, and was not started). The Progress view and the editor themselves (they need a build whose tools carry Longshot#1401's script; I ran only which folder they are given), and a Windows save folder (the game's id is compared without case there). To rerun it: `python -I tests/test_launcher_core.py --dotnet dotnet` and `python -I tests/test_release.py` in 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, then `git checkout f506942`. ## Risks - The Saves page lists a different profile than before for a player who had a stray profile first; that is the one the game opens. - `Saves.ShownProfile` compares the folder name with the game's id without case, as Windows file names are. - The Export picker still goes through `Saves.Pick`, which asks when several profiles are found; not changed here. ## Overlaps - **The other five branches** (my small fixes for the saves stack, opened together): it touches `Core/Saves.cs` (one new method), `App/LauncherService.cs`, `App/ViewModels/SavesViewModel.cs` (one line of the Saves page's own row) and `docs/saves.md`; the four zip branches edit `Core/SaveArchive.cs` and their own docs paragraphs, and `fix/edit-backups-label` edits `Core/SaveBackups.cs` and `What` in `SavesViewModel.cs`, a different line. I merged all six: no conflict. - **[#183](https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/183)** (one slot at a time, WIP, on hold): replaying #183's two own commits on top of this branch conflicts in the same files as on plain main, and in nothing new. It is the same problem #183's review has: `SaveSlots.LongshotSave` takes `Profiles[0]` too, and could call `Saves.ShownProfile` once this is on main (my review comment on #183: https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/183#issuecomment-45978). - **[#55](https://git.magicbean.dev/MagicBeanDev/LongshotLauncher/pulls/55)** (player profiles and progress previews, open): it already conflicts with main in `App/LauncherService.cs`, `App/ViewModels/SavesViewModel.cs` and `docs/saves.md`, which this branch also edits, so the order does not matter to the conflict: #55 rebases either way. The intent agrees: #55's `SaveProfilePath` is `Saves.ImportTarget(SaveEnv)` (`App/LauncherService.cs:478` on its head), the game's profile for the selected player, and `Saves.ShownProfile(env)` takes the environment of the player in use. I did not run #55. New on this forge; not opened on GitHub.
LauncherService.SaveFolder (and the Saves page's own row) took the first profile folder found in Longshot's save\ folder. A stray one
beside the game's (a copy made by hand) sorts first, so Progress edited a save the game never reads and the page listed its slots: the edit
said done and the game showed the save as it was. The game opens only Saves.ImportTarget (host/nn_applet.c's one user).

These checks need Saves.ShownProfile, which main does not have, so on main they stop at the build: the choice lives in the App project,
which the core tests do not compile, and the next commit moves it into the core where they can reach it.

Assisted-by: Claude Sonnet 5.5
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
fix(saves): the Saves page and the save editor use the profile the game opens, not the first one found
All checks were successful
CI / Compile and test (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 6s
f50694215c
Saves.ShownProfile gives the game's profile (Saves.UserId) when it is in Longshot's save folder, else the first one found, as before.
LauncherService.SaveFolder (what Progress edits, and the slots the Saves page lists) and the Saves page's own row use it, so a stray profile
beside the game's (a copy made by hand, which sorts first) is no longer the one edited: the edit and its backup were of a save the game
never reads. No new text. docs/saves.md says it.

Checks: core tests 1,988 pass (main 1,983 with one Linux-only check of main's own switched off); the whole solution builds, 0 warnings.

Assisted-by: Claude Sonnet 5.5
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
HumanBean deleted branch fix/editor-game-profile 2026-11-17 22:59:03 +00:00
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!193
No description provided.