Skip to content

Keep floating-editor caret reveals from scrolling the document - #4833

Merged
leaf-agent merged 3 commits into
mainfrom
repro/issue-4821
Nov 1, 2026
Merged

leaf-agent merged 3 commits into
mainfrom
repro/issue-4821

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Editing a floating card could move the document underneath it in Chromium, losing its held height and clipping the saved message. Keep document chrome clearance out of native caret reveals while a floating annotation surface holds focus. Inline editors retain the normal root scroll padding, and floating editors retain native anchor following and their own scrolling.

The shared annotation CSS now owns this rule for cards and floating comments. This removes the older comment-only post-input scroll restoration. The two rewrite regressions retain their explicit document-scroll, geometry, text-position and overflow assertions.

Validation: 18 focused browser cases passed, covering short and long rewrites, long caret following, reply pastes, native card following, scroll chaining, inline composer clearance, and floating-comment growth/resume. Both window-foot rewrite cases and floating-comment growth also passed at 10× CPU throttle. pnpm run check passed, including 737 runtime and 88 worker tests.

A matched served-browser journey at 1512×860 moved the base document from 1421px to 1435px and clipped the card from 663px to 538px. With the fix, document scroll stays at 1421px and the card returns to 663px without overflow. No console exceptions; startup keeps the same 28 upgrade/29 presentation requests and loads 628 fewer code bytes.

Fixes #4821.

This was written by Codex on behalf of max-sixty

The existing window-foot rewrite cases still fail on Chromium 156. Record the document scroll before the downstream geometry assertions and preserve the plain-browser reduction and rejected repairs. This is a failing reproduction, not a layout fix.

Refs #4821

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Withholding the verdict because the PR explicitly says this failing reproduction is not ready to merge. The repair for #4821 remains outstanding.

Both focused tests reproduce the new scroll assertion locally: 1421→1427px after shortening and discarding, and 1421→1834px after restoring the long message. The existing card geometry, text-position and overflow assertions remain intact.

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

The repair remains unresolved; this reproduction should not merge. I reproduced the long-message failure at this head (document scroll 1421→1834px) and narrowed why moving the comment editor's existing input-task protection did not suffice.

An instrumented run records the short replacement's lf-before-edit, input, and input microtasks at scrollY 1421, followed by the document's scroll event at 1427 before the next animation frame. The long insertion also has a synchronous reveal: its before-edit reads 1435 and its first input reads 1834. Protecting only the input callback therefore misses part of the native reveal lifetime. Restoring the document after placement has observed that movement would also leave its remembered height invalidated.

Chromium's September reland explicitly lets scroll-into-view continue through fixed boxes that need anchor scroll adjustment. That source change supplies a concrete mechanism to investigate, rather than treating all fixed boxes as immune to native reveal. It does not by itself establish which browser revision first broke these Leaf tests.

In a plain Chromium reduction, an anchored editor starting at y=700px with 30 inserted lines scrolls the document when capped at 430px, but a 150px scrollport contains the reveal and keeps scrollY at 1300. A 430px scrollport starting at y=200px also keeps the document still. In Leaf, experimentally removing the field's inner overflow: clip still fails both rewrite tests; that change was discarded.

The next repair step is to keep the floating editor within its available window room during the native mutation, before the asynchronous placement solve, while retaining anchor following on deliberate scroll. The existing geometry, text-position, and overflow assertions remain necessary. No production change was pushed, and no CI poll or merge was attempted under await_ci: false. The engineering work remains in #4821 and this PR.

Chromium applies root scroll padding while revealing a caret through a fixed CSS-anchored editor. Clear that document-only clearance while an annotation surface holds focus, preserving native anchor following and editor scrolling. This also removes the older comment-only post-input scroll restoration.

Both held-card rewrite regressions retain their document-scroll, geometry and overflow assertions. Eighteen focused browser cases pass, including long editor growth at 10x CPU throttle, alongside pnpm check. A matched served journey keeps scrollY at 1421 and restores the 663px card; base moves to 1435 and clips it at 538px.
@max-sixty max-sixty changed the title test: reproduce document scrolling during held-card rewrites Keep floating-editor caret reveals from scrolling the document Nov 1, 2026
@leaf-agent
leaf-agent merged commit 06aa939 into main Nov 1, 2026
3 of 5 checks passed
@leaf-agent
leaf-agent deleted the repro/issue-4821 branch November 1, 2026 15:58
leaf-agent added a commit that referenced this pull request Nov 2, 2026
Thread travel now keeps its passage above the fixed footer when a
floating card takes focus. #4833 cleared the document's scroll padding
whenever any part of a floating annotation held focus, so Show on page
lost the landing clearance it needed. The exception now applies only
while a `leaf-text` editor holds focus, preserving #4833's protection
against native caret reveals moving the page beneath a floating editor.

Both named and anonymous bounded-log regressions failed at the final
visibility assertion on main and pass with this change. Six related
browser cases pass, covering long rewrites, cards at the window's foot,
and growing floating comments. The 745 runtime tests and pre-commit
checks pass.

Before and after Show on page in the reported bounded-log case:

