Skip to content

Write Leaf's own data attributes and scroll mark under data-lf, which a page's CSS can't name - #5244

Merged
max-sixty merged 12 commits into
mainfrom
agent-a021572648b6475b6
Nov 4, 2026
Merged

max-sixty merged 12 commits into
mainfrom
agent-a021572648b6475b6

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Leaf wrote 84 data attributes on its own elements outside the lf- namespace that page check reserves for it: the floating panel's state (data-open, data-rest, data-shown, data-expanded, data-tone and two dozen more), a thread's and a message's identity (data-thread, data-event, data-message, data-attempt), the paint boxes' data-for, the composer's data-words and send corner, and the parts the bundled widgets draw: lf-code's line numbers and elided rows, lf-tabs' scroll buttons, the trace timeline's marks, the timeline's events, the deck's pips, the call diff's lines and the diff's file rows. It also wrote the scroll class on its own scroll surfaces. A page's own CSS for one of those names restyled Leaf. On a probe page whose <style> held [data-tone] { --warn: red }, [data-event] { --lf-msg-text-end: 123px }, [data-line] { background: blue } and .scroll { outline: 4px solid magenta }, main painted the panel's away leaf red (rgb(255, 0, 0)), gave a margin card's messages a 123px text end, painted lf-code's lines blue (rgb(0, 0, 255)) over its highlight, and outlined lf-tabs' strip and panel, lf-code's scroller and lf-options' "Add another option" field in magenta (4px rgb(255, 0, 255)). The chrome's all: revert-layer guard stops a plain declaration but not a custom property, and a widget's parts in the page have no guard at all.

Each is now the same name under data-lf-, its values unchanged, except where that name already meant something a document-wide reader or an unscoped rule relies on:

  • the panel view's data-view became data-lf-route, since prepaint.js sweeps [data-lf-view], a revision's view members;
  • the panel status's data-held became data-lf-held-lines, since thread/presentation.js strips data-lf-held from every node no thread holds;
  • an On me item's data-obligation became data-lf-obligation-id, since obligations/view.js sweeps data-lf-obligation, the location mark, and chrome.css gives every [data-lf-obligation] a landing margin;
  • the composer field's data-scrolls became data-lf-overflows, the name the margin card's transcript already gives the same fact, since reach.js writes data-lf-scrolls on that field too.

Where the prefixed name was already in use for the same kind of fact on other elements (data-lf-tone, data-lf-state, data-lf-open, data-lf-unread, data-lf-place, data-lf-ready, data-lf-line), every selector and query names its element, so the uses share a word without meeting. The video bar's data-hovered and data-keyed, built from one template, are data-lf-hovered and data-lf-keyed.

The scroll class stays the page's: page-authoring.md tells an author to add class="scroll" to a custom horizontal scroll box, and page check would refuse data-lf-scroll in markup. Leaf's own surfaces, and a package module's (module-scroll-and-motion.md now says so, as it already did for data-lf-track), wear data-lf-scroll, and reach.js and the shared containment rule in controls.css read both. Where the runtime marks an element the page owns (a code block, a part beside the Layout's views, a bounded block's body), the mark joins RUNTIME_PAINT_ATTRIBUTE, so a reading of the author's attributes looks past it, as it did past class.

Kept as they are: the attributes an author writes (data-width, data-height, data-bound, data-sample*, data-annotations, data-rail, and data-room, which Leaf's own controls also use, one rule for both), the playground's data-playground-* on its host, which the author's preview CSS reads by design, Pierre's attributes on the DOM it renders (data-line, data-line-type, data-code, data-content, data-separator and the rest), including the ones lf-diff copies onto its own rows and pre so Pierre's vocabulary keeps reading them, and the diagram's data-id, which pele writes.

On the same probe this change shows Leaf's own styling: the away leaf in the theme's warn (rgb(180, 116, 26)), the message's own 13px text end, lf-code's lines unpainted but for the highlight, and no outline on any widget part. Nothing changes on a page that doesn't target the old names, and specificity is unchanged: each [data-x] became [data-lf-x], and :where(.scroll) became :where(.scroll, [data-lf-scroll]).

Tests and dev tools read the new names. Attributes a test gives its own fixture, which only share a word with Leaf's, stay: the data-row key test_focus.py, focus.test.mjs and an application-boundary widget hand to holdFocus, a test widget's data-words and data-ready, the shift watch test's data-key on body, the write watch test's data-for, and the examples' own data-state and data-status. The shift and words watches' expected node paths lose the .scroll class (leaf-text#field, lf-diff#patch.lf-rendered), and reach.test.mjs asks a native code block for data-lf-scroll.

Checks

  • Main is merged in, and with it three new readers of the old names, which now read data-lf-obligation-id (the On card selector, ON_CARD), data-lf-key (the queue walk), data-lf-event (undo's message lookup) and data-lf-number (a text document's line number, in Load pages of many text documents in Firefox without restyling the page per document #5226's lf-text-document code and test). Show what a change replaced in a card over it, and mark a removal as a change #5249's change bars write theirs as data-lf-for, data-lf-gap and data-lf-kind, the stills drivers that moved to dev/leaf_dev/states.py in Open a stills state in probe with --state, and run stills through probe's loop in any engine #5259 read the new names, as do fix: fold from the menu's row in one paint, as the fold key does #5263's fold test (data-lf-says, data-lf-rest) and Sample the panel's fold as a probe journey, and profile bench-latency's transitions with --profile #5264's dev browser helper (data-lf-open).

  • The pull request's test job: its failures outside the journeys fail on main too; of the journeys, test_the_feature_gallery_exercises_its_core_journeys failed here because the test read the gallery's own preset buttons as data-lf-route, and now reads the author's data-view. The pressed-controls sweep's 28 cases, test_an_aimed_comment_keeps_its_place_with_on_me_open, and the navigation, controls and website-server journeys that failed fail the same way on main.

  • pnpm run check and pnpm run test:runtime (753 pass), pre-commit over the changed files, and the kernel rebuilt with pnpm run build:browser.

  • 67 browser tests, by node id, that read the renamed attributes: the floating panel's status peek, passing notices, versions, menu lists and Threads' New; thread summaries, attempts, failure receipts and message obligations; reactions; the send corner; the shift and words watches' field paths; reach for an authored .scroll box; the trace timeline and overview; timeline steps; lf-code excerpts and text-document numbers; the diff's cut path; the call diff; overflowing tabs; On me cards; rings and aim; a board's lifecycle; the recording bar; the smoke tier's three changed tests; and read state. test_a_pointer_folds_the_panel_from_its_corner fails the same way on main: the corner button calls foldPanel directly, so no lf-command-invoked arrives for the test to read.

  • leaf-dev stills over the 61 catalogue states that draw the renamed attributes found no computed style that differs; the style lists only re-key the elements that lost the scroll class. Stills differ only where every run differs: About's fingerprint and port, a caret's blink, an overlay scrollbar's fade, and a target trace one arm caught mid-transition, in the other arm on a second run. The stills drivers name the new attributes, so for this comparison 21 states drove the merge base's runtime through a local patch that accepted either name.

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

… a page's CSS can't name

Leaf wrote 84 data attributes on its own elements outside the
`lf-` namespace that `page check` reserves for it: the floating panel's
state (`data-open`, `data-rest`, `data-shown`, `data-expanded`,
`data-tone` and two dozen more), a thread's and a message's identity
(`data-thread`, `data-event`, `data-message`, `data-attempt`), the paint
boxes' `data-for`, the composer's `data-words` and send corner, and the
parts the bundled widgets draw: lf-code's line numbers and elided rows,
lf-tabs' scroll buttons, the trace timeline's marks, the timeline's
events, the deck's pips, the call diff's lines and the diff's file rows.
It also wrote the `scroll` class on its own scroll surfaces. A page's own
CSS for one of those names restyled Leaf. On a probe page whose `<style>`
held `[data-tone] { --warn: red }`, `[data-event] { --lf-msg-text-end:
123px }`, `[data-line] { background: blue }` and `.scroll { outline: 4px
solid magenta }`, main painted the panel's away leaf red (rgb(255, 0,
0)), gave a margin card's messages a 123px text end, painted lf-code's
lines blue (rgb(0, 0, 255)) over its highlight, and outlined lf-tabs'
strip and panel, lf-code's scroller and lf-options' "Add another option"
field in magenta (4px rgb(255, 0, 255)). The chrome's `all: revert-layer`
guard stops a plain declaration but not a custom property, and a widget's
parts in the page have no guard at all.

Each is now the same name under `data-lf-`, its values unchanged, except
where that name already meant something a document-wide reader or an
unscoped rule relies on:

- the panel view's `data-view` became `data-lf-route`, since prepaint.js
sweeps `[data-lf-view]`, a revision's view members;
- the panel status's `data-held` became `data-lf-held-lines`, since
thread/presentation.js strips `data-lf-held` from every node no thread
holds;
- an On me item's `data-obligation` became `data-lf-obligation-id`, since
obligations/view.js sweeps `data-lf-obligation`, the location mark, and
chrome.css gives every `[data-lf-obligation]` a landing margin;
- the composer field's `data-scrolls` became `data-lf-overflows`, the
name the margin card's transcript already gives the same fact, since
reach.js writes `data-lf-scrolls` on that field too.

Where the prefixed name was already in use for the same kind of fact on
other elements (`data-lf-tone`, `data-lf-state`, `data-lf-open`,
`data-lf-unread`, `data-lf-place`, `data-lf-ready`, `data-lf-line`),
every selector and query names its element, so the uses share a word
without meeting. The video bar's `data-hovered` and `data-keyed`, built
from one template, are `data-lf-hovered` and `data-lf-keyed`.

The `scroll` class stays the page's: page-authoring.md tells an author to
add `class="scroll"` to a custom horizontal scroll box, and `page check`
would refuse `data-lf-scroll` in markup. Leaf's own surfaces, and a
package module's (module-scroll-and-motion.md now says so, as it already
did for `data-lf-track`), wear `data-lf-scroll`, and reach.js and the
shared containment rule in controls.css read both. Where the runtime
marks an element the page owns (a code block, a part beside the Layout's
views, a bounded block's body), the mark joins `RUNTIME_PAINT_ATTRIBUTE`,
so a reading of the author's attributes looks past it, as it did past
`class`.

Kept as they are: the attributes an author writes (`data-width`,
`data-height`, `data-bound`, `data-sample*`, `data-annotations`,
`data-rail`, and `data-room`, which Leaf's own controls also use, one
rule for both), the playground's `data-playground-*` on its host, which
the author's preview CSS reads by design, Pierre's attributes on the DOM
it renders (`data-line`, `data-line-type`, `data-code`, `data-content`,
`data-separator` and the rest), including the ones lf-diff copies onto
its own rows and `pre` so Pierre's vocabulary keeps reading them, and the
diagram's `data-id`, which pele writes.

On the same probe this change shows Leaf's own styling: the away leaf in
the theme's warn (rgb(180, 116, 26)), the message's own 13px text end,
lf-code's lines unpainted but for the highlight, and no outline on any
widget part. Nothing changes on a page that doesn't target the old
names, and specificity is unchanged: each `[data-x]` became
`[data-lf-x]`, and `:where(.scroll)` became
`:where(.scroll, [data-lf-scroll])`.

Tests and dev tools read the new names. Attributes a test gives its own
fixture, which only share a word with Leaf's, stay: the `data-row` key
test_focus.py, focus.test.mjs and an application-boundary widget hand to
`holdFocus`, a test widget's `data-words` and `data-ready`, the shift
watch test's `data-key` on `body`, the write watch test's `data-for`, and
the examples' own `data-state` and `data-status`. The shift and words
watches' expected node paths lose the `.scroll` class
(`leaf-text#field`, `lf-diff#patch.lf-rendered`), and reach.test.mjs
asks a native code block for `data-lf-scroll`.

### Checks

- `pnpm run check` and `pnpm run test:runtime` (753 pass), pre-commit
over the changed files, and the kernel rebuilt with
`pnpm run build:browser`.
- 67 browser tests, by node id, that read the renamed attributes: the
floating panel's status peek, passing notices, versions, menu lists and
Threads' New; thread summaries, attempts, failure receipts and message
obligations; reactions; the send corner; the shift and words watches'
field paths; reach for an authored `.scroll` box; the trace timeline and
overview; timeline steps; lf-code excerpts and text-document numbers;
the diff's cut path; the call diff; overflowing tabs; On me cards; rings
and aim; a board's lifecycle; the recording bar; the smoke tier's three
changed tests; and read state.
`test_a_pointer_folds_the_panel_from_its_corner` fails the same way on
main: the corner button calls `foldPanel` directly, so no
`lf-command-invoked` arrives for the test to read.
- `leaf-dev stills` over the 61 catalogue states that draw the renamed
attributes found no computed style that differs; the style lists only
re-key the elements that lost the `scroll` class. Stills differ only
where every run differs: About's fingerprint and port, a caret's blink,
an overlay scrollbar's fade, and a target trace one arm caught
mid-transition, in the other arm on a second run. The stills drivers
name the new attributes, so for this comparison 21 states drove the
merge base's runtime through a local patch that accepted either name.

> _This was written by Claude Code on behalf of max-sixty_
# Conflicts:
#	browser/runtime/floating-panel.js
#	dist/kernel/kernel.json
#	dist/kernel/leaf.js
#	dist/kernel/runtime/bundle-errors.js
#	tests/browser/navigation/test_reading_place.py
leaf-agent
leaf-agent previously approved these changes Nov 3, 2026

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing yet states the rule this PR enforces: everything Leaf writes on DOM that a page's CSS can reach goes under data-lf- and lf-. src/leaf/validation.md reserves those namespaces against authors, and browser/AGENTS.md and packages/AGENTS.md never require the runtime or bundled widgets to stay inside them, which is how 84 names drifted out. With no stated rule and no check, the next data-foo that Leaf writes will reopen the same collision. A line in browser/AGENTS.md (and packages/AGENTS.md for widget parts) would close it. So would a runtime test that holds the attribute names in the runtime's and bundled widgets' templates to data-lf-, allowing the exceptions this PR lists (author-written attributes, Pierre's, pele's data-id, data-playground-*). Adding either later is no harder than now, so this doesn't block the merge.

# Conflicts:
#	dist/kernel/kernel.json
leaf-agent
leaf-agent previously approved these changes Nov 3, 2026
# Conflicts:
#	packages/default/widgets/lf-text-document.js
leaf-agent
leaf-agent previously approved these changes Nov 3, 2026
# Conflicts:
#	dist/kernel/kernel.json
leaf-agent
leaf-agent previously approved these changes Nov 3, 2026
The gallery's preset buttons are the page's markup and keep the author's
data-view; only the panel's view became data-lf-route.
# Conflicts:
#	dev/leaf_dev/commands/stills.py
#	dist/kernel/kernel.json
leaf-agent
leaf-agent previously approved these changes Nov 3, 2026
# Conflicts:
#	dist/kernel/kernel.json
@max-sixty
max-sixty merged commit a39a5dd into main Nov 4, 2026
3 of 4 checks passed
@max-sixty
max-sixty deleted the agent-a021572648b6475b6 branch November 4, 2026 00:45
max-sixty added a commit that referenced this pull request Nov 4, 2026
…ix (#5273)

#5050 and #5244 moved the classes and data attributes Leaf writes on its
own elements under `lf-` and `data-lf-`, the names `page check` refuses
an author, so a page's CSS can't restyle Leaf by naming one. Nothing
kept the next write there: each sweep was a grep, and the second found
about eighty names the first missed.

`test_leaf_writes_its_own_marks_under_its_prefix` reads every runtime
and bundled package module through a new `marks` reading in
`tests/js_facts.mjs`. It parses each module with oxc and its templates
and HTML strings with parse5's tokenizer, and collects each class and
`data-` attribute the module writes: in a start tag, through
`className`, `dataset`, `classList.add` or `toggle`, `setAttribute` or
`toggleAttribute`, `keeps`, or the class handed to `el` and the offer
builders. The test fails on a name outside the prefix unless it is one
of two kinds of name Leaf writes without owning:

- An author's: the idioms and tones the registries declare, such as
`label.choice`, `[data-room]` and `.ok`, which the theme draws alike on
Leaf's own controls. The test reads them from the registries, so a new
idiom needs no edit.
- A library's, on an element Leaf draws for that library: Pierre's
`data-code`, `data-line-type` and `data-overflow` on lf-diff's rows, and
markdown-it's `task-list-item-checkbox`, which the composer's editor
draws too.

It reads 1,464 writes in 336 modules, and found one name #5244 missed:
the composer's attachment shelf carried the `scroll` class, so a page
rule for `.scroll` reached it. The shelf now carries `data-lf-scroll`,
which the theme's scroller rule (`controls.css`) and the runtime's
scroll edges (`reach.js`) already read beside the authored `.scroll`.

A name built from a dynamic part, such as `lf-${kind}`, goes unread.

### Checks

- The new test, which fails on `class="lf-composer-media scroll"`.
- Browser tests for a margin reply with a pasted image and for an
attached image in the floating panel.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 4, 2026
Only the rebuilt kernel conflicted; it is main's, rebuilt from the merged sources.

Brought this branch's additions up to main's conventions: the two new tests read the
panel's thread by `data-lf-thread` (#5244), and the two comments that pointed at
destination.js's `page` option now name `reader: "page"`, its name on this branch.

test_z_shows_a_thread_resolved_in_its_card_by_its_passage now waits for the page to
scroll to the card before resolving it. After this merge, Shift+t focused the card before
the page had scrolled there, and Home pressed during that scroll lost to it in two runs
out of three under xdist.
max-sixty added a commit that referenced this pull request Nov 4, 2026
…heir owners

#5244 and #5242 have landed, so three questions they held open now have one
owner that every caller asks.

A drawn thread's id. Seven readers spelled `data-lf-thread` themselves beside
`drawnThreadId` in thread/selectors.js: thread/held-news.js,
thread/reply-continuity.js, thread/surfaces.js twice,
annotation-overlay/thread-preview.js, and annotation-overlay/margin-projection.js
twice. Those that read one element's id now call `drawnThreadId`. Those that
looked up the page threads drawn with an id call the new `drawnThreadsWithId`
beside it, which queries `.lf-page-thread` by the escaped id as they did. The
floating panel's `.lf-fp-asked` outlets keep their own `data-lf-thread`: it
holds a thread's key on an outlet, not the id of a drawn thread.

A page of parts' views. content-layout.js found the parts container itself:
`body > main`, the `--lf-layout-box` test and the `[data-lf-views="parts"]`
selector, all of which passages.js's `layoutBox` already reads. passages.js
now exports `layoutParts` beside `layoutBox`, both read one selector constant,
and content-layout.js's title marking calls it.

Whether the user can scroll a box. box-motion.js tested `auto|scroll` against
either axis and against overflowY, and scroll-containers.js tested it against
overflowY. Each now asks geometry.js's `userScrollport`, which answers the same
for every overflow value. Neither module crosses a boundary by importing
geometry.js: dependency-cruiser finds no cycle and no closure rule against it.

browser/AGENTS.md's question index names `drawnThreadsWithId` and
`layoutParts` in their rows. No behaviour changes, so no test changed.
max-sixty added a commit that referenced this pull request Nov 14, 2026
Main (#5368) moved every time-axis item's position into one rule in controls.css
(`.lf-on-axis`), so the label no longer sets its own `left`. The fix needs that
position to cap the label's width to the room on its side of the mark, so the
shared rule now names it `--lf-axis-x` and sets `left` from it, and the label
reads it in place of the PR's own `--lf-timeline-x`, rather than restating the
axis formula in the timeline package. module-reading.md, "Time axes", says so.

Main also renamed Leaf's data attributes under data-lf (#5244), so the PR's
label reading takes `dataset.lfEvent` and `dataset.lfKind`.
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