launcher: restart after an update that changes the launcher, also in the installed app; the status corner shows the new commit #3427

Merged
leonida/mandy
OreoFR merged 1 commit from oreofr/launcher-global-3 into main 2026-12-04 04:28:15 +00:00 AGit

Pull request successfully merged and closed

Member

Launcher change: needs OreoFR's review. AI-assisted.

What happened. On OreoFR's PC, the installed app (Mandy.exe, repo copy at main 312d88d1d) showed 6 updates. Update Mandy moved the copy to e1a13ab25; #3405/#3414, #3421 and #3425 change tools/leonida_launcher.py and its translations. The launcher did not restart. The window stayed on the old code, said "À jour", and its status corner still showed main 312d88d1d.

Root cause.

  • The restart depended on the exit code of the whole update. In 312d88d1d the window restarts only when restart_due(True, code, ...) is true (tools/leonida_launcher.py:5125), and restart_due needs code == 0 (:1067). On main it is the same code (:6271, :1516). run_update returns rebuild_if_changed(...) (312d88d1d:2047), and that is the exit code of the runtime build when d3d12/ changed (return build(), :1615). The six merges change d3d12/ (dlss.rs, fg.rs, ffx.rs, ...), so the build ran right after the pull. In the copy, the reflog shows the pull at 04:47:08, and d3d12/target/diag was written from 04:47:11 to 04:49 but holds no leonida.exe. So the build did not finish, code != 0, and restart_due returned false. Git had already moved the launcher files, so the window kept running old code over new files. The check_updates(fetch=False) that follows then said "Up to date".
  • The status corner's commit was read once. read_rail() is called only in __init__ (312d88d1d:4097; main :5115), so the corner keeps the commit from the window's start.
  • Not the cause: stdout in the frozen child. The suspect was that a windowed exe loses print(). It does not on this install. Mandy.exe --run-python probe.py, started with stdout=PIPE and CREATE_NO_WINDOW as spawn does, gives a real sys.stdout (TextIOWrapper, cp1252) and fd 1 works, and console_streams() covers the None case. I also ran the old 312d88d1d launcher's --update on a temporary clone (312d88d1d -> e1a13ab25): it prints @@launcher-updated and exits 0 when the build succeeds. The window no longer relies on that line anyway: see the fix.

Fix.

  • run() records launcher_fingerprint(REPO) (HEAD plus a SHA-256 of the LAUNCHER_FILES on disk) before Update Mandy starts. When the update ends, after_update compares it with launcher_changed: either the hash differs, or HEAD moved and git diff --name-only before after names a launcher file. The decision no longer needs the child's stdout, and it also works for a zip copy (hash only). The @@launcher-updated line still counts.
  • update_restart(updated, code, game_running): "restart" when the update succeeded (as before, restart_due). "ask" when the launcher files changed and the update then stopped with an error, such as a failed build: a dialog offers the restart and the output stays readable. If the player says no, the log tells them to close and reopen the launcher. Never while a game runs (restart_launcher/ask_restart return while self.process is set).
  • Restart: launcher_command() gives [Mandy.exe] in the installed app (the new process hands over to the repository's new launcher; is_hosted is false for the bundle's copy even with MANDY_HOST inherited) and python -I tools/leonida_launcher.py from source. The old window then calls root.destroy(). This part is unchanged; only its docstring is updated.
  • The status corner: read_rail_version() reads rail_version() (git rev-parse --abbrev-ref HEAD / --short HEAD) again after every update (after_update) and every check (show_update). The card line is kept (rail_text).
  • Two new strings, translated in de/es/fr/pt. docs/launcher.md updated.