| Before | After |
| --- | --- |
| ![Passage beneath the
footer](https://github.com/user-attachments/assets/ad8f810a-57c3-4e8c-bc98-80a5b7dc8d21)
| ![Passage visible above the
footer](https://github.com/user-attachments/assets/d0d82660-7c04-4bbf-9723-2e6171bb86ed)
|

The `plan-card-keyboard` and `plan-card-reply` stills were also compared
against main. Card travel lands higher with its clearance restored; the
focused reply retains the editor exception. The change adds no state or
scrolling mechanism.

Closes #5082 — automated triage

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

Leaf's own landings now keep their full band (landing room below the
head room, and clearance above the foot room and floating panel) while
the user is in an editor inside a floating box. Chromium's native caret
reveal still gets no padding there. This is the narrow #5182 repair
@max-sixty chose on #4751: reply fields keep native text editing, and
the rare overshoot when several keystrokes land in one frame stays
accepted.

**Cause.** #4833 sets the root's `scroll-padding` to 0 while a floating
editor holds focus, so the native caret reveal stops moving the document
under the editor. Leaf's landings read that same padding as their band
(`geometry.js`, `landingInsets`), so any landing made during focus lost
its room. Resume writing (`g i`) focuses the editor and lands its
passage in the same task, which put the passage flush against the
window's top (`y=-3.05` in #5182).

**Change.**
- The root states its band as `--lf-landing-top` / `--lf-landing-bottom`
(`base.css`, registered `<length> | none`), and its `scroll-padding`
copies them.
- `landingInsets` reads a scroller's stated edges, falling back to
`scroll-padding`. So the override zeroes only what the browser reads.
- `motionBand` mirrors Chrome's scroll-anchoring region, so it keeps
reading the computed padding.
- The override moves from `annotation-chrome.css` into `base.css`,
beside the padding it changes, as `!important`. Since #5389 made the
root's `scroll-padding-top` `!important` inside the `lf-base` layer, the
unlayered override had lost the top edge: it zeroed only the bottom, so
#4833's top-edge protection was off. That is also why
`[combined-selection]` started passing on main. This PR turns that
protection back on.
- The public `landingInsets` description in
`module-scroll-and-motion.md` now says what it reads.

**Verification.**
-
`test_a_wheel_return_attaches_the_comment_box_in_the_first_visible_frame[combined-selection]`:
with the override restored and the old `geometry.js`, it fails exactly
as #5182 reported (`y=-3.046875`). With this change it passes, and the
passage lands at `y≈9` under the 12px band, with the override active
(`scroll-padding-top: 0px`, `--lf-landing-top: 12px`).
- Also passing: all of `test_render_send_placement.py` and
`test_public_api.py`, #4833's regressions (now subtests of
`test_a_card_at_the_windows_foot_grows_back_to_how_it_stood`), #4751's
`test_a_pointed_cards_reply_brings_the_pointed_row_back`, and 67
drafts/margin/threads/navigation tests selected by `-k "caret or reveal
or resume or floating or foot or reply_row or follows"`. `pnpm run
check` and pre-commit pass.
- Two tests in that selection fail identically on main without this
change, so they're inherited:
`test_a_seat_send_at_the_window_foot_shows_the_thread_it_started[verdict]`
and
`test_a_thread_walk_starts_one_page_trip_and_reveals_its_nested_passage`.

Nothing changes on screen while no floating editor holds focus. The band
values are the same expressions as before.

Fixes #5182. Closes #4751.

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Nov 6, 2026
…ails without it (#5589)

While the user writes in a floating comment box, the root drops its
scroll padding (`data-lf-floating-editor`, `browser/base.css`), because
the browser's caret reveal through a box anchored to the page applies
that padding and moves the words beneath a box already in view (#4821).
Nothing in the suite failed with that rule removed: #4833's
`test_a_card_at_the_windows_foot_grows_back_to_how_it_stood` stands its
card in the window plane, which writes no `position-anchor`, so the
reveal stops at the box there. This adds a test that does fail, and
records why the rule has no structural replacement.

- **Test.**
`test_writing_in_a_comment_box_over_the_window_foot_moves_no_words`
(`tests/browser/test_chrome_contracts.py`, Chromium and WebKit) opens a
comment box on words low in a 1512×860 window, so the box stands over
the foot band the panel states, types four letters, and asserts the page
didn't scroll. It also asserts the caret stands inside that band, so a
layout change that moves the box clear of it fails the test rather than
passing it vacuously. With the rule's declaration removed, the words
move 16 px in Chromium 156 and 14–21 px in WebKit 27.2.
- **Why the rule stays.** Chromium stops a scroll-into-view at a fixed
box only when the box has no anchor scroll adjustment (`IsFixedToFrame`,
`scroll_into_view_util.cc`); since crbug.com/469481151 an anchored fixed
box bubbles to the root and takes its padding, pinned by WPT
`css-anchor-position/scroll-to-anchored-fixed-001…006`. WebKit does the
same (`adjustForScrollByAnchor`, `LocalFrameView.cpp`). Firefox 157
reveals nothing through a fixed box. An agent tried, on a plain anchored
contenteditable and in Leaf: the field or the box as its own scroller,
`overflow`, `contain`, `overscroll-behavior`, the top layer (popover),
`position: absolute`, `scroll-margin` on the caret's text, and taking
typing in `beforeinput`. Each either still moved the page in Chromium or
WebKit, or stopped the box following its anchor. The comments in
`base.css` and `floating.js` now name WebKit and say what was rejected.
- **Engine note.** `notes/browser-support.md` records a Chromium bug
found on the way: each reveal of an anchored fixed box made before the
next frame scrolls the full amount again (three `scrollIntoView` calls
scroll 270 px where one scrolls 90; four keys in one frame 240 px where
one scrolls 60). WebKit reveals once. It is the overshoot #5417
accepted, and the note gives the check that shows when Chromium fixes
it.
- The rule's comment now names `leaf-dev bench`, which replaced
`leaf-dev scaling` in #5576.

Checked: the new test passes on both engines at the head and fails on
both with the rule's declaration removed (Chromium 2076 → 2092, WebKit
2075 → 2096, rerun independently); #5580's restyle test passes;
pre-commit on the changed files.

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

Thread rewrites shrink cards held at the window foot

2 participants