Skip to content

LRC-LIB-KEYWORDS: the Keyword List holds its place as the Keywords box above it changes - #1755

Merged
echelon merged 2 commits into
storytold:mainfrom
nledford:keyword-list-holds-its-place
Oct 15, 2026
Merged

echelon merged 2 commits into
storytold:mainfrom
nledford:keyword-list-holds-its-place

Conversation

@nledford

Copy link
Copy Markdown
Contributor

Problem

When you scroll down a long Keyword List and tick or untick keywords, the Keywords box above it grows or shrinks (a row of chips, the suggestions). The tree then slides down or up under the pointer, by a row or more with each tick, so the next click has to find its row again.

Fix

The panel now holds the list in place, the way a browser's scroll anchoring does. When the box changes height, the panel moves its scroll offset by the same amount, and the pass is drawn again (request_discard) so the list never shows a frame out of place. It holds only:

  • while the box's top is scrolled out of sight. At the top of the panel the box grows in view, as before.
  • while the change doesn't come from the box itself. With the pointer on the visible part of the box (a chip's ×, a keyword-set button, a suggestion) or the cursor in its field, the box grows in place.

Details that tracing turned up (crates/ui-egui/src/panels/right.rs):

  • How the offset is set. It is set on the scroll area as the redrawn pass starts (vertical_scroll_offset). A scroll requested during a pass (scroll_with_delta, even with no animation) only lands a frame later, so one frame was drawn out of place and a click could hit the wrong row.
  • What the hold counts from. It starts from the offset the previous pass started at, not the one it ended at. Near the bottom, egui pulls a shrunken panel's offset back by the end of a pass, and counting from there subtracted the shrink twice.

This is the app's first request_discard, so the second commit makes App::logic drain control requests (and take the fps sample) only on a frame's first pass. A redrawn pass has no input of its own and still holds the discarded pass's widget rects, so a request answered there would click where a row used to be (crates/ui-egui/src/lib.rs).

Three panels of the Keywords panel. START: scrolled down, nothing ticked. BEFORE: after ticking five keywords, the list slid down. AFTER: after ticking the same five, the list stayed

Left, START: the panel scrolled down, nothing ticked. Middle, BEFORE (main): after ticking lake, macro, mountains, night and ocean, the list has slid down by the growth of the box. Right, AFTER (this PR): the same five ticks, with every row where it was. Demo library, 1400×800, lightcraft-cli snapshot.

Tests

In crates/ui-egui/src/tests_keyword_list.rs:

  • ticking_a_keyword_keeps_the_list_in_place: a 40-keyword list, scrolled so the box is out of sight. Ticks and unticks six keywords and checks three things after each click: the clicked row's rect is unchanged, the click toggled that keyword, and the box really changed height. Fails on main.
  • ticks_in_quick_succession_land_on_their_rows: six ticks clicked back to back with no settling between them, as a script or a quick hand does. All six must land on their rows. Failed with the first version of this fix, which held the list a frame late.
  • at_the_top_the_box_grows_in_sight: at the top of the panel, ticked keywords' chips push the list down, as before.

Verification

  • cargo fmt --all --check, cargo clippy -p lightcraft-ui-egui --all-targets -D warnings, cargo xtask layers, cargo xtask parity
  • cargo test -p lightcraft-ui-egui --lib: 839 pass. The six tests_model_setup tests fail when the crate is built alone (the denoise feature is off) and pass under --workspace; they're unrelated to this change.
  • cargo test -p lightcraft-cli: 21 pass.
  • Two independent read-only reviews. Their findings are fixed in this PR: the pointer-on-box test is clipped to what is visible, control requests are answered on the first pass only, and a hold lasts one pass.

Limits

  • Already at the bottom: shrinking the box can't be held there, since there is nothing further to scroll.
  • No selection: deselecting every photo while scrolled down still moves the list, because that branch draws a one-line message in place of the box.
  • Wheel scrolling at the same moment: a frame where the box changes height drops that frame's wheel delta. An in-flight scroll animation (egui's scroll-to-focus on Tab) resumes toward its old target.
  • Cost: a frame where the box changes height off-screen is drawn twice. That happens once per tick, or per selection change while scrolled down.

Overlap

🤖 Generated with Claude Code

nledford and others added 2 commits October 14, 2026 12:38
…x above it changes

Scrolled down a long Keyword List, ticking or unticking a keyword grew or
shrank the Keywords box above it (a row of chips, suggestions) and slid
the tree under the pointer. The panel now moves its scroll offset by the
same amount and draws the pass again, so the list stays put. It holds
only while the box's top is scrolled out of sight and the change does not
come from the box itself (the pointer on it, or typing in its field).

The offset is set on the scroll area as the redrawn pass starts, from the
offset the pass before started at: a scroll asked for during a pass lands
a frame later, and egui pulls a shrunken panel's offset back by the end
of a pass. Ticks clicked one after another (a script, a quick hand) then
land on the rows clicked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…old lasts one pass

A pass drawn again after a discard still has the widgets of the pass
thrown away, so a control request answered there found a row where it no
longer is; it also added a 240 fps sample to perf.fps. Control requests
and the fps sample now run on a frame's first pass only. The Keyword
List's hold is kept for the pass right after it was asked for, so it
never moves a panel that was not drawn in between.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@echelon

echelon commented Oct 15, 2026

Copy link
Copy Markdown
Member

Thank you @nledford! This landed on main in integration batch 37 (#1852), rebased onto main after the previous batches.

If you haven't already, please join our Discord: https://discord.gg/artcraft. We'd love to have you there.

chrisgleissner pushed a commit to chrisgleissner/lightcraft that referenced this pull request Oct 15, 2026
@nledford
nledford deleted the keyword-list-holds-its-place branch October 15, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants