Skip to content

Remove per-row CSS anchors from margin placement - #1890

Merged
max-sixty merged 7 commits into
mainfrom
codex/leaf-issue-fixes
Oct 6, 2026
Merged

max-sixty merged 7 commits into
mainfrom
codex/leaf-issue-fixes

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Thread navigation repeatedly forces document layout. When every margin row uses CSS anchor positioning, each pass revisits every thread target, multiplying that cost on pages with many comments. Margin rows now get measured positions from one geometry owner; root scrolling carries them naturally, and nested scrolling uses the shared scroll-motion primitive. All rows remain rendered.

Placement renewal and native motion now share the same passage attachment. Clearance chooses the initial seat; every landed surface retains its passage-relative frame through scrolling and typing growth. Client geometry, anchor boxes and scroll origins are captured together before asynchronous solving. Compatible sampled effects survive renewal and are cancelled at cleanup. This includes signed/transformed axes, shadow/slotted targets, constrained attachments, overflow growth/disappearance and virtual quotes. The obsolete CSS-anchor diagnostic and hiding rule are removed. The typing sensor protects fields, reading/control landmarks and painted holders while allowing transparent coordinate carriers to rebase; behavior contrasts retain detection of actual movement.

Validation: 56 placement tests, 262 stability-sensor tests (six skipped), 32 margin contracts, 223 runtime tests and pre-commit checks pass. Fresh independent review verifies scrolling, rotated and fallback attachment, geometry capture, effect lifetime, and editor growth above and below the passage. The native renewal recording retains focus with less than 0.006px attachment drift across 29 samples. In the final local Chrome 154 comparison of f4e74b7 against frozen main 58aaf44, median thread-step duration falls from 172ms to 80ms, and mean forced-layout time from 4.11ms to 0.13ms. All 104 rows remain rendered and all six card positions are identical. The separately traced third step keeps 23 layout passes but removes 2,392 margin anchor invalidations. These local elapsed measurements are diagnostic, not the original Linux environment’s latency percentile.

Closes #1839.

This was written by Codex on behalf of max-sixty

Derive widget capacity from the room its holder grants, including framed and Ask evidence tracks. Suspend distant Copy controls under the shared anchor lifetime, preserving retained widget bindings on reconnection. Require hosted agents to validate edited source before finalizing, and compare the same working and historical document inventory when re-vendoring.
# Conflicts:
#	skills/leaf/packages/default/runtime/annotation-overlay/floating.js
leaf-agent
leaf-agent previously approved these changes Oct 6, 2026

@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 transformed quote attachment regressed. In test_a_quote_surface_follows_scaled_inner_scroll_and_retains_native_editing, a diagonal scroll inside #quote under scale(.8) rotate(10deg) moves the selected words about 13 px left, while the thread preview's x coordinate stays unchanged. The test passes at merge base 6df5ef51 and fails on this head, both locally and in the PR's test job; the shift watcher also reports the card moving after input settles. The new scroll motion used by floatingPlacement needs to carry this card along both axes before the approval can stand.

@leaf-agent
leaf-agent dismissed their stale review October 6, 2026 08:04

CI reproduced a transformed quote attachment regression on the reviewed head.

Initial clearance chooses the seat; every landed surface retains its passage-relative frame through scrolling, typing growth and renewed placement. Capture anchor geometry and scroll origins together before asynchronous positioning, and renew sampled motion effects instead of exposing a pending replacement.

