Skip to content

Stop the file tree rewriting its end scroll on each scroll and model change - #6595

Merged
max-sixty merged 1 commit into
mainfrom
pierre-tree-end-clamp
Nov 20, 2026
Merged

max-sixty merged 1 commit into
mainfrom
pierre-tree-end-clamp

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The file tree's vendored @pierre/trees clamps its virtualized list's scroll against a maximum it computes from the viewport's fractional getBoundingClientRect height, while Chrome holds the box at whole pixels. So at the list's end each scroll event and model change wrote a scrollTop that moved nothing (1038.94 against the 1039 Chrome holds), which the write watch reports. This adds a seam in build/vendor.mjs beside the four #6149 added for the same mismatch: the clamp writes only when the box stands a pixel or more past the maximum. The rebuilt bundle changes one expression. Firefox keeps fractional offsets and never made the write.

It surfaced in test_presses_and_fills_leave_no_element_naming_stale_keys[file-tree], which fails whenever its random sweep leaves the tree at its end: 2 of 5 local runs on main, and every run on #6569, whose row change reshuffles the sweep. With the seam it passed 5 of 5 on each. Collapsing a folder at the list's end still clamps the box to the new end. Ref #6303, whose list of Nov 17 nightly failures includes this test.

Found while checking #6569's full test run; nobody asked for it separately. Tests: that node 5 of 5 on main and on #6569 merged; the file-tree widget's tests by node id; pnpm run check:browser.

This was written by Claude Code on behalf of max-sixty

…odel change

