Skip to content

Keep the comment box beside a tall focused element through a scroll's momentum - #6892

Merged
max-sixty merged 4 commits into
mainfrom
comment-box-follows-scroll
Nov 23, 2026
Merged

max-sixty merged 4 commits into
mainfrom
comment-box-follows-scroll

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The comment box beside a tall focused element now follows a scroll on every frame, a trackpad's momentum included. It waits at the window's top while the element scrolls past, goes in the frame focus leaves sight, and comes back in the frame the element does. Before, the resting box rode the element's top off the window, and on the way back it stayed hidden until the scroll stopped, for about 2.7 s with the element in view in Firefox.

Nobody chose the wait. #1705 put the open box on CSS anchors, so no scroll solved it again. #5242 left the page plane that way with a TODO, and #5428 made the resting box ride the same way. After that, only the scroll-end repaint that #5192 added in user-place.js moved it. focusPlace has since read where glides land, so that repaint protected nothing.

  • floating.js solves a box again on each scroll around the element it watches. A solve beside the words writes nothing, and a box held in by the window's edge stands fixed. Each surface's autoUpdate takes ancestorScroll: false, so each scroll solves the box once.
  • geometry.js whenChanges reports each frame focusPlace flips, replacing the scroll-end repaint. whenNone now wraps it.
  • The open or resting box writes its width only up to the card's measure. A sideways scroll under it no longer rewrites --lf-float-w on every step.

Behavior changes to weigh. Where c goes now updates during a scroll. The resting box goes as focus leaves sight, though its placement could keep it on screen a little longer. On a page where On Me lists anything, the panel's row shows Next On Me instead of c, so after the box goes nothing shows where c goes. field-readings.js records that choice.

Evidence (Firefox, the css-theme-structure page, 1440×900): the resting box showed on exactly the frames where focus was in sight, 1013 of 1013; on the base, 360 frames owed a box and showed none. The open box held on 1030 of 1030 frames, keeping its typed words and focus. In Chromium, script time over a 160-frame smooth scroll was 11.5 ms against 11.3 ms on the parent commit.

Max asked for this in a comment on a Leaf page, and a fresh-context agent reviewed it over three rounds. test_the_box_beside_a_tall_target_waits_at_the_window_s_top_through_a_scroll fails on the base in Chromium and Firefox, and floating-placement.test.mjs covers the scroll listeners.

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

Beside an element taller than the window whose top has scrolled away, the
comment box, resting or open, now waits at the window's top on every frame of
the scroll, as placement-rules.json's `scroll-held-in` says and as the thread
card already does. Before, the box rode the element's top off the window for
the whole scroll, momentum included, and the resting box jumped back to the
window's top only when the scroll sequence ended; the open box never came back
until Resume writing.

Cause: floating-response.js passed the open and resting box to floating.js as
always in the page's plane ("page"), and its editing observer ignored ancestor
scrolls, so no scroll solved the box again. The only later placement was the
generic repaint at `watchScrollEnds` (user-place.js), which re-placed the
resting box and skipped the open one (`nativeAttachment`).

What changes:

- The box takes the plane its answer's binding edge names, like the card, and
  every ancestor scroll invalidates it. Beside its words the answer writes
  nothing (`anchoredAt`'s unchanged check), so the browser still carries the
  box by its anchor with no frame of lag; held in, it stands fixed in the
  window's or region's plane.
- floating.js drops the `"page"` literal for `planeOf` and its exception in the
  old-size solve, which #5242 left as "placing the open box again on every
  scroll". The editing observer drops its own scroll-offset bookkeeping, which
  existed only to ignore scrolls.
- browser/AGENTS.md's "read again when the scroll ends" now names the case it
  already didn't cover: a box an edge holds in is solved at each scroll.
- Rejected, and recorded in floating.js: a CSS `clamp()` over `anchor()`.
  Chromium 159 re-solves it each frame, but Firefox 159 solves it once and
  carries the box by the scroll, and WebKit 27.2 does under the wheel.

Behaviour a test protected that changes: a tall comment box over a passage
(test_a_text_comment_chooses_above_when_the_page_has_more_room_there) now
waits inside the window while the paragraph it stands over shows, as the card
does, rather than riding off with the passage.

Evidence, Firefox 159 on the user's page (css-theme-structure, a 2,303 px
lf-group at 1440x900, a 49-step momentum-like wheel): base, the box's top went
14 -> -884 px across the 1.3 s scroll and jumped to 8 px about 100 ms after it
stopped; head, 8 px on every sampled frame after the crossing one. Cost in
Chromium over 80 frames of smooth scroll: about 0.3 ms of main-thread time per
frame.

