Skip to content

Land near-fit threads on complete content boundaries - #956

Merged
max-sixty merged 13 commits into
mainfrom
codex/reader-intent-navigation
Sep 22, 2026
Merged

max-sixty merged 13 commits into
mainfrom
codex/reader-intent-navigation

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Opening a page mark on a near-fit thread could leave the quoted-passage label cut by the panel's pinned heading. The landing chooser considered message blocks but omitted the thread's earlier header and title boundaries; when the chosen message could not reach the requested position before the list hit its scroll limit, the heading crossed a text line.

The landing chooser now considers the thread's complete top-level blocks alongside message paragraphs. The browser test checks one visible-boundary rule across short, near-fit, and long replies, including the reply remaining visible and no text line crossing the pinned heading. The revised test fails with the old landing chooser and passes with this change.

This was written by Codex on behalf of max-sixty

Capture navigation ownership before hydration or materialization and pass it through nested reveals. Preserve synchronous focus handoffs without renewing the original input generation, and let newer input cancel delayed tab scrolling.

Exercise stale and untouched arrivals in the real browser, including mobile tray handoffs and lazy data hydration. Align the existing shadow-root animation assertion with the canonical element diagnostic.
Carry focus and caret with values before waiting for presentation. Preserve focused descendants while reading-layout constructs its wrappers, so reload upgrades do not break ongoing typing. Keep only scroll correction delayed and cancellable.

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

[long-clamped] is red on Linux. On the Ubuntu 24.04 runner, with the suite's pinned headless shell, an 18-paragraph reply produces the aligned landing rather than the clamped one, so both of the clamped branch's assertions are false: scroll 392 against maximumScroll 420, and blocks[0]["top"] −99.3 against start 181. [long-aligned] passes at 932 of 960. The case is nightly, so test on the PR stays green and this lands on main's nightly after the merge.

Re-pinning the count doesn't settle it, and that's the more interesting half. Sweeping the reply length on this runner: 8 paragraphs never scrolls at all, so the arming wait_for_function times out after 30s; 10 clamps exactly, scroll 60 against maximumScroll 60; 12 aligns with 0.3px to spare, blocks[0]["top"] 180.7 against start 181. The clamped landing lives in a two-paragraph window whose position is set by the panel's height, the platform's font metrics, and the collapsed neighbour's height — none of which the case arranges. That window sits somewhere else on the machine 18 was measured on, which is how the assertion this PR is repairing got here in the first place.

At the count that does clamp here, the clamp also isn't a second valid landing — it breaks the guarantee the case exists to hold. Running the clamped branch at 10 paragraphs, its two new assertions pass (scroll 60 = max 60, blocks[0]["top"] 232.7 ≥ start 181) and the shared crossedLines assertion fails: the run heading's bottom edge, at 181, cuts the thread's quoted-passage label — the .lf-quote-label holding "bold text" — which spans y 167.7 to 182.7. The thread's head sits under the pinned heading, which is the state --lf-head-room and the list's scroll-padding exist to prevent; thread-list.js names it under "Being pinned is .lf-pinned" as "a walk lands threads under the heading with the opening words of the comment behind it".

The thread fits whole at that length — compose bottom 788 against a list bottom of 835 — so there is room to land clear of the heading; the browser clamps only because block: "start" asked for more scroll than the list has. threadLandingStart in skills/leaf/assets/runtime/conversation/landing.js chooses the boundary block and hands it straight to scrollIntoView, with nothing between that choice and the scroll range it can exceed. That reads as what this failure is pointing at, and settling it there leaves the case with one landing rule rather than two branches keyed on a reply length.

Measured landings, one reply length per row

Same fixture as the case, .lf-threads read at the point the test reads it, on Ubuntu 24.04 / Playwright's pinned chromium headless shell. start is 181 throughout.

paragraphs scroll maximumScroll first .lf-msg top landing
8 — — — list never scrolls; arming wait times out
10 60 60 232.7 clamped, and the run heading cuts .lf-quote-label
12 112 150 180.7 aligned
14 212 240 80.7 aligned
16 302 330 −9.3 aligned
18 392 420 −99.3 aligned — the case asserts clamped
24 662 690 −369.3 aligned
30 932 960 −639.3 aligned
60 2282 2310 −1989.3 aligned

