Skip to content

Write Leaf's own states as data-lf attributes, which a page's CSS can't name - #5050

Merged
max-sixty merged 3 commits into
mainfrom
list-ui-fixes
Nov 2, 2026
Merged

max-sixty merged 3 commits into
mainfrom
list-ui-fixes

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Leaf wrote seven state names on its own elements as plain classes, outside the lf- namespace that page check reserves for it: the leaf's tone (working, listening, away, blocked on .lf-dot), a message's author (user and agent on .lf-msg), detached on a thread's quote and on a message link whose target the shown version lacks, and hi on 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's all: revert-layer guard 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-tone on 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 carry data-lf-tone for their colour role.
  • data-lf-author on a message.
  • data-lf-detached on a quote or a message link.
  • data-lf-hi on a highlighted code line or elided row. The hi attribute 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_why also 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.
  • The detached link, code highlight, status tone, All pages and message layout browser tests, and test_interface_fonts.py.
  • leaf-dev stills over the states these attributes paint showed no visual difference.

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

…'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
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`.
@max-sixty
max-sixty merged commit 1f49b64 into main Nov 2, 2026
3 of 4 checks passed
@max-sixty
max-sixty deleted the list-ui-fixes branch November 2, 2026 05:19
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_
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