Skip to content

Work out a target's box and its marks' room once, for every surface that stands by it - #6771

Merged
max-sixty merged 7 commits into
mainfrom
focus-boxes
Nov 22, 2026
Merged

max-sixty merged 7 commits into
mainfrom
focus-boxes

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Every surface Leaf stands beside a target now takes the target's box from geometry.js: inkedBox, what the target draws with its list marker, and markedBox, where Leaf's marks at its edges stand. Both read each shown part and scale by the transforms on it (elementAxes). The margin bars read the first. The thread card, the comment box and previews keep clear of the second through markRoom (a new mark-room.js), and the design label stands on it. Before, each measured its own way: the card kept a fixed 16px, a preview a fixed 11px, the label read the outline from the box's style, and the bars kept a copy of the list rule. This finishes what #6700 started for the marks themselves.

To make the stylesheet the one statement of where marks stand, every box now states --lf-band-gap and --lf-band-room at rest through the existing :where(*) rule, and markedBox reads them. Worth weighing:

  • Two custom properties on every element. On leaf-dev bench's largest page (12,211 elements) a keystroke, scroll, hover and aim cost what they did; load measured 1,016ms against 978ms, lowest of three rounds on a busy machine.
  • Marks of a box around the target count where they would stand in the card's gap. A choice widget rings on its own frame (2px) while the decision around it rings 8px out, plus any padding; without this the card stood on the decision's ring. markRoom walks up through the boxes a comment can name whose edge stands within the surface's gap, and stops at the first box with no edge there. Every box states a room, so the walk skips boxes no comment names, which never wear a mark; a wrapper with padding would otherwise push the card out.
  • What moves: a card beside a table cell stands 8px off rather than 16, since a cell's marks stand inside it; a preview beside a region stands 14px off rather than 11; a card on a list item's left, and the design label over one, clear the marker; a card or preview beside a widget in a padded decision stands past the decision's ring rather than on it; a to-do's bar beside a display: contents target stands beside it rather than at the window's edge, and a preview of an element inside nested display: contents wrappers shows rather than standing nowhere.
  • A 1px wobble left in. An action's mark draws a 1px band where every other mark draws 2px, and the room follows the band the box shows, so a card beside such a target stands 1px closer while that mark shows. Holding the room still would take a second property beside --lf-band-room, or moving that band 1px out.

The design legend, landings, pins and key chips keep their own boxes, since each asks a different question. Before/after captures and the gallery comparison are on the Leaf page for this work.

The maintainer asked for "a single way of working out boxes" that handles bullets by design; Codex reviewed the change three times, and its findings are fixed apart from the 1px wobble above. Tests: new tests that a card on a widget stands its gap past the ring round its padded decision (0px without the walk), and that a link's preview stands its gap past the ring round a padded box it fills (1px without it); the changed card, send-placement, code-review, bar and aim tests; the preview and design-mode selections, test_interact_layer.py, and pnpm run test:runtime.

This was written by Claude Code on behalf of max-sixty

…rgin bars use

