WIP: fix(mods): switching one mod off while the game runs no longer stops every other mod the start turned on #2829

Draft
llun wants to merge 4 commits from llun/Longshot:fix/mod-api-live-switch into mod-api
Member

Summary

For #2822 (into mod-api). Switching one mod off while the game runs, in the Mods tab or by the launcher changing profile.json, stops every player's mod and development mod that the start turned on, not just the one switched. The log names each as turned off in the Mods tab.

The cause: a player's and a development mod's row is made off (Row::new(…, false) in game/crates/api/src/loader/mod.rs) and then turned on by the profile's list or by the run. At the start's end the loader brings start_enabled up to date with that switch, but not switch_on, the live switch. Only the system mods' rows set that (put_systems). So every player's and development mod ran with switch_on false. The first switch pass while the game ran (switch_frame) took that as "off" and stopped them all. The Mods tab reads the same field for a live mod (tab.rs, row_of), so it also showed running mods as off. This sets switch_on together with start_enabled at the start.

To see it on mod-api: a profile listing two script mods as on; start the game; switch one off in the Mods tab, or in profile.json while it runs. Both stop.

Read first: the end of Loader::scan in game/crates/api/src/loader/mod.rs.

Testing

Tested: Windows 11, RTX 5080, NVIDIA 621.40, the game confined through longshot-builder game with a profile listing local/rupee-alarm and local/heart-log as on, plus a development mod (LONGSHOT_DEV_MODS, local/first-mod). 40 s in, heart-log was switched off in profile.json.

  • Before: mods: local/heart-log switched off (at once), then local/first-mod: turned off in the Mods tab, local/heart-log turned off in the Mods tab and local/rupee-alarm turned off in the Mods tab.
  • After: local/heart-log turned off in the Mods tab alone; rupee-alarm and first-mod ran on.

Both runs are on mod-api with #2726's save-folder fix and its broker change applied locally, beneath this PR: on plain mod-api a confined Windows start with a profile stops at the save folder.

Checks: the new loader::tests::a_mod_switched_off_while_the_game_runs_stops_alone lists two script mods as on, runs them, and switches one off. It fails on mod-api @ eaf4a48b (a/one runs on, left: Off) and passes here, on Linux (WSL Ubuntu 24.04, Rust 1.99.1: cargo test -p api, all 443 pass) and on Windows (--target x86_64-pc-windows-gnullvm with llvm-mingw: 442 pass). The one failure on Windows, a_content_mods_changed_module_runs_again_and_its_outputs_are_served, fails the same way on mod-api and passes on Linux. cargo fmt -p api --check and cargo clippy -p api --all-targets --no-deps -- -D warnings (Windows target) pass, and so does mise run lint.

The sandbox's guard checks: a_switch_while_the_game_runs_never_starts_a_mod_that_waits_for_its_permissions and a_switch_in_a_game_not_confined_never_starts_a_held_script pass here (and on mod-api). The fix keeps the permission and confinement gates; these pin them.

Still to test:

  • Windows: switch a running mod off and on again in the Mods tab (F1), expecting only that mod to stop and start, and the tab to show the others as On (by hand)
  • Linux: the same in the game (@Beanstalk: switch one script mod off in the Mods tab while two run; only it stops)

Measurements

Verdict: fixed. A mod switched off while the game runs stops alone.

