feat(game): the Game language row lists the languages the profile's mods add, as its builder says them #380

Merged
HumanBean merged 1 commit from HumanBean/LongshotLauncher:feat/mod-game-languages into main 2026-11-30 15:43:37 +00:00
Owner

Summary

Longshot's mod API lets a mod add a game language, a new choice of the game's Game language row
(MagicBeanDev/Longshot#2881, into mod-api). The
launcher's own Game language dropdown kept a fixed list of the game's 16, so it couldn't show or keep a mod's language.

Now it asks the profile's builder: Longshot.exe --profile P --output json mod languages (added by that PR) gives the
game's 16, then each language a mod that is on adds, {id, name, base, mod}.

  • When it asks: on a thread, again when the profile, its builder, its profile.json or its mods/ folder
    changes. Meanwhile the dropdown shows the 16, so nothing waits on the builder.
  • An older builder: with no mod languages (every Longshot before #2881), the launcher keeps the 16, as now.
  • Saving: a mod language's id is taken and saved as game_language= like any code, and shown by its name.

Read first: src/game/languages.rs, then src/players/language.rs (the code rule now asks it).

Testing

Tested: cargo test (a new test reads a mod languages document and checks the choices, the lookups and the
names), clippy and fmt, Linux.

Still to test:

  • With a mod-api build and a mod that adds a language, open Settings → Game: expecting the mod's language after the
    16, and choosing it writes game_language=<its id> (by hand). Not run here: no released builder has
    mod languages yet.
  • With a released build: expecting the dropdown as before, the 16 (by hand).

Risks

  • Fallback: a builder that fails or lacks the command leaves the 16, as before.
  • Settings file: the launcher still writes game_language= into the profile's settings.ini, which the
    mod-api game reads once into settings/settings.toml. That's as before this change.

🤖 Generated with Claude Code

https://claude.ai/code/session_016o1k1QvyUwMcv8kvCNXuco

## Summary Longshot's mod API lets a mod add a **game language**, a new choice of the game's Game language row ([MagicBeanDev/Longshot#2881](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2881), into `mod-api`). The launcher's own Game language dropdown kept a fixed list of the game's 16, so it couldn't show or keep a mod's language. Now it asks the profile's builder: `Longshot.exe --profile P --output json mod languages` (added by that PR) gives the game's 16, then each language a mod that is on adds, `{id, name, base, mod}`. - **When it asks:** on a thread, again when the profile, its builder, its `profile.json` or its `mods/` folder changes. Meanwhile the dropdown shows the 16, so nothing waits on the builder. - **An older builder:** with no `mod languages` (every Longshot before #2881), the launcher keeps the 16, as now. - **Saving:** a mod language's id is taken and saved as `game_language=` like any code, and shown by its name. Read first: `src/game/languages.rs`, then `src/players/language.rs` (the code rule now asks it). ## Testing **Tested:** `cargo test` (a new test reads a `mod languages` document and checks the choices, the lookups and the names), clippy and fmt, Linux. **Still to test:** - With a `mod-api` build and a mod that adds a language, open Settings → Game: expecting the mod's language after the 16, and choosing it writes `game_language=<its id>` (by hand). Not run here: no released builder has `mod languages` yet. - With a released build: expecting the dropdown as before, the 16 (by hand). ## Risks - **Fallback:** a builder that fails or lacks the command leaves the 16, as before. - **Settings file:** the launcher still writes `game_language=` into the profile's `settings.ini`, which the `mod-api` game reads once into `settings/settings.toml`. That's as before this change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016o1k1QvyUwMcv8kvCNXuco
feat(game): the Game language row lists the languages the profile's mods add, as its builder says them
Some checks failed
CI / What the change needs (pull_request) Successful in 4s
CI / Lint (actionlint, ShellCheck, gitleaks) (pull_request) Successful in 10s
CI / Rust formatting, lint and tests (pull_request) Successful in 12m24s
CI / Release packages and stable upgrades (pull_request) Failing after 28m4s
PR title / Conventional Commit title (pull_request) Failing after 36s
7fd61f24e4
A Longshot whose game lets mods add game languages (gameLanguages) says the row's choices with
`mod languages`: the game's 16, then each language a mod that is on adds. The launcher asks the profile's
builder for them on a thread, again when the profile, its builder, its list or its mods' folder changes,
and shows the 16 meanwhile. A builder without the command (every Longshot before it) leaves the 16, as now.
A mod's language's id is taken and saved as game_language= like a game's code, and shown by its name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1QvyUwMcv8kvCNXuco
Member

Possibly related, for context:

  • PR #364 feat(profiles): a profile's game language, kept with its settings so an update keeps it — Earlier PR introduced profile game-language handling; this extends its dropdown with mod languages.
  • issue #371 [BUG] Build advanced game language selection is not persisted between launcher restarts — Open report about game-language selection in advanced build options; related UI, distinct persistence symptom.
Possibly related, for context: - PR #364 feat(profiles): a profile's game language, kept with its settings so an update keeps it — Earlier PR introduced profile game-language handling; this extends its dropdown with mod languages. - issue #371 [BUG] Build advanced game language selection is not persisted between launcher restarts — Open report about game-language selection in advanced build options; related UI, distinct persistence symptom.
HumanBean changed title from WIP: feat(game): the Game language row lists the languages the profile's mods add, as its builder says them to feat(game): the Game language row lists the languages the profile's mods add, as its builder says them 2026-11-30 15:01:55 +00:00
Author
Owner
@review
BeanBot left a comment

Recommendation: Request changes. A saved mod language is not restored reliably, and rebuilding can replace it with English. Profile changes and overlapping queries can also leave another profile’s languages in the dropdown.

The change asks the selected builder for mod-provided game languages and adds them to the launcher’s language model. The shared cache and its integration with profile rows and the build wizard need correction before the feature can reliably preserve a player’s choice.

Blocking (7): must change before merging.

  1. L1 src/game/languages.rs:141: Publishing the language list does not refresh the profile rows that were read before the query completed. (more on the line) Do: After publishing the current profile’s result, refresh the profile rows as well as the choice models, and test reopening a profile with a saved mod language.
  2. L2 src/game/languages.rs:140: Every query publishes unconditionally, including results for a profile or builder that is no longer current. (more on the line) Do: Track the latest requested key or generation, clear the old profile’s choices on a switch, and publish only if the completed query still matches the current request.
  3. L3 src/game/wizard.rs:222: The wizard discards a saved mod language and later writes its fallback over that choice after a build. (more on the line) Do: Keep the profile’s mod language separate from the builder’s built-in build language, and do not replace the saved choice merely because the wizard needs a built-in language.
  4. L4 src/game/actions.rs:88: The expanded model is also used by the build wizard, whose validation only accepts built-in languages. (more on the line) Do: Give the wizard a built-in-only model, or explicitly support mod languages throughout its build and validation path.
  5. L5 src/game/languages.rs:122: The cache key and refresh triggers do not observe changes inside the mods tree. (more on the line) Do: Invalidate the language query when the observed mod tree changes, including nested manifests, and invoke it after mod operations and external edits.
  6. L8: The check CI / Release packages and stable upgrades (pull_request) fails on this head and passes on the base branch: Failing after 28m4s.
  7. L9: The check PR title / Conventional Commit title (pull_request) fails on this head and passes on the base branch: Failing after 36s.

Should fix (1): not blocking, but worth doing before merging.

  • L6: The pull request changes a visible dropdown but does not include the screenshot required by the repository’s contribution rules. When: Reviewers cannot inspect the new language choice in the launcher from the pull request. Do: Add a launcher screenshot showing a mod-provided language in the dropdown.

Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)

  • L7 src/game/languages.rs:132: The player-facing builder integration has not yet been exercised. (more on the line) Do: Run the described mod-enabled and older-builder checks, including switching profiles and reopening the launcher, and record the results.

@fix can do L1, L2, L3, L4, L5, L6, L8 and L9.

More: does it help, other systems, switches, what was read

Does it help: Unproven: the new unit test exercises parsing and lookups, but the described manual runs with a mod-enabled builder and an older builder have not been done.

Other systems: The language model is shared by Settings and the build wizard, and language lookup is also used for every profile row and for build completion. The same asynchronous cache and invalidation issues affect Windows and Linux. No player-facing run with the new builder is recorded.

Switches: None.

Reviewed: 7fd61f24e4 against 29c6603aa4: Read AGENTS.md, CONTRIBUTING.md, the commit and diff, the new language module, player language and row code, and the relevant refresh, builder-command, live-watch, UI and wizard paths. Skimmed the remaining changed files and surrounding code; no review checklist or pull request template was present. The other changed code files were not read in full.; nothing run (a code review).

Checked and fine:

  • The commit includes AI-assistance trailers.
  • The added test fixture is synthetic; no game-derived output is apparent in the diff.
  • The builder subprocess uses the existing bounded-output and timeout implementation.

Testing: No commands from the project or tests were run, as requested. The pull request reports Linux cargo test, clippy and formatting checks; its manual integration checks remain outstanding. CI reports two checks failing only on this head.

Overlaps and merge order: None found in the supplied pull request information; network access was unavailable.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** A saved mod language is not restored reliably, and rebuilding can replace it with English. Profile changes and overlapping queries can also leave another profile’s languages in the dropdown. The change asks the selected builder for mod-provided game languages and adds them to the launcher’s language model. The shared cache and its integration with profile rows and the build wizard need correction before the feature can reliably preserve a player’s choice. **Blocking (7)**: must change before merging. 1. **L1** `src/game/languages.rs:141`: Publishing the language list does not refresh the profile rows that were read before the query completed. (more on the line) **Do:** After publishing the current profile’s result, refresh the profile rows as well as the choice models, and test reopening a profile with a saved mod language. 2. **L2** `src/game/languages.rs:140`: Every query publishes unconditionally, including results for a profile or builder that is no longer current. (more on the line) **Do:** Track the latest requested key or generation, clear the old profile’s choices on a switch, and publish only if the completed query still matches the current request. 3. **L3** `src/game/wizard.rs:222`: The wizard discards a saved mod language and later writes its fallback over that choice after a build. (more on the line) **Do:** Keep the profile’s mod language separate from the builder’s built-in build language, and do not replace the saved choice merely because the wizard needs a built-in language. 4. **L4** `src/game/actions.rs:88`: The expanded model is also used by the build wizard, whose validation only accepts built-in languages. (more on the line) **Do:** Give the wizard a built-in-only model, or explicitly support mod languages throughout its build and validation path. 5. **L5** `src/game/languages.rs:122`: The cache key and refresh triggers do not observe changes inside the mods tree. (more on the line) **Do:** Invalidate the language query when the observed mod tree changes, including nested manifests, and invoke it after mod operations and external edits. 6. **L8**: The check `CI / Release packages and stable upgrades (pull_request)` fails on this head and passes on the base branch: Failing after 28m4s. 7. **L9**: The check `PR title / Conventional Commit title (pull_request)` fails on this head and passes on the base branch: Failing after 36s. **Should fix (1)**: not blocking, but worth doing before merging. - **L6**: The pull request changes a visible dropdown but does not include the screenshot required by the repository’s contribution rules. *When:* Reviewers cannot inspect the new language choice in the launcher from the pull request. **Do:** Add a launcher screenshot showing a mod-provided language in the dropdown. **Testing before merging (1)** (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation) - **L7** `src/game/languages.rs:132`: The player-facing builder integration has not yet been exercised. (more on the line) **Do:** Run the described mod-enabled and older-builder checks, including switching profiles and reopening the launcher, and record the results. `@fix` can do L1, L2, L3, L4, L5, L6, L8 and L9. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven: the new unit test exercises parsing and lookups, but the described manual runs with a mod-enabled builder and an older builder have not been done. **Other systems:** The language model is shared by Settings and the build wizard, and language lookup is also used for every profile row and for build completion. The same asynchronous cache and invalidation issues affect Windows and Linux. No player-facing run with the new builder is recorded. **Switches:** None. **Reviewed:** 7fd61f24e4c3 against 29c6603aa473: Read AGENTS.md, CONTRIBUTING.md, the commit and diff, the new language module, player language and row code, and the relevant refresh, builder-command, live-watch, UI and wizard paths. Skimmed the remaining changed files and surrounding code; no review checklist or pull request template was present. The other changed code files were not read in full.; nothing run (a code review). **Checked and fine:** - The commit includes AI-assistance trailers. - The added test fixture is synthetic; no game-derived output is apparent in the diff. - The builder subprocess uses the existing bounded-output and timeout implementation. **Testing:** No commands from the project or tests were run, as requested. The pull request reports Linux cargo test, clippy and formatting checks; its manual integration checks remain outstanding. CI reports two checks failing only on this head. **Overlaps and merge order:** None found in the supplied pull request information; network access was unavailable. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -99,2 +87,2 @@
.as_slice(),
));
// (the game's 16 at once; the languages the profile's mods add once its builder says them)
super::languages::set_models(ui);
Member

