Skip to content

Commit f154596

Browse files
Give the scroller's gutter one reading, and drop the tolerance the fix retired (#65)
## Problem `main` had two independent stale layout assertions: - The margin-resident test expects a 720px column minus a 15px scrollbar gutter, although #64 now correctly preserves the full 720px column at and above the combined strip floor. - The option-address test pinned a digit to the old 6px inset, although the status stripe now occupies the start of that gutter and the digit correctly begins at 15px. #56 has since repaired the stale option-address assertion on `main` and directly checks the status/address/prose relation for the card form. This branch is therefore back to the scrollbar-gutter repair alone. #66 remains separate: it has been reopened to retain the corresponding row-form and cross-form coverage. ## Solution The runtime now has one `scrollerGutter` reading beside `pageScroller`; `stateStrip` and `stateRoom` both use it. The browser test asks that production helper for the width it drives, but first cross-checks it against an independent body-box reading. That guard catches a correlated overread before the helper can choose and judge the same viewport. The roomy column is then required to remain the full 720px; the retired gutter tolerance and its prose form are removed. ## Testing - `test_opposite_margin_residents_wait_for_the_room_they_need`, the current `test_a_questions_digits_are_drawn_whole`, and #56's direct option-pointer regression: 3 passed together after merging current `main`. - All four files changed relative to current `main` pass pre-commit. - Gutter overread bug-back: without the independent cross-check, a planted 30px reading passes; with the guard, it fails at `30 == 15`. - Removing `scrollerGutter()` from the strip calculation fails at `705 == 720`. Exact-head full CI and review remain the merge gate. --------- Co-authored-by: leaf-agent <[email protected]> Co-authored-by: Maximilian Roos <[email protected]>
1 parent fe4e8ea commit f154596

4 files changed

Lines changed: 83 additions & 27 deletions

File tree

‎plugins/leaf/skills/leaf/CLAUDE.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ rendering, and async settlement;
5151
`runtime/widget-elements.js` owns widget-element construction, labels, gesture
5252
guards, deferred measurement, and control sizing;
5353
`runtime/registry.js` owns vocabulary queries;
54-
`runtime/scrolling.js` owns the document scroller identity;
54+
`runtime/scrolling.js` owns the document scroller identity and the gutter its bar
55+
takes;
5556
`runtime/presentation.js` owns runtime paint and the words it projects;
5657
`runtime/reach.js` owns keyboard access to overflow and the containing block a
5758
scroller owes what it scrolls;
@@ -1127,7 +1128,12 @@ comment panel and tray panel each occupy their own strip when the viewport can
11271128
hold it and cover the page under their respective media query otherwise.
11281129
`stateStrip` and `stateRoom` are the geometry readings, and both count every
11291130
strip the chrome holds and the gutter the scroller's own bar takes — a window is
1130-
the page's box on neither count; CSS owns the body's corresponding layout.
1131+
the page's box on neither count; CSS owns the body's corresponding layout. The
1132+
gutter has one reading, `scrollerGutter`, beside the scroller it is a fact about.
1133+
`stateRoom` is restated by the observation of body's box; `stateStrip` writes
1134+
that box's padding, so it is called instead, and the gutter it reads cannot go
1135+
stale between calls because the stylesheet that makes body the scroller reserves
1136+
the room whether or not a bar is drawn in it.
11311137

11321138
Both regions fixed to a side of the window are drawn by the reader. `drawnEdge`
11331139
is the one implementation: each caller supplies the side its region is held to, a