The typing sensor now protects reading and control landmarks and painted holders, rather than transparent coordinate carriers. Behavior contrasts retain detection of field, declared region and painted-holder motion. The fallback contract now follows quoted words after a real wheel gesture.
@max-sixty
max-sixty merged commit 7bd43bc into main Oct 6, 2026
4 checks passed
@max-sixty
max-sixty deleted the codex/leaf-issue-fixes branch October 6, 2026 09:07
leaf-agent added a commit that referenced this pull request Oct 6, 2026
Opening a folded margin pin moved its toggle 96 pixels away from the
finger in [the failed main
run](https://github.com/max-sixty/leaf/actions/runs/37448602643). The
margin layout introduced in #1890 seats a folded pin as one control, but
the open row contains its options too. The layout wrote the one-control
seat's left edge to the wider row, placing the toggle to the right of
its original position. It now keeps that narrow seat for collision
packing while placing the wider row from the seat's right edge. The
existing phone browser test fails before this change and passes after
it, including the hit test for the opened actions.

Two thread-card checks in the same run required the card's left edge to
be exactly eight pixels after its pin. The card is clear of the pin and
reaches the viewport's right edge, but its natural width leaves extra
space after the pin. Their assertions now check clearance while
retaining width, viewport, clipping, and scroll-following checks.

Verified locally: the three named margin browser tests pass, and `npm
run test:runtime` passes.

---------

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 6, 2026
The full Python suite failed when `HOLD_MOTION` assigned `currentTime =
0` to a scroll timeline animation created by the native scroll motion
added in #1890. Chromium rejects an absolute time on a progress based
timeline; the resulting page error stopped
`test_a_refused_position_reconciles_the_logged_order_of_sibling_units`
before it could observe the refusal. The helper now holds only
animations on the document timeline, which are the gesture animations
this test needs to inspect.

The test failed in [the main CI
run](https://github.com/max-sixty/leaf/actions/runs/37448602643) before
this change and passes locally afterward: `uv run pytest -q -n0
tests/test_render_outbox.py::test_a_refused_position_reconciles_the_logged_order_of_sibling_units`.
`npm run test:runtime` also passes.

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Oct 6, 2026
A margin pin whose target scrolls inside a pane followed that scroll
through a ScrollTimeline motion layer, which Chrome can paint a frame
before or after the scrolled content, as #1916 found for the comment
box. On CI's Linux runner under load, 6 of 20 runs of a pane pin drew a
frame with the pin a wheel step (40px) off its target, and three
tripped the suite's shift watch ("span.lf-margin-marker moved without
input by (0, 40)px").

A row whose target scrolls inside a box short of the document now
stands in a carrier: a fixed box anchored to an element that box's
scroll carries (`carriedAnchor`), so CSS anchor positioning moves it
with the target in the frame that scrolls. With the change the same
job showed 0 of 20 desynced and no shift-watch reports. Rows share a
carrier per anchor, axis set and run, not one per row, which keeps the
layout cost #1890 removed: rows still name no anchor of their own. A
rail row's carrier follows only the block axis, as the rail does not
follow a region's sideways scroll, and a sideways page scroll places
those rows again. A carrier takes a row only where every box between
its target and the scroller is in flow: a sticky, fixed or absolute box
there moves the target other than the scroll does. Motion layers remain
where no anchor reaches, as inside a shadow tree, or when the lane
itself rides one. Each pass names the carrier's anchor again, since a
revision that rewrites the anchor's style takes the name away. A
carrier holds one run of consecutive rows and stands in its lane where
that run comes, so rows keep document order across carriers.

`carriedAnchor` (anchor-names.js) is now the one rule for "an element a
scroller's scroll carries"; the comment box's anchor (#1916) uses it.
The scroll reading that withholds a row as its target leaves no longer
reads the row's box, which a carried row reports a frame late after a
scroll, but the offset from its target recorded at placement.

Tests: `test_a_pin_in_a_pane_paints_in_the_frame_its_target_scrolls`
reads Chrome's compositor frames through a pane scroll. It passes
locally on either mechanism; the desync shows on CI's Linux runner
under load. The trace helper behind it (`compositor_trace`, with
`frame_image` and `marked_tops`) is shared with the wheel-return test
and records only the categories it names: Chrome otherwise adds its
default ones, and the forced-layout events the suite's own watchers
cause made a two-second idle trace 2.9 million events long, so the
trace often outlasted its wait under load.



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

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 9, 2026
Main's #1890 holds a landed comment box by its edge as it grows, so Floating
UI's size gives only the room from that edge to the window. With the page no
longer scrolled to make room, a box under or over its passage stopped at the
window's edge instead of sliding. The box's height now reaches the whole
boundary on every side, as it already did beside its passage, and shift
slides it inside the window.

test_where_a_comment_stands_before_and_after_send's phone case no longer
requires the box to overlap its block only when the two cannot show
together; it requires the box to stand at the window's edge.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 9, 2026
…e page (#1784)

Typing in a floating comment box scrolled the page whenever the box
stood
under or over its passage and grew past the room shown on that side. On
every content change, `floating-response.js` asked `makeRoom` to scroll
the reading region until the whole box fit clear of the passage. A
stack-logged probe at 900x700 measured it. With the box over its passage
at mid-window, the first keystroke scrolled the page 162px. With the box
under a passage near the top, the page scrolled 55px once the box
reached
the window's foot. The user's rule is that the box moves and the page
stays.

The comment box's height may now reach the whole boundary on every side,
as it already could beside its passage, and growth never spends scroll
travel. It grows from the edge that holds it (#1890 holds a landed box
by
that edge). Once the window stops that edge, shift
slides it over its passage, and once it fills the window it scrolls its
own words. This is what a box beside its passage already did at the
window's foot. Only a thread card opening under or over its target still
scrolls to make room. The margin card's reply never scrolled the page
while typing; the same probe confirmed that at both widths.

Letting the box fill the window exposed a 2px mismatch at Send. The box
reserved 2px less beneath its words than the card's reply row takes, so
a
card capped at the window's height shrank its transcript and shifted the
sent words up 2px (`test_send_grows_thread_around_the_words` at
900x600).
One token, `--lf-comment-reply-row`, now sizes both.

Behavior changes the tests now protect:

- `test_typing_moves_the_comment_box_and_leaves_the_page_still` (new)
  types line by line into a box under and over its passage and checks
that the page never scrolls and the box stays in the window. Both cases
  fail on main.
- `test_a_growing_text_comment_keeps_its_side_and_the_page_still` (was
  `..._keeps_its_passage_clear_without_changing_sides`) and
  `test_a_text_comment_chooses_above_when_the_page_has_more_room_there`
asserted that typing scrolled the page and kept the passage clear. They
now assert that the page stays put, and that a later scroll carries the
  grown box with its passage.
-
`test_a_wheel_return_attaches_the_comment_box_in_the_first_visible_frame`
types a shorter draft. In its pane cases, typing used to scroll the pane
  to make room under the passage, and the test expected the box there.
- `test_where_a_comment_stands_before_and_after_send`'s phone case
  required the box to overlap its block only when the two couldn't show
  together, which only held while typing scrolled the page. It now
  requires a box that overlaps to stand at the window's edge.

The assets AGENTS.md "Stability" section now says a floating box grows
inside the window and never scrolls the page for its growth. A field in
flow, which cannot move apart from the page, still keeps its controls in
view.


## Add-on F: one shared reading of where the user works

The design review proposed one reading of the user's working point,
shared
by the card's held edge (`holding`, fed by `drafting` in
`margin-projection.js`), the place keeper (`recentPlaceInput` in
`user-place.js`) and typing growth. This change doesn't add it. I sorted
the place- and landing-hold repairs since 2026-09-23 by the question
each
answered:

- Which edge of the card stays still: #1429, #1536, #1552, #1574, #1587,
  #1771. #1552 and #1574 fixed how the hold was keyed across a second
  placement pass and across Send's admission, not which point the user
  works at.
- Which item in a scroller stays still: #1045, #1464, #1480, #1549,
#1694,
  #1715, #1735.
- What waits behind a notice: #1473, #1493, #1725, #1738, #1742.
- What a landing reveals on entering, sending or typing: #1303, #1364,
  #1571, #1602, #1624, #1626, #1645.
- Whether the box or the page moves as the box grows: #1453 and this
one.

None of these commits names a case where `drafting` and
`recentPlaceInput` disagreed, so a shared reading wouldn't have
prevented
them. The two readings also differ by design. `drafting` counts words
left
in the reply and a send still in flight, both of which outlast focus and
the pointer. The place keeper deliberately follows whichever of pointer
and focus came last. Their outputs differ in kind too: one is an edge of
a
floating surface, the other a node in a scroller's list. The typing
scroll
was a question of which thing moves, so it needed no working-point
reading.

One rule does repeat: a focused control counts as the user's place only
while it is on screen. `holdBox` (`reply-landing.js`), the place
keeper's
"begins in the band" filter, and #1735's resize landing each state it.
It
is a candidate for a shared predicate, but not the primitive F
described.

## Overlap with work in other worktrees

`leaf.shift-a-thread-jitter` has uncommitted changes to
`comment-placement.js`, `floating.js` and `floating-response.js`, based
on
#1705. Its `floating-response.js` hunk is small. Its
`comment-placement.js`
header rewrite overlaps the paragraph this change rewrites, so expect a
textual conflict there. `leaf.thread-card-margin-avoidance` is mid-merge
in
`comment-placement.js` and `margin-projection.js`. Neither touches
`makeRoom`'s call from `floating-response.js` or the frame tokens.

> _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.

t takes over a second on a page with ~100 code blocks: anchored copy controls make every forced layout ~40 ms

2 participants