The browser draws an outside list marker beyond its item's border box, and
Leaf drew the aim, a comment's brackets, the margin trace and the proxy and
location rings as the marked box's outline, which stands the same distance
out on every side. On a list item those marks ran between the bullet and
the words: in Firefox the bracket touched the disc, and in every engine it
covered a number's full stop. The change bars, the outline round a pointed
change and the change card already stood clear of the marker (#6615), by a
rule of their own.

`markerReach` in geometry.js now holds one rule for all of them. A box that
draws an outside marker (`display: list-item` with a marker, outside), or a
block that opens one at its content's first line and start edge, reaches by
the list inset on the item's start side. Every other box keeps to its own
edge. The rule reads computed styles rather than the `li` tag, so a `div`
drawn as a list item reaches and a list of cards with `list-style: none`
doesn't.

- The bars, the change outline and the change card read `markerReach` in
  place of their own rule.
- Each mark writer reads the side for every box it marks along with its
  other reads, and stamps it as `data-lf-beside-marker="left|right"` along
  with its other writes, so marking many boxes lays the page out once.
- A stamped box draws its marks as a border image, which stands where the
  outline would on three sides and by the list inset further out on the
  stamped side. The aim's veil reaches with it. The bracket clip reads the
  same band, and also cuts what the veil's wider spread adds above and
  below. The new band properties are registered non-inheriting, as the
  others are.
- Focus alone keeps the outline, so a page's `:focus { outline: none }`
  still hides it.
- `--lf-list-inset` is registered as a length, so the runtime reads it in
  pixels.
- The design label above the aim reads the border image's outset as well
  as the outline's room.

Behaviour that changes:

- A bar beside an item's second paragraph now stands at that paragraph's
  edge, since no marker stands beside it.
- A box beside a marker that draws its own border loses that border while
  a mark shows on it, since the border image takes the border's place.
- A mark whose ring stands inside its box, beside a marker, stands on the
  box's edge, since a border image can't stand further in.

Measured marker ink, in px left of the item's words at the theme's 17px
text: a disc 18 to 12 in Chromium and WebKit and 14.5 to 8.5 in Firefox;
"9." 18 to 6 and "10." 27 to 6 in all three. With a 6px gap and a 2px
band, the outline stood 6 to 8px out.

Asked for by Max on a Leaf page. Firefox, Chromium and WebKit captures,
right to left, under forced colours and with an inward ring were checked,
and the built Firefox capture matches the approved sketch pixel for pixel.
A fresh reviewer read the captures, and Codex reviewed the diff: its
findings on a layout per marked box, the clip's band under an inward ring,
the stamp losing the marker's side, and `div` list items are fixed here.
`test_the_aim_on_a_list_item_stands_clear_of_its_marker` fails with the
reach removed and passes with it.
`test_the_bar_beside_a_list_item_stands_clear_of_its_marker`, the bracket,
ring, bar and outline tests, `pnpm run check:browser`,
`pnpm run test:runtime` and `tests/model/test_interact_layer.py` pass.
…ay: contents wrapper

markerReach read only the list style, so an item whose ::marker content
draws an arrow with list-style none got no reach, and its bracket ran
through the arrow. It now reads the marker's own computed content, which
also hides a marker. A display: contents holder between a paragraph and
its item draws no box, so the paragraph no longer has to stand at its
corner to open the item.

Found by Codex's second review; checked in Firefox, Chromium and WebKit.

> _This was written by Claude Code on behalf of max-sixty_
The reach covers a marker within the list's 24px inset. On CI's Ubuntu runner,
Charter is missing and the theme's serif falls back to DejaVu Serif, whose "10."
starts 33px left of the words, so the bracket at 30-32px crosses its "1"; with
Charter it starts at 27px and clears. "9." fits the inset in both and still has
the full stop the unreached band crossed. The band is now the blue the aim adds,
read against a capture before the aim, since a subpixel-smoothed "10." drew
blue glyph edges the old reading took for band.
…hat stands by it

geometry.js now answers two questions for every caller: what a target draws on
screen, its list marker included (`inkedBox`), and where the marks Leaf draws
round it stand (`markedBox`). Both read each shown part, so a target drawn
through `display: contents` measures by its parts rather than its own empty box.
Every box states its marks' gap and room in CSS whether or not a mark shows
(surfaces.css), so a script reads the room the stylesheet draws; a drawing's
parts state the band alone, since their marks follow each shape's contour, and a
box whose marks stand inside it, as a table cell's do, takes none. The room
scales by the transforms on the box and its ancestors, read from element-axes.js
(`elementAxes`) on each axis, so a rotated box's band stays its width on every
side.

mark-room.js (`markRoom`) adds, for every surface that stands beside a
subject, the marks of a box round it that a comment can name where that box's
edge stands within the surface's gap, as the ring round a decision stands past
the choice widget that fills it, its padding included. The walk skips boxes no
comment names, since every box states a room and a padded wrapper would
otherwise push the surface out.

- The margin's bars read `inkedBox`, so a to-do's bar beside a
  `display: contents` wrapper in a list item stands left of the marker, where it
  stood at the window's left edge.
- A thread card and the comment box stand clear of the marks at their subject's
  edge on each side (`markRoom`), then `COMMENT_GAP`, where they stood a fixed
  16px off. A card on a list item's left clears its marker, a card beside a
  table cell stands 8px off, and a card on a widget in a padded decision stands
  8px past the decision's ring, where it stood on it.
- A preview stands 6px past the marks round the element it previews
  (`markRoom`): 11px from a control, as before, and 14px from a region, 3px
  further, and past the ring of a padded named box the element fills. It stands by
  the box the element shows as (`shownBox`), so an element drawn through nested
  `display: contents` wrappers previews where it stood nowhere.
- The aim's design label stands above the marks at the box's top, and over a
  list item's marker at its start.

The design legend, landings, pins and key chips keep their own boxes: each asks
a different question (the element's own border box, a constant ring room before
focus arrives, a seat touching the target, a fragment's corner).
leaf-agent
leaf-agent previously approved these changes Nov 22, 2026
# Conflicts:
#	browser/AGENTS.md
#	browser/runtime/annotation-overlay/comment-placement.js
@max-sixty
max-sixty merged commit e4cf280 into main Nov 22, 2026
6 checks passed
@max-sixty
max-sixty deleted the focus-boxes branch November 22, 2026 22:24
max-sixty added a commit that referenced this pull request Nov 23, 2026
…vent that ends its input (#6798)

`leaf-dev stills` reported states as changed when both arms ran the same
commit, each state for a cause of its own. Each is fixed where it
arises:

- retained-quote pressed inside its live sample before the sample's page
had started, so Playwright retried, and each retry scrolled by a
different amount. The state now waits for the sample first.
- A thread view named its quote with a random id, and stills keys styles
by id, so every state with an open thread read as restyled.
`thread-card.js` now numbers views in drawing order, since one thread
can show in two views at once.
- Three hover states were captured on either side of the preview's 200
ms delay. They now wait for the preview, which is what a resting pointer
gets.
- States that press Tab for keyboard focus styling placed focus before
the runtime's Tab step had ended, so the focused control's preview
opened in some runs (panel-leaf in 5 of 10). A `keyboard_modality`
helper now waits for that step, in 12 states.
- gallery-theme scrolled before a margin layout pass that closing its
disclosure queues.
- After the screenshot's style on the root, Chromium can report an auto
margin as 0px though the box hasn't moved. Stills now reads styles
before it takes the screenshot.

The flake that started this, the chart states' scroll offset, was fixed
in the runtime by #6783, which landed meanwhile, so this branch takes
main's `settle`. With it, chart-preview, chart-point-aim,
gallery-metrics and six of the fixed states drew unchanged stills in two
runs on identical arms, and each fix's own reruns match across runs.

Max asked for the chart flake to be fixed, as a follow-up to #6771;
these are the other flakes the survey for it found.
`dev/tests/model/test_stills.py` and the thread-quote tests in
`tests/browser/threads/test_targets.py` and
`tests/browser/test_render_floating_panel.py` pass.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 23, 2026
…lace of size ratios a turn defeats (#6795)

Several readings worked out an element's scale as its bounding rect's
size over its offset size: what a container shows (`shownBand`), what a
sample's frame shows (`frameView`), a region capture's crop of a sample,
the drag grip's offset, the prose box, and the render checks for
scrollbar clearance and the room in the Layout's shell. A rotation
defeats that ratio, since a box turned a quarter reads its height
across; under a quarter turn a dragged card ran about 24,700px off in 12
frames. Each now asks `element-axes.js`, which composes an element's map
to the viewport from every transform and zoom around it
(`elementMatrix`), places its border box (`elementBorderFrame`) and
carries a box through it (`carriedBox`).

Where to look: a container's band starts from the browser's own bounding
rect and is brought in by the border and scrollbar the map carries
(`innerBox`), so where Leaf can't read a transform the browser draws, a
motion path or a perspective, the error stays within those insets, as
with the ratio. `frameView`, the capture crop and the grip still convert
through the map's inverse, so a sample frame on a motion path is
approximate there, as on main. Nested SVG viewports now clip to their
own box (main read them as empty) through `viewBoxFit`, a port of SVG's
equivalent-transform rule. The clip walk builds each box's map from its
parent's, once per pass.

On four corpus pages, at the top and three pages down, every element's
`seenRect` matches main within 0.01px, and both render checks return
what main returns.

A follow-up to #6771; Max asked for it, and two Codex reviews' findings
are folded in. New browser and journey tests cover a turned box's clip,
a carried card, a region capture and a sample's view; `pnpm run check`
passes.

> _This was written by Claude Code on behalf of max-sixty_
leaf-agent added a commit that referenced this pull request Nov 23, 2026
…marks (#6887)

A margin marker's focus preview now stands 6px past the ring of the
element the marker stands for, instead of flush on that ring. This
repairs
`tests/journeys/test_render_controls.py::test_each_sampled_focus_ring_is_shown_whole_in_its_surface`,
which has failed on macOS since #6771.

**Cause.** #6771 made previews keep clear of the marks round their
subject through `markRoom`
([mark-room.js](https://github.com/max-sixty/leaf/blob/397cd7d5c4f083cc22ae5fb05610f2f6660f719e/browser/runtime/mark-room.js)),
which walks up the subject's tree ancestors. A margin marker sits in a
margin seat, not inside the element it marks, so the walk never reached
that element. On pr-walkthrough at 1200×900, the preview of the
`lf-group` decision's marker stood above the marker and reached back
over the decision. Its bottom edge was at y 434.8, exactly the outer
edge of the decision's ring (top 442.8 − 6px offset − 2px band). The
preview face's box-shadow then covered x 1058–1192 of the ring's top
edge. Before #6771 the fixed 11px gap kept the preview clear of it.

**Change.** The walk now starts from the element a margin seat stands
for (`[data-lf-margin-for]`'s `lfTarget`, the lookup
`margin-projection.js` already uses). The element's ring counts wherever
the seat sits in the tree, so the preview stands its gap past the
decision's ring, like the previews #6771 placed beside a widget inside a
padded decision. The thread card and the comment box use `markRoom` too,
so they also clear that ring when they stand by a margin entry.

**On screen.** One state moves: the focus preview of a margin marker
that reaches back over its marked element stands 6px further from that
element. Where the preview stands beside the element, clear of it,
nothing moves.

**Verification.**
- `ci` dispatched on macOS with `flake`: the journey test failed 9 of 9
copies on main at `1bf92095f` ([run
45203893598](https://github.com/max-sixty/leaf/actions/runs/45203893598))
and passes 3 of 3 on this branch ([run
45236891419](https://github.com/max-sixty/leaf/actions/runs/45236891419)).
- A bisect over the same dispatch put the first failing commit at #6771
(`e4cf28028`); its parent passes.
- The new browser test
`test_a_margin_markers_preview_stands_its_gap_past_the_ring_of_what_it_marks`
reproduces the fault on Linux (clearance 0 instead of 6) and passes with
the change.
- The #6771 preview and card-placement tests,
`test_render_send_placement.py`, `pnpm run test:runtime` and `pnpm run
check:browser` pass.

#6872's other tests are unchanged: the intermittent lf-diff teardown
shift in `test_render_read_state.py`, and three tests that passed every
copy on macOS.

Refs #6872 — automated triage

Co-authored-by: leaf-agent <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants