Repository navigation
Write Leaf's own states as data-lf attributes, which a page's CSS can't name - #5050
Merged
Merged
Conversation
…'t name
Seven state classes Leaf wrote on its own elements stood outside the
`lf-` namespace `page check` reserves for it: the leaf's tones
(`working`, `listening`, `away`, `blocked` on `.lf-dot`), a message's
author (`user`, and `agent` beside it, on `.lf-msg`), `detached` on a
thread's quote and on a message link to a part the shown version lacks,
and `hi` on lf-code's highlighted lines. A page's own rule for one of
those names restyled Leaf. On a probe page whose `<style>` held
`.hi { background: blue }`, `.user { --lf-msg-text-end: 123px }`,
`.detached { --muted: green }` and `.away { --warn: red }`, the merge
base painted the highlighted line blue, ended the user's message text
123px short, coloured the detached link green, and painted the away leaf
and the tab's icon red. The chrome's `all: revert-layer` guard stops a
plain declaration but not the last three, since `all` leaves custom
properties alone, and a thread seated on the page stands outside the
chrome altogether.
Each state is now an attribute in Leaf's namespace: `data-lf-tone` on
the leaf, on All pages' leaves and on the probe the tab's icon reads its
colour from; `data-lf-author` on a message; `data-lf-detached` on a
quote or link; `data-lf-hi` on a highlighted line or elided row. A page
can't author those names, so the same probe now reads Leaf's own
values: the highlight tint, the thread's text inset, the muted link, and
the warn tone on both the leaf and the tab. The `hi` attribute an author
writes on `<lf-code>` is unchanged. The composer's quote, which is never
shown, no longer carries `detached`, which styled nothing there.
Tests that read the classes now read the attributes.
`test_a_tap_on_a_reply_link_to_a_missing_section_says_why` also asserts
the detached link's dashed underline, which no test held; it fails with
the old selector. The stills and bench-latency drivers find a message by
its words, so the base arm's runtime answers them too.
> _This was written by Claude Code on behalf of max-sixty_
leaf-agent
previously approved these changes
Nov 2, 2026
# Conflicts: # dist/kernel/kernel.json
The test arrived from main reading the user's message by the old `user` class, which this branch writes as `data-lf-author`.
leaf-agent
approved these changes
Nov 2, 2026
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_
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Leaf wrote seven state names on its own elements as plain classes, outside the
lf-namespace thatpage checkreserves for it: the leaf's tone (working,listening,away,blockedon.lf-dot), a message's author (userandagenton.lf-msg),detachedon a thread's quote and on a message link whose target the shown version lacks, andhion lf-code's highlighted lines. A page's own CSS for one of those names restyled Leaf. On a probe page whose<style>held.hi { background: blue },.user { --lf-msg-text-end: 123px },.detached { --muted: green }and.away { --warn: red }, main painted the highlighted line blue, ended the user's message text 123px short, coloured the detached link green, and painted the away leaf and the tab's icon red. The chrome'sall: revert-layerguard stops a plain declaration but not a custom property, and a thread seated on the page sits outside the chrome altogether.Each state is now an attribute in Leaf's namespace, the form most of Leaf's states already take:
data-lf-toneon the leaf, on All pages' leaves, and on the hidden probe the tab's icon reads its colour from. The margin's Accept and Save buttons already carrydata-lf-tonefor their colour role.data-lf-authoron a message.data-lf-detachedon a quote or a message link.data-lf-hion a highlighted code line or elided row. Thehiattribute an author writes on<lf-code>is unchanged.A page can't author those names, so the same probe now shows Leaf's own highlight tint, text inset, muted link and warn tone. Nothing changes on a page that doesn't target the old names. The composer's hidden quote no longer carries
detached, which styled nothing there.Tests that read the classes now read the attributes.
test_a_tap_on_a_reply_link_to_a_missing_section_says_whyalso asserts the detached link's dashed underline, which no test held before. The stills and bench-latency drivers find a message by its words, so the base arm's runtime answers them too.Checks
pnpm run check,pnpm run test:runtime(737 pass), pre-commit over the changed files.test_interface_fonts.py.leaf-dev stillsover the states these attributes paint showed no visual difference.