fix(ui): a collapsible Section stays as tall as its rows when it hears two of their sizes at once #3280

Merged
HumanBean merged 3 commits from cuecuemoar/Longshot:fix/sharpness-row-3229 into main 2026-12-05 23:37:25 +00:00
Contributor

Summary

Fixes #3229. On the menu's Graphics tab, switching Upscaler sometimes made the Sharpness slider disappear in place: the rows above it and the next section's heading stayed where they were.

The cause. Sharpness is the last row of the collapsible Resolution and upscaling section. A collapsible Section (ShutSection in game/modapi/ui/kit.tsx) cuts its rows to a fixed height, tall. That height comes from its rows' onLayout, but the handler only set it when the new size differed from the tall of the last render:

onLayout={(z) => { if (z.height !== tall) setTall(z.height); }}

The UI engine posts a node's size only when it changes (events_after_paint, game/crates/ui/src/core.rs). Sometimes the rows get shorter and then as tall again (rows mounting and unmounting as Upscaler changes) across two presents before the menu's script takes its events. The script then hears both sizes in one batch, and both go to the handler of the last render:

  • the shorter size differs from that render's tall, so it is set;
  • the full size equals that stale tall, so it is dropped.

The engine never posts the full size again. The section stays cut at the shorter height, and its last row, Sharpness, sits under the cut until the rows' height changes again.

The fix takes every size: onLayout={(z) => setTall(z.height)}. useState's setter already ignores a value equal to the current one (runtime.js, useState), so a size that didn't change still doesn't render again.

How to see it on main. It needs the menu's script to fall behind the presents, as on the reporter's AMD Radeon 860M, where the menu's script also runs past its budget (#3230, #3232). I couldn't make it happen on an RTX 4090; see Testing.

Read first: game/modapi/ui/kit.tsx ShutSection, then the new test in game/crates/modtool/src/testing_game/tests.rs.

A second, small commit. cargo test -p modtool doesn't compile on main. 3145d9d48 (#3165) gave game_files::patches::collect a refuse step, and modtool's import test still calls it with three arguments. The first commit passes |_| Ok(()), as build-driver's tests do, so the new test can run. It is test code only.

Testing

Tested: Windows 10 22H2, RTX 4090, NVIDIA 617.42, keyboard and mouse, by hand, menu under F1:

  • main 6b93f9e2b: many Upscaler changes on the Graphics tab, fast and slow, between Off, Game's own, FSR and MAKO, with Dynamic resolution on and off. Sharpness never disappeared here: this PC's menu script keeps up with the presents.
  • This change (50839aadc, the same game code as the head eaffea2ee; the two differ only in a comment and in the test): the same Upscaler changes. Sharpness stays, and the section fits its rows with no gap or cut. Resolution and upscaling, other Graphics sections and the Mods tab still ease open and shut. The run's log has no fault from system/menu. It does show one frame where the menu's script took 4.0 ms of CPU, so even here the script can take more than a frame's time.

Game-free, in WSL (Linux), head eaffea2ee against main 302cdf035:

  • New test, cargo test -p modtool a_section_whose_rows_shrink_and_grow_back_between_two_frames_of_the_mod_shows_its_last_row_whole. It runs the real kit.tsx and runtime.js on the fake game's UI core, and checks four things:
    1. the Section follows a row that is taken away and put back;
    2. two sizes in one batch (a row's hover style, then not, at two presents with no frame of the mod's between) leave it as tall as its rows, with the last row inside the cut;
    3. a Section made shut opens to its rows' height.
    • It fails on the test commit c2d58f90f with AssertionError: as tall as its rows again: 118 of 128 and passes on the head.
  • Mutations of the fix, each failing the test: main's comparison put back ("118 of 128"); setTall dropped ("opened: as tall as its rows"); only the first size kept, setTall((t) => t ?? z.height) ("as short as its rows: 128 of 84").
  • cargo test -p modtool: 279 passed, 3 failed. The same 3 fail on the first commit alone (main plus the build fix; 278 passed there): handle::tests::set_mods_reorders_switches_and_keeps_every_other_key, profile::tests::pins_are_added_moved_and_removed and testing_game::tests::the_menu_passes_its_tests. They were already broken on main, hidden behind the compile error, and this change doesn't touch them.
  • cargo test -p script (it ships kit.tsx): passes.
  • cargo clippy -p modtool --all-targets --no-deps -- -D warnings (Rust 1.99.1): clean. The workspace-wide clippy stops in api on main too, which this change doesn't touch.
  • tests/run_all.py --strict: head 873 passed, 65 failed, 13 skipped; main the same 873/65/13, and no file fails only here.

Still to test:

  • Windows 11, AMD Radeon 860M (the reporter's PC): switch Upscaler on the Graphics tab as in #3229, expecting Sharpness to stay (by hand, the reporter asked on #3229)

Measurements

Nothing to measure: the change is one handler, which runs only when a Section's rows change size, and it renders no more often than before except once after a batch of sizes that ends where it started.

Risks

Small. A collapsible Section now takes every size its rows report, instead of skipping one equal to its last render's. A wrong height there would show as a section cut short or with a gap; none showed on the Graphics tab or the Mods tab here. A revert is enough. Nothing changes in saves, settings.toml or the caches.

A follow-up, not in this change: mod-inspector's useGraph (game/mods/mod-inspector/src/main.tsx, around line 455) compares a Canvas size with its render's value in the same way.

Checklist

Ready for review

  • One topic, on current main; 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).
  • 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.
  • 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.ai/code/session_01VxeaZi9Np8FcHAzJs2LM9d

## Summary Fixes #3229. On the menu's Graphics tab, switching **Upscaler** sometimes made the **Sharpness** slider disappear in place: the rows above it and the next section's heading stayed where they were. **The cause.** Sharpness is the last row of the collapsible **Resolution and upscaling** section. A collapsible Section (`ShutSection` in `game/modapi/ui/kit.tsx`) cuts its rows to a fixed height, `tall`. That height comes from its rows' `onLayout`, but the handler only set it when the new size differed from the `tall` of the last render: ```tsx onLayout={(z) => { if (z.height !== tall) setTall(z.height); }} ``` The UI engine posts a node's size only when it changes (`events_after_paint`, `game/crates/ui/src/core.rs`). Sometimes the rows get shorter and then as tall again (rows mounting and unmounting as Upscaler changes) across two presents before the menu's script takes its events. The script then hears both sizes in one batch, and both go to the handler of the last render: - the shorter size differs from that render's `tall`, so it is set; - the full size equals that stale `tall`, so it is dropped. The engine never posts the full size again. The section stays cut at the shorter height, and its last row, Sharpness, sits under the cut until the rows' height changes again. **The fix** takes every size: `onLayout={(z) => setTall(z.height)}`. `useState`'s setter already ignores a value equal to the current one (`runtime.js`, `useState`), so a size that didn't change still doesn't render again. **How to see it on `main`.** It needs the menu's script to fall behind the presents, as on the reporter's AMD Radeon 860M, where the menu's script also runs past its budget (#3230, #3232). I couldn't make it happen on an RTX 4090; see Testing. Read first: `game/modapi/ui/kit.tsx` `ShutSection`, then the new test in `game/crates/modtool/src/testing_game/tests.rs`. **A second, small commit.** `cargo test -p modtool` doesn't compile on `main`. 3145d9d48 (#3165) gave `game_files::patches::collect` a `refuse` step, and modtool's import test still calls it with three arguments. The first commit passes `|_| Ok(())`, as `build-driver`'s tests do, so the new test can run. It is test code only. ## Testing **Tested:** Windows 10 22H2, RTX 4090, NVIDIA 617.42, keyboard and mouse, by hand, menu under F1: - **`main` 6b93f9e2b:** many Upscaler changes on the Graphics tab, fast and slow, between Off, Game's own, FSR and MAKO, with Dynamic resolution on and off. Sharpness never disappeared here: this PC's menu script keeps up with the presents. - **This change (50839aadc, the same game code as the head eaffea2ee; the two differ only in a comment and in the test):** the same Upscaler changes. Sharpness stays, and the section fits its rows with no gap or cut. Resolution and upscaling, other Graphics sections and the Mods tab still ease open and shut. The run's log has no fault from `system/menu`. It does show one frame where the menu's script took 4.0 ms of CPU, so even here the script can take more than a frame's time. Game-free, in WSL (Linux), head eaffea2ee against `main` 302cdf035: - **New test**, `cargo test -p modtool a_section_whose_rows_shrink_and_grow_back_between_two_frames_of_the_mod_shows_its_last_row_whole`. It runs the real `kit.tsx` and `runtime.js` on the fake game's UI core, and checks four things: 1. the Section follows a row that is taken away and put back; 2. two sizes in one batch (a row's hover style, then not, at two presents with no frame of the mod's between) leave it as tall as its rows, with the last row inside the cut; 3. a Section made shut opens to its rows' height. - It fails on the test commit c2d58f90f with `AssertionError: as tall as its rows again: 118 of 128` and passes on the head. - **Mutations of the fix, each failing the test:** main's comparison put back ("118 of 128"); `setTall` dropped ("opened: as tall as its rows"); only the first size kept, `setTall((t) => t ?? z.height)` ("as short as its rows: 128 of 84"). - **`cargo test -p modtool`:** 279 passed, 3 failed. The same 3 fail on the first commit alone (`main` plus the build fix; 278 passed there): `handle::tests::set_mods_reorders_switches_and_keeps_every_other_key`, `profile::tests::pins_are_added_moved_and_removed` and `testing_game::tests::the_menu_passes_its_tests`. They were already broken on `main`, hidden behind the compile error, and this change doesn't touch them. - **`cargo test -p script`** (it ships `kit.tsx`): passes. - **`cargo clippy -p modtool --all-targets --no-deps -- -D warnings`** (Rust 1.99.1): clean. The workspace-wide clippy stops in `api` on `main` too, which this change doesn't touch. - **`tests/run_all.py --strict`:** head 873 passed, 65 failed, 13 skipped; `main` the same 873/65/13, and no file fails only here. **Still to test:** - Windows 11, AMD Radeon 860M (the reporter's PC): switch Upscaler on the Graphics tab as in #3229, expecting Sharpness to stay (by hand, the reporter asked on #3229) ## Measurements Nothing to measure: the change is one handler, which runs only when a Section's rows change size, and it renders no more often than before except once after a batch of sizes that ends where it started. ## Risks Small. A collapsible Section now takes every size its rows report, instead of skipping one equal to its last render's. A wrong height there would show as a section cut short or with a gap; none showed on the Graphics tab or the Mods tab here. A revert is enough. Nothing changes in saves, `settings.toml` or the caches. A follow-up, not in this change: mod-inspector's `useGraph` (`game/mods/mod-inspector/src/main.tsx`, around line 455) compares a Canvas size with its render's value in the same way. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [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. - [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) https://claude.ai/code/session_01VxeaZi9Np8FcHAzJs2LM9d
3145d9d48 (#3165) gave game_files::patches::collect a refuse step; modtool's import test still made the call
without it, so `cargo test -p modtool` no longer compiled on main. It refuses nothing, as build-driver's tests do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VxeaZi9Np8FcHAzJs2LM9d
A scratch mod mounts the kit's Section in the fake game (the real runtime.js and UI core). It follows a row taken
away and put back, and a Section made shut opens to its rows' height. Then one row is hovered and not at two
presents with no frame of the mod's between, so the mod hears the rows' two sizes in one batch of events: on main
the Section stays cut to the shorter size (118 of 128) and its last row is partly hidden. The Graphics tab's
Sharpness, the last row of its section, vanished that way as Upscaler changes added and took away rows above it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VxeaZi9Np8FcHAzJs2LM9d
fix(ui): a kit Section stays as tall as its rows when it hears two of their sizes at once (#3229)
Some checks are pending
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Waiting to run
eaffea2ee8
ShutSection cut its rows to the height its rows' onLayout last set, but set it only when the size differed from
the render's `tall`. Two sizes in one batch of events (the rows shorter, then as tall again, before the mod's
next render) set the shorter and dropped the second as the same, and the engine says a size only once: the section
stayed cut short. On the Graphics tab that hid Sharpness, the last row of Resolution and upscaling, as Upscaler
changes added and took away rows above it, on a PC where the menu's script falls behind the presents. setTall now
takes every size; useState already ignores the same value.

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

Tested in game: Windows 10 22H2, RTX 4090, NVIDIA 617.42, keyboard and mouse; F1 menu, Graphics tab, at 50839aadc (the same game code as the head): many Upscaler changes fast and slow (Off, Game's own, FSR, MAKO), Dynamic resolution on and off: Sharpness stays and Resolution and upscaling fits its rows; sections on Graphics and the Mods tab ease open and shut as before; no system/menu fault in the log. On main 6b93f9e2b the bug did not show on this PC (the menu's script keeps up here).

Tested in game: Windows 10 22H2, RTX 4090, NVIDIA 617.42, keyboard and mouse; F1 menu, Graphics tab, at 50839aadc (the same game code as the head): many Upscaler changes fast and slow (Off, Game's own, FSR, MAKO), Dynamic resolution on and off: Sharpness stays and Resolution and upscaling fits its rows; sections on Graphics and the Mods tab ease open and shut as before; no system/menu fault in the log. On main 6b93f9e2b the bug did not show on this PC (the menu's script keeps up here).
cuecuemoar changed title from WIP: fix(ui): a collapsible Section stays as tall as its rows when it hears two of their sizes at once to fix(ui): a collapsible Section stays as tall as its rows when it hears two of their sizes at once 2026-12-05 20:33:55 +00:00
Owner
@review
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left (a run of the change itself). The game-free test reproduces the stale-height sequence and passes with the fix. The reported in-game case still needs verification on the affected PC, and CI is running. Recommend approval; not approved on the forge.

The Section now accepts each reported row height, so a shorter height followed by the original height in one event batch no longer leaves the last row clipped. The change also repairs the modtool import test’s call to the updated patch collector.

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)

  • L1 game/modapi/ui/kit.tsx:434: The original in-game failure has not yet been checked on the reporter’s affected machine. (more on the line) Do: Have the reporter repeat the Upscaler changes on the affected Windows 11 PC and record whether Sharpness remains visible and the section fits its rows.

