Skip to content

Keep quoted margin rows with their words during inner scroll - #3091

Merged
leaf-agent merged 1 commit into
mainfrom
fix/ci-38867808372-margin
Oct 16, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/ci-38867808372-margin

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

The failed main run exposed three margin outcomes after #3083: a release-notes suggestion pin covered its own words, a moved suggestion's folded row hid Accept, and a quoted passage marker moved one frame after its words scrolled. This change keeps the new quoted-passage placement while restoring the inset above seat for other inline targets. A passage row now uses the text's scrolling CSS anchor, so its marker travels in the same frame as the words.

The three reported cases failed on current main before the repair and pass afterward. Focused quoted-passage rail and pane checks also pass. The committed kernel is rebuilt; pnpm run test:runtime passes 495 tests, and pnpm run check passes. The run's two composer return failures have a separate scrolling cause and are being repaired separately.

Quoted passage rows now use the passage text carrier, so an inner scroll moves their marker in the same frame as the words. Keep the prior clear above seat for non-quoted inline suggestions; the new hanging seat belongs to quoted passages only. This restores the release-notes pin and moved-suggestion action without changing the quoted-passage placement intent of #3083.
@leaf-agent
leaf-agent merged commit 75c9fb1 into main Oct 16, 2026
4 checks passed
@leaf-agent
leaf-agent deleted the fix/ci-38867808372-margin branch October 16, 2026 09:22
leaf-agent added a commit that referenced this pull request Oct 16, 2026
The [failed main
run](https://github.com/max-sixty/leaf/actions/runs/38867808372) exposed
two Resume writing failures. An editor arrival used smooth scrolling
while the preceding wheel scroll could still be active, leaving the
editor and its passage offscreen. In a rotated two-axis scroller, the
inverse scroll conversion also requested horizontal travel past its
edge; the browser clamped that axis and left the quoted words clipped.
Editor arrivals now land immediately, and the free scroll axis takes the
remaining projected movement at an edge.

Both reported cases failed on the main checkout before this repair and
pass afterward. Three nearby attachment cases pass, as do all 495
runtime tests and `pnpm run check`; the committed kernel is rebuilt. The
other outcomes in the run are margin placement failures covered by
#3091.

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Nov 2, 2026
…#5097)

A comment on a line of a code block whose `code` scrolls, as reveal.js's
theme makes every long one (`pre code { overflow: auto; max-height:
400px }`), stood its pin in one of two places. A layout pass put it
above
the block's top-right corner; a scroll of the code then carried it away
with the lines, 40px for a 40px scroll, until the next pass put it back.
The row also stayed shown while its line was scrolled out of the code's
view.

This happens only where pins are placed by the block: workspace pages,
so every reveal deck, and column pages narrower than the rail needs. On
a desktop column page the row stands in the rail, level with its line,
and the only change there is that it hides while its line is scrolled
out of the code's view.

## The cause

The carrier was right: since #3091 a passage's row is carried by its
words (`anchorFor`), so it moves with the code's scroll. The pass
measured the row against its target instead. The target is the `pre`,
which the code's scroll doesn't move, so the block seats (the `pre`'s
corner), the words' visibility (clipped by the `pre`'s ancestors, not by
the `code` inside it) and the offsets the scroll reading and
`paintedBox` find the row by all disagreed with the carrier. And a
passage in code took the seats built for prose: the seat level with the
line fails whenever the next line reaches as far right, the raised
fallback hangs off the end of the line above, and the slide-left
fallback crosses every word to the window's edge. The pass reached the
block's corner because the margin counted the keyboard stop reach.js
lends the `pre` (claimed by Copy) as a control, so no seat inside a code
block was clear.

## What changed

- **Visibility.** `wordsShown` answers what shows of each quoted line
  through every box holding it, the `code` included, in the pass and in
  the scroll reading, which also hears a scroll of a box inside the
  target. The row shows while one quoted line does, and comes back with
  it.
