Skip to content

fix: land each scroll glide on a whole pixel so u after d returns to the top - #6364

Merged
max-sixty merged 1 commit into
mainfrom
fix/issue-5883-glide-whole-pixels
Nov 18, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/issue-5883-glide-whole-pixels

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

glideTo aimed at fractional positions, and since #5806 setScroll skips any write that lands within a pixel of where the box already stands. So a glide could end a pixel off its goal: when a page of the threads view measures about 159.7px, a late frame of d's glide leaves the box at 160, and the final write to 159.7 is skipped. u, pressed once that glide has landed, then aims for 0.3. A late frame leaves the box at 1, and the final write is skipped again. The view stops at scrollTop 1, and test_keys_in_threads_act_on_threads times out waiting for scrollTop === 0. #5806 landed the day before that test's first failure.

The glide now rounds its goal and each frame's write to whole pixels, so its last write always moves the box onto the goal. A goal at the box's end stays exactly scrollLimit, because scrollToEnd and the glide's end flag compare against it (scrolling.js). Behavior change: d, u and every other glide end on a whole pixel.

Verification:

  • The new runtime test in tests/runtime/scrolling.test.mjs drives a glide's frames over a box that snaps to whole pixels. It fails before the change (the box ends at 1) and passes after it. pnpm run test:runtime passes.
  • The CI picture of the failure matches a locally rendered threads view at scrollTop 1 far better than one at 0 (1,499 differing pixels against 11,477).
  • In a 1440×503 window, d → wait → u left the view at 1 in 2 of 4 tries before the change and in 0 of 4 after it.
  • 78 focused browser tests that exercise glides, paging and scroll landings pass.

This fixes only test_keys_in_threads_act_on_threads. #5883's other intermittent tests, the diff sideways reader and the visual action's Locator.focus timeout, have different mechanisms and stay open there.

Refs #5883 — automated triage

A glide's goal and per-frame writes were fractional, and since #5806
setScroll skips any write within a pixel of where the box stands. When a
page step measured, say, 159.7px, a late frame of `d`'s glide left the box
at 160 and the final write to 159.7 was skipped; `u` pressed after that
glide landed then headed for 0.3, a late frame left the box at 1, and the
final write was skipped again, so the threads view stopped a pixel short
of its top. That is the state the failing CI picture of
test_keys_in_threads_act_on_threads shows, and why its wait for
scrollTop === 0 timed out.

glideTo now rounds its goal, keeping a goal at the end equal to
scrollLimit, and rounds each frame's write, so the last write always
lands the box on its goal. Behavior change: `d`/`u` and every glide end
on a whole pixel. The new runtime test drives a glide's frames over a box
that snaps to whole pixels and fails before the change with the box at 1.

Refs #5883
@max-sixty
max-sixty merged commit 7d11d06 into main Nov 18, 2026
6 checks passed
@max-sixty
max-sixty deleted the fix/issue-5883-glide-whole-pixels branch November 18, 2026 08:00
max-sixty pushed a commit that referenced this pull request Nov 18, 2026
#6364 rounds every scroll glide's goal to a whole pixel, and a press
made during a glide adds its step to that rounded goal.
`test_the_reading_keys_accumulate_and_reverse` still expected unrounded
multiples of the step. With `d`'s step of 482.4 px, three presses rest
at 482 → 964 → 1446, and the test wanted 1447.2 ± 1. It failed on main
in push run
[44269587200](https://github.com/max-sixty/leaf/actions/runs/44269587200)
with `assert 1446 == 1447.1999999999998 ± 1`.

Only the test changes. Each expected resting place now comes from the
rule `glideTo` states: round the previous goal plus the step. The ±1
bound stays. What the test guards is unchanged. A second press that
measured from a glide still in flight would rest hundreds of pixels
short, and one that ignored the user's mid-glide scroll would miss 400
by a whole step. Rounding at each press drifts at most half a pixel per
press, which no reader sees, so I kept #6364's rule rather than adding a
separate unrounded aim to the glide.

Verification: the test fails on main locally with the CI message and
passes on this branch, together with
`test_the_reading_page_step_never_paints_behind_where_it_started`.

Refs #3985 — automated triage

Co-authored-by: leaf-agent <[email protected]>
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