Checks: Still running: 11 checks.

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

Does it help: Yes in the game-free test: the reported run fails on the test commit with 118 of 128 pixels and passes at head; mutations of the fix also fail. The original in-game symptom was not reproduced on the tested RTX 4090, so its resolution on the reporter’s PC remains unverified.

Other systems: The handler is shared by collapsible kit Sections, including the Graphics and Mods tabs and Sections used by mods. The reported Windows NVIDIA run covers opening and closing sections; the synthetic test covers row removal, restoration, batched size events and opening a shut section. No rendering, save, audio or input code is changed.

Switches: None added, changed or removed.

Reviewed: eaffea2ee8 against 302cdf0352: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the applicable standards, the diff and commit messages, the changed import test and Section code, and the new test. Inspected the state setter, event dispatch, layout event generation and fake UI hover path. The full kit and testing_game tests files were skimmed outside the changed and related code; the requested review checklist and adjacent Tooling checkout were absent.; nothing run (a code review).

Checked and fine:

  • The state setter compares against its current stored value, so both sizes in a batch are accepted in order.
  • The added test checks layout behavior and is reported to fail when the original comparison is restored.
  • All three commits record AI assistance; no generated files, game-derived files, switches or versioned renderer interfaces are changed.

Testing: Read-only review; no tests or project scripts were run. The author reports the new test and script tests passing, with existing modtool and game-free failures reproduced on the base. CI is still running.