New test: test_the_box_beside_a_tall_target_waits_at_the_window_s_top_through_a_scroll,
resting and open, in Chromium and Firefox; it fails on the base.
…hear each floating box's scrolls in one place

Before this change, scrolling back up into a tall focused element left its resting
comment box hidden until the scroll ended. A fresh review in Firefox found this as the
same symptom in reverse: the group's foot was in view for about 2.7 s with no box,
361 to 378 frames across runs. The box was let go once the scroll that carried focus out of
sight ended. Whether it rests again was decided only at the next scroll's end, by the
repaint `user-place.js` made in `watchScrollEnds`.

That repaint was added in #5192, when "only a settled scroll counts" protected a key
pressed during a walk's glide. `focusPlace` has since read where glides land
(`seenAhead`), so it gives the same answer mid-scroll as at the scroll's end.

- `geometry.js`: `whenChanges(holds, changed, nodes)` reports each time a reading of
  what is seen starts or stops holding. It reads in the same pass `whenNone` did:
  after each `watchRoom` change, a scroll's every frame included, and when a watched
  node crosses the window. `whenNone` is now a wrapper over it.
- `user-place.js`: `whenChanges(focusPlace, repaint)` replaces the scroll-end repaint.
  The page repaints in the frame where focus moves into or out of sight, which moves
  `c` and rests or lets go of the box.
- `floating.js`: scrolls are the placement's own, for every plane. `watch` takes
  `getOverflowAncestors` and listens to the scrollers around the watched element
  from the watch on, so a card that no placement has stood yet, waiting for room,
  still hears a scroll that gives it some. Each placement then moves the listeners to
  the words it stood the box beside. Each surface's `autoUpdate` gets
  `{ancestorScroll: false}`. Before this, the box and the card each heard a held-in
  scroll twice, once through their own watch and once through floating.js.
- `floating-response.js`: the placement's `update` ends the native attachment itself,
  so the editing observer's `invalidate` wrapper is gone. The open or resting box
  writes its room only up to the card's measure, which its frame never exceeds, as the
  card's width does. Since the previous commit solved the open box on each scroll, a
  sideways scroll of a code block under it wrote `--lf-float-w` on 20 of 20 steps and
  forced a layout each time; it now writes on none.

