Skip to content

Carry target paint through every scroll around its target - #1862

Merged
max-sixty merged 14 commits into
mainfrom
shift-a-thread-jitter
Oct 6, 2026
Merged

max-sixty merged 14 commits into
mainfrom
shift-a-thread-jitter

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

The target trace, the aim and the visual marks were drawn in the document's plane from the target's box as each pane clipped it, so every scroll of a pane holding the target rewrote their position and clip, a frame behind the words. They now move with every scroll around their target without script, the way #1782 made the thread card do.

Paint stands

Each paint box stands in a paint stand (runtime/target-paint-geometry.js, paintStand): one frame per box that clips the target, cut to that box's band, inside the frame of the box holding it. geometry.js paintClips reads those bands from the existing clip walk, which clipped and pagePlaneRect now share through clipWalk and cutBy.

Each frame is moved by the scroll of the box holding it through native motion layers (new runtime/scroll-motion.js). Lengths are written where they stand at their scrollers' start, so placing the paint again after a scroll writes nothing. A header stuck over the page's top cuts the paint in the window's plane, as a fixed frame round the page's motion. The thread panel and drawers cut only paint stacked above them (data-lf-paint-plane="chrome"), since they hide what stacks under them. A stand whose box is put away drops its frames and timelines.

Motion layers

