fix(ui): a collapsible Section stays as tall as its rows when it hears two of their sizes at once #3280
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3280
Loading…
Reference in a new issue
No description provided.
Delete branch "cuecuemoar/Longshot:fix/sharpness-row-3229"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 (
ShutSectioningame/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 thetallof the last render: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:tall, so it is set;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.tsxShutSection, then the new test ingame/crates/modtool/src/testing_game/tests.rs.A second, small commit.
cargo test -p modtooldoesn't compile onmain.3145d9d48(#3165) gavegame_files::patches::collectarefusestep, and modtool's import test still calls it with three arguments. The first commit passes|_| Ok(()), asbuild-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:
main6b93f9e2b: 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.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 fromsystem/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
eaffea2eeagainstmain302cdf035: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 realkit.tsxandruntime.json the fake game's UI core, and checks four things:c2d58f90fwithAssertionError: as tall as its rows again: 118 of 128and passes on the head.setTalldropped ("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 (mainplus the build fix; 278 passed there):handle::tests::set_mods_reorders_switches_and_keeps_every_other_key,profile::tests::pins_are_added_moved_and_removedandtesting_game::tests::the_menu_passes_its_tests. They were already broken onmain, hidden behind the compile error, and this change doesn't touch them.cargo test -p script(it shipskit.tsx): passes.cargo clippy -p modtool --all-targets --no-deps -- -D warnings(Rust 1.99.1): clean. The workspace-wide clippy stops inapionmaintoo, which this change doesn't touch.tests/run_all.py --strict: head 873 passed, 65 failed, 13 skipped;mainthe same 873/65/13, and no file fails only here.Still to test:
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.tomlor 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
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
https://claude.ai/code/session_01VxeaZi9Np8FcHAzJs2LM9d
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
6b93f9e2bthe bug did not show on this PC (the menu's script keeps up here).WIP: fix(ui): a collapsible Section stays as tall as its rows when it hears two of their sizes at onceto fix(ui): a collapsible Section stays as tall as its rows when it hears two of their sizes at once@review
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)
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:
eaffea2ee8against302cdf0352: 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:
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.
@ -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)}>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.