Overlaps and merge order: Not checked; network unavailable.


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

**Recommendation: Approve.** The code is ready: only testing is left (a run of the change itself). The game-free test reproduces the stale-height sequence and passes with the fix. The reported in-game case still needs verification on the affected PC, and CI is running. Recommend approval; not approved on the forge. The Section now accepts each reported row height, so a shorter height followed by the original height in one event batch no longer leaves the last row clipped. The change also repairs the modtool import test’s call to the updated patch collector. **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) - **L1** `game/modapi/ui/kit.tsx:434`: The original in-game failure has not yet been checked on the reporter’s affected machine. (more on the line) **Do:** Have the reporter repeat the Upscaler changes on the affected Windows 11 PC and record whether Sharpness remains visible and the section fits its rows. **Checks:** Still running: 11 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes in the game-free test: the reported run fails on the test commit with 118 of 128 pixels and passes at head; mutations of the fix also fail. The original in-game symptom was not reproduced on the tested RTX 4090, so its resolution on the reporter’s PC remains unverified. **Other systems:** The handler is shared by collapsible kit Sections, including the Graphics and Mods tabs and Sections used by mods. The reported Windows NVIDIA run covers opening and closing sections; the synthetic test covers row removal, restoration, batched size events and opening a shut section. No rendering, save, audio or input code is changed. **Switches:** None added, changed or removed. **Reviewed:** eaffea2ee803 against 302cdf0352b7: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the applicable standards, the diff and commit messages, the changed import test and Section code, and the new test. Inspected the state setter, event dispatch, layout event generation and fake UI hover path. The full kit and testing_game tests files were skimmed outside the changed and related code; the requested review checklist and adjacent Tooling checkout were absent.; nothing run (a code review). **Checked and fine:** - The state setter compares against its current stored value, so both sizes in a batch are accepted in order. - The added test checks layout behavior and is reported to fail when the original comparison is restored. - All three commits record AI assistance; no generated files, game-derived files, switches or versioned renderer interfaces are changed. **Testing:** Read-only review; no tests or project scripts were run. The author reports the new test and script tests passing, with existing modtool and game-free failures reproduced on the base. CI is still running. **Overlaps and merge order:** Not checked; network unavailable. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -432,2 +432,3 @@
{rows ? (
<Box style={s.sectionRows} onLayout={(z) => { if (z.height !== tall) setTall(z.height); }}>
// (every size heard: two in one batch of events may end where they started; setTall ignores the same)
<Box style={s.sectionRows} onLayout={(z) => setTall(z.height)}>
Member

L1 (should fix): The original in-game failure has not yet been checked on the reporter’s affected machine.

When: On the Radeon 860M, changing Upscaler could leave Sharpness clipped when two row sizes arrived together. The RTX 4090 run did not reproduce that failure on main.

Do: Have the reporter repeat the Upscaler changes on the affected Windows 11 PC and record whether Sharpness remains visible and the section fits its rows.

**L1** (should fix): The original in-game failure has not yet been checked on the reporter’s affected machine. *When:* On the Radeon 860M, changing Upscaler could leave Sharpness clipped when two row sizes arrived together. The RTX 4090 run did not reproduce that failure on main. **Do:** Have the reporter repeat the Upscaler changes on the affected Windows 11 PC and record whether Sharpness remains visible and the section fits its rows.
HumanBean deleted branch fix/sharpness-row-3229 2026-12-05 23:37:26 +00:00
Some checks are pending
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Waiting to run
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 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!3280
No description provided.