Skip to content

Follow the pointer in Design mode at a cost the control sets, not the page's size - #6203

Merged
leaf-agent merged 2 commits into
mainfrom
grind/5194-design-hover
Nov 16, 2026
Merged

leaf-agent merged 2 commits into
mainfrom
grind/5194-design-hover

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

In Design mode, each move of the pointer onto a control part, such as a tab in a
side tab list, captured the part's durable anchor only to paint its box and name.
The capture asks namedParts whether another control in the same owner has the
part's name, and controlPassages which controls nest inside the part. Both
filtered pageQueryAll(WORKS), a query of every element on the page. On #4781's
page (30 tabs of large text documents) that cost about 0.7 s a move.

Change

  • aimTargetAt(node, {design: true}) returns the target's inventory reading,
    as aimTargets already does for the target picker. The box and name a
    hovering pointer paints read only the element, its surface and the part's
    name, so a move no longer captures.
  • Whoever commits a target captures it, through one helper, captured
    (anchor-resolution.js). A press captures what it claims in claimPress
    (aim.js), once for the press and any continuation, so the composer opens on
    the same anchor as before. The picker's choice and Capture area already
    captured at their choice and now call the same helper. The helper keeps what
    the caller added to the target, such as the point a press landed on.
  • The capture's two queries ask only the owner and the part
    (queryAllUnder, shadow.js: root's tree and the declared shadow roots
    under it). pageQueryAll and the projection's two copies of the same query
    (projectedDescendants, markedDatums) and the page-words watcher's
    idsUnder now call it.

Evidence