‎plugins/leaf/skills/leaf/assets/leaf.js‎

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ import {
249249
renderSaid,
250250
} from "./runtime/presentation.js";
251251
import { reachScrollers } from "./runtime/reach.js";
252-
import { pageScroller } from "./runtime/scrolling.js";
252+
import { pageScroller, scrollerGutter } from "./runtime/scrolling.js";
253253
import {
254254
matchesWhen,
255255
registry,
@@ -1734,9 +1734,21 @@ const trayStrip = () =>
17341734
// Its own function, and not syncLayout's, because the strip it vetoes is body's own
17351735
// padding (theme.css) and syncLayout runs from an observation of that box — CLAUDE.md's
17361736
// "The one writer may not write the box the layout is measured from", and the same reason
1737-
// the strip the panel takes is a rule in the stylesheet above. Moving it costs nothing,
1738-
// because neither fact it turns on is a reading of that box: the window states one and the
1739-
// panel the other, and each arrives on an occasion of its own.
1737+
// the strip the panel takes is a rule in the stylesheet above.
1738+
//
1739+
// So it is called and not observed, and it is only as fresh as its callers — which is
1740+
// enough, because each fact it turns on either arrives on an occasion of its own or does
1741+
// not move at all. The window states the cap on a resize, and the panel its strip on the
1742+
// gesture that moves it. The scroller's gutter is the one with no occasion to arrive on:
1743+
// body gains or loses its bar as the document's height crosses the viewport, and replay
1744+
// retiring a slot, a widget settling late, or an image arriving can each do that with no
1745+
// resize and no chrome gesture behind it. What answers that is the stylesheet rather than
1746+
// a call from every such path — body is given scrollbar-gutter: stable in the same rule
1747+
// that makes it the scroller (chrome-style.js), so the room is reserved whether or not a
1748+
// bar is drawn in it and the difference between the two boxes holds still for the page's
1749+
// life. Joining layoutSizes would be the fix if it did not, and it is the one the rule
1750+
// above forbids: the strip this vetoes is padding on the observed box, and stateRoom can
1751+
// be observed only because it writes nothing that box is measured from.
17401752
//
17411753
// The strip is stated rather than measured off body, whose clientWidth is the box itself
17421754
// and would be the natural reading. The margin transitions, so a measurement taken during
@@ -1752,16 +1764,18 @@ const trayStrip = () =>
17521764
// scroller's own bar and this can, which is the whole of what the runtime adds; a page with
17531765
// no runtime behind it falls back to the viewport in each rule that reads it.
17541766
function stateStrip() {
1755-
// The same gutter stateRoom takes off, and taken the same way, for the reason it gives
1756-
// there: body is the document's scroller, so a classic bar comes out of the room this
1767+
// The scroller's gutter, which stateRoom takes off for the same reason and by the same
1768+
// reading: body is the document's scroller, so a classic bar comes out of the room this
17571769
// page has while the window says nothing about it. The coarse answer owes it as much as
17581770
// the fine one. Without it the floor was met by a window with a bar's width less page
17591771
// behind it, and the strip came out of the column the floor exists to keep it out of —
17601772
// a sidenote page at exactly 1152px read at a 705px measure, and a sidebar and a note at
1761-
// 1416px did the same. Overlay scrollbars are 0 here, which is why a Mac never saw it.
1762-
const gutter = pageScroller.offsetWidth - pageScroller.clientWidth;
1773+
// 1416px did the same.
17631774
const avail =
1764-
document.documentElement.clientWidth - gutter - panelStrip() - trayStrip();
1775+
document.documentElement.clientWidth -
1776+
scrollerGutter() -
1777+
panelStrip() -
1778+
trayStrip();
17651779
document.body.toggleAttribute("data-lf-cramped", avail < stripMin());
17661780
document.documentElement.style.setProperty("--lf-avail", avail + "px");
17671781
}
@@ -1870,14 +1884,16 @@ function stateRoom() {
18701884
const body = getComputedStyle(document.body);
18711885
const column = getComputedStyle(main);
18721886
// The gutter body reserves for its own scrollbar, which the window does not know about
1873-
// and the box in front of us has already given up. Read as the difference between the
1874-
// two boxes rather than asked of the platform, which has no way to be asked; it is a
1875-
// constant through a slide, both boxes moving with the margin together.
1876-
const gutter = document.body.offsetWidth - document.body.clientWidth;
1887+
// and the box in front of us has already given up. One reading (scrolling.js), because
1888+
// the veto above owes the same number and a second spelling of it here would be true by
1889+
// inspection rather than by construction.
18771890
const room =
18781891
Math.min(
18791892
document.body.clientWidth,
1880-
document.documentElement.clientWidth - panelStrip() - trayStrip() - gutter,
1893+
document.documentElement.clientWidth -
1894+
panelStrip() -
1895+
trayStrip() -
1896+
scrollerGutter(),
18811897
) -
18821898
parseFloat(body.paddingLeft) -
18831899
parseFloat(body.paddingRight) -

‎plugins/leaf/skills/leaf/assets/runtime/scrolling.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,16 @@
66
// SortableJS walks up from the dragged card and, on reaching body, hands back
77
// document.scrollingElement, so lf-board passes this in rather than letting it guess.
88
export const pageScroller = document.body;
9+
// The room the scroller's own bar takes out of the page, which is a fact about the
10+
// scroller and so belongs beside it: every geometry reading that starts from the window
11+
// owes it, and each of them differs in what the gutter is coming off rather than in how it
12+
// is found. The difference between the scroller's two boxes is the only way to ask — no
13+
// platform states the width, and the window states nothing about a bar drawn inside it.
14+
// Constant through a panel's slide, both boxes moving with the margin together, and
15+
// invariant under the strip veto's own padding, which is inside both. Constant over the
16+
// page's life as well, and that is the stylesheet's doing rather than this line's: the
17+
// rule that makes body the scroller gives it scrollbar-gutter: stable, so the room is
18+
// reserved whether or not a bar is drawn in it and a document that stops overflowing
19+
// keeps it. A caller reading this off a stale occasion is therefore not a way to be
20+
// wrong. Overlay scrollbars are 0, which is why one platform never sees any of this.
21+
export const scrollerGutter = () => pageScroller.offsetWidth - pageScroller.clientWidth;

‎tests/test_render_pages.py‎

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,9 +1936,10 @@ def test_opposite_margin_residents_wait_for_the_room_they_need(
19361936
19371937
At the ordinary 1152px floor, the sidenote keeps its established right margin and
19381938
the sidebar remains in flow. Giving both their full strips there leaves only 504px
1939-
for prose. At the combined floor, both may stand outside a full-width column once
1940-
the window also supplies a live platform's stable scrollbar gutter. A script-free
1941-
copy has to make the same choice from its viewport alone.
1939+
for prose. At the combined floor of the page's own box, both may stand outside a
1940+
full ordinary column; a window short of that floor by a live platform's stable
1941+
scrollbar gutter has the veto hand the strips back. A script-free copy has to make
1942+
the same choice from its viewport alone.
19421943
19431944
The second sidebar is the other composition case: only the first direct child of
19441945
main may take the sticky page-level slot, so an accidental second one remains in
@@ -1995,21 +1996,41 @@ def test_opposite_margin_residents_wait_for_the_room_they_need(
19951996

19961997
# The floor is a fact about the page's box, and the window is not that box wherever
19971998
# the platform draws a classic scrollbar: body is the document's scroller, so its bar
1998-
# comes out of the room the strips and the column divide between them. So the page is
1999-
# asked for the difference rather than a number being written that is right on one
2000-
# platform. Either way the column keeps its measure at the floor itself, which is what
2001-
# the strip is floored to protect: given the room, both strips stand outside a full
2002-
# column; short of it by the width of a bar, the veto hands them back.
1999+
# comes out of the room the strips and the column divide between them. The column
2000+
# keeps its full measure on both sides of that, which is what the strip is floored to
2001+
# protect: given the room, both strips stand outside a full column, and short of it by
2002+
# a bar's width the veto hands them back. So neither read subtracts a bar from what it
2003+
# expects — the widths the page is driven at are where the bar is accounted for, and a
2004+
# measure that fell short of 720 anywhere here would be the fault this floor exists to
2005+
# prevent rather than a tolerance to write down.
20032006
resized(page, 1416, 800)
2004-
bar = page.evaluate(
2005-
"() => document.documentElement.clientWidth - document.body.clientWidth"
2006-
)
20072007
at_floor = page.evaluate(reading)
20082008
assert at_floor["column"]["width"] == 720, (
20092009
"the strip came out of the column at the combined floor, which is the one width "
20102010
f"the floor exists to keep it out of: {at_floor}"
20112011
)
20122012

2013+
# The runtime's own reading of the gutter, asked of the module that owns it, so the
2014+
# width this drives at is the one the veto is doing its arithmetic in by construction
2015+
# rather than by a second spelling that agrees on inspection. Its own evaluate and not
2016+
# a key on `reading`, which the script-free copy below shares and which has no module
2017+
# to ask; the window against body's padding box, the other candidate, would agree only
2018+
# while body carries no margin, and the panel's strip below is a body margin.
2019+
bar = page.evaluate(
2020+
"() => import('/runtime/scrolling.js').then(m => m.scrollerGutter())"
2021+
)
2022+
# Driving the page at a width the helper chose and then testing the veto that spends
2023+
# the same helper leaves one thing the reads below cannot see: an error in the helper
2024+
# itself, which lands on both sides and cancels. A gutter overread as 30 puts the page
2025+
# at 1446 and has stateStrip take 30 off it, so the floor is met on the nose and every
2026+
# measure here passes while the band from 1431 up is cramped for nothing. So the two
2027+
# spellings are held to each other first, at the one viewport both are read at, and
2028+
# `reading` keeps the key: it is a claim about what the gutter is rather than a second
2029+
# copy nothing checks, and it is what the failure dumps report a short measure against.
2030+
assert bar == at_floor["gutter"], (
2031+
"the module's gutter and the page's own reading of it have come apart, which "
2032+
f"would leave the widths below chosen and judged by the same error: {at_floor}"
2033+
)
20132034
resized(page, 1416 + bar, 800)
20142035
roomy = page.evaluate(reading)
20152036
assert [(s["float"], s["position"]) for s in roomy["sidebars"]] == [

0 commit comments

Comments
 (0)