Every aligned row stops 28px short of the maximum, so the shortfall is set by what sits below the landing block rather than by the reply's length.

@max-sixty max-sixty changed the title Check clamped and aligned long-thread arrivals Land near-fit threads on complete content boundaries Sep 22, 2026
@max-sixty
max-sixty merged commit f8660f7 into main Sep 22, 2026
5 checks passed
@max-sixty
max-sixty deleted the codex/reader-intent-navigation branch September 22, 2026 22:08
max-sixty added a commit that referenced this pull request Sep 23, 2026
…the gesture (#982)

"Keep the reader's place" had been fixed one surface at a time (#919,
#922, #937, #946, #954, #955, #956, #971). The thread list had a good
hold that no other surface could use. The Page Map restored its raw
`scrollTop`, so a group arriving above the view pushed the rows the
reader was on down by that group's height. The margin card relied on
native anchoring. The panel's visible band was measured three different
ways. Separately, `reveal()` took its reader intent when it was called,
so an async caller that forgot to pass one got a late capture, and
`lf-diff` moved focus and scroll after a network wait no matter what the
reader had done since.

## What changed

- **`runtime/reader-place.js`**: `placeKeeper(scroller, {items,
identity})` holds one reference node's content offset through a
mutation. It picks the reference from the pointer, then focus, then the
visible band. It suspends `overflow-anchor` while the hold lasts, hands
the place to whatever node a render put under the same identity, and
follows a running fold. The thread list (keyed by thread id), the Page
Map's `renderSheet` (keyed by `data-lf-map-key`), and the margin card's
re-render of the same thread (keyed by event id) all use it. A node with
an empty identity hands the place to the next candidate and is never
matched to another node that also lacks one.
- **`geometry.js`**: `visibleBand` (the shown band minus stuck
`.lf-pinned` covers) and `landingBand` (minus the declared
`scroll-padding`). Read acknowledgement, the thread card's being-read
check, conversation landing, and anchor travel now read these instead of
measuring for themselves.
- **Reader intent**: `reveal(el, intent)` now requires the intent
retained at the gesture and throws without one. `lf-diff`'s `stepHunk`
and `nextUnreviewed` capture intent before they load a file, and land
only if that intent still stands. `references/packages.md` states the
contract. `scroll` is still not a cancelling input: the runtime's own
landings fire it. `reader-intent.js` now lists the input that begins
each way a reader can scroll. A probe confirmed that pressing a
scrollbar fires `pointerdown` on the scroller.
- **The #954 ordering rule is now the interface**: `chrome-layout.js`
exports `takeShell(key)` in place of a frame that took a callback. A
surface owner therefore has no way to render inside the frame that
native anchoring depends on.

## Behavior that moved

- With no pointer or focus to lead, the thread list's hold now uses the
topmost visible card, which is what its header said. Before, it used the
second.
- A card entirely under a stuck heading no longer counts as visible.
- The Page Map keeps the rows the reader was looking at, not a scroll
offset.

## Tests

- `tests/runtime/reader-place.test.mjs` covers candidate order, the
clamp-aware correction, band insets, the identity hand-across, and an
empty identity that must not hand the place across. Each hand-across
case was checked by disabling the hand-across and watching the case
fail.
- `test_chrome_contracts.py` (everyday) gets a new Page Map continuity
test. It fails against the base `page-map-dialog.js` (row moved 36px).
The file also takes
`test_taking_the_panels_strip_leaves_the_reader_on_the_same_words` from
the nightly controls file.
- `test_render_anchors.py` gets a nightly test: a hunk step still
waiting on a file leaves a reader who has pressed elsewhere. It fails
against the base `lf-diff.js`.
- Local: `npm run test:runtime` 60 passed. A focused browser selection
across margin, controls, widgets, projection, anchors, and chrome
contracts: 142 passed.
`test_render_navigation.py::test_pressing_a_page_mark_stands_in_the_thread_it_opens[long]`
fails the same way on the unchanged base.

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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

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