Skip to content

Read every element's computed style in leaf-dev stills, beside its screenshots - #4648

Merged
max-sixty merged 3 commits into
mainfrom
stills-computed-styles
Oct 28, 2026
Merged

max-sixty merged 3 commits into
mainfrom
stills-computed-styles

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

leaf-dev stills now reads every element's computed style on both arms, beside the screenshots it already takes, so a cascade question ("does moving this rule change anything?") is one command instead of a hand-written sweep. Sessions here have written that sweep at least nine times since September, at 50 to 1,100 lines each; the reading-theme split (#4637) alone wrote five variants.

What it does

  • Each capture also reads a fixed set of computed properties (STYLED: faces, borders, outlines, margins, padding, display, overflow and similar) for every element in the document and in every open shadow tree, hidden ones included. It leaves out width, height and offsets, which shift with every reflow and which the screenshots already show.
  • Elements are keyed by their path of tags, ids and first two classes. A state with a differing property, or with a subtree only one arm has, counts as changed. Its styles.txt groups the differences by property and value, with example elements, and names each one-sided subtree by its outermost element, so a chart that drew in only one arm is one row rather than 500.
  • The corpus states (on-me, on-agent) read every page the corpus composes. A rule that depends on a page's own Layout, such as a sidebar page's panels, shows up only in that page's own states.
  • build_source now generates the corpus before reading it. Without that, the corpus states failed in any checkout that hadn't generated it yet, and so did --authored, which now copies docs/examples.html for the generator.
  • developing-leaf now points cascade questions at stills instead of a hand-written sweep.

Checked against earlier sessions

  • Split Leaf's reading look into a bundled theme a page can decline #4637, as landed (ae2e3f34f vs 13b1289e2): it reproduces that session's findings: html's own colour and font changed, and nothing else changed except timing noise. It also shows that the Another option form and its wrappers changed from UI sans 14px to the inherited reading serif 17px. The text field inside is 17px serif on both arms and the box is the same size, so nothing visible changed. The session's PR didn't list this.
  • Split Leaf's reading look into a bundled theme a page can decline #4637's rejected theme.css placement (rebuilt on a scratch commit): it reproduces the finding that decided the placement, section.panel regaining 18px margins on sidebar pages (pr-walkthrough, triage-board).
  • The .lf-ui reorder that repainted lf-diff (Sept 19): the pages involved (pr-walkthrough, corpus) are in the catalogue, and its probe read the same kind of difference.
  • Not covered: that session's second reading, which added a page <style> with element rules. A trial version of that reading on Split Leaf's reading look into a bundled theme a page can decline #4637 added nothing the plain reading didn't already show. Leaf's faces now sit in cascade layers that page CSS outranks by design, so I left it out. Also not covered: hover/focus censuses within one arm (the unmerged face-census branch), pseudo-elements, print media, and Firefox.

Noise

A widget inside a tab or disclosure the page opens shut may or may not have drawn by the time of the reading, in either arm. This happened with lf-chart in the corpus's shut tabs, and with lf-generated-document in dynamic-widgets under --authored. The module header says to rerun a state before taking a difference confined to one such widget as a change. The race itself is a runtime question, left for a separate change.

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

…reenshots

Each stills capture now also reads a fixed set of computed properties (the
faces, boxes and flow a rule sets, not the geometry it produces) for every
element in the document and its open shadow trees, hidden ones included, on
both arms. A state whose styles differ, or that has a subtree only one arm
has, counts as changed, and its styles.txt groups the differences by property
and values. The corpus states read every composed page.

Sessions kept hand-writing this sweep (about nine since September, 50 to
1,100 lines each); developing-leaf now points cascade questions at stills.

@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.

The additional developer-tool test test_preview_file_subscription_follows_atomic_replacements fails at assert pin in watched.roots on both this head and current main (ed2bc25f9386813ac917320d7fc4148c81c3c399); it does not withhold this approval.

@max-sixty
max-sixty merged commit 09bffe5 into main Oct 28, 2026
4 checks passed
@max-sixty
max-sixty deleted the stills-computed-styles branch October 28, 2026 23:52
max-sixty added a commit that referenced this pull request Oct 29, 2026
…and keys

#4648 made `stills` read every element's `STYLED` computed properties,
keyed by its path, in every capture. The census read the same elements a
second time: its own walk for presses, its own `getComputedStyle` reads
and its own ids for pairing. It now has the one reader:

- The styles reading moves to `dev/leaf_dev/styled.js` and leaves its
  reader on the page (`leafDevStyled`): the properties, the element each
  key names, and the read of any element or pseudo-element through
  `STYLED`. `STYLED` gains `stroke` and `fill`, an icon's ink, which
  `styles.txt` now reads too.
- The census finds its presses among the elements that reading keyed,
  and reads every computed property, at rest, revealed and under the
  pointer, through that reader. It reads only geometry itself: boxes,
  the hit test and the `::before` box, which `STYLED` leaves out.
- A press's identity is its styles key. Pairing reads its own id and its
  nearest ancestor's id off that key, in place of the census's own
  id/data-key reading, and the report names an element by its key's
  last part.
max-sixty added a commit that referenced this pull request Oct 30, 2026
…ev stills (#4713)

`leaf-dev stills` now says which rule is behind each computed-style
difference it reports. Under the grouped differences in `styles.txt`, it
takes each group's first element and lists the declarations that match
it in only one arm, or in a different order, each labelled with its
sheet, `@layer`, `@scope` and selector. The declarations come from
Chrome's DevTools protocol (`CSS.getMatchedStylesForNode`). Two of the
sessions surveyed for #4648 wrote this lookup by hand to find a cause.

## What it shows

Replayed against #4637's base (`leaf-dev stills ae2e3f3 --state
on-me`, about 2 minutes), it names both causes that session found by
hand:

```
html
    + theme.css @layer lf-base :where(:root) { color: revert; }
    + theme.css @layer lf-base :where(:root) { font-family: revert; }
…lf-options#ar-3ds-choice > form.lf-another.lf-ui
    + theme.css @layer lf-base lf-options:has(> lf-option > strong) > .lf-another { font: inherit; }
```

It also names a later commit's `:nth-child(1 of :not(.lf-ui,
[data-lf-gen])) { margin-block-start: 0 }` behind a paragraph's margin
change. Where an element's declarations match on both arms, such as the
hidden-widget noise, it says `none: it inherits the difference or reads
it from a custom property`. A separate probe read an element inside
lf-diff's shadow tree on pr-walkthrough, which is where the `.lf-ui`
reorder regression appeared.

## Design

- **Declarations, not a winner.** Naming the declaration that wins would
take part of the cascade. Shorthands such as `font: var(...)` leave
their longhands blank in the protocol, and on top of that it would need
logical properties, `!important` across layers, and shadow-tree
ordering. Listing what changed, in the protocol's order, avoids all of
that, and the reader infers the winner. A declaration that moved shows
as a `-` line and a `+` line with the same text.
- **Labels stable across arms.** The labels use a sheet's file name, or
`constructed`, `<style>` or `user-agent`. Never a URL, since an inline
sheet's URL is its document's and includes the arm's port.
- **Both arms stay open.** `capture` is now a context manager, so the
comparison can read both tabs after `style_changes` has found which
elements differ.

## Also here

`main`'s stills tests have failed since #4686, which launches the
browser with `ignore_default_args`; the test's stand-in for
`headless_shell` now accepts launch options. `capture` is annotated as a
`Generator`, as ty (#4647) asks.

> _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