Repository navigation
Split Leaf's reading look into a bundled theme a page can decline - #4637
Conversation
Under "Primitives, not a template", the core sheet now holds only what Leaf's own interface and guarantees need: tokens, the faces of Leaf's controls and marks, and the element rules that keep a guarantee (a wide pre or table scrolls inside itself, identifiers break, media fits, paper wraps). The reading look, the body's type and colour, headings, figures, disclosures, definition lists, the apparatus voice and the idioms (.callout, .tag, .metric, .lede, .eyebrow, .facts, section.panel, ol.steps, td.num, svg.drawing, the sidenote's in-flow look), moved into packages/reading. Selection uses #4551's theme model. A new page takes `reading` unless the user's catalogue names another default; `page init --no-theme` takes none, and the page then starts from the browser's defaults and Leaf's tokens. `--no-packages` now clears only content packages, since the theme is the page's look rather than one more package. `leaf theme list` lists `reading` first. `package check` renders a package in the layer a new page selecting it composes, default theme included, as before. - Markup's reading face (links, code, quotes, tables, lists, rules, pictures, styles/components/reading.css) stays one statement shared by Leaf's surfaces and the page: its rules stand in `@container style(--lf-reading-face: 1)`. Transcripts, the chrome and Leaf's controls set the input; the reading theme sets it on the root; a declared shadow tree resets it on `:host`. lf-code, lf-trace and lf-worktree set it on themselves, since the code they draw is their own face. - A package's new `elements.css` composes in lf-base after the kernel and before every package's widget sheets, so the moved rules keep the cascade position they had in the kernel. The theme itself still composes last. - The root's `color-scheme: light dark` and `html { background: var(--paper) }` are the reading theme's. The chrome and the held-keys strip set their own colour scheme and ground; Web Awesome's root colour and scheme are reverted in the core. Body's `--lf-ground` defaults to Canvas. - The chrome no longer leans on page element rules: Leaf's icons keep their middle alignment, the panel's title its tracking, and lf-activity rows their spacing. - The plain-page corpus takes no theme. Its pinned findings fall from 42 to 3: the "inherited" and "color-scheme" obstacles are gone; "canvas" remains on three pages, since body stays the lf-shell size container Layouts and widgets' 100cqi ask. A record with `theme: null`, which every earlier page carries, reads as Leaf's default theme, so those pages keep their look. Taking none is recorded explicitly as the reserved name `none`, which `page init --no-theme` alone writes and a catalogue may not list (`themes.theme_package`). No protocol bump: the layer record's schema is unchanged (the build moved only a description). The reading face's switch, `@container style(--lf-reading-face: 1)`, gives lists, tables, code, quotes and pictures the same computed faces on a default-theme page and in a thread transcript in Chromium 153, Playwright Firefox 155, Playwright WebKit (Safari 26.6) and Safari 26.1 on the iPhone simulator, and none on the page with the input off. Measured: every corpus page (examples, developer examples, fixtures, docs; 54) and five chrome states compute the same styles with the default theme on the merge base and this tree, apart from html's own colour (Web Awesome's, now reverted; html draws no text). `leaf-dev stills` reports 20 of 20 catalogued states unchanged.
The user chose this order: a theme is the base look, so it composes right after Leaf's default package, and a project package can restate one of its idioms, such as `.callout`, replacing the registry entry and winning a tie in the stylesheet, as it could while the reading look was the kernel's. `package check` renders a package over the default theme the same way. A personal theme that only adjusts the reading look is now selected as a content package on a page that keeps `reading`. The shipped pages restate no theme idiom, so their computed styles are unchanged (command-hub and pr-walkthrough checked against the merge base).
Five findings from review of the reading-look split: - The chrome follows the page's colour scheme again, as on main: it no longer states `light dark` itself, so a page that fixes `color-scheme: light` keeps a light chrome in a dark medium. The chrome and held-keys strip state no ground or scheme of their own; on a page that takes no theme they follow the browser's. - An option card's chip keeps its face on a page that takes no theme: lf-option states the shared chip face and its tones for `small.tag` itself (options.css), at a class's weight, so it agrees with the reading theme's `.tag` wherever both apply. - Thread messages keep the whole reading face whatever the page takes: headings, paragraphs, figures and captions, disclosures and summaries, definition lists, media alignment and the apparatus voice for those elements moved from the reading theme into the gated face (reading.css), which transcripts, the chrome and Leaf's controls turn on and the reading theme turns on for the page. The core rule that gave Leaf's icons their alignment and the panel title's tracking go, since the face covers both. - The core's reset of Web Awesome's root styles also reverts its sans, so a page that takes no theme gets the browser's default font. - A code block's and a table's overlay-scrollbar clearance stands with the scrolling it makes usable, in the core, on every page. The plain dashboard page pins that 8px under a table as the `scroll-clearance` obstacle. Measured against the merge base with the default theme: all 54 corpus pages, a page that fixes `color-scheme: light` in a dark medium (at rest and with the threads panel), and the thread card, threads panel (light, dark, and with a message holding lists, a table, code, a quote, a figure, a disclosure and a definition list) and floating thread compute the same styles, apart from html's own colour and font (Web Awesome's, now reverted; html draws no text). Two states moved on reruns in either direction and are timing (trace transport buttons, a deck's margin cluster). With the page taking no theme, the chrome, thread card, panel and the message's every element compute the same as with the default theme; an option card's `small.tag.ok` stays a green 11.5px chip. What still differs in Leaf's controls placed in the page is inherited type and colour, which follow the page.
…age takes Three findings from review, and the rest of their class from a sweep: - A card's add-option field takes the type the cards take from the page rather than the controls' face, so the words typed stand as the option they become will: with the reading theme 17px Charter on a 27.2px line, with none the browser's. - Working density's small margins (p, lists, headings, cells) answer wherever markup's reading face is worn: they moved from the reading theme into the face (reading.css), so a widget wearing the face keeps its density on any page. - Markup Leaf renders from Markdown is Leaf's reading of it and wears the face itself, like a thread: `.lf-markdown-body` and `.lf-markdown-words` (x-text-format, lf-draft) set the input in the core, and lf-text-document's Markdown preview, which renders through the public API, sets it on its preview. - The sweep compared every default- and bundled-package widget's own nodes with and without the theme across the corpus. lf-activity and lf-visual-review draw lists and headings of their own and now set the face for themselves, as lf-code, lf-trace and lf-worktree do; lf-activity's hand-written row spacing goes. What still differs with and without a theme follows the page by design: inherited font, size and colour, a widget's ground (`--lf-ground`), positions that follow the page's length, a widget's margin a page idiom's frame trims (a callout, panel or disclosure), and a breakout kept inside a figure's browser indent. With the default theme, against the merge base, every corpus page computes the same styles apart from html's own colour and font (Web Awesome's, reverted) and the add-option form's wrappers, whose font is now the card's; no box moves. Rendering timing (lf-chart drawn or not, trace transport, a deck's margin cluster) varies run to run in both directions.
# Conflicts: # dist/kernel/kernel.json
…ments.css role elements.css put a package's element rules in lf-base ahead of every package's widget defaults. The bundled reading theme was its only user, and as the theme composes right after the default package, the slot decided only ties with the default package's widget rules. Moving reading's rules to its widgets.css changed no computed style on any of the 52 corpus pages (the two that differed differ HEAD against HEAD too), so the role buys nothing and goes. Moving them to theme.css instead would put them above Layouts: section.panel in a layout-sidebar regained an 18px margin on 10 pages.
leaf-agent
left a comment
There was a problem hiding this comment.
The old-record compatibility branch adds more than the theme split needs. In themes.py, theme_package(None) now selects reading specifically to preserve pre-split pages, forcing an explicit none sentinel, reserved-name validation, and additional rules in the public theme contract. Every future theme reader pays for that distinction, while its benefit is confined to disposable earlier records.
AGENTS.md, Stage, explicitly says “Add no migration, compatibility shim, old-record validator, fallback read”. Keep theme: null meaning no theme, let fresh initialization record reading as it already does, and remove the sentinel and old-record fallback together with their contract and test expectations. That preserves the new default and --no-theme behavior without retaining a compatibility mechanism. This is the remaining reason I’m withholding approval.
…e way The review asked for no compatibility read (AGENTS.md, Stage): a null theme had read as reading so pages made before the split kept their look, which forced a reserved `none` name, its catalogue refusal and its contract. Null now means no theme, and a new page records `reading` as before. A page made before the split takes no theme until `page init --theme reading`. Delivery's sample copies named the recorded theme itself instead of asking `theme_package`, which is how `none` reached package resolution and failed the plain corpus and the frozen preview test; it asks now. The example manifest lists content packages, so it leaves out the bundled theme.
# Conflicts: # browser/theme.css
…reenshots (#4648) `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 - **#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. - **#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 #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_
…age its own chips (#4653) Leaf's stylesheets are now named for where they rank, and the default package draws its own chips, so a page with no theme keeps them. A follow-up to #4637, which made the reading look an optional theme and left "theme" naming three different things. ## Names - **Package sheets:** `widgets.css` becomes `defaults.css` (in `lf-base`, below Layouts) and `theme.css` becomes `overrides.css`, in the tier `lf-theme` renamed `lf-overrides` (above Layouts). Each sheet keeps its tier and order, so no page computes a different style. The bundled packages, `docs/package`, `package init`'s scaffold, the composer, `schema.PACKAGE_STYLES`, `packages.md`, `package-themes.md`, `docs/extending.html`, the tests and the `native-package-scopes` eval prompt follow. A package still shipping the old names contributes nothing (AGENTS.md, "Stage"). - **The kernel's sheet:** `browser/theme.css` becomes `browser/base.css`, and the comments that pointed at it follow. The composed page stylesheet keeps its served name, `/theme.css`, as do the examples' own `STEM.page/theme.css` page files. - **One list of the kernel's files:** `schema.KERNEL_FILES` (`KERNEL_STYLES` plus registry and icon) sits beside `PACKAGE_FILES`. The layer check, `layer.input_paths` and the server identity (`runtime_selection.LAYER_SOURCES`) read it instead of `LAYER_TOP_FILES`, the names a composed layer serves. That list had left out `layouts.css` and `state.css`, so an edit to either changed neither what a live preview follows nor the identity that refuses a stale open document. ## Chips The `lf-tally` count and the change counts on a tab or a settled decision wore the reading theme's `.tag`, so with `--no-theme` they drew as bare text. They now wear `.lf-chip`, whose face `packages/default/styles/chip.css` states once beside `lf-option`'s author chips, replacing the copy `options.css` kept. The change-count tint moves there from the kernel, which no longer names a default-package class. With the reading theme, command-hub's tally and option chips compute the same faces as on `main` (`leaf-dev probe --base`). ## Comments - `base.css`'s anonymous important layer no longer claims to outrank every other layer: it names what wins over it, which is `lf-reset`, Web Awesome's `lf-vendor` sublayer and inline importance. - `chrome-guard.css` records what a shadow-root chrome would cost: no engine yet lets a shadow tree's own styles name a document `anchor-name` (the spike, e7745b7, #2828), though a document `::part()` rule setting `position-anchor` anchors in Chromium, Firefox and WebKit today; the direction was set aside in #3579, and #4030 would bring it back. ## Checks Model tests for the layer, themes, documents, revision and module delivery and previews (one failure, `test_preview_file_subscription_follows_atomic_replacements`, which fails on `main` too), and `pnpm run check`. Codex reviewed the rename; its one finding, the eval prompt, is fixed. > _This was written by Claude Code on behalf of max-sixty_
…ge (#4660) #4608 added a suite test that presses every bundled widget's controls with the server's answer held. This extends the same check to Leaf's own controls that send a reader's gestures, which stand in the floating panel: On me's answers and to-do Done, and in each thread's view its Resolve or Reopen and its reactions. **The panel sweep.** `tests/journeys/test_pressed_controls.py` (nightly) opens On me, then each thread the Threads view lists, on every corpus page served with its log, and presses every control in the view with the event POST held. Each control must keep its cursor and its available, idle face while its gesture travels, and a second press on the same control must send again. The test also fails if On me lists an item and nothing was pressed, or if any thread's sweep didn't check a Resolve or Reopen, so it can't pass by reaching nothing. All 44 corpus pages pass in about 80 s on four workers. A thread's card in the margin isn't swept: its Resolve and reactions remove the control they were pressed on, so there's no face left to compare. **The shared sweep.** `press_each_control` in `browser/widgets/test_pressed_controls.py` now takes an open page and a selector for the elements whose controls count. It presses the controls a press revealed first, such as a reaction palette's buttons after its trigger. It passes over a control the pointer can't reach. When nothing is left, it presses Escape and calls the caller's `restore`, which reopens a thread's view that a control such as Show on page took away. An earlier version that pressed every control on the whole page reached thread controls only by luck: two runs of one page pressed 39 and 11 controls, and several pages never reached Reopen. Opening each view by its own route makes the reach the same on every run. The package test takes about 8% longer than before. **Bug-back controls.** Each of these broken versions made a sweep fail: - the panel's Resolve/Reopen showing `aria-busy`, or ignoring a second press; - lf-options' Done showing busy, or ignoring a second press; - the playground's submit showing busy, or ignoring a second press; - lf-suggestion's Undo standing disabled after Accept. **Two failures on main fixed:** - `test_a_pressed_control_keeps_its_face_and_takes_the_next_press[reading]` has failed since #4637 added `reading`, a package with no widgets. The test now expects no presses from a package with no own tags, and two packages drop off its hand-kept list. - `test_an_older_settlement_cannot_repaint_over_a_newer_decision` has failed since #4561, which made lf-suggestion name its decision through the dispatch's `says`. The runtime now announces "Accepted suggested change" when Accept is pressed, so the live region still holds it after the other tab's reject arrives. The test read the live region for the old behavior, where the widget announced in its send's continuation. It now checks what protects the user: once the late accept is answered, the suggestion still shows the reject. It also drops a fixed 100 ms wait. > _This was written by Claude Code on behalf of max-sixty_
…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_
Leaf's reading look moves out of the core into a bundled theme package,
reading, that every page takes by default and a page can decline withpage init --no-theme. Part of the "Primitives, not a template" survey (SOUL.md); the maintainer chose the split, and the theme's place right after the default package, on the survey's Leaf page.What a page sees
html's own colour and font (Web Awesome's, now reverted;htmldraws no text). The only other differences were timing (a chart drawn or not, trace transport buttons, a deck's margin cluster) and moved in both directions on reruns.--no-theme: the page starts from the browser's defaults and Leaf's tokens. Leaf's own surfaces keep their faces: the chrome, thread messages, rendered Markdown and option chips compute the same as with the theme. What differs follows the page by design: inherited font, size and colour, and a widget's ground.theme: nullmeans no theme, so a page made before the split takes no theme untilpage init <page> --theme reading; per AGENTS.md's Stage, there is no compatibility read.tests/fixtures/plain/, which takes no theme): pinned findings fall from 42 to 4. Left arecanvason three pages (body stays the size container Layouts and widgets'100cqiask for) andscroll-clearanceon one (the 8px under a scrolling table, which keeps an overlay scrollbar off its last row).How it's built
preor table scrolls inside itself, identifiers break, media fits, paper wraps). The body's type and colour, headings, figures, disclosures and the idioms (.callout,.tag,.metric,.lede,section.panel,ol.steps, …) move topackages/reading/widgets.css.lf-base, where they were in the kernel, below Layouts. A theme package contributes through the same stylesheet roles as any package; the corpus showedwidgets.csskeeps every computed style, whiletheme.css(lf-theme, above Layouts) would have givensection.panelback an 18px margin inside a sidebar layout on 10 pages.browser/styles/components/reading.css) stays in the core under@container style(--lf-reading-face: 1). The reading theme sets that inherited switch on the root; thread transcripts, rendered Markdown, the chrome and Leaf's controls set it on themselves, as do the widgets that draw prose of their own (lf-code,lf-trace,lf-worktree,lf-activity,lf-visual-review, the text document's preview). A declared shadow tree resets it on:host. Checked in Chromium, Firefox and WebKit, including iOS.--no-packagesclears only content packages;leaf theme listlistsreadingfirst;package checkrenders a package over the default theme.Checks
Model tests for the layer, themes and the interaction contracts,
pnpm run check, and computed-style comparisons across the corpus (default theme against the merge base, and with and without a theme). Codex reviewed each round, and the review bot asked for the compatibility read to go; their findings (the chrome's colour scheme, option chips and thread messages losing their faces with no theme, an add-option field's type, widget density, the old-record read) are fixed here.