L4 (blocking): The expanded model is also used by the build wizard, whose validation only accepts built-in languages.

When: After a mod language loads, the player can select it in the wizard’s Game language dropdown. Starting the build then fails with “Choose a supported game language.”

Do: Give the wizard a built-in-only model, or explicitly support mod languages throughout its build and validation path.

**L4** (blocking): The expanded model is also used by the build wizard, whose validation only accepts built-in languages. *When:* After a mod language loads, the player can select it in the wizard’s Game language dropdown. Starting the build then fails with “Choose a supported game language.” **Do:** Give the wizard a built-in-only model, or explicitly support mod languages throughout its build and validation path.
@ -0,0 +119,4 @@
.unwrap_or_default();
let changed = |p: PathBuf| std::fs::metadata(p).and_then(|m| m.modified()).ok();
let key = (
program,
Member

L5 (blocking): The cache key and refresh triggers do not observe changes inside the mods tree.

When: Editing an existing nested mod.json changes neither the top-level mods directory timestamp nor profile.json. The live watcher detects nested manifests only while the installed Mods page is visible, and even then does not call this refresh, so the language choices remain stale.

Do: Invalidate the language query when the observed mod tree changes, including nested manifests, and invoke it after mod operations and external edits.

**L5** (blocking): The cache key and refresh triggers do not observe changes inside the mods tree. *When:* Editing an existing nested mod.json changes neither the top-level mods directory timestamp nor profile.json. The live watcher detects nested manifests only while the installed Mods page is visible, and even then does not call this refresh, so the language choices remain stale. **Do:** Invalidate the language query when the observed mod tree changes, including nested manifests, and invoke it after mod operations and external edits.
@ -0,0 +129,4 @@
}
let weak = ui.as_weak();
std::thread::spawn(move || {
let found =
Member

L7 (should fix): The player-facing builder integration has not yet been exercised.

When: The recorded test uses a synthetic document; no run confirms that the builder’s response reaches the dropdown and that selecting and reopening a mod language preserves it.

Do: Run the described mod-enabled and older-builder checks, including switching profiles and reopening the launcher, and record the results.

**L7** (should fix): The player-facing builder integration has not yet been exercised. *When:* The recorded test uses a synthetic document; no run confirms that the builder’s response reaches the dropdown and that selecting and reopening a mod language preserves it. **Do:** Run the described mod-enabled and older-builder checks, including switching profiles and reopening the launcher, and record the results.
@ -0,0 +137,4 @@
});
*ADDED.write().unwrap_or_else(|e| e.into_inner()) = (Some(key), added);
let _ = weak.upgrade_in_event_loop(|ui| set_models(&ui));
});
Member

