refactor(ui): the engine is controls' behaviour, the kit their look, and the one place mods take them from #3069
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3069
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:refactor/ui-kit"
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
Work in progress: the menu still needs trying by hand in the game.
On top of the engine and kit split described below, this PR now also has:
mod testfaster: a test per system mod, and the crates they run optimised in dev builds (about 11 minutes to under 3; these crates rebuild more slowly after an edit).Testing of the later commits:
6bc22d6d(main6318f405), Linux, game-free: shaders, FFI and schema generation,cargo check --workspace --all-targets,cargo testof the touched crates, the four mod tests (menu 71/71), Linux and Windows host builds, selected Python tests.modtool: 269 passed, 1 failed (a_mod_written_off_the_first_time_is_installed_over_without_replace), which fails the same way on plainmain.main's (the branch does not touch the code): clippy stops atbuilder/crates/build-core/src/sandbox_linux.rs:1050, so the touched crates are not fully linted on this base; website test 27 (table/menu graphics coverage mismatch at Profile).run_allwas not re-run after the last rebase.With #3105: a copied mod starts off, and a mod that has only themes does not load into the running game: it needs a restart.
The engine and kit split
Mods' UI had two places to take controls from, and most inputs drew their look in Rust. Now the engine
(
game/crates/ui) does controls' behaviour with as little look as it can, and the kit (longshot/ui/kit) drawsevery look from theme tokens. The kit is also the one place a mod imports controls from.
What changes for mod authors (breaking; the mod API is not stable yet):
longshot/ui/kit:Button,Checkbox,Choice,Slider,Keybind,TextInput,Tabs,HelpLine, plus the containers and rows.longshot/uikeeps the primitives and theheadless engine parts the kit is made of:
ChoiceBase,SliderBase,KeybindBase,TextInputBase,TabsBase.Choice: the engine keeps the arrows and the dropdown over everything; the kit draws the well, the value andthe chevrons.
Slider: the engine maps the drag onto the child withpart: "track", sizes thepart: "fill"child to thevalue's share, and writes the
part: "value"text.Keybind: its children areselectedwhile it waits for a key.TextInput: the kit draws its box; the engine keeps typing, the caret and the selection.keysstyle state. It applies while the player uses the keyboard or a controller.0.5 to 0.45 opacity.
HelpLineandonHelp.HelpLineis a kit component;onHelpis a new prop on any Box. A mod's own windowcan show the label and help of the control the player is at, as the Insert menu's help card does for a hosted page.
Toggle; useCheckbox.$shadow,$sandInk,$icon, and"transparent"as a colour. The kit and the key cap no longerhardcode colours or icon sizes.
game.ui.theme(n)draws in a given Menu theme.Fixed: a dropdown now opens on the side with room. In the compact menu, Render resolution's list opened down past
the card and under the hint bar, so options were cut off. A dropdown now opens below when its list fits there, above
when it fits there, otherwise on the side with more room and scrolls. It stays inside the hosted page above the hint
bar, and on screen for a window. This is the engine's placement (
widgets::popup_rect,Core::popup_room), so everymod's dropdown gets it.
Not moved:
banner are about 500 lines of engine code.
Read first:
game/modapi/ui/kit.tsx: Choice, Slider, Keybind, TextInput, HelpLine.game/crates/ui/src/layout.rs: the Slider parts.paint.rs: the input looks taken out.core.rs:set_ring,set_listening,tell_help,popup_room.widgets.rs:popup_rect.Testing
Tested: Linux, RTX 3090, game-free:
-D warnings, schema-gen and ffi-gen--check, tsgo on the gallery,dev.py rt. In the game: PASS on Linux, RTX 3090: headless dev.py smoke, in play from the kokiri-start save, 900 frames, the Insert menu opened and its page hosted; run_all --strict: 868 passed, 2 failed not from this change (test_vk_wb_cpu_words_fast.py: a renderer C++ test's std::min types under GCC 16; test_lifter.py: build-driver's dev_runtime test hit a file lock, WouldBlock), and modtool's sparkline cost test failed once under load and passes alone.disabled inputs, now dimmed. The Slider's track ends about 2 px earlier.
not this change.
Still to test:
behave as before. Switching from the mouse to the keys swaps a Choice's chevron for its arrows. Disabled rows look
dimmed. (by hand)
The list opens upward, inside the card, never under the hint bar. (by hand)
Measurements
Verdict: the menu's script cost is the same as
main's within the spread between runs, well under every ceiling.Setup: Linux, this PC,
mod test --echo game/mods/menu(optimised builder), itsmenu cost:line;mainand thisbranch run alternately, twice each, in one queued job.
796fdb0bb915ae04Risks
longshot/ui, or usingToggle, need the new import path.ChoiceBase,SliderBaseorKeybindBasedrawn without children shows nothing,which is intended.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (Run as its parts:run_all --strict868 passed, 2 failed, neither from this change:test_vk_wb_cpu_words_fastandtest_lifter(abuild-driverfile-lock test under load), both onmain; the website check fails onmaintoo, "Dynamic resolution minimum".)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here. (dropdown placement:widgetsandcoretests)tests/that reads changed source is updated, not weakened.mainand here, for a change that shows on screen. (reference renderer, above)Assisted-by:/Co-Authored-By:trailers.🤖 Generated with Claude Code
https://claude.ai/code/session_017vw8e2fJhRpDrY7pgVx6oJ
Tested in game: Linux, RTX 3090, NVIDIA 620.70.06: headless dev.py smoke on
b915ae04, in play from the kokiri-start save, 900 frames, the Insert menu opened and its page hosted. The menu has not been tried by hand with mouse, keys or a pad.b915ae046b01c213bdf1refactor(ui): the engine is controls' behaviour, the kit their look, and the one place mods take them fromto WIP: refactor(ui): the engine is controls' behaviour, the kit their look, and the one place mods take them from@review
Recommendation: Request changes. Rapid inventory edits can queue changes against stale counts and give Link the wrong amount. The current head also needs in-game validation and measurement; the reported menu measurements predate the search and later changes.
The PR separates control behavior from appearance, adds theme mods and search, and reorganizes menu and cheat pages. It expands the UI and modding API, but adds substantial menu and inventory logic that needs further review and testing.
Blocking (2): must change before merging.
game/mods/cheats/src/system_mod.rs:501: Each inventory change computes its edits from the last game snapshot without accounting for edits already queued for the same row. (more on the line) Do: Track the projected inventory state including queued edits, or coalesce each row's pending target and compute its next edit from a fresh game state. Add a test with consecutive changes before the inventory snapshot refreshes.@fixor@rebasetry first). (for the author)Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixdoes its part first: Reduce or spread search indexing and matching work across frames.)@fixcan do L1 and L2.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven at the current head. The PR reports two interleaved menu-cost runs for an earlier commit, with steady redraw medians of 0.24/0.27 ms before and 0.21/0.29 ms after; those numbers do not cover the later search or test-splitting commits.
Other systems: The changes affect hosted and standalone mod UIs, keyboard and controller navigation, theme persistence, settings, inventory cheats, Windows and Linux, and all GPU vendors. The reported in-game smoke run was on Linux with an RTX 3090 before the latest commits; the menu was not exercised by hand.
Switches: HOS_SYSTEM_MODS_DIR and HOS_MODS_WATCH are used by the theme reload path; no switch-table change was identified in the portions reviewed.
Reviewed:
01c213bdf1against9a1f19b462: Read repository rules and the PR template, commit log, theme loader and theme registry, cheat system mod, inventory action logic, and menu search in full. Inspected selected UI engine, menu, settings persistence, host watcher, renderer input and test diffs. The 158-file change and all surrounding callers were not read in full, and generated files, translations and recorded runs were not comprehensively checked; this review is therefore incomplete.; nothing run (a code review).Checked and fine:
Testing: No code, tests or project scripts were run, as requested. CI is still running; the PR reports earlier runs and their known failures.
Overlaps and merge order: Not checked; network access was unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -398,0 +498,4 @@if follow.shown == Some(want) {return;}let counts = game_core::travel::inventory().counts;L1 (blocking): Each inventory change computes its edits from the last game snapshot without accounting for edits already queued for the same row.
When: If a count is 0 and the player moves its slider to 1 and then 2 before the twice-per-second inventory refresh, the two changes queue +1 and +2 from the same 0 snapshot. Link receives 3 instead of 2; repeated toggle or tier changes can likewise enqueue edits based on stale state.
Do: Track the projected inventory state including queued edits, or coalesce each row's pending target and compute its next edit from a fresh game state. Add a test with consecutive changes before the inventory snapshot refreshes.
01c213bdf1f9a16bc09ff9a16bc09f6bc22d6d0eReplying to the review of
01c213bd:a02db651. Each inventory row remembers what Link will hold once its queued edits are made and computes the next change from that, for counts, toggles and tiers. Test:a_change_before_the_game_has_the_last_one_edits_from_where_that_leaves_link, which fails with the fix disabled. Two cases remain, found by reading: a count the game caps (a small ammo bag) followed by another change within about 1.5 s works from the amount asked for, and a song toggled twice before the game updates may lose the second toggle.6318f405.🤖 Generated with Claude Code
https://claude.ai/code/session_017vw8e2fJhRpDrY7pgVx6oJ
@review
Recommendation: Request changes. Successive inventory edits can still leave Link with a different value from the one selected. The current head also needs its in-game menu and search validation, and Forgejo reports it as not mergeable.
The PR separates control behavior from their themed appearance and expands and reorganizes the menu. The follow-up spreads search work across frames and tracks pending inventory edits, but that tracking still assumes every queued edit produces the requested result.
Blocking (1): must change before merging.
game/mods/cheats/src/system_mod.rs:501: Pending inventory state assumes queued edits reach the requested value, including when the game caps a count. When: With an ammo capacity of 20, request 30 and then 29 before the pending state settles. The game caps the first edit at 20, but the second is computed as 30 to 29 and removes one, leaving 19 instead of 29 or the capacity-limited 20. Do: Track the actual result of each queued edit, including game limits, before computing subsequent edits; ensure successive song changes also wait for or account for queued flag writes.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixdoes its part first: Reduce or spread search indexing and matching work across frames.)@fixcan do L1 and L2.Since the last review (on
01c213bdf1)Resolved: L3 (It conflicts with its base branch: bring it up to date (
@fixor@rebasetry first).)Still open: L1 (Pending inventory state assumes queued edits reach the requested value, including when the…); L2 (The current head's menu behavior and search cost still need validation in game.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven for the current head: the reported game-free search worst frame is 1.67 ms against a 2.00 ms limit, but the menu and search have not been exercised in game on this head. Earlier menu cost comparisons were on different commits.
Other systems: The shared UI engine affects mod windows and the fallback menu as well as the system menu. The reported Linux NVIDIA game run was on an earlier head; Windows, other GPUs and Steam Deck remain unvalidated in game.
Switches: No switches added or changed by the follow-up.
Reviewed:
6bc22d6d0eagainst6318f4056e: Read the repository rules and PR template, the inventory changes and their queue and game-action paths; inspected the menu search, main and view code and the supplied rebase and test reports. The full PR diff and all changed files were not read in full; generated files and translations were not independently reviewed.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run project code were executed. The author reports game-free checks on the current head and an earlier Linux NVIDIA game run; CI is still running.
Overlaps and merge order: #3105 changes mod loading behavior; the PR description records the resulting theme-mod restart behavior.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
WIP: refactor(ui): the engine is controls' behaviour, the kit their look, and the one place mods take them fromto refactor(ui): the engine is controls' behaviour, the kit their look, and the one place mods take them fromRecommendation: Request changes. Rapid inventory edits can still leave Link with the wrong count or song state. The current menu and search also need an in-game run.
The change separates control behavior from appearance, reorganizes the menu, and adds search and theme mods. It improves mod authors’ control API and adds menu features, but pending inventory edits can produce incorrect results.
Blocking (1): must change before merging.
game/mods/cheats/src/system_mod.rs:501: Pending inventory state assumes queued edits reach the requested value, including when the game caps a count. When: With an ammo capacity of 20, request 30 and then 29 before the pending state settles. The game caps the first edit at 20, but the second is computed as 30 to 29 and removes one, leaving 19 instead of 29 or the capacity-limited 20. Do: Track the actual result of each queued edit, including game limits, before computing subsequent edits; ensure successive song changes also wait for or account for queued flag writes.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixdoes its part first: Reduce or spread search indexing and matching work across frames.)@fixcan do L1 and L2.Since the last review (on
6bc22d6d0e)Still open: L1 (Pending inventory state assumes queued edits reach the requested value, including when the…); L2 (The current head's menu behavior and search cost still need validation in game.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven: the current head has not been tried in game. The reported game-free search worst frame is 1.67 ms against a 2.00 ms limit; the earlier before-and-after menu timings are within run-to-run spread and are not for the current head.
Other systems: The UI engine and kit serve mod windows and the fallback menu as well as the Insert menu. The reported in-game smoke was on an earlier Linux NVIDIA head; current-head behavior on Windows, other GPUs and Steam Deck remains unverified.
Switches: No switch changes were checked in this re-check.
Reviewed:
6bc22d6d0eagainst6318f4056e: Read AGENTS.md and CONTRIBUTING.md, the inventory follow and action code, menu search, the diff statistics and commit list. The full pull-request diff, remaining changed files, generated files, translations, checklist and template were not read in this re-check; the sibling Tooling repository was unavailable.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run the project were executed. The author reports game-free checks on this head and an in-game smoke on an earlier head; CI is still running.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as HumanBean took it out of WIP. Nothing was run; a maintainer decides.
6bc22d6d0e1f6178f0cf@review
Recommendation: Approve. The code is ready: only testing is left. The inventory fix now waits for fresh game counts before applying a later change, including capped counts and song toggles. The current head still needs an in-game menu and search-cost run. Recommend approval; not approved on the forge.
The PR consolidates mod controls in a themed UI kit and expands the menu, including search and inventory editing. The latest fix avoids predicting inventory results, at the cost of delaying successive edits until fresh counts arrive.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixdoes its part first: Reduce or spread search indexing and matching work across frames.)@fixcan do L2.Since the last review (on
6bc22d6d0e)Resolved: L1 (Pending inventory state assumes queued edits reach the requested value, including when the…)
Still open: L2 (The current head's menu behavior and search cost still need validation in game.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven for the current head: earlier menu script measurements were within run-to-run spread, and the current head has not been exercised by hand in game.
Other systems: The UI engine and kit affect mod windows and hosted pages on Windows and Linux, with mouse, keyboard and controller. The reported Linux smoke run used an earlier head; the current menu behavior remains untested in game.
Switches: No switch changes identified in the lines changed since the ledger.
Reviewed:
1f6178f0cfagainstf2cd2f4b34: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the latest fix diff, and the inventory queue and count-refresh code around it. Skimmed the earlier inventory diff and commit list; the full PR and its other changed files were not reread.; nothing run (a code review).Checked and fine:
Testing: No commands that run project code or tests were executed. CI is still running; the supplied report records game-free checks and an earlier Linux smoke run.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
llun referenced this pull request2026-12-03 23:38:52 +00:00