Baseline: mod-api (#2822's head), the branch this PR goes into: the bug is there, not on main. The in-game runs are both on mod-api with #2726's save-folder fix and broker change applied locally, beneath this PR.

Setup: Windows 11, RTX 5080, NVIDIA 621.40, the game confined, the same profile and development mod. heart-log switched off in profile.json 40 s in. The mods the log says were turned off, and the test.

Before: mod-api @ eaf4a48b After: this PR @ e4c1acb9
Mods stopped when heart-log is switched off heart-log, rupee-alarm, first-mod heart-log
a_mod_switched_off_while_the_game_runs_stops_alone FAIL (a/one: Off) pass (Linux and Windows)

Risks

The sandbox: a switch's pass still starts nothing the start held back. It starts a switched-on mod only after the confinement's check and through can_start's grants, and a held row (Waits, Cannot, Held) is never one it starts. Two new checks pin this: a_switch_while_the_game_runs_never_starts_a_mod_that_waits_for_its_permissions, and a_switch_in_a_game_not_confined_never_starts_a_held_script.

A live mod's switch now starts as the list says. The switch passes (switch_frame) and the Mods tab read the same field, so the change also fixes running mods showing as off in the tab. Rows the start turns off keep switch_on false, as before. A revert is enough. Players notice that switching one mod no longer stops the others.

Checklist

Ready for review

  • One topic, on current mod-api (#2822's head); the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named). (The checks this change reaches pass: cargo test -p api, as above. mod-api's whole suite has failures on Windows that this PR doesn't change: #2825 and #2826 fix eight of them.)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here. (It fails on mod-api, where the bug is.)
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary For [#2822](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2822) (into `mod-api`). Switching one mod off while the game runs, in the Mods tab or by the launcher changing `profile.json`, stops every player's mod and development mod that the start turned on, not just the one switched. The log names each as `turned off in the Mods tab`. The cause: a player's and a development mod's row is made off (`Row::new(…, false)` in `game/crates/api/src/loader/mod.rs`) and then turned on by the profile's list or by the run. At the start's end the loader brings `start_enabled` up to date with that switch, but not `switch_on`, the live switch. Only the system mods' rows set that (`put_systems`). So every player's and development mod ran with `switch_on` false. The first switch pass while the game ran (`switch_frame`) took that as "off" and stopped them all. The Mods tab reads the same field for a live mod (`tab.rs`, `row_of`), so it also showed running mods as off. This sets `switch_on` together with `start_enabled` at the start. **To see it on `mod-api`:** a profile listing two script mods as on; start the game; switch one off in the Mods tab, or in `profile.json` while it runs. Both stop. Read first: the end of `Loader::scan` in `game/crates/api/src/loader/mod.rs`. ## Testing **Tested:** Windows 11, RTX 5080, NVIDIA 621.40, the game confined through `longshot-builder game` with a profile listing `local/rupee-alarm` and `local/heart-log` as on, plus a development mod (`LONGSHOT_DEV_MODS`, `local/first-mod`). 40 s in, `heart-log` was switched off in `profile.json`. - Before: `mods: local/heart-log switched off (at once)`, then `local/first-mod: turned off in the Mods tab`, `local/heart-log turned off in the Mods tab` and `local/rupee-alarm turned off in the Mods tab`. - After: `local/heart-log turned off in the Mods tab` alone; rupee-alarm and first-mod ran on. Both runs are on `mod-api` with [#2726](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2726)'s save-folder fix and its broker change applied locally, beneath this PR: on plain `mod-api` a confined Windows start with a profile stops at the save folder. Checks: the new `loader::tests::a_mod_switched_off_while_the_game_runs_stops_alone` lists two script mods as on, runs them, and switches one off. It fails on `mod-api` @ eaf4a48b (`a/one runs on`, `left: Off`) and passes here, on Linux (WSL Ubuntu 24.04, Rust 1.99.1: `cargo test -p api`, all 443 pass) and on Windows (`--target x86_64-pc-windows-gnullvm` with llvm-mingw: 442 pass). The one failure on Windows, `a_content_mods_changed_module_runs_again_and_its_outputs_are_served`, fails the same way on `mod-api` and passes on Linux. `cargo fmt -p api --check` and `cargo clippy -p api --all-targets --no-deps -- -D warnings` (Windows target) pass, and so does `mise run lint`. The sandbox's guard checks: `a_switch_while_the_game_runs_never_starts_a_mod_that_waits_for_its_permissions` and `a_switch_in_a_game_not_confined_never_starts_a_held_script` pass here (and on `mod-api`). The fix keeps the permission and confinement gates; these pin them. **Still to test:** - Windows: switch a running mod off and on again in the Mods tab (F1), expecting only that mod to stop and start, and the tab to show the others as On (by hand) - Linux: the same in the game (@Beanstalk: switch one script mod off in the Mods tab while two run; only it stops) ## Measurements **Verdict:** fixed. A mod switched off while the game runs stops alone. Baseline: `mod-api` (#2822's head), the branch this PR goes into: the bug is there, not on `main`. The in-game runs are both on `mod-api` with #2726's save-folder fix and broker change applied locally, beneath this PR. Setup: Windows 11, RTX 5080, NVIDIA 621.40, the game confined, the same profile and development mod. `heart-log` switched off in `profile.json` 40 s in. The mods the log says were turned off, and the test. | | Before: mod-api @ eaf4a48b | After: this PR @ e4c1acb9 | |---|---|---| | Mods stopped when `heart-log` is switched off | heart-log, rupee-alarm, first-mod | heart-log | | `a_mod_switched_off_while_the_game_runs_stops_alone` | FAIL (`a/one`: Off) | pass (Linux and Windows) | ## Risks **The sandbox:** a switch's pass still starts nothing the start held back. It starts a switched-on mod only after the confinement's check and through `can_start`'s grants, and a held row (`Waits`, `Cannot`, `Held`) is never one it starts. Two new checks pin this: `a_switch_while_the_game_runs_never_starts_a_mod_that_waits_for_its_permissions`, and `a_switch_in_a_game_not_confined_never_starts_a_held_script`. A live mod's switch now starts as the list says. The switch passes (`switch_frame`) and the Mods tab read the same field, so the change also fixes running mods showing as off in the tab. Rows the start turns off keep `switch_on` false, as before. A revert is enough. Players notice that switching one mod no longer stops the others. ## Checklist ### Ready for review - [x] One topic, on current `mod-api` (#2822's head); the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). (The checks this change reaches pass: `cargo test -p api`, as above. `mod-api`'s whole suite has failures on Windows that this PR doesn't change: [#2825](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2825) and [#2826](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2826) fix eight of them.) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. (It fails on `mod-api`, where the bug is.) - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(game)!: the game side and the whole mod API in Rust, with system mods and the sandbox on by default
Some checks failed
CI / Third-party parts and guide screenshots (pull_request) Successful in 28s
PR description / Title and description (pull_request_target) Successful in 47s
CI / What the change needs (pull_request) Successful in 2m21s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 1m48s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
9e6b9c5782
The game side (between the C host and the lifted game) and the mod API move from C to Rust (game/crates), every game
setting and feature becomes a system mod (game/mods, Rust or TypeScript), and longshot-builder becomes the game's only
entrypoint, its sandboxer (Landlock and seccomp on Linux, an AppContainer on Windows) and its broker over one framed
channel. Native C mods and wasm are removed. The Insert menu is the menu system mod. One squashed commit of the former
mod-api branch (#2434).

Co-authored-by: Chloe Christley <[email protected]>
Co-authored-by: Jer9 <[email protected]>
Co-authored-by: snaildev99 <[email protected]>
Co-authored-by: SqueezyLemonade <[email protected]>
Co-authored-by: flashman4 <[email protected]>
Co-authored-by: dyst <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two player's script mods profile.json lists on, running; a/two switched off in the Mods tab while the game runs. a/two
must stop and a/one run on. It fails on mod-api: a/one is Off too (in the game, switching one mod off in profile.json
while it ran stopped every player's and development mod: "local/rupee-alarm turned off in the Mods tab").

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(mods): switching one mod off while the game runs no longer stops every other mod the start turned on
All checks were successful
PR description / Title and description (pull_request_target) Successful in 31s
6d4bccd24b
A player's and a development mod's row is made off (Row::new(..., false)) and the profile's list, or the run, turns it
on; the start brought start_enabled up to date with that, but not the live switch, switch_on, which only the system
mods' rows were given (put_systems). So every player's and development mod ran with switch_on false, the Mods tab
showed it off, and the first switch's pass while the game ran (the tab's, or profile.json changed by the launcher)
stopped them all with "turned off in the Mods tab". The start now sets switch_on with start_enabled.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

Tested in the game: Windows 11, RTX 5080, NVIDIA 621.40, confined through longshot-builder game, a profile listing local/rupee-alarm and local/heart-log as on plus a development mod (local/first-mod); heart-log switched off in profile.json 40 s in (on mod-api with #2726's save-folder fix and its broker change applied locally, beneath this PR). Before: heart-log, rupee-alarm and first-mod were all "turned off in the Mods tab". After: local/heart-log turned off in the Mods tab alone; rupee-alarm and first-mod ran on.

Tested in the game: Windows 11, RTX 5080, NVIDIA 621.40, confined through `longshot-builder game`, a profile listing `local/rupee-alarm` and `local/heart-log` as on plus a development mod (`local/first-mod`); `heart-log` switched off in `profile.json` 40 s in (on `mod-api` with #2726's save-folder fix and its broker change applied locally, beneath this PR). Before: heart-log, rupee-alarm and first-mod were all "turned off in the Mods tab". After: `local/heart-log turned off in the Mods tab` alone; rupee-alarm and first-mod ran on.
Member

Possibly related, for context:

  • PR #1958 feat(mods): the Modding API: TypeScript mods the game compiles and sandboxes, system mods, a Mods tab, hot reload, custom actors and in-game tests — Mod API implementation containing the affected loader; closed in favour of #2434
  • issue #1097 Feedback on the Modding API Spec from the code mod work (#134 and its stack) — Modding API feedback documents the related live-switch behavior (#1036)
Possibly related, for context: - PR #1958 feat(mods): the Modding API: TypeScript mods the game compiles and sandboxes, system mods, a Mods tab, hot reload, custom actors and in-game tests — Mod API implementation containing the affected loader; closed in favour of #2434 - issue #1097 Feedback on the Modding API Spec from the code mod work (#134 and its stack) — Modding API feedback documents the related live-switch behavior (#1036)
llun force-pushed fix/mod-api-live-switch from 6d4bccd24b
All checks were successful
PR description / Title and description (pull_request_target) Successful in 31s
to dc4deb403a
All checks were successful
PR description / Title and description (pull_request_target) Successful in 8s
2026-11-29 22:15:21 +00:00
Compare
Author
Member

Rebased onto mod-api's new squash eaf4a48b (the same tree as 9e6b9c57, which this branch was on): the diff is this PR's own commits again. The checks and runs above hold as they are (the tree under them is unchanged); the description's commits are the new ones.

Rebased onto mod-api's new squash eaf4a48b (the same tree as 9e6b9c57, which this branch was on): the diff is this PR's own commits again. The checks and runs above hold as they are (the tree under them is unchanged); the description's commits are the new ones.
test(mods): a switch while the game runs never starts a mod that waits for its permissions
All checks were successful
PR description / Title and description (pull_request_target) Successful in 6s
aef3d97067
With the live switch now the list's at the start, a switch's pass sees every listed mod on. It must start nothing the
start held back: a/one, listed on but without its state.read granted, waits; a/two is switched off while the game runs;
a/one still waits and is never started (the pass starts a switched-on mod only through can_start's grants, after the
confinement's check). It passes: the fix keeps the gates; this pins them.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
test(mods): a switch in a game the sandbox did not confine never starts a held script
All checks were successful
PR description / Title and description (pull_request_target) Successful in 10s
2b8e3c2c01
Two player's script mods the list turns on, in a game not confined: both held by the sandbox (Cannot). a/two switched
off while the game runs; a/one stays held and no script is started (a switch's pass starts a script only after the
confinement's check, and a held row is never one it starts). It passes: the fix keeps the sandbox's hold; this pins it.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

Pushed two guard checks for the sandbox: a switch while the game runs never starts a mod that waits for its permissions, and in a game the sandbox did not confine never starts a held script. Both pass: the fix keeps can_start's grants and the confinement's check, and these pin them. Risks says so.

Pushed two guard checks for the sandbox: a switch while the game runs never starts a mod that waits for its permissions, and in a game the sandbox did not confine never starts a held script. Both pass: the fix keeps can_start's grants and the confinement's check, and these pin them. Risks says so.
llun force-pushed fix/mod-api-live-switch from 2b8e3c2c01
All checks were successful
PR description / Title and description (pull_request_target) Successful in 10s
to 4f8c8bb6ae
All checks were successful
PR description / Title and description (pull_request_target) Successful in 17s
2026-11-29 23:27:35 +00:00
Compare
Author
Member

Rebased onto mod-api's newest (4cc50ca1: main's newest merged in), with no conflict; this PR's own checks were run again on the rebased head and pass as before. The merge touched none of this PR's files (#2827: only a comment in host/hos_main.c, far from its change), so the measurements and runs above hold; the After commit is the rebased head.

Rebased onto mod-api's newest (4cc50ca1: main's newest merged in), with no conflict; this PR's own checks were run again on the rebased head and pass as before. The merge touched none of this PR's files (#2827: only a comment in host/hos_main.c, far from its change), so the measurements and runs above hold; the After commit is the rebased head.
llun force-pushed fix/mod-api-live-switch from 4f8c8bb6ae
All checks were successful
PR description / Title and description (pull_request_target) Successful in 17s
to eb4ee5c106
All checks were successful
PR description / Title and description (pull_request_target) Successful in 13s
2026-11-29 23:58:36 +00:00
Compare
Author
Member

Rebased onto mod-api @ 816d2354 (#2837, headless shots of the mods' UI), now eb4ee5c1. No conflict, and the diff is the same as before (same git patch-id). #2837 touches none of this PR's files.

Rebased onto `mod-api` @ 816d2354 ([#2837](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2837), headless shots of the mods' UI), now eb4ee5c1. No conflict, and the diff is the same as before (same `git patch-id`). #2837 touches none of this PR's files.
llun force-pushed fix/mod-api-live-switch from eb4ee5c106
All checks were successful
PR description / Title and description (pull_request_target) Successful in 13s
to 5af7d9a3e1
All checks were successful
PR description / Title and description (pull_request_target) Successful in 1m34s
2026-11-30 00:39:10 +00:00
Compare
llun force-pushed fix/mod-api-live-switch from 5af7d9a3e1
All checks were successful
PR description / Title and description (pull_request_target) Successful in 1m34s
to e4c1acb9ca
All checks were successful
PR description / Title and description (pull_request_target) Successful in 19s
2026-11-30 00:43:05 +00:00
Compare
Author
Member

Rebased onto mod-api @ c5e5b676: it was re-squashed onto main @ 46291934 (#2833) twice today (cdbb8551, then c5e5b676), which made this PR show main's and the whole mod API's diff. Now e4c1acb9, the same diff as before (same git patch-id), no conflict. The changes underneath touch none of this PR's files, so its checks still hold.

Rebased onto `mod-api` @ c5e5b676: it was re-squashed onto main @ 46291934 (#2833) twice today (cdbb8551, then c5e5b676), which made this PR show main's and the whole mod API's diff. Now e4c1acb9, the same diff as before (same `git patch-id`), no conflict. The changes underneath touch none of this PR's files, so its checks still hold.
All checks were successful
PR description / Title and description (pull_request_target) Successful in 19s
This pull request is marked as a work in progress.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/mod-api-live-switch:llun-fix/mod-api-live-switch'
git switch 'llun-fix/mod-api-live-switch'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'mod-api'
git merge --no-ff 'llun-fix/mod-api-live-switch'
git switch 'llun-fix/mod-api-live-switch'
git rebase 'mod-api'
git switch 'mod-api'
git merge --ff-only 'llun-fix/mod-api-live-switch'
git switch 'llun-fix/mod-api-live-switch'
git rebase 'mod-api'
git switch 'mod-api'
git merge --no-ff 'llun-fix/mod-api-live-switch'
git switch 'mod-api'
git merge --squash 'llun-fix/mod-api-live-switch'
git switch 'mod-api'
git merge --ff-only 'llun-fix/mod-api-live-switch'
git switch 'mod-api'
git merge 'llun-fix/mod-api-live-switch'
git push origin 'mod-api'
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/Longshot!2829
No description provided.