L2 (blocking): Every query publishes unconditionally, including results for a profile or builder that is no longer current.

When: A slow query for profile A starts, the player switches to B, and B’s query completes first. When A finishes it overwrites B’s cache and dropdown, allowing A’s languages to be selected for B and hiding B’s choices.

Do: Track the latest requested key or generation, clear the old profile’s choices on a switch, and publish only if the completed query still matches the current request.

**L2** (blocking): Every query publishes unconditionally, including results for a profile or builder that is no longer current. *When:* A slow query for profile A starts, the player switches to B, and B’s query completes first. When A finishes it overwrites B’s cache and dropdown, allowing A’s languages to be selected for B and hiding B’s choices. **Do:** Track the latest requested key or generation, clear the old profile’s choices on a switch, and publish only if the completed query still matches the current request.
@ -0,0 +138,4 @@
*ADDED.write().unwrap_or_else(|e| e.into_inner()) = (Some(key), added);
let _ = weak.upgrade_in_event_loop(|ui| set_models(&ui));
});
}
Member

L1 (blocking): Publishing the language list does not refresh the profile rows that were read before the query completed.

When: On launcher startup, a profile already has a mod language in settings.ini. While ADDED is empty, chosen() rejects it and profile_row falls back to a built-in language; when the query finishes, set_models updates only the choices, so the row continues to show the fallback instead of the saved language.

