Repository navigation
Draw the contents map's spine and markers in their first frame - #3931
Merged
Merged
Conversation
In the margin, `lf-toc`'s map showed nothing until its module upgraded: the initial drawing gave the widget its final box and rows, but the disclosure holding them stayed closed until the module opened it, so the spine and its markers first appeared at upgrade. Opening it earlier would not have been enough, since each row's flex share and each crowded label's fitted shift came from the module's own measurement. The map's layout now lives in the drawing both renderers share (`toc-view.js`): the disclosure's posture (`posture`, with the in-flow open choice it holds), each row's span, and the label fitting that shifts crowded markers (`measure`, `fitLabels`). The initial renderer lays the map out once the document has parsed, and the module lays it out again whenever the document moves, keeping only the lens and the current entry. That exposed a second difference. `.lf-ui`'s `box-sizing: border-box` reset lived in `runtime/chrome.css`, which the document adopts only at boot, so before upgrade the map's title label measured content-box, fitted one line, and after upgrade wrapped onto two, moving the title's marker 14px. The reset now stands in the render-blocking theme (`components/surfaces.css`), under `:where(:root)` like the face beside it, so it reaches the same document elements as before and no declared shadow tree. On the feature gallery after upgrade, every one of 4,240 elements computes the same `box-sizing` on main and with this change; the reset is now layered, and no Leaf rule sets another `box-sizing` on a `.lf-ui` element. Evidence: `test_the_reading_map_first_paints_its_spine_where_it_keeps_it` holds `leaf.js` and checks that the margin map is open with a marker per section at its section's share of the page, and that the upgrade leaves every marker where it stood. It fails on main (the disclosure is closed at first paint) and passes with this change in Chromium, Firefox and WebKit. A probe of the same page loads the same 41 requests before presentation on main and with this change. Ran: the `lf-toc` tests in `test_contents_and_glosses.py`, `test_render_initial_delivery.py`, `test_initial_drawings_keep_their_nodes_and_wrapped_geometry_on_upgrade`, the widget quality checks for every package, `tests/model/test_interact_layer.py`, `test_a_coined_class_cannot_reach_the_chromes_rules`, `pnpm run test:runtime` and `pnpm run check:browser`. > _This was written by Claude Code on behalf of max-sixty_ Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
previously approved these changes
Oct 25, 2026
The comment on `fitLabels` now says which labels compact the map and which open it as an outline. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 25, 2026
This was referenced Oct 25, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 27, 2026
Reverts #3931 (8143581), which laid out `lf-toc`'s margin map (its open disclosure, each row's share of the page and the fitted labels) in the initial drawing, before the module upgrades. **Why.** The theme's pre-upgrade rule, `html[data-lf-interactive] body:not([data-lf-upgraded]) > main .lf-ui {visibility: hidden !important}`, hides every row and marker of that map until upgrade, so the early layout drew nothing a reader could see. The user chose to keep that rule and take the early layout out rather than narrow the rule (#3962): the map keeps appearing when the page's code loads. **What it removes.** 477 lines deleted and 200 added, net −277: | | added | deleted | |---|---:|---:| | Hand-written source and test | 191 | 300 | | Generated (`lf-toc-initial.js` bundle, `shadow.css`, `runtime/chrome.css`) | 9 | 177 | - The layout (`posture`, `measure`, `fitLabels`) moves back from `toc-view.js` into `widgets/lf-toc.js`, and `initial/lf-toc.js` again only draws the outline. - `.lf-ui`'s `box-sizing` reset returns from the render-blocking theme (`components/surfaces.css`) to `styles/chrome.css`, where it stood before #3931 moved it for the early measurement. - `test_the_reading_map_first_paints_its_spine_where_it_keeps_it` goes with the behavior it held. No later commit built on the reverted code. Two files conflicted. In `TODO.md`, #3931 had deleted the "Draw the contents map's spine in its first frame" item; the backlog has since moved to issues, and the user decided against the feature, so the item is not restored. In the test file, main had since changed the deleted test's teardown. **Verified.** - `pnpm run build:browser` leaves the committed bundles unchanged, and `pnpm run check` passes. - The `lf-toc` tests in `test_contents_and_glosses.py` pass in Chromium. In Firefox, through a temporary fixture override, the same three tests fail on this branch and on the base, and none of them is about the map. - `test_render_initial_delivery.py`, `test_initial_drawings_keep_their_nodes_and_wrapped_geometry_on_upgrade`, `test_bundled_widgets_meet_the_widget_quality_checks`, `tests/model/test_interact_layer.py` and `test_a_coined_class_cannot_reach_the_chromes_rules` pass. - `leaf-dev probe docs/extending.html --base` at 1440x900, in Chromium and Firefox. After upgrade, the map's seven markers stand at the same positions on both arms, and the viewport stills are pixel-identical. With `leaf.js` held, every row and marker computes `visibility: hidden` on both arms in both engines, and Chromium's held stills are pixel-identical. The one difference is invisible: on this branch the held map's disclosure is closed and its hidden markers are evenly spaced. > _This was written by Claude Code on behalf of max-sixty_ Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.
In the margin,
lf-toc's map showed nothing until its module upgraded: the initial drawing gave the widget its final box and rows, but the disclosure holding them stayed closed until the module opened it, so the spine and its markers first appeared at upgrade. Opening it earlier would not have been enough, since each row's flex share and each crowded label's fitted shift came from the module's own measurement.The map's layout now lives in the drawing both renderers share (
toc-view.js): the disclosure's posture (posture, with the in-flow open choice it holds), each row's span, and the label fitting that shifts crowded markers (measure,fitLabels). The initial renderer lays the map out once the document has parsed, and the module lays it out again whenever the document moves, keeping only the lens and the current entry.That exposed a second difference.
.lf-ui'sbox-sizing: border-boxreset lived inruntime/chrome.css, which the document adopts only at boot, so before upgrade the map's title label measured content-box, fitted one line, and after upgrade wrapped onto two, moving the title's marker 14px. The reset now stands in the render-blocking theme (components/surfaces.css), under:where(:root)like the face beside it, so it reaches the same document elements as before and no declared shadow tree. On the feature gallery after upgrade, every one of 4,240 elements computes the samebox-sizingon main and with this change; the reset is now layered, and no Leaf rule sets anotherbox-sizingon a.lf-uielement.Evidence:
test_the_reading_map_first_paints_its_spine_where_it_keeps_itholdsleaf.jsand checks that the margin map is open with a marker per section at its section's share of the page, and that the upgrade leaves every marker where it stood. It fails on main (the disclosure is closed at first paint) and passes with this change in Chromium, Firefox and WebKit. A probe of the same page loads the same 41 requests before presentation on main and with this change.Ran: the
lf-toctests intest_contents_and_glosses.py,test_render_initial_delivery.py,test_initial_drawings_keep_their_nodes_and_wrapped_geometry_on_upgrade, the widget quality checks for every package,tests/model/test_interact_layer.py,test_a_coined_class_cannot_reach_the_chromes_rules,pnpm run test:runtimeandpnpm run check:browser.