Repository navigation
Report a code block drawn too narrow to read in page check --render - #5747
Conversation
The reading theme contains every code block (`contain: inline-size` on `pre`), so a
long line never widens the flex items and grid tracks above it. The same rule leaves
a block nothing in a box that takes its width from its content: two short commands
in a flex row each stood 30px wide at 390px, showing a letter or two of their
lines, and `leaf page check --render` reported nothing.
The theme keeps the containment, and the render check now reports such a block, as
it already reported a table that scrolls with a cell wrapped. `squeezedTables`
becomes `squeezedBoxes` (`src/leaf/render-checks/layout.js`), the gate's one reading
of a box the theme scrolls sideways. It takes each table or `<pre>` that scrolls with
visible words past its inner box, and reads it under a sheet that changes what
decides its width. A table's sheet turns wrapping off, as before. A block's sheet
lifts its containment and lets its lines wrap anywhere, so the block asks for its
lines' width again while its minimum stays about a character. A holder whose width
comes from its items' minimum or from none of them (the column, a `flex: 1` item, a
`1fr` track) gives the block the same width under the sheet. Only a holder sized to
what its items ask for (a flex item at its default `flex`, an `auto` track, a table
cell, a box sized to fit) gives it more. A block that stands more than 1px wider
under the sheet is reported as `squeezed-code` advice:
at 360–1920px wide, <pre id=a1> is 30px wide and scrolls 73px sideways where
there is room for 103px: a code block asks what holds it for no width, so a box
sized to its content, such as a flex item, a grid auto track or a table cell,
sizes without it; give the block or that box a width, such as a min-width on
the block, flex: 1 on the flex item or a 1fr track
Lifting the containment alone would also report `flex: 1` halves scrolling long
lines, which read well: they widened from 163px to 688px under it. The table's sheet
comes off before the block's goes on, so a column holding a block is read with the
block contained, as the page sets it.
`squeezed_table_advice` becomes `squeezed_advice`; it already keyed each finding by
its place and code, so it carries the new code unchanged. `page-authoring.md` said a
`<pre>` needs no width under the face; it now says a box sized to its content needs
one for it, beside the existing advice for a table in such a box. The `pre` rule's
header in `reading.css` records the cost, the report, and the rejected one-column
grid inside the block: it sized the block by its lines, but a text-only line kept
1px after its last character where a block keeps 15px, and a block mixing text and
tags stood each run in a row of its own.
Follows #4035.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…heet Review of the first version found that its sheet, which lifted each scrolling block's containment to read the width its holder would give it, reported a block that read well: two `flex: auto` halves under headings, 361px and 343px wide, where the After block's basis grew with its lines and took room from its sibling. A `flex-grow` column beside a nav did the same. The sheet also reset every scrolling block to its start, against the reading's read-only contract. A block is now squeezed when it scrolls with words past its edge and has less than four times its font size inside its padding, about six monospace characters. Every block a content-sized holder left measured 0–34px inside at 360–1920px (a flex row, an `auto` track beside `1fr`, a column flex aligned to its start, a heading's width, a box sized to fit, a table cell), under 2.6 times its 13.5px font. Every block that read well measured 77px or more, the narrowest a `flex-grow` column beside a nav at 360px. No sheet goes on for a code block, so the table path is main's again. The finding carries the width inside the block and whether a table cell holds it. Outside a cell, its words offer a fixed width for the block or a `1fr` track, and no longer `flex: 1`, which in a column flex aligned to its start sets the block's height and left it 0px wide. In a cell, a width for the block would contradict the table's advice beside it, so they offer the table's own remedy: move a long command out of the table, or write a short one as inline `<code>`, which breaks inside the cell. `page-authoring.md` keeps main's paragraph but for the claim that a `<pre>` needs no width, which now says a box sized to its content can leave one too narrow to read and that `page check --render` reports it. `render_version`'s docstring names the new advice. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ords The floor reports any code block left a few characters wide, whatever narrowed it, but its words blamed a box sized to its content and offered a fixed width or a `1fr` track. That was wrong for four `minmax(0, 1fr)` tracks (44px inside at 390px), for a `flex: 1` column beside a wide nav (37px at 360px), and for 20px code in three tracks (73px at 390px), where the tracks are already `1fr`, the column already flexible, and a fixed width would push a phone page sideways. Stacking the tracks or wrapping the row at that width fixes them. The words now say the block shows a few characters at most, and offer more room for the block or what holds it, or stacking or wrapping what stands beside it where the window is that narrow, pointing at `page-layout.md`, "Layouts". In a table cell they now read "since a code block asks its table cell for no width". The scroll test measured each text node whole, so a short line ending in spaces, which a `<pre>` keeps, read as words past the edge though every letter fit. It now measures each line from its first character to its last that isn't a space; a table's text measures the same, since its trailing spaces collapse. The floor now reads the font size of the words that run out rather than the block's, so a rule setting the `<code>` inside apart from the `<pre>` sets the floor too: 9px code in four tracks, 44px inside at 390px and about eight of its characters, is no longer reported. The test reads at 390px and 360px, adds the four tracks as a reported case whose words must cite a heading `page-layout.md` has, the same tracks stacked on a phone as a remedy that leaves nothing to scroll, and a line whose trailing spaces alone run past the edge as a control, which fails with the trailing-space change undone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
The description lags the head in a few places. Since the squash merge makes it main's commit message, it should match the code before this lands:
- Quoted finding text. Both quoted findings under "The words" are earlier versions.
_squeezed_codenow says "so it shows a few characters at most; give the block or what holds it more room … or stack or wrap what stands beside it … (page-layout.md, "Layouts")". The cell variant reads "since a code block asks its table cell for no width". - Test summary. "Tests" says the new test holds six squeezed blocks. The test asserts ten: the four
minmax(0, 1fr)tracks (four-a…four-d) were added. It also has controls the description doesn't list: the stacked tracks as a remedy, the trailing-spaces block, and the check that thepage-layout.mdsection the finding cites exists. - Scope of the floor. "Why a width floor" and the evidence table present the floor as catching blocks that a content-sized holder squeezes. The
squeezedBoxesheader now also reports blocks that too many fixed tracks narrow, for example fourminmax(0, 1fr)tracks at 390px leaving 44px. Those aren't caused by the containment. That case also explains why the words offer stacking, so it belongs in the description's reasoning and table.
…ack a row Trimming each line's trailing spaces in the shared scroll test dropped a squeezed table: an Exit column whose `white-space: pre` cells end in spaces held the column open at 188px, and the prose beside it wrapped at 100px, which main reports at 360px and the previous commit didn't. The trim is now a code block's alone; a table measures every character, as on main, since spaces a cell keeps do hold its column open. The words cited only `page-layout.md`'s "Layouts", which gives `layout-tiles` but not a page's own grid stacked at a narrow width, which "A workspace" shows. They now name `layout-tiles` and a grid that stacks below a width, and cite both sections. The test adds that table as a reported control at 390px and 360px, which fails with the trim applied to tables, and checks that every section the words cite is a heading of `page-layout.md`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
The new test fails on this Linux runner at both widths, because the two blocks whose width comes from a heading land on either side of the floor depending on which font draws the heading. Charter isn't installed here, so the serif fallback draws the <h2>Before</h2> 88.7px wide. That gives #labelled 87px wide and 59px inside its padding, over the 54px floor (4 × 13.5px), and it isn't reported. #fitted, under "Run it", has 52px inside, 2px under the floor. The test job on this PR is still pending and should show the same failure if its runner has the same fonts.
This also limits a claim in the description and in the squeezedBoxes header: "every block such a holder left measured 0–34px inside … whether … a heading … set its width". That holds for the fonts the PR measured with, not in general. A heading-sized holder can leave a block anywhere from a few characters to many, depending on how long the heading is and what font draws it, so for that holder there's no reliable gap for the floor to sit in. A floor is still a reasonable reading. But the test should use fixtures that sit well below it whatever the font, and the prose should state the 0–34px range as what those fixtures measured, not as a property of headings.
On a Linux runner without Charter, the serif fallback drew `<h2>Before</h2>` 88.7px
wide, which left `#labelled` 59px inside, over the 54px floor, so the test failed at
390px and 360px; `#fitted` passed by 2px. A heading or a cell's label gives its holder
the width its font draws, so the heading-sized, fit-content and table-cell fixtures now
carry three-letter labels ("Run"), which left their blocks 13-22px inside under the
theme's font, Times, Helvetica, Georgia, Verdana and Arial alike. The nav beside the
`flex-grow` control is two words, so its column stays over 100px inside in every
font, and the trailing-space control is a `6ch` box rather than a heading's width, so
its letters fit and it stays under the floor whatever the faces. The track lines are
shorter, so the stacked remedy fits a 360px column with room to spare.
The `squeezedBoxes` header gave 0-34px as what any content-sized holder leaves; it is
what the measured pages left. A holder sized by a heading or a cell's column leaves
whatever that text's length and font give it, so the floor reads the result, not the
cause.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…5747, squeezedBoxes (#5786) `test_the_data_structures_tables_read_on_a_phone` calls a render-check probe that no longer exists, so all three of its widths fail. This renames the call to the probe's current name. #5769 added the test with `evaluate_probe(page, "squeezedTables")`. #5747 landed after it and renamed that probe in `src/leaf/render-checks/layout.js` to `squeezedBoxes`, which now reports a code block squeezed too narrow to read as well as a table. #5747 updated every caller that existed when it was written, but not this new one. The driver throws `unknown Leaf browser probe squeezedTables` for a name it doesn't know (`src/leaf/render-checks/driver.js`). `tests/journeys` runs only on schedule, so neither pull request's CI ran the test. The test now keeps both pull requests' intent. The data-structures reference must read on a phone, and with the wider probe that also covers its code blocks. **Verified locally:** the test fails at 640, 600 and 360 px on `main` and passes with the change. Co-authored-by: leaf-agent <[email protected]>
Follows #4035.
The reading theme contains every code block (
contain: inline-sizeonpre), so a long line never widens the flex items and grid tracks above it. The same rule leaves a block nothing in a box that takes its width from its content: two short commands in a flex row each stood 30px wide at 390px, in Chromium and Firefox alike, with no room inside their padding for a character of their lines, andleaf page check --renderreported nothing.The theme keeps the containment, and the render check now reports such a block as
squeezed-codeadvice, beside the table it already reported scrolling with a cell wrapped. A call Max may reverse: this reports rather than changes the layout, so no page draws differently.What changes
The reading (
src/leaf/render-checks/layout.js):squeezedTablesbecomessqueezedBoxes, still thesqueezedfield of the gate's geometry sample. A table and a code block share its first test, that the box scrolls with visible words past its inner edge. For a code block, that test measures each line from its first character to its last that isn't a space, since a<pre>keeps the spaces that end a line and they read as words past the edge though every letter fits. A table measures every character, as onmain, since spaces a cell keeps (white-space: pre) do hold its column open; trimming them for tables too dropped a squeezed table main reports. A table is then read as onmain. A code block is squeezed when it has less than four times the font size of the words that run out inside its padding, about six monospace characters; no sheet goes on for it. Reading the words' size rather than the block's lets a rule on the<code>inside set the floor: 9px code in four tracks, 44px inside at 390px and about eight of its characters, isn't reported.The words (
src/leaf/findings.py), read at the narrowest width of each run, as every swept finding is. The floor reports any block left a few characters, whatever narrowed it, so the words name no cause: they offer more room for the block or what holds it, or letting what stands beside it wrap or stack withlayout-tilesor a grid that stacks below a width, citing thepage-layout.mdsections that give each ("Layouts" and "A workspace") rather than restating them. A block in a table cell gets the table's own remedy instead, consistent with the table advice beside it:The advice path (
src/leaf/render_gate/readings.py,version.py):squeezed_table_advicebecomessqueezed_advice, which already keyed each finding by its place and code.render_version's docstring names the new advice.Contract prose:
skills/leaf/references/page-authoring.mdkeepsmain's paragraph but for "so it needs no width", which now says a<pre>asks its container for no width, so a box that takes its width from its content can leave it too narrow to read, whichpage check --renderreports. Theprerule's header inreading.cssrecords the cost, the report and the rejected alternative below.Why a width floor
The floor reads the result, not the cause. A content-sized holder with nothing else in it leaves a block no room at all. One sized by a heading or a cell's column leaves whatever that text's length and font give it, from a few characters to many, so for those holders no gap is guaranteed. On the pages measured here (the review's fixtures and mine, at every width from 360px to 1920px), every block a content-sized holder left measured 0–34px inside, under 2.6 times its 13.5px font: a flex row, an
autotrack beside1fr, a column flex aligned to its start, a flex item or a box sized to fit whose heading set its width, a table cell. Every block that read well measured 77px or more inside, 5.7 times its font: the narrowest was aflex-growcolumn beside a short nav at 360px, then halves of each kind (flex: 1,flex: auto,1fr) at 109px or more. The floor at four times the font size sits between those ranges, which are what these pages measured in the theme's fonts on macOS: on a Linux runner without Charter, a block under<h2>Before</h2>had 59px. It also reports blocks narrowed some other way, which show as few characters: fourminmax(0, 1fr)tracks at 390px (44px) and 360px (36px), 20px code in three tracks at 390px (73px, under its 80px floor), and aflex: 1column beside a wide nav at 360px (37px). Stacking the tracks or wrapping the row at that width clears them, which is why the words name no cause.The first version of this PR read instead the width each block's holder would give it, by lifting the containment under a probing sheet. Review found it reported a block that read well: under headings, two
flex: autohalves stood 361px and 343px wide, and the After block's basis grew with its lines and took room from its sibling. Aflex-growcolumn beside a nav did the same. The sheet also cost about 6ms a swept width and reset every scrolling block to its start. The floor has none of these costs.Rejected: a one-column grid inside the block, which sizes it by its lines and still lets it shrink. Measured at 390px, a text-only line kept 1px after its last character where a block keeps 15px, and a block mixing text and tags stood each run in a row of its own.
Evidence
Pre-check on
main. A page with two short commands in a flex row:leaf page check --renderreturned"findings": [], and both blocks measured 30px wide (28px inside the border, 0px inside the padding) at 390px in Chromium and in Firefox. With this change it reports both at 360–1920px.What the reading reports. The width inside each scrolling block's padding (
leaf-dev probe, Chromium, the theme's fonts on macOS), the same at every width from 360px to 1920px unless a range is given. A row whose width comes from a heading or label would measure differently in other fonts:autotrack beside1frflex: 1minmax(0, 1fr)tracksflex: 1column beside a wide nav1frtracks1frtracksflex-growcolumn beside a short navflex: 1,flex: autoand1frhalves with long lines, the review'sflex: autoBefore/After halves among themmin-width: 16chdetails,lf-option,lf-tabandlf-suggestionThe table remedy holds: the cell's command written as inline
<code>breaks inside its cell, and the table neither scrolls nor draws a finding.Shipped pages. I ran the gate's own sweep (
sweepat every width ofSWEEP_WIDTHSand 540px, thensqueezed_advice) throughleaf-dev probe --journeyon all 58 shipped pages: the 24 examples, 13 developer galleries and 11 fixture pages thatauthored_sources()lists, and the 10 site pages underdocs/. On this revision, no page draws asqueezed-codefinding, and the 33squeezed-tablefindings (31 ondocs/data-structures, 2 on thebreakout-table-captionfixture) are the ones the merge base reported in the same sweep of the first version, so no table finding moved. That sweep ran before the table's whole-text test was restored, which only adds back findings like the review's spaced Exit column; no shipped page has one, since the counts already match the merge base. This is the desktop sweep only, in the light scheme; the reading doesn't depend on the scheme, and the phone sweep's widths are among the desktop sweep's.Evals (
uv run leaf-dev eval <case> --harness claude-code --base, one sample per arm). Each run readpage-authoring.md: the base arm's record holds the old "so it needs no width" and the head arm's the new "too narrow to read".table-cells-wrap-in-the-themesource-code-readableAdds
squeezed-code, as advice, carryinginside,scrollsandcell.main.Tests
test_a_code_block_its_holder_sizes_without_is_reported_squeezed(tests/browser/test_render_gate.py) reads the gate's geometry sample at 390px and 360px on one page. It reports ten blocks: a flex row of two, anautotrack beside1fr, a flex item sized by its heading, a box sized to fit, fourminmax(0, 1fr)tracks, and a table cell, the only one marked as in a cell, and one squeezed table, whosewhite-space: preExit cell ends in spaces that hold its column open. Every section the four tracks' words cite must be a heading ofpage-layout.md. The heading-sized, fit-content and table-cell fixtures carry the three-letter labelRun. With the page's text forced to the theme's font, Times, Helvetica, Georgia, Verdana and Arial in turn, it left those blocks 13–22px inside, and every control but the trailing-space one at least 108px, with the same set reported in each. The trailing-space control is a6chbox, so its letters fit in any monospace face. The controls scroll long lines and read well: a block in the column,flex: 1halves,1frhalves, the review'sflex: autohalves under headings, aflex-growcolumn beside a nav, a block in a flex row given a fixed width, and a short line in a6chbox whose trailing spaces alone run past the edge. It asserts every control scrolls, so the reading considered each, and that both remedies leave nothing to scroll: the four tracks stacked below 720px, and the cell's command as inline<code>.leaf-dev bugbackshows it fails with the change reverted (AssertionError: []), and it fails with the trailing-space trim undone (on the trailing-space control) or applied to tables too (on the spaced table).test_the_squeeze_reading_follows_words_into_an_open_shadow_root;tests/model/test_render_gate.py; intests/browser/test_render_gate.py, the squeeze, table, caption, declared-space, sweep, scrollbar-clearance and gate tests that read the geometry sample or callrender_version(15 passed); the journeystest_every_table_the_theme_sets_honestly_passes_the_gate(whose scrolling table holds a<pre>in a cell and still draws no advice) andtest_the_render_gate_reports_a_table_squeezed_by_what_cannot_break;leaf page check --renderon the pre-check page, the review's false-positive page (no finding at any width), its near-floor page and my fixture; the browser type check (tsc --project browser/types/tsconfig.json); pre-commit on every changed file.