WIP: fix(mods): Windows: a changed folder mod's content module runs again while the game runs: its folder matches its mod #2832

Draft
llun wants to merge 2 commits from llun/Longshot:fix/mod-api-win-content-reload into mod-api
Member

Summary

For #2822 (into mod-api). On Windows, a folder mod's files changed while the game runs are never matched to that mod. So its content module is not run again, and the hot reload's log names "a mod". The watch hands the loader the folders whose served files changed with / between their names (game/crates/api/src/watch.rs, slashes). same_path (game/crates/api/src/loader/mod.rs) compared those with the mods' rows, whose paths keep Windows' backslash, as text (ignoring case). On Windows no changed folder matched, and hot_layers rebuilt the layers for no mod. same_path now treats either separator as the same on Windows, still ignoring case. Linux is unchanged.

To see it on mod-api: Windows, a profile with a content mod (the seven-rupee example), the game running. Change its src/content.ts: the log says mods: hot reload: a mod: rebuilt while the game runs, …, and the module doesn't run again.

Read first: same_path in game/crates/api/src/loader/mod.rs, and its caller hot_layers in game/crates/api/src/loader/hot.rs.

Testing

Tested: Windows 11, RTX 5080, NVIDIA 621.40, confined through longshot-builder game, a profile with local/seven-rupee (its content.add, content.read and items.grant granted). Its src/content.ts was changed 40 s in.

  • Before: mods: hot reload: a mod: rebuilt while the game runs, 0 paths served anew …, with no content line after it.
  • After: mod runtime: local/seven-rupee: content: Obj_M37444242_Rupee7, … (the module ran again), then mods: hot reload: local/seven-rupee: rebuilt while the game runs, … 64 ms.

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. In both runs the content's outputs could not be written to the game folder's modcache ("its plan cannot be kept"), so 0 paths were served. That's a separate Windows problem, not this one.

Checks: the new loader::tests::a_folder_is_the_same_path_with_either_separator_on_windows (Windows only) fails on mod-api @ eaf4a48b ("the watch's form") and passes here. The existing a_content_mods_changed_module_runs_again_and_its_outputs_are_served failed on Windows for the same reason and passes now. cargo test -p api --target x86_64-pc-windows-gnullvm: all 443 pass (on mod-api, 442 with that one failing). On Linux all 443 passed on mod-api, and the change is behind cfg!(windows). cargo fmt -p api --check, cargo clippy -p api --all-targets --no-deps -- -D warnings (Windows target) and mise run lint pass.

Still to test:

  • Windows: once a content mod's outputs can be written in the confined game, change its content module while the game runs, expecting its new outputs served from their next load (by hand)

Measurements

Verdict: fixed. On Windows, a changed content mod's module runs again while the game runs.

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. seven-rupee's src/content.ts changed 40 s in. The log's hot reload line, and the checks.

Before: mod-api @ eaf4a48b After: this PR @ d48c1ba7
The hot reload's log line hot reload: a mod: …, the module not run again content: … again, then hot reload: local/seven-rupee: …
a_folder_is_the_same_path_with_either_separator_on_windows FAIL pass
a_content_mods_changed_module_runs_again_and_its_outputs_are_served, Windows FAIL pass

Risks

The sandbox: not touched. same_path only picks which changed mod's content module runs again. Its files are still read through the builder's grants for the profile's mods folder, as at the start.

