Skip to content

Keep a key pressed during the thread walk's glide on the card it reached - #5841

Merged
max-sixty merged 4 commits into
mainfrom
glide-carries-card-focus
Nov 11, 2026
Merged

max-sixty merged 4 commits into
mainfrom
glide-carries-card-focus

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The thread walk (t) focuses the card it reaches and then glides the page toward the card's passage. focusPlace (user-place.js) counts a key pressed during that glide as meant for the card, but it looked for the glide among the boxes that scroll the card, and scrollersOf stops at the card's fixed box. So while the card was still below the window, the keyboard let go of it, and c opened the comment box on the paragraph at the window's top instead of focusing the card's reply; the glide then carried the page away from that box. Any key pressed within about 140 ms of t hit this.

focusPlace now keeps the node's own scrollers and, where their walk stops at a fixed box, follows that box's position-anchor to the anchor Leaf gave that name (anchorNamed, css-anchors.js) and goes on with the scrollers carrying it. This covers every box Leaf anchors in the page (the thread card, the comment box, the margin's carriers). A box held at a reading region's edge is anchored to the region's own box, which the region's scroll leaves in place, so that scroll doesn't count for it; a box held in the window has no anchor and stays as it was.

Where to look: only focusPlace reads the extended list; scrollersOf and its other callers (landings, holds, returnTo) are unchanged. Teaching scrollersOf itself to follow anchors would fix the same gap for those callers, but it would also make landings and holds scroll the page to move a card's contents, so it is left for a change of its own.

This is the cause of test_a_transfer_keeps_its_persisted_source_when_the_destination_write_fails[reply], which presses Shift+Tab, t, c back to back: it failed in 3 of 9 main push runs on Linux and 18 of 18 local runs on a Mac, and passes 18 of 18 here. Part of #5711, which Tend assigned to Max as needing a macOS reproduction. test_c_pressed_as_a_walk_glides_to_a_card_replies_in_it states the behavior on its own; it fails on main and passes here, unthrottled and at --cpu-throttle 6.

Max asked for the failures on main to be fixed. Codex reviewed two earlier versions: the first dropped the scrollers inside the card, and the second counted a region's own scroll for a box held at its edge. Probes now show a card's scrolled transcript keeping focus, and a box anchored to a region's own box letting go of it while the region glides, as a box anchored inside the region keeps it. Tests: the two above, the focused focus, walk and c-destination tests, pnpm run check:browser, pnpm run test:runtime.

This was written by Claude Code on behalf of max-sixty

The thread walk (`t`) focuses the card it reaches and then glides the page
to the words the card stands by. A key pressed on the way is meant for that
card (user-place.js, `focusPlace`), but the card is a fixed surface, so the
walk up from it through the boxes that scroll it stopped at its fixed box
and found no glide carrying it. While the card was still below the window,
`focusPlace` said the user was not on it, the keyboard let go of it, and
`c` opened the comment box on the words at the window's top; the glide then
carried the page away from that box. A key pressed within about 140 ms of
`t` did this, so `t` then `c` typed briskly missed the reply.

Each surface fixed over the page now declares what it stands by
(off-flow.js, `standsBy`): the thread card its entry place, the comment box
its target. `focusPlace` reads a glide through the boxes that scroll that,
which carry the surface as the browser carries a box anchored to it.

This was
test_a_transfer_keeps_its_persisted_source_when_the_destination_write_fails[reply],
which presses Shift+Tab, `t`, `c` back to back: it failed in 3 of 9 main
push runs on Linux (#5711) and in 18 of 18 local runs on a Mac, and passes
18 of 18 with this change.
test_c_pressed_as_a_walk_glides_to_a_card_replies_in_it states the
behavior on its own; it fails on main and passes here, unthrottled and at
--cpu-throttle 6.
The first version had each off-flow surface declare the element it stands
by and replaced the focused node's own scrollers with that element's. Review
found two problems: it dropped the scrollers inside the surface, so a
control in a card's transcript scrolled out of the transcript's view stopped
counting as where the user is (the transcript is a chrome list, which
`focusPlace` measures instead), and the declared element is a second copy of
the relationship placement already writes, which is wrong in a reading
region's plane, where the surface is anchored to the region's body.

`focusPlace` now keeps the node's own scrollers and, where their walk stops
at a fixed box, follows that box's `position-anchor` to the element Leaf
anchored it to (css-anchors.js, `anchorHolderNamed`) and goes on from
there. That covers every box Leaf anchors (the thread card, the comment
box, the margin's carriers) in every plane, and needs no declaration.

The transcript case reads as where the user is on both main and this
change (probe on ship-card-next-unread); the transfer test and
test_c_pressed_as_a_walk_glides_to_a_card_replies_in_it pass 18 of 18.
…edge

The anchor walk from a fixed box went on through every scroller that scrolls
its anchor, the anchor itself included. A box held at a reading region's edge
(floating.js, the region's plane) is anchored to the region's own box, which
the region's scroll leaves where it is, so a glide inside the region kept focus
on that box though it stayed off screen. css-anchors.js now maps a name back to
the anchor itself, an element or the start of a scroller's content, and
focusPlace leaves an element anchor's own scroll out, while a content start
still rides its scroller's.

A probe of rust-sort's pane, a fixed button 3000 px below its anchor, the pane
gliding 500 px: anchored to the pane's box, focusPlace was true during the
glide before and is false now, the button staying at y 3067; anchored to a
paragraph in the pane, it is true on both and the button moves 500 px.

Found by Codex reviewing e9c21c6.
@max-sixty
max-sixty merged commit 85ef1c9 into main Nov 11, 2026
5 checks passed
@max-sixty
max-sixty deleted the glide-carries-card-focus branch November 11, 2026 21:49
max-sixty added a commit that referenced this pull request Nov 14, 2026
…crollersOf (#5895)

#5841 let `focusPlace` follow a fixed box's `position-anchor` past where
`scrollersOf` stops, and left open whether `scrollersOf` itself should,
so landings, holds and `returnTo` would see the page scroll that carries
a card. This settles it: no. The anchor walk moves beside `scrollersOf`
as `carriersOf`, for questions about motions under way, and
`scrollersOf`'s comment records why landings stay off it.

With `scrollersOf` following anchors (tried, not kept), `t` then Tab
before the walk's glide ended left the margin card wholly above the
window with focus in it; main keeps it on screen. The landing read the
card where its last placement left it: in Chromium, Firefox and WebKit a
scroll moves an anchored box only at the next rendering update, and the
card's placement re-solves after a scroll, changing plane. Native wheel
chaining also passes from a fixed card to the root, not to its anchor's
pane.

One behavior change: `holdUserPlace` now yields to a browser-run scroll
in any box carrying the place (`carriersOf`). In a probe with an
anchored box whose own content scrolls, main scrolled that content back
116 px against a smooth page scroll. Leaf's cards rarely reach this,
since a card that fills its room is unanchored.

Max asked for this as a follow-up to #5841; Codex reviewed the
conclusion and found the hold case. Tests: `check:browser`,
`test:runtime`, #5841's two tests and the card, seated-thread and
arrival hold tests.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 14, 2026
… it lands (#5958)

Three readings asked where Leaf's glides under way will take a node,
each its own way. They now share `glideTravel` and `glideGap` in
`scroll-containers.js`: the distance the glides have still to scroll
every box carrying a node (`carriersOf`, so the page's glide carries a
thread card), and how far outside the window the node stands now and
once moved by it. Each caller keeps its own question.

Two behaviors change:

- **`focusPlace` counts a glide only while it carries focus toward the
window.** On main, with focus on a link mid-page, `g g` then `c` once
the link has left the window takes the page back down and comments on
the link. Now `c` opens the panel's comment at the top, as it does once
the glide has landed (Chromium and Firefox).
- **off-flow.js leaves an unseen surface to a glide that will bring it
into the window.** On main, `t` then `c` brings the card back mid-walk
and stops the page 360–375 px short of the walk's landing; now it lands
where `t` alone lands, and `t` then Tab does too in Firefox. Chromium's
own focus reveal still moves the page on `t` then Tab.

Where to look: focus uses "toward" and off-flow uses "into" because they
fail differently (a card's box trails its placement mid-walk; a
suppressed reveal is never retried), which the commit message details.
`alreadyShown` keeps its rule; `holdUserPlace` is untouched (it asks
whether any scroll moved the place, browser-run ones included).

Max asked for this as #6.3.3, the follow-up to #5895. Codex reviewed
three rounds; each found a defect in predicting where a node will stand,
which led to this design. Tests: a runtime assertion, a new `g g` then
`c` browser test and a stricter #5841 walk test, both failing on main's
runtime; `check:browser`, `test:runtime`, 25 focused browser cases.

> _This was written by Claude Code on behalf of max-sixty_
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