Repository navigation
Declare the margin's keys once, and group its rows by lane in one pass - #5367
Merged
Merged
Conversation
Every margin cluster declared the same commands as a scope of its own: 512 scopes on the `asks` page at 512 sections. The keyboard runtime's reflection walks every scope's rows on each pass, and the rows asked where the user is through computeds #5308 added so that answer was worked out once per focus move rather than once per cluster. The keys are now one scope on the projection `nav`, which holds every cluster in every lane, since a pane's lane is inserted beside the root lane inside it (margin-layout.js, `laneFor`). Nothing between a cluster and the projection declares keys, so a press on an entry or a marker reaches the same rows as before. The thread card stands outside the projection with its own scope and is unchanged. `aria-keyshortcuts` moves with the scope, from each cluster to the projection, since the keyboard runtime writes it on the element that declares a scope. That is a choice: a screen reader announces the shortcuts of the focused element, an entry or a marker, and the cluster and the projection are both its ancestors, so a reader hears the same either way. Deleted: the `onSteppableEntry` and `onMarker` computeds in margin-projection.js and `onOpener`'s in thread-preview.js, whose only purpose was sharing one answer among the clusters' reflections; the rows read focus directly. `drawnMargin` and `cardRevision` stay, since they keep the one reflection current when the margin renders or the card opens while focus stays put. Measured at 512 sections against main at 9328f61, both arms open and measured in alternation (minimum and median of 6 clicks, 18 Tabs and 18 walk steps): | input | main | this | |---|---|---| | click on an option | 248 / 419 ms | 219 / 404 ms | | Tab | 90 / 222 ms | 170 / 192 ms | | step of the marker walk | 132 / 582 ms | 223 / 599 ms | In a profile of 5 clicks, the keyboard's reflection of buttons per click went from 38 to 30 ms, of which reading every scope's declarations (`buttonDeclarations`) went from 28 to 21 ms. Most of what 512 cluster scopes once cost a click had already gone with the keyboard runtime's button index on main, so the change now buys less than an earlier ablation on an older main suggested (a click's median 450 to 322 ms).
A render puts each host that is not yet in the document before the next later host already in the toolbar. It found that host by slicing the rest of the inventory, mapping every later entry to its host and searching the result, once per new host: on a first render, where every host is new, a walk over the inventory for each entry, with an array the size of the rest of the inventory each time. Now the render reads every entry's next later host in the toolbar in one walk back over the inventory, the first time it needs one. The answers hold for the whole render: a host it puts in stands earlier in the inventory than any host it is read for, and hosts it creates later did not exist when the old search ran either. In a profile of loading the `asks` page at 512 sections, the search cost about 7 ms: 2.7 ms in its mapping and most of the render loop's own 6 ms, which is 1.9 ms now.
To place rows, the layout pass grouped them by lane by filtering every row for each lane, and searched the rows again for each lane's first. With a lane per independently scrolling pane, a page with a row in each of 512 panes read a row's lane 394,496 times a pass (review's count; 24,896 at 128), and a scroll of a pane can bring a pass. Now one pass over the rows, in their order, gathers each lane's rows, and the lanes come in the order of their first rows, as the sort by first index gave them. The lanes taken are the same: the root lane, and each pane lane with frames this pass.
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.
Every margin cluster declared the same keyboard commands as a scope of its own, 512 scopes on the
askspage at 512 sections, and #5308 added computeds so the rows' questions about where the user is were answered once per focus move rather than once per cluster. The keys are now one scope on the margin's projection, and those computeds are gone. Two loops over the margin's rows that searched them again for each member also run in one pass now.This follows root
AGENTS.md, "Responsiveness": an input's work depends on what it changes, and a step that walks one of the page's collections for each member of another grows with the square of the page.What changes
One scope on the projection. The margin's keys (moving through a cluster's entries, the marker walk, and Tab into and back past the thread card from its entry) are declared once, on the projection
nav, instead of on every cluster. The projection holds every cluster in every lane, since a pane's lane is inserted beside the root lane inside it (margin-layout.js,laneFor). Nothing between a cluster and the projection declares keys, so a press on an entry or a marker reaches the same rows as before. The thread card stands outside the projection with its own scope and is unchanged.aria-keyshortcutsmoves with the scope, from each cluster to the projection, since the keyboard runtime writes it on the element that declares a scope. That is a choice: a screen reader announces the shortcuts of the focused element, an entry or a marker, and the cluster and the projection are both its ancestors, so a reader hears the same either way.Deleted bookkeeping. The
onSteppableEntryandonMarkercomputeds inmargin-projection.jsandonOpener's computed inthread-preview.jsexisted to share one answer among the clusters' reflections; the rows now read focus directly.drawnMarginandcardRevisionstay: they keep the one reflection current when the margin renders, or the card opens, while focus stays put.Where a new margin host goes. A render puts each host not yet in the document before the next later host already in the toolbar. It found that host by slicing, mapping and searching the rest of the inventory once per new host; on a first render, where every host is new, that walked the inventory for each entry. It now reads every entry's next host in one walk back over the inventory, the first time the render needs one.
The rows of each lane. The layout pass grouped rows by lane by filtering every row for each lane and searching again for each lane's first row. With a row in each of 512 independently scrolling panes that was 394,496 lane reads a pass, and a pane's scroll can bring a pass. One pass over the rows now gathers each lane's rows, with the lanes in the order of their first rows as before.
Evidence
Measured at 512 sections on the
askspage against main at 9328f61, both arms open and measured in alternation (minimum and median of 6 clicks, 18 Tabs and 18 walk steps):In a profile of 5 clicks, the keyboard's reflection of buttons per click went from 38 to 30 ms, of which reading every scope's declarations (
buttonDeclarations) went from 28 to 21 ms. The keyboard runtime's button index on main had already removed most of what 512 cluster scopes once cost a click, so the change lands for its deletions, with the click's ~30 ms as a bonus. In a profile of loading the page, the host insertion search cost about 7 ms, which is now too small to show.A click's remaining margin work at 512 is the projection redrawing every host on every render (
renderNow, about 44 ms) and presenting each of the 1,024 entries again (presentContributionEntry, about 8 ms). Skipping unchanged hosts needs the inventory to keep each unchanged entry's identity, which is a change of its own.Checks
leaf-dev probe --base: 43 steps covering load, content inserted, shrunk and removed above every row, a target growing a line, a resize round trip, and stacked rail rows whose targets are hidden and shown with and without the pointer holding a row.ghints on margin entries, keyed reconciliation of the Page Map, a live version keeping the user on the same margin location, and the card following its entry in the Tab order.test_an_acknowledgment_uses_status_until_an_active_claim_restores_a_disclosurefails here and on main alike.pnpm run test:runtimepasses 781 tests, and the browser type check passes.