Only Windows' path comparison changes, and it has one caller (hot_layers): the two separators now count as the same, as Windows itself treats them. A revert is enough. Players on Windows see a content or files mod's change applied while the game runs, as the docs say it does.

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.)
  • 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`). On Windows, a folder mod's files changed while the game runs are never matched to that mod. So its content module is not run again, and the hot reload's log names "a mod". The watch hands the loader the folders whose served files changed with `/` between their names (`game/crates/api/src/watch.rs`, `slashes`). `same_path` (`game/crates/api/src/loader/mod.rs`) compared those with the mods' rows, whose paths keep Windows' backslash, as text (ignoring case). On Windows no changed folder matched, and `hot_layers` rebuilt the layers for no mod. `same_path` now treats either separator as the same on Windows, still ignoring case. Linux is unchanged. **To see it on `mod-api`:** Windows, a profile with a content mod (the `seven-rupee` example), the game running. Change its `src/content.ts`: the log says `mods: hot reload: a mod: rebuilt while the game runs, …`, and the module doesn't run again. Read first: `same_path` in `game/crates/api/src/loader/mod.rs`, and its caller `hot_layers` in `game/crates/api/src/loader/hot.rs`. ## Testing **Tested:** Windows 11, RTX 5080, NVIDIA 621.40, confined through `longshot-builder game`, a profile with `local/seven-rupee` (its `content.add`, `content.read` and `items.grant` granted). Its `src/content.ts` was changed 40 s in. - Before: `mods: hot reload: a mod: rebuilt while the game runs, 0 paths served anew …`, with no content line after it. - After: `mod runtime: local/seven-rupee: content: Obj_M37444242_Rupee7, …` (the module ran again), then `mods: hot reload: local/seven-rupee: rebuilt while the game runs, … 64 ms`. 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. In both runs the content's outputs could not be written to the game folder's `modcache` ("its plan cannot be kept"), so 0 paths were served. That's a separate Windows problem, not this one. Checks: the new `loader::tests::a_folder_is_the_same_path_with_either_separator_on_windows` (Windows only) fails on `mod-api` @ eaf4a48b ("the watch's form") and passes here. The existing `a_content_mods_changed_module_runs_again_and_its_outputs_are_served` failed on Windows for the same reason and passes now. `cargo test -p api --target x86_64-pc-windows-gnullvm`: all 443 pass (on `mod-api`, 442 with that one failing). On Linux all 443 passed on `mod-api`, and the change is behind `cfg!(windows)`. `cargo fmt -p api --check`, `cargo clippy -p api --all-targets --no-deps -- -D warnings` (Windows target) and `mise run lint` pass. **Still to test:** - Windows: once a content mod's outputs can be written in the confined game, change its content module while the game runs, expecting its new outputs served from their next load (by hand) ## Measurements **Verdict:** fixed. On Windows, a changed content mod's module runs again while the game runs. 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. `seven-rupee`'s `src/content.ts` changed 40 s in. The log's hot reload line, and the checks. | | Before: mod-api @ eaf4a48b | After: this PR @ d48c1ba7 | |---|---|---| | The hot reload's log line | `hot reload: a mod: …`, the module not run again | `content: …` again, then `hot reload: local/seven-rupee: …` | | `a_folder_is_the_same_path_with_either_separator_on_windows` | FAIL | pass | | `a_content_mods_changed_module_runs_again_and_its_outputs_are_served`, Windows | FAIL | pass | ## Risks **The sandbox:** not touched. `same_path` only picks which changed mod's content module runs again. Its files are still read through the builder's grants for the profile's mods folder, as at the start. Only Windows' path comparison changes, and it has one caller (`hot_layers`): the two separators now count as the same, as Windows itself treats them. A revert is enough. Players on Windows see a content or files mod's change applied while the game runs, as the docs say it does. ## 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.) - [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)
The watch hands the loader the folders whose served files changed with `/` between their names (watch.rs's slashes);
a row's path is the profile's, joined with `\`. A Windows-only test of loader::same_path with both forms, another
letter case, and another folder. It fails on mod-api ("the watch's form"): same_path compares the two as text, so on
Windows a changed folder matches no mod, and tests::a_content_mods_changed_module_runs_again_and_its_outputs_are_served
fails there for the same reason (it passes on Linux).

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(mods): Windows: a changed folder mod's content module runs again while the game runs: its folder matches its mod
All checks were successful
PR description / Title and description (pull_request_target) Successful in 15s
1b0897afed
The watch hands the loader the folders whose served files changed with `/` between their names (watch.rs's slashes),
and same_path compared them with the rows' paths, which keep Windows' `\`, as text (any case). On Windows no changed
folder matched its mod, so hot_layers rebuilt the layers for no mod: a content module was never run again, and the log
named "a mod". same_path now takes either separator on Windows, any case as before. Linux is unchanged.

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 with the seven-rupee example as a profile mod, its src/content.ts changed 40 s in (on mod-api with #2726's save-folder fix and its broker change applied locally, beneath this PR). Before: mods: hot reload: a mod: rebuilt while the game runs, 0 paths served anew ..., the module not run again. After: mod runtime: local/seven-rupee: content: Obj_M37444242_Rupee7, ... again, then mods: hot reload: local/seven-rupee: rebuilt while the game runs, ... 64 ms.

Tested in the game: Windows 11, RTX 5080, NVIDIA 621.40, confined through `longshot-builder game` with the seven-rupee example as a profile mod, its src/content.ts changed 40 s in (on mod-api with #2726's save-folder fix and its broker change applied locally, beneath this PR). Before: `mods: hot reload: a mod: rebuilt while the game runs, 0 paths served anew ...`, the module not run again. After: `mod runtime: local/seven-rupee: content: Obj_M37444242_Rupee7, ...` again, then `mods: hot reload: local/seven-rupee: rebuilt while the game runs, ... 64 ms`.
Author
Member

Description fixed: a shell quoting mistake when opening it cut its middle out (Testing, Measurements, Risks); this is the whole description.

Description fixed: a shell quoting mistake when opening it cut its middle out (Testing, Measurements, Risks); this is the whole description.
Author
Member

Risks now says how this change stands with the sandbox (what it touches, and why the confined game reaches nothing more).

Risks now says how this change stands with the sandbox (what it touches, and why the confined game reaches nothing more).
llun force-pushed fix/mod-api-win-content-reload from 1b0897afed
All checks were successful
PR description / Title and description (pull_request_target) Successful in 15s
to 8e2c8494bc
All checks were successful
PR description / Title and description (pull_request_target) Successful in 15s
2026-11-29 23:27:42 +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-win-content-reload from 8e2c8494bc
All checks were successful
PR description / Title and description (pull_request_target) Successful in 15s
to f1368c4c2b
All checks were successful
PR description / Title and description (pull_request_target) Successful in 12s
2026-11-29 23:58:41 +00:00
Compare
Author
Member

Rebased onto mod-api @ 816d2354 (#2837, headless shots of the mods' UI), now f1368c4c. 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 f1368c4c. 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-win-content-reload from f1368c4c2b
All checks were successful
PR description / Title and description (pull_request_target) Successful in 12s
to 8cb95a2f51
All checks were successful
PR description / Title and description (pull_request_target) Successful in 1m11s
2026-11-30 00:39:21 +00:00
Compare
llun force-pushed fix/mod-api-win-content-reload from 8cb95a2f51
All checks were successful
PR description / Title and description (pull_request_target) Successful in 1m11s
to d48c1ba7ab
All checks were successful
PR description / Title and description (pull_request_target) Successful in 19s
2026-11-30 00:43:11 +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 d48c1ba7, 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 d48c1ba7, 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-win-content-reload:llun-fix/mod-api-win-content-reload'
git switch 'llun-fix/mod-api-win-content-reload'

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