Each motion layer runs on a ViewTimeline of the box its scroller holds next (the next frame's box, or the target), so content growing elsewhere in a scroller leaves the paint on its target. Two cases keep the scroller's ScrollTimeline: words standing directly in a scroller, and an axis a scroller starts at its far end (right to left, vertical writing modes, reversed flex), where Chrome measures a ViewTimeline's range from the wrong end. The axis's direction comes from computed style. floating.js's motion layers move onto the same helper and gain both, with the right sign for those axes. Where the browser has no scroll timelines, as Firefox has none, the axes are listed without one and the box is placed again on each scroll.

Visible change

A contour whose target is partly scrolled out of a pane is now cut open at the pane's edge, as the target is, instead of closing along the pane's edge. leaf-dev stills gained a state for it (sort-aim-cut); it is the only state that changed.

Tooling and instructions

  • leaf-dev stills captures at two device pixels per CSS pixel, so crops show text and hairlines as the reader's display draws them.
  • /developing-leaf: a visible change's before/after pairs are handed over on a Leaf page, an lf-shot for each difference from the stills crops, rather than "embedded in the reply", which a terminal session cannot do. It keeps Show each visible difference once in a Leaf handoff #1861's rule to show each difference once.

Tests

  • test_the_paint_over_a_target_in_panes_rides_each_panes_scroll: no writes to the paint on either nested pane's scroll, the paint stays on its element, and stays there when content grows below it. It fails on main.
  • test_a_comment_box_on_words_in_a_scroller_stands_without_scroll_timelines: with no scroll timelines, the comment box for words in a scroller stands and holds its place; it threw before.
  • Two aim tests that measured the paint box's own rect for a clip now read the part its frames show.
  • npm run test:runtime passes. Before the merge with main, the margin, aim, drawing, reactions, anchors, navigation, controls, pages, widgets, shift-watch and send-placement files and the gate's scroll-writes and at-rest checks ran with 15 failures and 5 errors, all of which fail the same way without this change.

Still open

  • A thread card in the page's plane that a pane's edge cuts still rewrites its clip on each pane scroll; the stand's frames could carry that clip.
  • Paint over a sticky target inside a scroller still trails and is rewritten on scroll.
  • lf-shot's change reading outlines the whole pane for this one-line change, since the removed line touches the pane's border.

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

max-sixty and others added 12 commits October 4, 2026 13:06
A thread card beside an element stood level with the element's top as the
window clipped it. Once that top scrolled above the window, the clipped top
was the viewport's edge, so the card sat at y=0 under the banner in the page's
plane: anchored to the element, carried by each scroll frame, and placed back
by the next placement. Shift+a up to an Ask with a thread showed this as a
shaking card, and so did any scroll through a tall commented element.

Beside an element, the card now stands level with any line from the element's
unclipped top (`row`) to its foot (`lastRow`). While the top is scrolled away
and the rest shows, the boundary holds the card at the window's top below the
banner, in the window's plane, so the scroll writes nothing; it leaves with the
element's foot. A passage's card still goes with its first line.

Behavior change: the card on a partly scrolled element waits below the banner
instead of under it, and leaves with the element's foot rather than vanishing
when the last pixel leaves the window. The comment box shares the rule.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The thread card, comment box and Ask option badges keep a scroll from
writing to them by standing in the plane that carries them: anchored to
their subject, or fixed to the window. The plane was guessed from where
the box landed, so a box positioned by one scrolling box could be
anchored to another, carried by each scroll frame and placed back.

- comment-placement's `plane` reports what bound the answer: the rule's
  line, or the boundary edge it was shifted against. floating.js resolves
  that edge to its holder (`holderOf`), the innermost scroller or reading
  region around the subject with that edge, and anchors the box to it in a
  new `region` plane; no holder leaves it in the window's plane.
  `heldByWindow` is gone.
- A boundary carries the `key` that holds its side: the window's edges,
  or a region's whole size and the window's, so a page scroll that moves a
  pane's shown bounds no longer flips the card.
- The card's region clip comes from the solve (`clientBox`), not a read of
  a box that may not be laid out yet, and stops at the card's paint reach.
- A binding badge the banner holds in is fixed (`placeChip`'s `held`).

Behavior change: a card held in by a pane's edge stays still while the
pane scrolls, and keeps its side through a page scroll.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	skills/leaf/packages/default/runtime/annotation-overlay/comment-placement.js
#	skills/leaf/packages/default/runtime/annotation-overlay/margin-projection.js
#	tests/runtime/comment-placement.test.mjs
# Conflicts:
#	skills/leaf/packages/default/runtime/annotation-overlay/comment-placement.js
#	tests/runtime/comment-placement.test.mjs
The target trace, the aim and the visual marks were drawn in the document's
plane from the target's box as each pane clipped it, so every scroll of a
pane holding the target rewrote their position and clip a frame behind the
words. Each paint box now stands in a paint stand (target-paint-geometry.js,
`paintStand`): one frame per box that clips the target (geometry.js
`paintClips`, split from the clip walk), each cut to that box's band and
moved by the scroll of the box holding it through native motion layers
(new runtime/scroll-motion.js). Lengths are written where they stand at
their scrollers' start, so placing the paint again after a scroll writes
nothing. A header stuck over the page's top cuts the paint in the window's
plane, as a fixed frame round the page's motion; the thread panel and the
drawers cut only paint stacked above them, since they hide what stacks
under them.

Each motion layer runs on a ViewTimeline of the box its scroller holds
next, so content growing elsewhere in a scroller leaves the paint on its
target. An axis a scroller starts at its far end (right to left, vertical
writing modes, reversed flex), where Chrome measures a ViewTimeline's range
from the wrong end, and words standing directly in a scroller keep the
ScrollTimeline. floating.js's motion layers move onto the same helper and
gain both, with the right sign for those axes.

Behavior change: a contour whose target is partly scrolled out of a pane is
now cut open at the pane's edge, as the target is, instead of closing at
the visible part. Tests that measured the paint box's own rect for the
clip now read the part its frames show.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A before/after pair is read on a display drawing two device pixels to a
CSS pixel, and a still taken at one blurred text and hid a hairline's
change.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The maintainer skill let the pair be embedded in the reply, which a
terminal session cannot do, so a handoff could fall back to a linked or
hand-composited image instead of an lf-shot with its divider and
outlines. The handoff is now a Leaf page with one lf-shot per changed
state from the stills crops, linked from the reply.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Main's anchor views (#1851) read a target's box as the page's own boxes
cut it, without the window. Both that reading and paintClips now take
their cut from one helper.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handoff instruction here asks for one lf-shot per changed state, while #1861 changes this same paragraph to show each visible difference once. When one change appears in many states, this wording brings back the repeated pairs #1861 is removing. Please reconcile the instruction with that PR before either lands.

scrollMotions built a ViewTimeline or ScrollTimeline for every axis a
scroller scrolls, so in a browser without them a comment box on words in
a scroller threw instead of reaching floating.js's window-plane
fallback. It now lists those axes with no timeline, and the caller places
the box again on each scroll. The handoff instruction asks for an lf-shot
per difference rather than per changed state, matching #1861.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
leaf-agent previously approved these changes Oct 6, 2026
# Conflicts:
#	.claude/skills/developing-leaf/SKILL.md
@max-sixty
max-sixty merged commit 0e52b1b into main Oct 6, 2026
4 checks passed
@max-sixty
max-sixty deleted the shift-a-thread-jitter branch October 6, 2026 02:21
max-sixty added a commit that referenced this pull request Oct 6, 2026
…seen (#1880)

The runtime's reading of what is on screen (`geometry.js`) took the
sticky headers over a scroller's top out of its band (`headerInset`,
`--lf-top`), but nothing at its foot. A long open thread in the Threads
panel pins its reply row at the list's foot, so a turn under that row
read as seen, and read acknowledgement (`thread/read.js`, which counts a
message read once its whole extent has been shown) could count the part
under the row.

A box sticking at a scroller's foot now passes its height and offset to
what it stands over as `--lf-bottom`, registered beside `--lf-top` in
`theme.css`. `footerInset` reads it the way `headerInset` reads
`--lf-top`, and `visibleBand` and the clip walk take that band out at
the foot as they do at the top. The reply row is the one such footer;
its `scroll-margin-bottom` (from #1834) now derives from the same value,
so where a landing stops and what counts as seen agree.

Since #1862 the clip walk's bands also feed target paint, so paint over
thread content under the row is cut there too.

Both of the row's rules key on `.lf-thread-content`. #1834 had keyed its
scroll margin on `:is(… :has(> .lf-thread-reply) > :not(…), … *)`, a
`:has()` before a target that names nothing, which Chrome restyles from
the document root on every write.
`test_no_has_rule_restyles_the_whole_document` missed it because it read
only top-level compounds; it now reads each arm of a selector that is
one `:is()`/`:where()`. Content in a card with no reply row now takes a
ring's room of bottom scroll margin, which the list's own scroll padding
already gives it.

The long-thread edges test in `test_chrome_contracts.py` now asserts
that a turn straddling the reply row's top reads as seen only down to
the row; it fails without the change.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[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