Repository navigation
Keep a comment's pin by its code line through the code block's scroll - #5097
Merged
Merged
Conversation
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, and stood below the block for a line below the code's fold.
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 in its target's frame 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 (from the target's box) all disagreed with the carrier.
The pass reached the block's corner because the `pre` carries the
keyboard stop Copy claims (reach.js lends it), and the margin counted
that stop as a control, so no seat inside the code block was clear.
Now a passage's row is measured from its words:
- `wordsShown` clips the words through every box holding them, the
`code` included, in the pass and in the scroll reading. The scroll
reading also hears a scroll of a box inside the target that moves the
words. The row is withheld once its line leaves the code's view and
comes back with it.
- `passageBlock` is the block a passage's pin falls back to: the
outermost box from the words to the target that every scroll moving
them moves too, short of a box that scrolls them or carries a lent
stop. Words standing directly in the `code` have none.
- `coverIn` no longer counts a lent reach stop on a box holding the
passage's words as a control for that passage's pin, since reach.js
lends it for the keyboard to reach and scroll those words. The pin
can stand by its line inside a code block. An element comment on a
code block still stands above it, clear of Copy.
- `standsBy` records each row's offsets from its carrier's anchor (or
the document's origin for the root lane), which is what the browser
moves it by. `standsNow` reads where the row stands now for the scroll
reading, `paintedBox` and a held pin, which replaces the separate
`seats` record of a held pin's place.
In Chromium, #5058's `scrollend` pass inside a scaled box now writes the
insets the scroll left for such a row, rather than moving it back to the
block's corner. Firefox and WebKit still need it for the scale drift.
Evidence (`leaf-dev probe`, 1280x800, a `layout-workspace` page with a
`pre > code` scroller of 60 lines and a comment on line 24; pin offset
from the line's top after the scroll and after a forced pass, the same in
Chromium and Firefox within a pixel):
| code scrollTop | main: scroll | main: pass | branch: scroll | branch: pass |
| --- | --- | --- | --- | --- |
| 0 (line below the fold) | shown | shown | withheld | withheld |
| 200 | 0 | −313 (block corner) | −30 | −30 |
| 240 | −313 | −273 | −30 | −30 |
| 380 | 0 | −133 | −30 | −30 |
| 600 (line above the box) | shown, off screen | withheld | withheld | withheld |
On an unscaled copy of reveal's rule, the new test fails on main in
Chromium and Firefox with the pin 1011px right of and 193px above its
line; with that assertion removed, it fails where the pass moves the pin
40px from where the scroll carried it.
Other passages keep their seats: probes of a paragraph, a table cell, an
SVG label and an element comment on a code block place the pin exactly
as main does. A passage in a card that clips its own words keeps main's
seat too. A passage in a code block that fits now stands by its words,
or with every seat by its words covered, beside the code's first line,
where main stood it above the block's corner.
Part of #5024
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # dist/kernel/runtime/bundle-content-layout.js
Review of the reveal.js 5.1 deck found the pin for a commented line standing 30px high, at the end of the line above, in Chromium and Firefox, and on the block's left border in WebKit. At 390px a line reaching a scrolling `code`'s edge slid its pin to the window's left edge. 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. - A passage in preformatted text (`white-space-collapse: preserve`) has one seat: level with its line, at the inside right edge of what shows of its nearest block (`preformattedBlock`). `seatRow` keeps such a pin `level`: it takes that seat over the line's last words, or slides left past a control or a pin already seated there, never up, down or past words. Its carrier follows the line down the block but not sideways (`axes: "y"`), so a sideways scroll of the block's lines leaves it at the edge. - `coverIn` never counts a lent reach stop as a control, as control-selectors.js already says, and 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. A heading's link, made only when it shows, has no footprint. Both lent-stop clauses (`coverIn`'s and `passageBlock`'s) are gone. An element comment's pin on a code block now stands inside the block's corner, under Copy, where main stood it above the corner. - Copy writes its transform insets where it first stands, as a heading's link and a recording's bar already did, and every block control reads them again after a resize, so its box at rest is where it shows on a scaled slide in Firefox. Without that, the element pin stood on Copy at load and moved 31px when the pointer first revealed Copy. Tests: `test_a_pin_on_a_line_of_a_scrolling_code_block_marks_that_line` asserts the pin's vertical centre lies inside its line's box and the pin inside the code box, with short neighbours, with neighbours as long as the line (the deck's shape) and at 390px where the line runs past the code's edge; `test_a_pin_on_a_code_block_s_first_line_leaves_copy_pressable` needs no overlap with Copy and a Playwright click on it. All four fail on the previous head in Chromium, Firefox and WebKit (pin 30px high; x=4 at 390; overlapping Copy) and pass now. A runtime case covers the level seat in `seatRow`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… on a moved slide Second review of the reveal.js deck and the column pages: - On a reveal slide reached after load, Firefox kept Copy's box at rest where the slide had been, so the margin kept clear of the wrong box, the pin took Copy's corner, and a press on Copy reached the pin. `blockControlBoxes` now reads each control's transform insets from its block itself, every block before any control is written, once for every pin a pass seats. That covers a first stand, a resize and a slide change, so the resize re-read and Copy's write where it first stands are gone, and code-copy.js matches main. - A paragraph with `white-space: pre-wrap` took the code seat, since its spaces are kept, and stood its pin at the right edge over the words ending its line. The line seat is now for text that keeps its spaces and doesn't wrap (`text-wrap-mode: nowrap`), as reveal's `pre` and Leaf's document code blocks compute; wrapped text, `lf-code`'s lines included, takes prose seats as on main. - A comment on a whole code block stands its pin above the block's top-right corner, as on main, so it reads apart from a line-2 pin at the block's right edge. `preformattedBlock` takes the box holding a passage's words or the target of a row about the block itself, and the one seat it gives is at the block's right edge: level with the line for a passage, above the top-right corner for the block. Only a line's pin follows its line down the block alone (`axes: "y"`); the margin records beside that rule that a sideways scroll of a box around the block leaves the pin behind until the next pass. Tests: a line-1 pin on a slide moved after load must leave Copy pressable (fails on the previous head in Firefox), a block's own pin stands above its corner with a line pin level with its line (fails in all three engines), and a `pre-wrap` paragraph's pin stands where the same paragraph's does without it (fails in all three engines). Co-Authored-By: Claude Opus 5.5 <[email protected]>
leaf-agent
reviewed
Nov 2, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
A multiline code quote can leave its pin outside the code block while part of the quote remains visible; the inline finding has the reproduction.
max-sixty
marked this pull request as ready for review
November 2, 2026 12:01
Tend's review of #5097 found a pin for a quote of several lines of a scrolling code block seated by the passage's first line wherever that line had gone: with lines 4–11 quoted and the code scrolled 180px, the pin stood at y=15–41 above a code box starting at y=118, while the row stayed shown because later quoted lines still showed. Seating read the first raw line; visibility read the whole passage. Both now read one thing. `wordsShown` answers what shows of each quoted line, in order, the lines nothing shows left out. The row shows while one does; a pin on preformatted lines stands at the block's right edge, level with what shows of the first of them. A scroll carries the pin with its line, and once that carries its middle past the quoted lines that show, `targetShown` answers no for a pin kept `level` (recorded in `standsBy`), so the scroll reading brings a pass at once, in the next frame, which seats it by the first line still in view. Waiting for some later pass would have left it above or below the code box meanwhile. `test_a_pin_on_lines_partly_scrolled_away_stands_by_one_still_shown` scrolls two and a half quoted lines past the code box's top, and in a second case leaves 6px of a quote's first line showing at its foot. The pin's middle must lie beside a quoted line in view, after the scroll and after a forced pass, and the row hides once no quoted line shows. All six cases fail on fa60f48 (pin above the box at y≈64, or below it at y≈508) in Chromium, Firefox and WebKit, and pass now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
leaf-agent
approved these changes
Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A comment on a line of a code block whose
codescrolls, as reveal.js'stheme makes every long one (
pre code { overflow: auto; max-height: 400px }), stood its pin in one of two places. A layout pass put it abovethe 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 passmeasured 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'scorner), the words' visibility (clipped by the
pre's ancestors, not bythe
codeinside it) and the offsets the scroll reading andpaintedBoxfind the row by all disagreed with the carrier. And apassage 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 codeblock was clear.
What changed
wordsShownanswers what shows of each quoted linethrough every box holding it, the
codeincluded, in the pass and inthe 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.
its spaces and doesn't wrap its lines (
white-space-collapse: preserve,text-wrap-mode: nowrap, as reveal'spreand Leaf'sdocument code blocks compute) has one seat per pin, at the right edge
of what shows of it (
preformattedBlock): a line's pin inside theblock, 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.
seatRowkeeps such a pinlevel: it takes that seat whatever words it covers, or slides leftpast 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 longline leaves the pin at the edge. Wrapped text that keeps its spaces,
such as a
pre-wrapparagraph orlf-code's lines, keeps prose seats.coverInnever counts a lent reachstop 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 standson Copy or a recording's bar.
blockControlBoxesreads each control'stransform 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.
passageBlock, the block aprose passage's pin falls back to, is the outermost box from the words
to the target that every scroll moving them moves too.
standsByrecords each row'soffsets from its carrier's anchor, on the axes the carrier follows (or
from the document's origin in the root lane).
standsNowreads wherethe row stands now for the scroll reading,
paintedBoxand a heldpin, which replaces the separate record of a held pin's seat.
In Chromium, #5058's
scrollendpass inside a scaled box now writes theinsets 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
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.line, over the line's last words (pair:
~/.tmp/leaf.agent-a531589747ffee0ab/first-line-pin.png). Acceptedcost: a first-line pin beside Copy can cover the last characters of its
own passage when that line reaches Copy's column, as
namofprofile_name)at 760 (pair:~/.tmp/leaf.agent-a531589747ffee0ab/first-line-at-copy.png).top-right corner, as on main (pair:
~/.tmp/leaf.agent-a531589747ffee0ab/element-pin.png; the pin insidemain'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 alayout-workspacepage at 1440x900,
leaf-dev probe --base. Slide 1: comments onstep_05(the code's line 7) and on the whole
pre. Slide 2, reached withReveal.next()after load: comments on the wholepre, on line 1 and onstep_03. dy is the pin's top less its line's top (its centre at +16lies inside the line); right is the pin's right edge less the
pre's:step_05prestep_03preelementFromPointat its centre is Copy, all three enginesOn slide 1, scrolling the code 200px hides the
step_05row in all threeengines (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'sslide-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:
comment: dy −4 or −5 (centred on the line), right −10, or −24 in the
scrolling block, whose
codebox sits inside thepre. main: −93,−173 then +247 after a pass, and +0 from a line scrolled out of view.
−9).
first line ending under Copy: pin at x673–699 over
namof thecommented
profile_name), Copy at x708–732 and pressable.block sideways, the start's row hides and the tail's shows at right −10.
(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).
lf-codelines with neighbours as long as thecommented one (at 1280, 760 and 390): the same seats as main. A
pre-wrapparagraph's pin stands where the same paragraph's doeswithout
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(shortneighbours, 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.
290fcb8cbfailed 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.
290fcb8cbfailed the columncase;
d5c51bb0dfailed 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.
fa60f4806failed 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:d5c51bb0dfailed it (the pin stood inside the block, under Copy).
test_wrapped_prose_that_keeps_its_spaces_seats_its_pin_as_prose:d5c51bb0dfailed it (thepre-wrappin stood at the right edge).levelseat inseatRow.Checks run
uv run pytestontest_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 thepassage and Copy tests of
test_render_send_placement.pyandtest_render_anchors.py: all pass but five that fail the same way onmain:
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]andtest_a_quoted_passage_keeps_its_inline_attachment_before_and_after_send[pointer-900](the thread card never opens after the send).
test_scrollers.pyat the head (58 passed, the new cases in allthree engines),
pnpm run test:runtime(747 passed),pnpm run build:browser,pnpm run check:browser, pre-commit on the changedfiles.
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-windowobserver 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
sideways, which keeps it at the edge through a sideways scroll of a
long line.
Part of #5024