leaf-dev bench gains an inspect input: in Design mode, the pointer moves
between the page's first two tab controls 16 times. It needs [role=tab], so
it reads on documents (#4781's shape) and asktabs. Input gains leave,
which takes back the mode ready entered, so the inputs after it start from
the same page. The daily bench's documents step now reads it.

uv run leaf-dev bench documents --sizes 64,256 --input inspect --read cpu --base,
CPU ms a move, one round, load average 6–9:

8 64 256 exponent
main 7.3 14.3 38.6 1.08 (marked growing)
this branch 4.0 3.8 4.7 level

A CPU profile of eight moves between two tab controls on the 64 page
(leaf-dev probe --journey): main spent 11.2 of 13.9 ms a move in
querySelectorAll under namedParts and controlPassages; this branch spends
2.1 ms a move, none of it in either.

Tests

The check API exports captured. The test_render_aim.py reads of the target
a press carries now capture it as the press does; what they assert is
unchanged.

Ran: after the last commit, test_render_aim.py and threads/test_media.py
under -k "design or picker or capture or hint or repeated or part or pointed"
(59 passed); before it, test_render_aim.py in two -k selections that together cover the file
(45 and 87 passed), test_render_projection.py and threads/test_media.py (22
passed),
the design, aim and picker tests of test_chrome_contracts, test_render_drawing,
test_render_reactions, margin/test_opening_threads, navigation/test_key_scopes,
controls/test_rings, threads/test_targets, margin/test_scrollers and
widgets/test_playgrounds (9 passed), pnpm run test:runtime (993 passed),
pnpm run check:browser, and pre-commit on the changed files. Not run: the
whole suite, journeys, Firefox and WebKit.

Left as it was

  • A press on a part still queries the part's owner. On Export: an exported page parses every data source before its first draw #4781's page a press on
    a side tab queries the tabs widget, which holds every document, so the press
    that opens the composer still costs about what one move did on main. Walking
    down from the owner and skipping each addressable it holds would make it cost
    what the owner holds directly.
  • On asks at 256 sections, a Design mode move over an option (an addressable,
    so no part and no capture) spends about 8 ms in two forced layouts
    (labelAim → shownParts), each about 7 ms for 2 to 14 dirty objects, and
    grows with the page on main and on this branch.

Part of #5194.

… page's size

In Design mode, each move of the pointer onto a control part, such as a tab in a
side tab list, captured the part's durable anchor only to paint its box and name.
The capture asks `namedParts` whether another control in the same owner has the
part's name, and `controlPassages` which controls nest inside the part. Both
filtered `pageQueryAll(WORKS)`, a query of every element on the page. On #4781's
page (30 tabs of large text documents) that cost about 0.7 s a move.

## Change

- `aimTargetAt(node, {design: true})` returns the target's inventory reading,
  as `aimTargets` already does for the target picker. The box and name a
  hovering pointer paints read only the element, its surface and the part's
  name, so a move no longer captures.
- Whoever commits a target captures it, through one helper, `captured`
  (anchor-resolution.js). A press captures what it claims in `claimPress`
  (aim.js), once for the press and any continuation, so the composer opens on
  the same anchor as before. The picker's choice and Capture area already
  captured at their choice and now call the same helper.
- The capture's two queries ask only the owner and the part
  (`queryAllUnder`, shadow.js: `root`'s tree and the declared shadow roots
  under it). `pageQueryAll` and the projection's two copies of the same query
  (`projectedDescendants`, `markedDatums`) and the page-words watcher's
  `idsUnder` now call it.

## Evidence

`leaf-dev bench` gains an `inspect` input: in Design mode, the pointer moves
between the page's first two tab controls 16 times. It needs `[role=tab]`, so
it reads on `documents` (#4781's shape) and `asktabs`. `Input` gains `leave`,
which takes back the mode `ready` entered, so the inputs after it start from
the same page. The daily bench's `documents` step now reads it.

`uv run leaf-dev bench documents --sizes 64,256 --input inspect --read cpu --base`,
CPU ms a move, one round, load average 6–9:

| | 8 | 64 | 256 | exponent |
|---|---|---|---|---|
| main | 7.3 | 14.3 | 38.6 | 1.08 (marked growing) |
| this branch | 4.0 | 3.8 | 4.7 | level |

A CPU profile of eight moves between two tab controls on the 64 page
(`leaf-dev probe --journey`): main spent 11.2 of 13.9 ms a move in
`querySelectorAll` under `namedParts` and `controlPassages`; this branch spends
2.1 ms a move, none of it in either.

## Tests

The check API exports `captured`. The `test_render_aim.py` reads of the target
a press carries now capture it as the press does; what they assert is
unchanged.

Ran: `test_render_aim.py` in two `-k` selections that together cover the file
(45 and 87 passed), `test_render_projection.py` and `threads/test_media.py` (22
passed),
the design, aim and picker tests of `test_chrome_contracts`, `test_render_drawing`,
`test_render_reactions`, `margin/test_opening_threads`, `navigation/test_key_scopes`,
`controls/test_rings`, `threads/test_targets`, `margin/test_scrollers` and
`widgets/test_playgrounds` (9 passed), `pnpm run test:runtime` (993 passed),
`pnpm run check:browser`, and pre-commit on the changed files. Not run: the
whole suite, journeys, Firefox and WebKit.

## Left as it was

- A press on a part still queries the part's owner. On #4781's page a press on
  a side tab queries the tabs widget, which holds every document, so the press
  that opens the composer still costs about what one move did on main. Walking
  down from the owner and skipping each addressable it holds would make it cost
  what the owner holds directly.
- On `asks` at 256 sections, a Design mode move over an option (an addressable,
  so no part and no capture) spends about 8 ms in two forced layouts
  (`labelAim` → `shownParts`), each about 7 ms for 2 to 14 dirty objects, and
  grows with the page on main and on this branch.

Part of #5194.
…h its capture

`captured` returned the capture's own object, which leaves out the point
`pointedTarget` (aim.js) adds to a press in Design mode with the picker
open. It now carries the fields the caller added beside the captured anchor
and label, as main did when the target arrived captured.
@max-sixty
max-sixty marked this pull request as ready for review November 16, 2026 20:11
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