Skip to content

Let surfaces.css decide which mark a ringed box shows, and give every box mark one writer - #7072

Merged
max-sixty merged 3 commits into
mainfrom
one-box-mark
Nov 24, 2026
Merged

max-sixty merged 3 commits into
mainfrom
one-box-mark

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Two homes now settle where the user is shown on a box:

  • locationStandsDown (target-paint.js) decides whether the location ring shows round the decision the user is in.
  • surfaces.css decides which mark a box shows when several land on it. On a ringed box, it draws the ring whole in the accent, whatever trace or focus mark the box also wears.

Two code checks used to settle the second question themselves. The margin's trace and anchor-paint's focus mark each held their mark off a ringed box, and each read the decision from the obligation view to do it. Both checks are gone, and so is the currentLocationObligation capability both painters took. The margin's check dates from #5045, when the trace was a chrome element of its own.

Every attribute painted onto the boxes an element shows through now has one writer, keepsOnEach in lib/keeps.js. That covers the aim, trace, proxy and location marks, the data-lf-obligation stamp (which no longer clears itself with a page-wide query each frame), the annotation renderer's marks, and the user-override and reported origin marks.

What changes on screen:

  • When a question is styled display: contents and focus lands on one of its paragraphs, main drew the focus floor 3px out. Now that paragraph wears the focus mark 6px out, as any focused paragraph does. Main's copy of the ring's box list in anchor-paint skipped the stand-down rule.
  • When a question sits inside a closed <details> and a thread's margin marker on it holds focus, main drew nothing on the page. Now the summary wears the margin's grey brackets. That is what faceOf (margin-projection.js) asks for whenever a closed box hides a thread's target, so the page shows which box holds the thread. Main's check held the trace off because the user's location was that question, though the question's ring stood on a box the disclosure hides. The marker's preview card stands above or below the marker depending on what ran before the Tab, on main as here: a journey that settles before the Tab put it above in 3 of 4 runs on main and 4 of 4 here, and one that tabs straight after load put it below in 4 of 4 on both. This change doesn't move it.

Evidence: leaf-dev probe --frames read each marked box's computed outline, clip and border image after every frame, with the checks (3f5751a) and without them. Seven routes drew identical frame sequences:

  • m arrivals;
  • Tab into a question and back;
  • a pick on the question, then undo;
  • a pick from inside the question, which takes the location away, then undo;
  • Escape, then m;
  • a margin marker left and reached again.

On those routes the ringed box wore data-lf-traced or data-lf-mark without the checks, so the deleted paths ran.

Size against main: production code +60/−118 lines, comments +39/−42. Tests −50, mostly tests/runtime/anchor-paint.test.mjs, which guarded the focus mark against a stale stamp; anchor-paint no longer reads the stamp. Exports: keepsOnEach is added and locationStandsDown is now private.

Still hand-written: these keep their own add-and-remove loops:

  • holdWords: a placement and a draft add only the elements their words stand in, and the next paint that changes a mark lets go of the rest, as the header at anchor-paint.js says. keepsOnEach takes the whole set, so each such add would read every element holding a comment's words, a cost that grows with the page.

The rest diff a set that other code also reads, so moving them would hold that set twice:

  • thread/surfaces.js's outlets, which five other sites read;
  • anchor-paint's hover and here classes, which paintVisualStates reads;
  • focus.js paintFocus, whose diff also drives its moved reading and writes shadow part tokens.

Tests: pnpm run test:runtime (1119), pnpm run check, and 43 named browser tests on the location ring, focus rings, margin entries and traces, comment marks and origin marks all pass. test_an_obligations_margin_marker_keeps_its_location_ring_whole no longer asserts that no box wears data-lf-traced; its checks of the rings drawn stay. 17 leaf-dev stills states are unchanged against main. Two showed 0 px style differences that went away on a rerun.

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

…where it stands

Four painters each kept their own copy of "an attribute on each box an
element shows through, taken off the boxes it left": target-paint's
marks (aim, trace, proxy), its location ring, the obligation view's
`data-lf-obligation` stamp, and the annotation renderer's
`data-lf-mark`/`data-lf-projected-mark`. They now share
`keepsOnEach` (lib/keeps.js), beside `keepsOnOne`. The obligation
view's stamp, which found the boxes to clear with a page-wide
`querySelectorAll` on every repaint frame, is now written by
`paintLocation` from the same box list as the ring.

Three modules also answered "does the location ring stand on this
box?" each its own way: target-paint by its stand-down rule,
anchor-paint by a copy of the box list without that rule, and the
margin by comparing the decision element alone. `locationRingOn` is
now the one answer, read live as #4583 requires, and
`locationStandsDown` is private to target-paint.

No behaviour change is intended. The cases where the old copies
disagreed with the ring (focus on a shown part of a boxless decision;
a trace on one) already drew one ring through surfaces.css.
leaf-agent
leaf-agent previously approved these changes Nov 24, 2026
…rigin marks onto keepsOnEach

The margin trace (margin-projection.js) and the focus mark
(anchor-paint.js) no longer give way to the location ring in code, so
`locationRingOn` goes, and both painters lose their
`currentLocationObligation` capability. surfaces.css already draws a
ringed box's ring whole, in the accent, whatever trace or focus mark it
also wears. The margin's check dates from #5045, when the trace was a
chrome element of its own; the marks have since moved onto the boxes
they mark.

`leaf-dev probe --frames`, reading every marked box's computed outline,
clip and border image after each frame, drew the same sequence of frames
with and without the checks (base 3f5751a) on seven routes: `m`
arrivals, Tab into a question and back, a pick on the question and
undo, a pick from inside it, which takes the location away, and undo,
Escape and `m` again, and a margin marker left and reached again. Head
wore `data-lf-traced` and `data-lf-mark` on the ringed box in those
routes, so the comparison exercised the deleted paths.

tests/runtime/anchor-paint.test.mjs is deleted. It protected that the
focus mark followed the obligation view's live reading rather than a
stale `data-lf-obligation` stamp (#4583); anchor-paint no longer reads
the decision at all.

The user-override and reported origin marks (projection/presentation.js)
move onto `keepsOnEach`, which now answers the elements it reached.
`markOne` loses the mode it took for the decision stamp, which
`paintLocation` writes through `keepsOnEach` once a repaint frame, as
`markHere` did.
@max-sixty max-sixty changed the title Give every box mark one writer, and the location ring one answer for where it stands Let surfaces.css decide which mark a ringed box shows, and give every box mark one writer Nov 24, 2026
leaf-agent
leaf-agent previously approved these changes Nov 24, 2026
`test_an_obligations_margin_marker_keeps_its_location_ring_whole` asserted
that no box wears `data-lf-traced` while an obligation's marker holds
focus. Since the margin no longer holds its trace off a ringed target,
the question wears both, and surfaces.css draws the ring whole over it,
the same pixels as before. The test keeps its checks of the rings drawn,
which are what the user sees.
@max-sixty
max-sixty merged commit b13a80b into main Nov 24, 2026
6 checks passed
@max-sixty
max-sixty deleted the one-box-mark branch November 24, 2026 23:02
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