`@pierre/trees` clamps its virtualized list in `FileTreeView`'s viewport
`update()`: `if (scrollTop > maxScrollTop) scrollTop = maxScrollTop`, with
`maxScrollTop = visibleCount * itemHeight - viewportHeight`. The viewport
height comes from `getBoundingClientRect` (791.0625px in the file-tree
example at 1440x900), while Chrome's scroll range uses the pixel-snapped
`clientHeight` (791). At the list's end the box rests at 1039 and the
clamp writes 1038.9375, which Chrome snaps back to 1039. `update()` runs
on every scroll event and every model notification, so wheeling to the
end, collapsing a folder that leaves the list at its end, or pressing a
row there (Trees' own `onFocus` and `onClick` notify) each wrote a scroll
that moved nothing. No Leaf frame is on any of those stacks. Firefox keeps
fractional offsets (it rests at 1038.567, equal to the maximum) and makes
no write.

#6149 fixed the same mismatch in Trees' four scroll-target comparisons
with seams in `build/vendor.mjs`. The clamp is the remaining write whose
target comes from the fractional measure, so it joins them: it writes
only when the box stands a pixel or more past the maximum. The rebuilt
bundle changes only `g.scrollTop>ve` to `g.scrollTop-ve>=1`. Trees' other
scroll writes (drag auto-scroll, the sticky keyboard restore) take their
targets from the browser's own scrollHeight, clientHeight or scrollTop.

The unmoved-scroll watch reports it in
`test_presses_and_fills_leave_no_element_naming_stale_keys[file-tree]`
whenever the sweep leaves the tree at its end, as in the Nov 17 macOS
nightly (#6303). Which runs do varies on one commit: the sweep scrolls
its target into view by script and clicks without waiting for a
rendering update, and the file tree's reveal of the focused row moves
the list 10px only when no update ran in between. Locally, main failed
2 of 5 runs and the panel-leaf-inbox branch (#6569) 2 of 2.

Verification: a probe on main records the unmoved write after a wheel to
the end and two more on a press of the last row; with the change it
records none, and a folder collapse at the end still clamps the box to
the new end (1039 to 889) with rows covering the viewport, as on base.
The stale-keys node passed 5 of 5 runs on main and 5 of 5 on the branch
merge, across both sweep paths, including runs that rest the tree at its
end for several steps.
@max-sixty
max-sixty merged commit da4e538 into main Nov 20, 2026
6 checks passed
@max-sixty
max-sixty deleted the pierre-tree-end-clamp branch November 20, 2026 21:17
max-sixty added a commit that referenced this pull request Nov 20, 2026
)

The floating panel's row drops its On Me mark (the inbox icon). The row
is now the field, then the leaf, which takes both roles: it wears the
folded leaf's badges, its count of what waits on the user on a pill over
its corner and its news and error dots beside it, and a press opens the
On view on the tab those marks point at: the menu while an error waits
unseen in Errors, else On Me while anything waits, else Threads while a
thread has news or a draft waits, else the menu. A second press closes
the On view from any tab. A search's or mode's ✕ stands at the field's
end, before the leaf. Tab walks the row as it stands: the field, its
corner control, then the leaf. The leaf draws no ground, neither the
hover fill nor the chip while its view stands open, since its badges
stand over its top edge and a tile's edge met them; the user asked for
the tile to go, and other symbols keep their chip. Folded, the leaf
looks as before, and the fold now gathers into the side the leaf stands
on.

| | Before | After |
|---|---|---|
| At rest | <img
src="https://gist.githubusercontent.com/max-sixty/96b80ba99167f1fcc508eead8cfa0e1f/raw/fe68068fce0f803381db419ecd82297d992d4526/rest-before-ff.png"
width="420"> | <img
src="https://gist.githubusercontent.com/max-sixty/96b80ba99167f1fcc508eead8cfa0e1f/raw/fe68068fce0f803381db419ecd82297d992d4526/rest-badge.png"
width="420"> |
| Draw mode | <img
src="https://gist.githubusercontent.com/max-sixty/96b80ba99167f1fcc508eead8cfa0e1f/raw/fe68068fce0f803381db419ecd82297d992d4526/draw-before-ff.png"
width="420"> | <img
src="https://gist.githubusercontent.com/max-sixty/96b80ba99167f1fcc508eead8cfa0e1f/raw/fe68068fce0f803381db419ecd82297d992d4526/draw-badge.png"
width="420"> |

The badges hang past the leaf's top-left corner, so the leaf stands the
row's padding (6px) further off what precedes it: at the row's 2px gap
alone, the dots sat on the field's focus ring while the user wrote. That
gutter is the one call here the user didn't make; the badge in the row
and the press rule are theirs. Now that the field stands first, its slot
reaches out to the panel's start edge only while it wears the ring, so
the attachment shelf takes its start from the panel's edge and its
measure from the editors, which stay put: hung from the slot, a press on
a picture moved it from under the pointer. The test changes mostly
retarget selectors; `leaf_dev.browser.open_menu`, `on_tab` and
`open_on_me` reach the menu and the On view's tabs by pointer whatever
the leaf opens on.

Asked for by the user, who picked both the badge and the press rule on
the decision page. Tests: the browser tests whose code or helpers this
touches and the journeys that press the leaf or call those helpers,
locally; `pnpm run check:browser`; `pnpm run test:runtime`. A
[full-suite
run](https://github.com/max-sixty/leaf/actions/runs/44667922425) on an
earlier commit found the tests the new order broke, each rerun since by
node id, and a [second full
run](https://github.com/max-sixty/leaf/actions/runs/44708464239) on the
head finds nothing this change causes. Of its failures,
`test_the_shipped_long_thread_keeps_the_margin_and_its_height`,
`test_an_old_document_state_request_cannot_update_the_new_revision` and
`test_page_fixture_opens_without_firefox_console_warnings[thread-panel-gallery]`
fail in [main's nightly
run](https://github.com/max-sixty/leaf/actions/runs/44722728605) too;
`test_trace_replaces_captures_without_blank_pixels_or_layout_displacement`,
where a margin pin lags a script's instant scroll by a frame, fails at
the merge base;
`test_unsaved_words_join_another_tab_s_later_words_in_every_tab` trips
the words watch #6587 has since fixed on main; and Firefox's
`test_a_wheel_as_the_thread_gives_up_room_moves_it_as_far_as_without`
and
`test_a_carry_draws_the_way_of_a_step_news_may_take[overshoot-False-True]`
pass 6 of 6 locally.
`test_presses_and_fills_leave_no_element_naming_stale_keys[file-tree]`
fails whenever its random sweep leaves the file tree at its list's end,
where the vendored tree writes a `scrollTop` that moves nothing: 2 of 5
local runs on main, and every run here, since the row's one fewer
control reshuffles the sweep. #6595, now merged, fixes that write.

Left for a follow-up: a pointer on the leaf brings the panel's corner
fold mark over the count, which now holds that corner. Where the mark
goes is the user's pick.

> _This was written by Claude Code on behalf of max-sixty_
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