Skip to content

Walk a hint map without measuring every target again on each Tab - #6241

Merged
max-sixty merged 5 commits into
mainfrom
grind/remnants-1
Nov 17, 2026
Merged

max-sixty merged 5 commits into
mainfrom
grind/remnants-1

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Each Tab in the target picker, and each paint of an armed Go-to map, measured every hint's target again to find out whether any had moved: its visible parts, its clipped box and a hit test per chip. On documents, #4781's shape, that was the part of a picker Tab that grew with the side tabs in view. Now the map measures its targets when it reads them, and a paint between readings draws only the chips' faces.

Change

  • createHintSession (keyboard/hints.js) takes each member's box from read, which both callers already measured there, and its layout no longer measures: it turns a member into its face and the corner it asks for. The scene option goes, and the seating keeps no copy of the targets' boxes.
  • The map is read and seated again once a scroll settles, on a resize, when the chrome comes to cover other boxes, when a member leaves the document, and when the caller invalidates it. The chrome changes what it covers when the user opens a panel view, such as the Menu or On me, so that reading follows the user's own press, as a scroll's or a resize's does: a target the panel now hides leaves the map, and the others may take new letters. Between readings each chip rides its target by its anchor (chip-seats.js), so a page that moves under the map, as a revision or an opening disclosure does, moves the chips with their targets and changes no letter, as on main.
  • On main, a paint that found a heard target no longer laid out retired the walk. A target now leaves the map only on a reading, so that branch goes; the reading itself retires the walk when the target it heard is gone, as before.

What differs from main between readings

  • A target the chrome comes to cover leaves the map by a reading. On main each paint dropped its chip and kept every other letter. Now the map is read again, so the covered target goes, the walk retires if it stood there, and the remaining targets may take new letters.
  • A target a layout moves without a scroll keeps its seat relative to it. Its chip follows it by its anchor, where main seated it again on the next paint. A CSS transform on a target leaves its chip behind in Firefox between readings, the gap notes/browser-support.md records under "An anchor's transforms in Firefox". No gesture transforms a target while a map is armed.

Evidence

uv run leaf-dev bench documents --sizes 8,64,128,256 --input pick --read cpu --rounds 3 --base origin/main, Chromium, main-thread CPU per picker Tab, the lowest of three rounds, host load average 20 to 40 (an earlier run at load 10 read 11.9/13.9/16.8/18.5 against 10.9/11.7/14.2/14.9):

                 8 base   8 head  64 base  64 head 128 base 128 head 256 base 256 head
pick cpu ms        13.1     11.7     15.8     13.5     19.3     15.0     21.4     16.4

A V8 profile of 16 Tabs at 256 (--profile) put 4.7 ms per Tab in paintTargetPickerHints on main, 3.5 of it in elementFromPoint through exposes; on this branch the hint paint no longer appears among the top frames. The independent review counted 8–9 box reads and no hit tests per Tab here, against 178 reads and 56 hit tests on main.

What remains of a Tab, about 11 ms at 8 and 15 ms at 256, is outside the chips: the panel's Lit updates, the key dispatch's scope walk (currentLocation, pageSelection), the command hints (unclaimedScopes) and the document layout read (readDocumentHeaders), each 1 to 3.5 ms of a profiled Tab. The growth left from 8 to 256 is mostly namedParts naming a side tab among its owner's 34 tabs (#6227), and a forced layout the selection read pays.

Tests

  • test_a_revision_under_an_armed_go_to_keeps_its_letters_and_walk (tests/browser/navigation/test_go_to.py): with Go-to armed and the walk on the third of five links, a revision adds a paragraph and a link above them; every link keeps its letter, the third stays current, and the next Tab reaches the fourth. It fails on this PR's earlier version, which read the map again on each page layout move and relabelled it.
  • a walk redraws the chips it moves between and reads no target's box (tests/runtime/hint-session.test.mjs): two Tabs and their paints read no member's box. It fails when every paint reads the scene again.
  • a page that moves under the map keeps every letter and the walk replaces the case that asserted a re-seat on a layout move. a target the chrome comes to cover leaves the map covers a target with the harness's chrome and reads it gone from the map and from the chips shown; it fails without the re-read on a chrome change.

Ran pnpm run test:runtime (999 passed), pnpm run check:browser, pre-commit on the changed files, tests/browser/navigation/test_go_to.py and tests/browser/test_render_semantic_selection.py whole together with the 28 browser tests that read a chip, its seat or its code, or comment through a hint, and the 12 journey tests that do (104 passed).

Not run: the whole suite, Firefox and WebKit benches.

Part of #5194.

Each Tab in the target picker, and each paint of an armed Go-to map, measured every hint's target again to find out whether any had moved: its visible parts, its clipped box and a hit test per chip. On `documents`, #4781's shape, that was the part of a picker Tab that grew with the side tabs in view. Now the map measures its targets when it reads them, and a paint between readings draws only the chips' faces.

## Change

- `createHintSession` (keyboard/hints.js) takes each member's box from `read`, which both callers already measured there, and its `layout` no longer measures: it turns a member into its face and the corner it asks for. The `scene` option goes. The seating keeps no copy of the targets' boxes, since a new reading is the only way they change.
- The map is read and seated again together: once a scroll settles (as before), when the page's layout moves or the window resizes, when the chrome's covering boxes change, when a member leaves the document, and when the caller invalidates it. The layout door is page-geometry.js's `pageShifted`, the one the Design legend and the aim already follow; it now calls each session's new `moved()`, which replaces the session's own resize listener.
- A heard target that the chrome comes to cover leaves the map on that re-reading, which retires the walk, so the branch that retired it on a missing plan is gone.