Do: After publishing the current profile’s result, refresh the profile rows as well as the choice models, and test reopening a profile with a saved mod language.

**L1** (blocking): Publishing the language list does not refresh the profile rows that were read before the query completed. *When:* On launcher startup, a profile already has a mod language in settings.ini. While ADDED is empty, chosen() rejects it and profile_row falls back to a built-in language; when the query finishes, set_models updates only the choices, so the row continues to show the fallback instead of the saved language. **Do:** After publishing the current profile’s result, refresh the profile rows as well as the choice models, and test reopening a profile with a saved mod language.
@ -226,3 +222,1 @@
.instance()
.and_then(|version| super::builder_cli::built_language(&version.folder))
});
let built_language = players::game_language(&ctx.profile).or_else(|| {
Member

L3 (blocking): The wizard discards a saved mod language and later writes its fallback over that choice after a build.

When: With a recognized mod language in settings.ini, wizard open reads it but the LANGS filter selects en-US. Completing a rebuild of the profile’s version calls language_follows_build, which recognizes the old mod language and writes en-US to settings.ini.

Do: Keep the profile’s mod language separate from the builder’s built-in build language, and do not replace the saved choice merely because the wizard needs a built-in language.

**L3** (blocking): The wizard discards a saved mod language and later writes its fallback over that choice after a build. *When:* With a recognized mod language in settings.ini, wizard open reads it but the LANGS filter selects en-US. Completing a rebuild of the profile’s version calls language_follows_build, which recognizes the old mod language and writes en-US to settings.ini. **Do:** Keep the profile’s mod language separate from the builder’s built-in build language, and do not replace the saved choice merely because the wizard needs a built-in language.
HumanBean force-pushed feat/mod-game-languages from 7fd61f24e4
Some checks failed
CI / What the change needs (pull_request) Successful in 4s
CI / Lint (actionlint, ShellCheck, gitleaks) (pull_request) Successful in 10s
CI / Rust formatting, lint and tests (pull_request) Successful in 12m24s
CI / Release packages and stable upgrades (pull_request) Failing after 28m4s
PR title / Conventional Commit title (pull_request) Failing after 36s
to 19792c4d27
Some checks failed
CI / What the change needs (pull_request) Successful in 21s
PR title / Conventional Commit title (pull_request) Successful in 21s
CI / Lint (actionlint, ShellCheck, gitleaks) (pull_request) Successful in 29s
CI / Rust formatting, lint and tests (pull_request) Successful in 12m1s
CI / Release packages and stable upgrades (pull_request) Failing after 28m41s
2026-11-30 15:41:05 +00:00
Compare
Author
Owner

Review fixes, folded into the commit (now 19792c4d):

  • L1: after an answer is published, the profile rows are refreshed as well as the choices. A saved mod language now shows once the builder has named it. Tested.
  • L2: each query gets a number, and only the latest one's answer is published. An identical query already running isn't started again. Switching profiles clears the old profile's added languages at once. Tested.
  • L3: each mod language keeps its base from the builder. The wizard starts at that base, and a build in that base keeps the saved mod language. It's replaced only when the player picks another language in the wizard. Tested.
  • L4: the build wizard's dropdown now lists only the game's 16 (stock-languages, the dropdown's stock-only). The Settings row still lists the mods' languages.
  • L5: the cache key now covers profile.json, mods.json, and every folder and nested mod.json under mods/. A refresh follows every mod action and the live watcher's mods-changed event; the builder is asked again only when the key changed. Tested.
  • L6 / L7: still open. They need a run against a mod-api build: a screenshot of the dropdown, then switching profiles and reopening the launcher.
  • L9: the title is in Conventional Commit form; that check will run again on this head.

Checks: fmt and clippy -D warnings pass. cargo test gives 280 passed and 1 failed. The failure is releases::tests::adding_the_same_release_twice_creates_distinct_instances, which refuses to run while a Longshot process is open on this PC; it isn't related to this change.

Review fixes, folded into the commit (now 19792c4d): - **L1:** after an answer is published, the profile rows are refreshed as well as the choices. A saved mod language now shows once the builder has named it. Tested. - **L2:** each query gets a number, and only the latest one's answer is published. An identical query already running isn't started again. Switching profiles clears the old profile's added languages at once. Tested. - **L3:** each mod language keeps its `base` from the builder. The wizard starts at that base, and a build in that base keeps the saved mod language. It's replaced only when the player picks another language in the wizard. Tested. - **L4:** the build wizard's dropdown now lists only the game's 16 (`stock-languages`, the dropdown's `stock-only`). The Settings row still lists the mods' languages. - **L5:** the cache key now covers `profile.json`, `mods.json`, and every folder and nested `mod.json` under `mods/`. A refresh follows every mod action and the live watcher's mods-changed event; the builder is asked again only when the key changed. Tested. - **L6 / L7:** still open. They need a run against a mod-api build: a screenshot of the dropdown, then switching profiles and reopening the launcher. - **L9:** the title is in Conventional Commit form; that check will run again on this head. Checks: fmt and clippy `-D warnings` pass. `cargo test` gives 280 passed and 1 failed. The failure is `releases::tests::adding_the_same_release_twice_creates_distinct_instances`, which refuses to run while a Longshot process is open on this PC; it isn't related to this change.
HumanBean deleted branch feat/mod-game-languages 2026-11-30 15:43:38 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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!380
No description provided.