Behavior changes:
- Whether focus is in sight, and what follows from it (where `c` goes, the resting
  box, the panel's key hint), now updates during a scroll rather than at its end.
  Dispatch already read `focusPlace` at each key press.
- The resting box goes in the frame a scroll takes focus out of sight, though its
  placement would keep it on screen a little longer, carried up by the target's foot.
  Before, it slid off and was let go at the scroll's end, showing a `c` that already
  opened the panel's field. composing/surface.js's header now states this.

Tests:
- `test_the_box_beside_a_tall_target_waits_at_the_window_s_top_through_a_scroll` now
  scrolls past the target's foot and back. Its resting cases fail in Chromium and
  Firefox with the scroll-end repaint restored.
- `tests/runtime/floating-placement.test.mjs`: the test of a held plane keeping the
  watch's scroll invalidation becomes a test that a watched box hears its element's
  scroller before any placement, that each scroll around the words solves the box
  once, that a placement against nothing lets the scroller go, and that a stopped
  placement hears none. The watch-hears assertion fails without the watch's listener.
- `test_render_shift_watch.py` passes `getOverflowAncestors` to `watch`.

Firefox (`tall.py`, 1440×900, trackpad-like wheel steps, down past the group and back):
- Resting box: read after each frame, shown on exactly the 836 of 1013 frames where
  `focusPlace()` returns the group, and gone in the frame its foot leaves the window
  (base: 360 frames owed a box and showed none). A sample taken in the probe's own
  frame callback, which runs before Leaf's pass, reads that one frame stale.
- Open box: 1030 of 1030 painted frames match, and the typed words and focus are kept.
- Open box on words in a sideways-scrolling code block: 0 style writes in 20 steps,
  the box keeping its offset from the words.

Chromium smooth scroll of 160 frames: script time 11.5 ms on this commit against
11.3 ms on its parent, which is within noise.
@max-sixty
max-sixty merged commit 624f947 into main Nov 23, 2026
6 checks passed
@max-sixty
max-sixty deleted the comment-box-follows-scroll branch November 23, 2026 20:02
max-sixty added a commit that referenced this pull request Nov 23, 2026
…ages per frame with probe --frames (#6902)

With focus on an ask, a choice's digit now comes into view with the
choice during a scroll, a trackpad's momentum included. Before, it
appeared only once the scroll ended: in Firefox the first choice's digit
stayed missing for about 1.1 s on the way back up a tall group. It is
the symptom #6892 fixed for the resting comment box, found by checking
each owner that updates only at a scroll's end; the other five record
what the reader doesn't see, re-read a short-lived hint map, or already
follow the scroll.

- `command-hints.js` wears a face unmeasured where the window doesn't
show its control, and every face while any box on the page scrolls, so
the browser carries the digit with its control and clips and stacks it
as it does the control. The first scroll event paints once; the scroll's
end applies the rules for a page at rest again.
- `leaf_dev/frames.js` reads a page after every frame it draws.
`motion_frames.js` now records through it, and `leaf-dev probe --frames
EXPR` exposes it, named in `/developing-leaf` beside probe's other
options: a journey that samples in its own frame callback reads before
Leaf's rendering pass and sees the frame before, which misled a review
round of #6892.

**Behavior change to weigh.** A chip that stands in for a face the page
at rest withholds gives way to the face while any box on the page
scrolls. Where page content covers the face, neither shows until the
scroll ends or the face clears the cover; a face cut at the window's
edge shows cut while another box, such as a code block, glides.
Narrowing "moving" to the boxes around each control would need a new
reading from `arrivals.js` for that rare case.

**Evidence.** Firefox, momentum up past a choice entering at the
window's top: the digit shows on 316 of 316 frames (main: 176 of 310,
all after the scroll ended), and on 319 of 319 under a 200 px sticky
masthead. Chromium main-thread time over a 160-frame scroll is unchanged
(92.1 against 91.8 ms).


`test_a_digit_shows_on_its_choice_as_a_scroll_brings_the_choice_into_view`
(Chromium and Firefox) fails on main; `test_floating_box_motion.py`
passes on the shared reader. Max asked for this follow-up after #6892,
and a fresh-context agent reviewed both the first design and its
replacement.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty pushed a commit that referenced this pull request Nov 24, 2026
… test past the comment box's hold (#6917)

The six failures in [run
45263521603](https://github.com/max-sixty/leaf/actions/runs/45263521603)
come from two changes that meant to move the behavior these tests read.
The tests now follow those changes, and no runtime code changes.

- **#6796 (`aa34b6b22`)**: a Threads row now opens a passage's thread
beside the passage unless the tab chose the panel.
`test_whatever_the_field_holds_the_row_keeps_its_line`,
`test_a_thread_s_head_names_the_headings_over_its_words` and the
`rewritten-keyboard` case of
`test_original_quoted_words_remain_readable_after_the_page_rewrites_them`
still expected the panel's view. They pass at its parent `9da5040d6` and
fail from it on. Each now calls `choose_threads_in_panel` first, as
#6796 did for its other Threads tests, so they check the panel's row and
quote head again. The quote test drops its margin-card branch, which
expected `role="button"` on `.lf-thread-quote`. `thread/thread-card.js`
never sets that role.
- **#6892 (`624f947b5`)**: the comment box now waits at the window's top
while its target is in sight, which #6892 says covers the open box too.
So the beacon test's single wheel by the field's height leaves the field
72% in the window. It passes at `8c9a570ba` and fails at `624f947b5`.
The test now scrolls the paragraph out first, then the field. It still
checks that the beacon shows once the field leaves while the frame's
rows reach in.

On current main, the six cases fail without this change and all ten
cases in those tests pass with it, in Chromium and Firefox.

Closes #6909 — 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