## Calls Max may reverse

- **A layout move or chrome change re-reads the map, and the codes may change.** Before, each paint re-measured the same members and kept their codes, hiding a covered member's chip. Now such a change re-reads the scene, as a settled scroll and a resize already did, so a member that left sight drops out and later members may take new codes. It only happens with no letters typed; a part-typed code still freezes the map.
- **A layout move that nothing reports waits for the next reading.** A target moved by something that neither resizes `body`, sends `lf-layout`, nor changes the document's headers keeps its chip where it was seated until the next settled scroll, resize or re-arm. A page target's chip is anchored to it and rides along; a Go-to chip on a chrome row, such as a margin entry, stays put. Before, any frame that happened to repaint re-seated it.

## Evidence

`uv run leaf-dev bench documents --sizes 8,64,128,256 --input pick --read cpu --rounds 3 --base`, Chromium, main-thread CPU per picker Tab, the lowest of three rounds, load average 10:

```
                 8 base   8 head  64 base  64 head 128 base 128 head 256 base 256 head
pick cpu ms        11.9     10.9     13.9     11.7     16.8     14.2     18.5     14.9
exponent           0.44 (base), 0.28 (head)
```

A V8 profile of 16 Tabs at 256 (`--profile`) put 4.7 ms per Tab in `paintTargetPickerHints` on main, 3.5 of it in `elementFromPoint` through `exposes`; on this branch the hint paint no longer appears among the top frames. A probe counting re-reads over eight Tabs on `documents` at 64 in Design mode found none: no layout move, chrome change or `lf-layout` event fires during a walk.

What remains of a Tab, about 11 ms at 8 and 15 ms at 256, is outside the chips: the panel's Lit updates, the key dispatch's scope walk (`currentLocation`, `pageSelection`), the command hints (`unclaimedScopes`) and the document layout read (`readDocumentHeaders`), each 1 to 3.5 ms of a profiled Tab. The growth left from 8 to 256 is mostly `namedParts` naming a side tab among its owner's 34 tabs (#6227), and a forced layout the selection read pays.

## Tests

- `a walk redraws the chips it moves between and reads no target's box` (tests/runtime/hint-session.test.mjs): two Tabs and their paints read no member's box. It fails when every paint reads the scene again.
- `a heard target the chrome comes to cover retires the walk` replaces the case that covered a target through `layout`: the harness's chrome now covers the link, as the panel growing over it would.
- `a layout move reads the scene again…` and `a target a layout moves is seated again…` call `moved()`, the door a resize and a layout move now reach the session through.

Ran `pnpm run test:runtime` (999 passed), `pnpm run check:browser`, pre-commit on the changed files, `tests/browser/navigation/test_go_to.py` and `tests/browser/test_render_semantic_selection.py` whole (53 passed), and the 28 browser and 12 journey tests that read a chip, its seat or its code, or comment through a hint (`lf-key-hint`, `lf-target-picker-hint`, `data-lf-hint-code`, `lf-chip-seat`, `data-lf-go-to`, `hint_code`, `choose_comment_target`, `comment_on_target`, `go_to`): 35 and 15 passed.

Not run: the whole suite, Firefox and WebKit benches. Not checked: a Go-to map over a margin that re-lays out while armed.

Part of #5194.
Reading the map again on each page layout move, through `pageShifted`, relabelled
it: a revision that added a link above an armed Go-to changed 12 letters and
cleared the walk, so the letter the user had just read took a neighbouring
target, and Design mode's mutation observer re-read the whole map on every DOM
change. The session no longer has a `moved()` door, page-geometry.js no longer
calls one, and the session keeps its own resize listener. A chrome change seats
the chips again with their letters, rather than reading the map again. Between
readings each chip rides its target by its anchor, so a page that moves under
the map moves the chips and changes no letter, as on main.

test_go_to.py arms Go-to, walks to the third of five links, writes a revision
that adds a link above them, and reads every letter, the current hint and the
next Tab unchanged; it fails on the earlier version of this branch. The runtime
cases that asserted a re-seat on a layout move and a walk retired by a covered
target now assert that the letters and the walk stay.
Opening a panel view with a map armed grows the panel over targets the map
named: with Go-to and On me open, a hidden link's chip stood above the panel and
refused its press, and in Select mode with the Menu open 22 chips showed where
main showed 15, and Tab walked onto links under the panel. A change in the
chrome's covering boxes reads the map again, as a scroll or a resize does, so a
covered target leaves the map. That change follows the user's own press on the
panel; a revision or an opening disclosure still keeps every letter.

The runtime case now covers a target with the harness's chrome and reads it gone
from the map and from the chips shown; it fails without the re-read.
@max-sixty
max-sixty marked this pull request as ready for review November 17, 2026 05:18
@max-sixty
max-sixty merged commit c2ec34f into main Nov 17, 2026
6 checks passed
@max-sixty
max-sixty deleted the grind/remnants-1 branch November 17, 2026 05:33
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