Repository navigation
Read every command hint's box before writing any, so a paint forces one layout for its faces - #5366
Merged
Merged
Conversation
…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_
leaf-agent
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
paintin 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.
reservealready 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,
mandtwalks, option focus) on theaskspage ofleaf-dev scalingat 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
reservegives the earlier route (an earlier route keeps its face under a later route's face in another shadow tree, a runtime test).On the
askspage 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):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).