- **One seat on a block of preformatted lines.** A block whose text
keeps
  its spaces and doesn't wrap its lines (`white-space-collapse:
  preserve`, `text-wrap-mode: nowrap`, as reveal's `pre` and Leaf's
  document code blocks compute) has one seat per pin, at the right edge
  of what shows of it (`preformattedBlock`): a line's pin inside the
  block, its centre on what shows of the passage's first line still in
  view, and the block's own pin above its top-right corner, where main
  stood it. A scroll carries a line's pin with its line; once that
  carries its middle past the quoted lines that show, the scroll reading
  brings a pass in the next frame that seats it by the first line still
  in view. `seatRow` keeps such a pin
  `level`: it takes that seat whatever words it covers, or slides left
  past a control or a pin already seated there, never up, down or past
  words. A line's carrier follows the line down the block but not
sideways (`axes: "y"`, as a rail row's), so a sideways scroll of a long
  line leaves the pin at the edge. Wrapped text that keeps its spaces,
such as a `pre-wrap` paragraph or `lf-code`'s lines, keeps prose seats.
- **Block controls are controls.** `coverIn` never counts a lent reach
  stop as a control, as control-selectors.js already says of it. It
  counts instead the box of every control block-controls.js stands over
  a block (`blockControlBoxes`), at rest as when shown, so no pin stands
  on Copy or a recording's bar. `blockControlBoxes` reads each control's
  transform insets from its block first, every block before any control
  is written, since a deck moves and scales its slides with no resize to
  say so; on a reveal slide reached after load in Firefox, Copy's box at
  rest had been read from before the move. A heading's link, made only
  when it shows, has no footprint, since counting it would move pins on
  hover.
- **Prose fallback in the words' frame.** `passageBlock`, the block a
  prose passage's pin falls back to, is the outermost box from the words
  to the target that every scroll moving them moves too.
- **Where a row stands between passes.** `standsBy` records each row's
  offsets from its carrier's anchor, on the axes the carrier follows (or
  from the document's origin in the root lane). `standsNow` reads where
  the row stands now for the scroll reading, `paintedBox` and a held
  pin, which replaces the separate record of a held pin's seat.

In Chromium, #5058's `scrollend` pass inside a scaled box now writes the
insets the scroll left for such a row instead of moving it back to the
block's corner. Firefox and WebKit still need it for the scale drift.

## Visible changes

- A line's pin in a code block, where pins are placed by the block,
  stands level with its line at the block's right edge rather than above
  the block's corner (main). On a phone it covers the last visible
  characters of a line that reaches the edge, as Copy does on line 1.
  Still pair (760px, main | this branch):
  `~/.tmp/leaf.agent-a531589747ffee0ab/line-pin.png`.
- A first-line pin that meets Copy slides left of Copy, level with its
  line, over the line's last words (pair:
  `~/.tmp/leaf.agent-a531589747ffee0ab/first-line-pin.png`). Accepted
cost: a first-line pin beside Copy can cover the last characters of its
  own passage when that line reaches Copy's column, as `nam` of
  `profile_name)` at 760 (pair:
  `~/.tmp/leaf.agent-a531589747ffee0ab/first-line-at-copy.png`).
- An element comment's pin on a code block stands above the block's
  top-right corner, as on main (pair:
  `~/.tmp/leaf.agent-a531589747ffee0ab/element-pin.png`; the pin inside
main's block belongs to the scrolling block above it, which main stands
  247px below its line after a pass).

## Evidence

Real reveal.js 5.1 deck (`embedded`, scale 1.22) in a `layout-workspace`
page at 1440x900, `leaf-dev probe --base`. Slide 1: comments on
`step_05`
(the code's line 7) and on the whole `pre`. Slide 2, reached with
`Reveal.next()` after load: comments on the whole `pre`, on line 1 and
on
`step_03`. dy is the pin's top less its line's top (its centre at +16
lies inside the line); right is the pin's right edge less the `pre`'s:

| | main | this branch |
| --- | --- | --- |
| Slide 1, `step_05` | dy +321 to +322, right −9 (below the block) | dy
+3, right −28, all three engines |
| Slide 1, the `pre` | 30px above the block's top, right −9 | 29–30px
above, right −10 |
| Slide 2, line 1 | dy +408, right −9 | dy +2 to +4, right −28 (ends
where Copy begins) |
| Slide 2, `step_03` | dy −1 to 0, right −1103 | dy +3 to +4, right −28
|
| Slide 2, the `pre` | pin bottom 4px above the block | 3px above |
| Slide 2, Copy | pressable | pressable, `elementFromPoint` at its
centre is Copy, all three engines |

On slide 1, scrolling the code 200px hides the `step_05` row in all
three
engines (main kept it shown, from a line out of view) and scrolling back
shows it at the same place. At `d5c51bb0d`, the review found Firefox's
slide-2 element pin standing on Copy and a click on Copy timing out.

Column page at 760 and 390 in Chromium and 760 in Firefox (the review's
states), this branch:

- A line in a short block, in a scrolling block, and beside an element
  comment: dy −4 or −5 (centred on the line), right −10, or −24 in the
  scrolling block, whose `code` box sits inside the `pre`. main: −93,
  −173 then +247 after a pass, and +0 from a line scrolled out of view.
- The block's own pin: 29px above the block's top, right −10 (main −30,
  −9).
- The first line beside Copy: dy −5, right −37, slid left of Copy. A
long
  first line ending under Copy: pin at x673–699 over `nam` of the
  commented `profile_name)`, Copy at x708–732 and pressable.
- A line wider than its block: level at right −10; after scrolling the
block sideways, the start's row hides and the tail's shows at right −10.
- Two comments on adjacent lines: the second slides left of the first
(right −45). At 390 a scrolling block's line reaching the edge: right
−24,
  inside the code box (main: 273px above the line; this PR's first head:
  x4, at the window's edge).
- A prose passage, and `lf-code` lines with neighbours as long as the
  commented one (at 1280, 760 and 390): the same seats as main. A
  `pre-wrap` paragraph's pin stands where the same paragraph's does
  without `pre-wrap` (the test below).

The new tests fail on the head before each fix and pass now, in
Chromium, Firefox and WebKit:

- `test_a_pin_on_a_line_of_a_scrolling_code_block_marks_that_line`
(short
  neighbours, long neighbours, 390px): the pin's vertical centre lies
  inside its line's box and the pin inside the code box; a 40px scroll
  carries it with no layout pass and a forced pass leaves it there; it
  hides while the line is out of view. `290fcb8cb` failed it (30px high;
  x4 at 390).
- `test_a_pin_on_a_code_block_s_first_line_leaves_copy_pressable`
  (column, and a slide moved after load): no overlap with where Copy
  shows, and a Playwright click on Copy. `290fcb8cb` failed the column
  case; `d5c51bb0d` failed the moved slide in Firefox.
- `test_a_pin_on_lines_partly_scrolled_away_stands_by_one_still_shown`
  (a quote of eight lines with two and a half scrolled past the code
  box's top, and one with 6px of its first line at the box's foot): the
  pin's middle lies beside a quoted line in view, after the scroll and
  after a forced pass, and the row hides once none shows. `fa60f4806`
  failed all six cases (the pin above the box, or below it), as Tend's
  review found with lines 4–11 and the code scrolled 180px.
- `test_a_code_block_s_own_pin_stands_above_its_corner`: `d5c51bb0d`
  failed it (the pin stood inside the block, under Copy).
- `test_wrapped_prose_that_keeps_its_spaces_seats_its_pin_as_prose`:
  `d5c51bb0d` failed it (the `pre-wrap` pin stood at the right edge).
- A runtime case for the `level` seat in `seatRow`.

## Checks run

- `uv run pytest` on `test_scrollers.py`, `test_pins.py`,
  `test_clusters.py`, `test_card_placement.py`, `test_entries.py`,
  `test_render_margin.py`, `test_rail.py`, `test_status.py`,
  `test_render_heading_links.py`, `test_render_code_reading.py`,
  `controls/test_recording_bar.py`, `test_opening_threads.py`, and the
  passage and Copy tests of `test_render_send_placement.py` and
  `test_render_anchors.py`: all pass but five that fail the same way on
main:
`test_release_notes_pins_under_a_finger_stand_by_the_words_they_decide`,
  `test_a_finger_hides_the_annotations_from_the_leaf_s_menu`,

`test_suggestion_actions_stay_reachable_through_a_decision_and_its_undo`
  (an unchanged style write at teardown, in earlier runs only),
`test_a_new_anchored_comment_keeps_the_users_thread_view[760-False]` and

`test_a_quoted_passage_keeps_its_inline_attachment_before_and_after_send[pointer-900]`
  (the thread card never opens after the send).
- `test_scrollers.py` at the head (58 passed, the new cases in all
  three engines), `pnpm run test:runtime` (747 passed), `pnpm run
  build:browser`, `pnpm run check:browser`, pre-commit on the changed
  files.

## Not verified

- After reveal's animated slide change in Firefox, the reading taken on
  slide 2 still shows Copy's box at rest at its unscaled place: the last
  pass ran while Copy was still `hidden` (its block's near-window
observer had not fired), and nothing reads it again once Copy shows. On
  that slide no pin needed to keep off Copy and Copy stayed pressable;
a line-1 pin whose seat met Copy there would stand on it until the next
  pass. A slide moved without a transition is covered by the test above.

- A code block inside a box that scrolls sideways around it: a line's
  pin follows its line down the block only, so that outer scroll leaves
  it where the window holds it until the next pass, as it does a rail
  row. Accepted.
- A passage in a scroller inside a widget's shadow tree inside the
  target, and a real trackpad scroll (probes and tests set `scrollTop`).

## Calls Max may reverse

- A line's pin follows the line's scroll down the block but not
  sideways, which keeps it at the edge through a sideways scroll of a
  long line.

Part of #5024

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
max-sixty added a commit that referenced this pull request Nov 3, 2026
…lls (#5225)

A margin row quoting a passage now stands in the root lane wherever the
page's own scroll is the only thing moving its words, as rows on whole
elements already did, so a script finds the row where it is drawn in the
same task as a scroll. Every row is also placed again once a CSS
transition or animation that moved its words or its element ends.

**What this buys, and what it doesn't.** Real users saw nothing wrong on
main. A real tap or click on the marker three frames after a scroll
reached it in 12 of 12 runs, and an independent review's recordings show
the painted marker within ±1 px of its words on both arms, smooth scroll
included. The gain is for scripts, which on main read the row at its old
place until the next frame rendered. That includes Playwright's actions:
#5120's reviewer saw a tap aimed in that window scroll to the old place
and miss. It also covers probes and the suite, and it leaves fewer
`position: fixed` carriers on a page. The transition re-placement is a
gain for users. A row on an element whose transition moved it 160 px
stayed 160 px off on main until some unrelated pass ran, and so did a
quoted row in Firefox; both now stand on their words once the transition
ends.

**Cause.** #3091 put every quoted row in a carrier anchored to its
words, so the row would follow words that a box inside the target
scrolls. It did that for every passage, including words that only the
document scrolls. A carrier takes up a script's scroll only as the next
frame renders: css-anchor-position-1 updates anchor positions once a
frame. Chromium also caches an `elementFromPoint` answer given in that
window, for 23 to 28 more frames.

**Change.** `carrierAnchor` takes the passage's words as the row's
subject, by the rule rows on elements follow:

- A row whose words sit in a pane, an inner scroller, or inside a sticky
or fixed box keeps a carrier anchored to its words.
- A row under a sticky header the page declares stands in a carrier
anchored to the document's first box, as a row on an element does. Pages
with such a header, an `lf-tabs` strip for instance, keep every row in a
carrier, and this change doesn't reach them.
- Every other row stands in the root lane.

Rows stand where they stood. On `review-a-plan` at 1440 × 900 and 390 ×
844, and `ship-review` and `release-notes` at 1440 × 900, every row's
rectangle matches main's.

The re-check that already runs, once a frame, when a box inside the page
scrolls and when a transition or animation ends asked only whether each
row under that box still shows. It now also places a row again when its
subject, the words or element it stands by, has moved from where the
last pass stood the row by it (`subjectMoved`). The re-check measures
that against whatever carries the row, so it covers rows in carriers
too.

**A trade-off Max may reverse.** In Chromium and WebKit, a carrier
anchored to the words carried a quoted row along while a transform moved
them. In the root lane the row trails a running transform and lands at
its end, as rows on elements always have. The decision and the rejected
alternative are recorded in `carrierAnchor`'s comment. Two cases stay
off, as rows on elements already are on both arms:

- A scroll-driven animation fires no end event. Its quoted row ends 39
px off in Chromium and WebKit until the next pass, where main left it 16
px off.
- A Web Animations motion (`element.animate`) fires no end event either,
so `subjectMoved` never sees it. In the review, with a held animation in
Chromium, main's quoted row followed its words and this branch's stays
160 px off until the next pass, as element rows already do on both arms.
`lf-deck` flights land right on both arms only because the deck's
put-away step writes a style at the end of the flight, which brings a
pass. A quoted row and an element row on the card Back brings in
measured the same on both arms, during the flight and at rest, in all
three engines.

`subjectMoved` also runs in the existing once-a-frame reading of a
scroll inside a box, not only when a transition ends. In Firefox, inside
a scaled box, that changes what a smooth scroll does. Firefox carries an
anchored row by the scroll's layout distance, not the distance the words
move on screen. On main the row drifted up to 48 px and was placed once
at `scrollend`. Now the re-check finds the words leaving it and places
it again during the scroll: 26 passes over 72 frames, the row within 7
px of its words, and no frame over 15 ms on a four-row page. The
`scrollend` pass stays, since WebKit is 24 px off without it. By the
code's reading, WebKit's measured anchor moves with the words, so its
rows still drift until `scrollend`; that is not measured. The stir
comment, the `css-anchors.js` header and the scaled-scroll entry in
`notes/browser-support.md` now say so.

**Evidence.** The scroll measure loads `review-a-plan` at 390 × 844 with
touch and reduced motion, and scrolls the marker to a third of the
window. It then counts the frames until the marker's box, and a hit test
at one point where the marker is drawn, have caught up. 0 means they
were right in the task that scrolled. Five runs per cell, main and this
branch back to back:

| engine | main: box | main: hit test | this branch |
| --- | --- | --- | --- |
| Chromium 156.0.8078.4 | 2 frames late | 23–28 frames late | 0 for both
|
| Firefox 157 | 2 | 2 | 0 for both |
| WebKit 27.2 | 1 | 0 | 0 for both |

The transform measure, at 1440 × 900, is the offset of each row from
where a fresh pass stands it, at rest after a 160 px transition. It uses
the reviewer's page with its quoted row (`moving`) and element row
(`mover`), run with `leaf-dev probe --journey --base=origin/main`:

| engine | main: quoted | main: element | this branch: quoted | this
branch: element |
| --- | --- | --- | --- | --- |
| Chromium | 0 | 160 | 0 | 0 |
| Firefox | 160 | 160 | 0 | 0 |
| WebKit | 0 | 160 | 0 | 0 |

During the 500 ms transition, the quoted row in Chromium trailed by up
to 160 px on this branch, where main kept it on the words; WebKit and
Firefox trailed on both arms.

**Tests.**

-
`test_a_passage_s_row_moves_with_the_page_s_scroll_in_the_task_that_scrolls`
scrolls a quoted row into view and reads, in the same task, its offset
from its words and whether `elementFromPoint` where it is drawn finds
it, for a pin at 390 px and a rail row at 1440 px. On main both cases
fail: the box is still 3727 px and 1374 px from its words.
- `test_rows_stand_by_words_a_transition_moved_once_it_ends` moves a box
160 px by a CSS transition and reads, two frames after `transitionend`,
where the quoted row and the element row stand. On main the element row
fails, 160 px off. Without `subjectMoved` both fail.
- `test_the_rail_tab_stop_follows_a_carried_row_back_into_view` needs a
row that stands in a carrier. ship-review's first row no longer does, so
the test now builds one on a line a box scrolls sideways; the behaviour
it protects is unchanged.
- `notes/browser-support.md` records Chromium's cached
`elementFromPoint` answer, with the evidence that real input isn't
affected, under "A cached `elementFromPoint` answer in Chromium". Rows
in carriers keep it.

Ran:

- the three tests above against main, the branch without `subjectMoved`,
and this branch;
- 53 tests in `tests/browser/margin/test_scrollers.py` selected for
carriers, panes, passages, code blocks, scaled and widened boxes, sticky
cuts and transitions;
- 13 tests asserting that a scroll writes nothing or reflows nothing;
- 26 more on quoted rows, cards on shipped examples, comment marks and
the smoke tests;
- `pnpm run test:runtime` (753 passed), `pnpm run build:browser`, `pnpm
run check:browser`, and pre-commit on the changed files.

Not verified: the iOS simulator; and the journeys tier and corpus render
gate, which landing runs.

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

---------

Co-authored-by: Claude Opus 5.5 <[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.

1 participant