Tests (tests/test_leonida_launcher.py). They are red on main e1a13ab25 (tools/ stashed, new tests kept): 4 errors (the functions don't exist) and 5 failures. All are green with the fix.

  • UpdateRestartWindowTests builds the real window (run_gui, Tk withdrawn) on a real temporary git repository. A fake update child commits a change and prints nothing on stdout, like a frozen child whose output is lost:
    • change in tools/leonida_launcher.py: restart requested (main: no restart)
    • change in tools/launcher_i18n/fr.json: restart requested (main: no restart)
    • change in d3d12/ only: no restart, no question
    • launcher changed and exit code 1 (tonight's failed build): the restart is offered (main: nothing)
    • status corner after a check, and after an update: main 312d88d1d -> main e1a13ab25 (main: unchanged)
  • Pure tests: update_restart; launcher_changed with a fake git (diff --name-only aaa bbb: launcher file -> true, d3d12/ only -> false, HEAD unchanged -> false); a zip copy (hash only); rail_text.
  • All standalone test files whose name contains launcher, tool, docs or i18n, plus test_text_write_line_endings, test_bug_report_info and test_win_launchers (29 files), run with scripts/run_standalone_tests.py -j 8: all OK. The i18n JSON files load (545 keys each). check_no_game_data passes on the changed files. compileall passes. There is still a single if __name__ == "__main__":.
  • Not tested: a real restart of the installed Mandy.exe (no game started, and no restart was triggered on this PC).

Windows 11, Python 3.12. No GPU involved.

🤖 Generated with Claude Code

Launcher change: needs OreoFR's review. AI-assisted. **What happened.** On OreoFR's PC, the installed app (Mandy.exe, repo copy at main `312d88d1d`) showed 6 updates. Update Mandy moved the copy to `e1a13ab25`; #3405/#3414, #3421 and #3425 change `tools/leonida_launcher.py` and its translations. The launcher did not restart. The window stayed on the old code, said "À jour", and its status corner still showed `main 312d88d1d`. **Root cause.** - **The restart depended on the exit code of the whole update.** In `312d88d1d` the window restarts only when `restart_due(True, code, ...)` is true (`tools/leonida_launcher.py:5125`), and `restart_due` needs `code == 0` (`:1067`). On main it is the same code (`:6271`, `:1516`). `run_update` returns `rebuild_if_changed(...)` (`312d88d1d:2047`), and that is the exit code of the runtime build when `d3d12/` changed (`return build()`, `:1615`). The six merges change `d3d12/` (`dlss.rs`, `fg.rs`, `ffx.rs`, ...), so the build ran right after the pull. In the copy, the reflog shows the pull at 04:47:08, and `d3d12/target/diag` was written from 04:47:11 to 04:49 but holds no `leonida.exe`. So the build did not finish, `code != 0`, and `restart_due` returned false. Git had already moved the launcher files, so the window kept running old code over new files. The `check_updates(fetch=False)` that follows then said "Up to date". - **The status corner's commit was read once.** `read_rail()` is called only in `__init__` (`312d88d1d:4097`; main `:5115`), so the corner keeps the commit from the window's start. - **Not the cause: stdout in the frozen child.** The suspect was that a windowed exe loses `print()`. It does not on this install. `Mandy.exe --run-python probe.py`, started with `stdout=PIPE` and `CREATE_NO_WINDOW` as `spawn` does, gives a real `sys.stdout` (`TextIOWrapper`, cp1252) and fd 1 works, and `console_streams()` covers the `None` case. I also ran the old `312d88d1d` launcher's `--update` on a temporary clone (`312d88d1d` -> `e1a13ab25`): it prints `@@launcher-updated` and exits 0 when the build succeeds. The window no longer relies on that line anyway: see the fix. **Fix.** - `run()` records `launcher_fingerprint(REPO)` (HEAD plus a SHA-256 of the `LAUNCHER_FILES` on disk) before Update Mandy starts. When the update ends, `after_update` compares it with `launcher_changed`: either the hash differs, or HEAD moved and `git diff --name-only before after` names a launcher file. The decision no longer needs the child's stdout, and it also works for a zip copy (hash only). The `@@launcher-updated` line still counts. - `update_restart(updated, code, game_running)`: `"restart"` when the update succeeded (as before, `restart_due`). `"ask"` when the launcher files changed and the update then stopped with an error, such as a failed build: a dialog offers the restart and the output stays readable. If the player says no, the log tells them to close and reopen the launcher. Never while a game runs (`restart_launcher`/`ask_restart` return while `self.process` is set). - Restart: `launcher_command()` gives `[Mandy.exe]` in the installed app (the new process hands over to the repository's new launcher; `is_hosted` is false for the bundle's copy even with `MANDY_HOST` inherited) and `python -I tools/leonida_launcher.py` from source. The old window then calls `root.destroy()`. This part is unchanged; only its docstring is updated. - The status corner: `read_rail_version()` reads `rail_version()` (`git rev-parse --abbrev-ref HEAD` / `--short HEAD`) again after every update (`after_update`) and every check (`show_update`). The card line is kept (`rail_text`). - Two new strings, translated in de/es/fr/pt. `docs/launcher.md` updated. **Tests** (`tests/test_leonida_launcher.py`). They are red on main `e1a13ab25` (tools/ stashed, new tests kept): 4 errors (the functions don't exist) and 5 failures. All are green with the fix. - `UpdateRestartWindowTests` builds the real window (`run_gui`, Tk withdrawn) on a real temporary git repository. A fake update child commits a change and prints nothing on stdout, like a frozen child whose output is lost: - change in `tools/leonida_launcher.py`: restart requested (main: no restart) - change in `tools/launcher_i18n/fr.json`: restart requested (main: no restart) - change in `d3d12/` only: no restart, no question - launcher changed and exit code 1 (tonight's failed build): the restart is offered (main: nothing) - status corner after a check, and after an update: `main 312d88d1d` -> `main e1a13ab25` (main: unchanged) - Pure tests: `update_restart`; `launcher_changed` with a fake git (`diff --name-only aaa bbb`: launcher file -> true, `d3d12/` only -> false, HEAD unchanged -> false); a zip copy (hash only); `rail_text`. - All standalone test files whose name contains launcher, tool, docs or i18n, plus `test_text_write_line_endings`, `test_bug_report_info` and `test_win_launchers` (29 files), run with `scripts/run_standalone_tests.py -j 8`: all OK. The i18n JSON files load (545 keys each). `check_no_game_data` passes on the changed files. `compileall` passes. There is still a single `if __name__ == "__main__":`. - Not tested: a real restart of the installed Mandy.exe (no game started, and no restart was triggered on this PC). Windows 11, Python 3.12. No GPU involved. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The window decided the restart only from the @@launcher-updated line of the
update child and only when the whole update exited 0. Tonight's update on
the installed app moved the copy 312d88d1d -> e1a13ab25 (launcher files
changed), then the runtime build that follows a d3d12/ change left no
leonida.exe: the exit code was not 0, restart_due said no, and the window
stayed on the old code over the new files. The status corner's commit was
read once at start, so it still showed main 312d88d1d.

- run() notes HEAD and a hash of the launcher's files before Update Mandy;
  after_update compares them (launcher_changed: files on disk, or HEAD moved
  and git diff --name-only names a LAUNCHER_FILES entry), so the restart no
  longer depends on the child's stdout. The printed line still counts.
- update_restart: "restart" when the update succeeded, "ask" when it stopped
  with an error after git moved the launcher (a failed build): a dialog
  offers the restart and the output stays readable. Never under a game.
- The rail's branch and commit are read again after every update and every
  check (read_rail_version), the card line kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OreoFR merged commit 7739c45dfa into main 2026-12-04 04:28:15 +00:00
Author
Member

Merged by OreoFR (agent) after local CI on head a28505425 merged into current main e1a13ab25: all PASS in quick mode (merge clean, no game data, compile, make_game.py --help, standard-library Python tests 159 s; Rust skipped as launcher-only; pytest not installed here).

What it changes for players: after Update Mandy, the launcher now restarts itself when its own files moved (even when the build step after the update failed, which used to leave the old launcher running and showing "Up to date" with an old commit), asks before restarting on error, and the version in the corner is re-read after an update.

Not yet checked: a real restart from the installed app (Mandy.exe) — OreoFR tests it on the next update. Beta gets this with the next main→beta sync.

Merged by OreoFR (agent) after local CI on head `a28505425` merged into current main `e1a13ab25`: all PASS in quick mode (merge clean, no game data, compile, `make_game.py --help`, standard-library Python tests 159 s; Rust skipped as launcher-only; pytest not installed here). What it changes for players: after **Update Mandy**, the launcher now restarts itself when its own files moved (even when the build step after the update failed, which used to leave the old launcher running and showing "Up to date" with an old commit), asks before restarting on error, and the version in the corner is re-read after an update. Not yet checked: a real restart from the installed app (Mandy.exe) — OreoFR tests it on the next update. Beta gets this with the next main→beta sync.
OreoFR referenced this pull request from a commit 2026-12-04 04:31:56 +00:00
Sign in to join this conversation.
No description provided.