Skip to content

Read every command hint's box before writing any, so a paint forces one layout for its faces - #5366

Merged
max-sixty merged 2 commits into
mainfrom
agent-aa9e1c6c855e164e3
Nov 4, 2026
Merged

max-sixty merged 2 commits into
mainfrom
agent-aa9e1c6c855e164e3

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

paint in command-hints.js lent each route's face, read it, then wore or withheld it before moving to the next route, so each face it lent forced two style recalcs and a layout. #5309 showed what that costs: under a rule that widened every restyle to the whole page, a Tab that lent six faces spent 715 ms in the loop's 11 recalcs (root AGENTS.md, "Responsiveness").

The faces now go in passes over every route: which controls the window shows, then each face lent, then each face read as it stands, then each worn or withheld. The chips read where each goes before writing any digit, and the badge placement writes each chip's visibility once every chip is placed; a chip takes no presses, so none was in the stack another chip's place reads.

With every face lent before any is read, a face lent in the same pass no longer counts as covering another. reserve already gives two faces whose boxes overlap to the earlier route. Before, whether one face covered another depended on paint order: an earlier route's face always did, and a later one only while still lent from the previous paint, so two faces over each other could both be withheld. None of the pages compared below shows a case where the two orders differ.

Every face's digit, worn state, opacity, display and box, and every command chip's digit, visibility and box, matched main after each of 15 inputs (Tabs, Shift+Tab, m and t walks, option focus) on the asks page of leaf-dev scaling at 8 and 64 sections, alert-review, release-notes, heat-loss, and the developer deck, feature gallery and playground (leaf-dev probe --base, reduced motion; 527 face and 24 chip readings).

A hit test names a shadow tree's host for whatever that tree holds, so a host over a face is now read again inside its tree: it covers the face unless all its tree holds there is faces lent in the same pass. Without that, a later route's face in a shadow tree, lent before the earlier face was read, covered it through its host and took the slot reserve gives the earlier route (an earlier route keeps its face under a later route's face in another shadow tree, a runtime test).

On the asks page at 64 sections, a Tab that lends six faces ran 18 style recalcs and 7 layouts on main, 11 and 6 of them forced by the hint loop; it now runs 8 and 2, 1 and 1 of them the loop's. A Tab that lends none is unchanged. Main-thread CPU, two rounds interleaved against main 9328f61, moved within the host's noise now that #5363 keeps each recalc local (Tab: median of six Tabs from load; click: median of four):

main this
Tab, 64 sections 43 / 42 ms 43 / 33 ms
The Tab lending six faces, 64 sections 51 / 50 ms 40 / 34 ms
Tab, 512 sections 272 / 160 ms 220 / 224 ms
Click, 64 sections 60 / 54 ms 53 / 51 ms
Click, 512 sections 302 / 210 ms 243 / 259 ms

Tests: pnpm run test:runtime (782 passed), pnpm run check:browser, and the 29 browser tests that read binding faces or chips, in test_command_routes, test_card_placement, test_clusters, test_pins, test_obligation_walk, test_render_options, test_render_options_addition, test_render_widgets and test_obligations (33 cases passed).

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

…ne layout for its faces

`paint` in command-hints.js lent each route's face, read it, then wore or
withheld it before moving to the next route, so each face it lent forced
two style recalcs and a layout. #5309 showed what that costs: under a rule
that widened every restyle to the whole page, a Tab that lent six faces
spent 715 ms in the loop's 11 recalcs (root AGENTS.md, "Responsiveness").

The faces now go in passes over every route: which controls the window
shows, then each face lent, then each face read as it stands, then each
worn or withheld. The chips read where each goes before writing any
digit, and the badge placement writes each chip's visibility once every
chip is placed; a chip takes no presses, so none was in the stack another
chip's place reads.

With every face lent before any is read, a face lent in the same pass no
longer counts as covering another. `reserve` already gives two faces whose
boxes overlap to the earlier route. Before, whether one face covered
another depended on paint order: an earlier route's face always did, and a
later one only while still lent from the previous paint, so two faces over
each other could both be withheld. None of the pages compared below shows
a case where the two orders differ.

Every face's digit, worn state, opacity, display and box, and every
command chip's digit, visibility and box, matched main after each of 15
inputs (Tabs, Shift+Tab, `m` and `t` walks, option focus) on the `asks`
page of `leaf-dev scaling` at 8 and 64 sections, alert-review,
release-notes, heat-loss, and the developer deck, feature gallery and
playground (`leaf-dev probe --base`, reduced motion; 527 face and 24 chip
readings).

On the `asks` page at 64 sections, a Tab that lends six faces ran 18 style
recalcs and 7 layouts on main, 11 and 6 of them forced by the hint loop;
it now runs 8 and 2, 1 and 1 of them the loop's. A Tab that lends none is
unchanged. Main-thread CPU, two rounds interleaved against main 9328f61,
moved within the host's noise now that #5363 keeps each recalc local
(Tab: median of six Tabs from load; click: median of four):

| | main | this |
|---|---|---|
| Tab, 64 sections | 43 / 42 ms | 43 / 33 ms |
| The Tab lending six faces, 64 sections | 51 / 50 ms | 40 / 34 ms |
| Tab, 512 sections | 272 / 160 ms | 220 / 224 ms |
| Click, 64 sections | 60 / 54 ms | 53 / 51 ms |
| Click, 512 sections | 302 / 210 ms | 243 / 259 ms |

Tests: `pnpm run test:runtime` (781 passed), `pnpm run check:browser`,
and the 29 browser tests that read binding faces or chips, in
test_command_routes, test_card_placement, test_clusters, test_pins,
test_obligation_walk, test_render_options, test_render_options_addition,
test_render_widgets and test_obligations (33 cases passed).

> _This was written by Claude Code on behalf of max-sixty_
…ute's face in a shadow tree doesn't cover an earlier one's

482671b lends every face before reading any, and lets `reserve` give two
overlapping faces to the earlier route, so a face lent in the same pass no
longer counts as covering another. But a hit test outside a shadow tree
names the tree's host for whatever the tree holds. A face lent in a shadow
tree therefore reached an earlier route's face, read in another tree, as
its host, which counted as covering it, and the later face won.

`exposedBindingBadge` now reads a host over the face again inside the
host's own tree, with `elementsFromPoint` on its shadow root and down
through any tree nested in it. The host covers the face unless all its tree
holds over the face there is faces lent in this pass. The host's own box
over the face still covers it, as does anything else in its tree, and a
host whose tree is closed covers it as before.

`an earlier route keeps its face under a later route's face in another
shadow tree` (command-controls.test.mjs) puts two overlapping faces in
sibling shadow trees. Without the change, the second face is worn and the
first withheld. happy-dom's document isn't a `Document`, so each face there
stands in a shadow tree of its own, rather than one in the document as in
the review's case.

Every face's and command chip's placement matched main again after the
same 15 inputs on the same eight pages (527 face and 24 chip readings). Tests: `pnpm run
test:runtime` (782 passed), `pnpm run check:browser`, and the 29 browser
tests that read binding faces or chips (33 cases passed).

> _This was written by Claude Code on behalf of max-sixty_
@max-sixty
max-sixty merged commit 24e1520 into main Nov 4, 2026
4 checks passed
@max-sixty
max-sixty deleted the agent-aa9e1c6c855e164e3 branch November 4, 2026 12:26
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