Repository navigation
Get out of the way of agents writing ordinary HTML and CSS - #4490
Merged
Merged
Conversation
…changed A version comparison used to read the base version's source against the live page, so every word a page module wrote into the page had no twin in the base and marked its block as changed. `leaf page check --render` refused such a page with a `read-as-changed` finding and asked the author to mark every word with `generatedElement`, which a plain script setting `textContent`, appending a paragraph or rendering with lit-html shouldn't owe. What changed for the user: - The comparison (`applyDiff` in `browser/runtime/version.js`) now reads two sources: the base version's and this version's (`versionSource()`), each copied and painted with the widget state it shows (`paintedSource`: Markdown formatted, body records painted, created children placed). Each changed block marks the live node its source node is paired with (`standingFor`); where a module took that node off the page, the nearest ancestor still on it is marked. Words a module wrote are in neither source, so they can't mark a block, marked or not. - The tint a live revision gives the blocks it changed uses the same reading, so it no longer tints a script's words on every revision. - A marked block offers its inline word diff only while the live block reads the same as its source. A block a module writes into stays marked whole rather than painting the source's words over the module's. - `page check --render` no longer reports `read-as-changed`: `selfComparison`, the `wordsReadAsChanged` probe, the finding's message and its gate call are deleted, with the test fixtures that asserted it. - A live revision that keeps a widget unchanged now keeps its interior's source-to-live pairs (`pairInterior` in `dom-children.js`). Before, only the widget's own element stayed paired, so a comparison reaching back past such a revision marked the whole board instead of the card the author rewrote. `generatedElement` keeps its other jobs: words it marks leave the `wrote` reading and form a passage cell of their own, and `says` decides whether they can be quoted. The comments that gave the diff as its reason now give these. `module-authoring.md` no longer lists marking among what a module owes, and says plainly that words a module writes need no marking. The playground's comments that cited the comparison are updated. `prepareDeclaredMarkdown` had one caller, which now loads the renderer and leaves formatting to the copy, so it is deleted. Cost: a comparison and a live revision each copy and format one more source than before. Neither runs on the startup path. Tests: `test_the_diff_marks_what_the_author_changed_and_no_word_a_script_wrote` covers a readout, an appended paragraph and a lit-html list, on a live revision and a fresh load, for the comparison's marks, the revision tint and the inline offer; it fails on the base runtime, which marks five blocks and tints the script's words. `test_a_change_inside_a_widget_a_later_revision_kept_marks_its_block` and a runtime test in `dom-children.test.mjs` cover the kept interior's pairs.
…ts the theme A survey of where Leaf gets in the way of an agent writing ordinary HTML and CSS found the cascade already yields to page CSS; the obstacles were checks, messages and instructions. Behavior that changes: - Console warnings and Chrome DevTools issues are advice in the render gate; console errors and exceptions still refuse. A library's development-build notice or an unnamed input no longer fails a page, and a widget failing soft reports an error. - Widgets accept `title`, `lang`, `dir`, `aria-*` and the page's own `data-*` outside their schemas, as they accepted `class` and `style`; `data-lf-*`, `hidden` and `inert` still validate. The undeclared-attribute probe accepts the same platform attributes. - `covered-words` allows overlap up to a quarter of the shorter run's line box, so display type set solid passes, and skips text inside `[aria-hidden=true]`, which the page declares decorative. Two labels a few pixels apart still fail. - `outside-main` names only the outermost elements outside `main` and says to move them in; capture refusals say page files live under `page/` and a bare module name needs a full URL; `past-column` names `data-width`. Instructions: - page-authoring.md gains "Style the page": a design of the page's own is ordinary CSS, a page restyles itself through theme tokens on `:root` (a palette set on `body` leaves Leaf's surfaces on their own grounds), `body` is Leaf's, and a reset or app shell keeps `--lf-foot-room` on what scrolls. - page-behavior.md gains "A page script": the four things a page script owes. SKILL.md and the playground guide send only widget authors to module-authoring.md. - page-layout.md documents `data-bound` as the scroll box that keeps the reader's place, resolving a contradiction with page-authoring.md. - Two eval rubrics pass a page's own control face and its own grid, keeping the browser-default face and the retired elements as failures. Scored with brief-document-needs-no-outline and page-arrangement-uses-layouts on claude-code, merge base against this tree, two repeats: 8/8 pass, every candidate run read the new section.
…d drop a repeated paragraph
# Conflicts: # dist/kernel/kernel.json # dist/kernel/runtime/bundle-data.js
…cript guide - The comparison finds a block's live node by id when its paired node left the page, as when a script swaps an element for a copy, before falling back to an ancestor. A widget set among words (x-inline, such as a gloss) is part of its paragraph's words rather than a block of its own, so rewording the words around a gloss marks the paragraph; before, the paragraph was skipped as holding a nested block, on main too. - covered-words compares the reach of a run's letters, from the font's own metrics scaled to the rect, instead of the font's ascent-to-descent rect, so stacked display type at line-height .8 passes and the quarter-box allowance goes. It skips an aria-hidden word only when it is drawn at under half opacity; an opaque decoration over a label still fails. - Widgets accept any `data-*` name outside `data-lf-*`, as HTML does. - page-behavior.md no longer promises Escape reaches a `document` listener before Leaf's, and recommends listening on `main`.
… keep suggestion slots as blocks Second review found three regressions in the previous commit: - A rotated SVG label or vertical writing lays the text's length along the rect's height, so scaling the font's ascent by that height trimmed the text's ends and missed real collisions. Only a horizontal run whose rect matches the font's proportions (checked against its advance on one line) is trimmed now; any other keeps its whole rect. - Canvas measured the source text, so lowercase source drawn uppercase by text-transform lost its capitals' reach. The letters are measured in both cases. - Making every x-inline widget part of its paragraph also took a suggestion's slots, so a paragraph holding one compared across the opaque suggestion and its inline diff wrote into the unchanged slot. Only preserving inline widgets, such as a gloss, join their paragraph now.
# Conflicts: # browser/runtime/version.js # dist/kernel/kernel.json # dist/kernel/runtime/bundle-data.js
A third review found a nearly square rotated SVG label passed the proportion guard and lost its ends, and lowercase drawn by text-transform lost its descenders. SVG text, any transformed ancestor and vertical writing now keep their whole rect, which over-reports, the safe side, and the letters are measured in all three cases.
…a988d8337a15a9cb8
…ce group close Decided on the survey page: - SOUL.md gains "Primitives, not a template": an author who writes good HTML and CSS gets the page they wrote, and Leaf reaches into it only to keep a guarantee the user relies on. - Reduced motion no longer stops the page's own CSS motion. The guard moves from an !important rule in lf-base, which outranked every page stylesheet, to an ordinary rule in lf-state, the last layer, so it stops every theme, package and widget declaration while the page's unlayered rules and inline styles outrank it. Leaf's chrome and controls, some of whose rules stand unlayered, keep an !important guard. `page check --render` now sets the preference and reports, as advice, page content still animating (`unreduced-motion`). - `lf-options closed` leaves out the "Another option" field, for a group that answers only from its listed options.
A revision used to hold only the page files a script or stylesheet named by a
literal path, so a module's `fetch(new URL("./data.json", import.meta.url))`
answered 404 although the file sat in page/. Each revision now captures every
file under page/ (`revision_artifact.page_files`), so a served revision answers
any of them under its asset root, live and in versions alike.
Behavior that changed:
- Every non-hidden file under page/ is in the revision, served and written to
a published site. Hidden entries (.DS_Store, editor swap files) stay out, so
they never make a revision; a literal reference still captures one.
- Each captured file is typed by Leaf's table, then the standard library's
built-in table (not the host's mime.types), then application/octet-stream,
so JSON, CSV, text, wasm, fonts and images serve with their usual types. The
`dependency-type` refusal is gone: an unknown suffix serves as bytes, and an
HTML file under page/ serves as text/html. Stylesheet and module references
keep their own type checks (`stylesheet-type`, `module-type`).
- Every captured module and stylesheet has its imports checked, referenced or
not, and a symlink out of page/ is refused even when nothing names it, since
the revision would otherwise hold the outside file.
- `page inspect` lists a stylesheet nothing links, with no documents, and
counts it in the page's CSS totals.
An export embeds the captured files but page code can't fetch them: its
modules are data: URLs, so `import.meta.url` is no base, and a document-
relative URL names a file beside the export. A URL relative to a served
document (`fetch("page/data.json")`) also reaches no page file, since the page
root doesn't serve page/. page-behavior.md now says to fetch relative to a
module under page/, that an export can't, and keeps data the agent replaces
while the page is open in data/ sources.
leaf-agent
reviewed
Oct 27, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The new overlap regression test fails with Leaf’s Linux fonts, and the page-script guidance still promises automatic reduced-motion handling for CSS that this PR deliberately leaves to the page.
…, and serve the journey's files by resource_type On CI's Linux fonts the stacked display type's ascenders reached into the paragraph above it, a real overlap the fixture didn't mean. The journey test still imported the type table the page-files change folded into resource_type.
# Conflicts: # dist/kernel/kernel.json
…which Leaf no longer forces
leaf-agent
previously approved these changes
Oct 27, 2026
# Conflicts: # dist/kernel/kernel.json
leaf-agent
approved these changes
Oct 27, 2026
This was referenced Oct 27, 2026
leaf-agent
added a commit
that referenced
this pull request
Oct 27, 2026
The package reduced-motion fixture still set an inline transition, which deliberately outranks the stylesheet guard since #4490. Remove that redundant inline declaration so the existing assertions exercise package CSS in both light and shadow DOM. Product behavior stays the same. Both variants failed on current main before this change and pass after it. The ordinary-motion controls, immediate reduced-motion transition assertions, pseudo-element animation completion, and preference restoration assertions remain intact. The existing page-authored motion test also passes (3 focused cases total). Closes #4523 — automated triage Co-authored-by: leaf-agent <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Oct 28, 2026
…ce, and measure ordinary pages against Leaf (#4546) Three follow-ups to #4490 under "Primitives, not a template" (`SOUL.md`): two obstacles lifted for authors writing ordinary pages, and a test that keeps the principle measured. ## Behavior that changes - **An author's own shadow DOM is accepted.** The render gate no longer refuses a page whose own custom element attaches a shadow root the registry doesn't declare (`undeclared-shadow` is gone). The passage reading already treated such a root as opaque, reading its host by its light children as Python does, so no anchoring rule changed: words only the shadow tree shows can't be quoted, a drag inside it captures no passage, and `x-shadow` stays the way a widget makes its shadow words quotable. `page-behavior.md`, `module-authoring.md` and the `x-shadow` key description say so. - **One `page check` reports every capture problem.** `revision_artifact.py` collects findings across the whole capture of `index.html` and `page/` (every file, every import and stylesheet reference) and refuses once with all of them; a save's refusal names the same list. Each refusal's code and text are unchanged. A file that can't be read isn't followed, a refused `@import` yields nothing further, and a malformed stylesheet reports `css-invalid` rather than aborting the check. Callers that read one module or sheet still get a raise, now carrying every problem in it. - **Export no longer fails on a declaration the browser ignores.** Omitting an unavailable URL from a rule that also holds an invalid declaration (`broken;`) raised on serializing it; the invalid declaration is now dropped, as the browser drops it. ## A plain-HTML corpus `tests/fixtures/plain/` holds eight standalone pages, each an ordinary pattern (CSS reset, `:root` palette with dark mode, grid app shell with sticky header, guarded animation and fixed badge, native form and `<dialog>`, a module fetching a page file, a classic script, and three ports of real designs), whose only Leaf edit is wrapping the body in `main`. `tests/browser/test_plain_pages.py` runs `page check --render`'s readings on each, then serves it standalone and through Leaf and compares every property the author's CSS decides, in light and dark, with and without reduced motion. Its module header is the corpus's one description. Every page still meets an obstacle that needs a maintainer decision, so each runs as an expected failure pinned to its exact findings (kind, property, elements): any new finding fails the page, and so does a pinned one that stops occurring. The obstacles: theme rules beating type and colour a page sets on `:root` or `body`, `color-scheme: light dark` on the root, `body` as a size container with `html` painting Leaf's paper, the refusal of classic inline scripts, `scrollbar-clearance` on a scrolling nav, and `past-column` on a fixed corner badge. The first three belong to the decided split of the reading look out of the core; the last three are open decisions. ## Checks `tests/model` (1850), `pnpm run test:runtime` (685), the render-gate tests the shadow change touches, the new corpus test (4–7 s a case at load ~28), and deliberate overrides showing the corpus catches a new theme override and a dark-only colour change. Codex reviewed the combined branch; its five findings are fixed or answered, and the fixes were re-checked. > _This was written by Claude Code on behalf of max-sixty_
This was referenced Oct 28, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 28, 2026
… delivery uses (#4619) `page check` now reports everything wrong with a page in one run, and the CSS it refuses is decided by the same reader delivery uses, so nothing passes the check and then fails at delivery. Part of the "Primitives, not a template" survey (`SOUL.md`), after #4490, #4546 and #4554. ## Behavior that changes - **Markup errors no longer hide page-file problems.** A page with a markup error stopped there, so a missing `page/` file or broken stylesheet surfaced only on the next run. Capture now runs beside markup validation over one walk of the document, and each problem is reported once, by the check that owns it (`validation/source.py`, `revision_artifact._collect`). - **A broken `page/registry.json` reports one problem per declaration.** The registry stopped at its first error. It now collects the first problem in each widget entry and each missing layer fact (`registry/state.gathering()`), so a registry with several bad entries takes at most a few runs instead of one per entry. `RegistryError` and the layer refusals carry a list of findings. A boolean attribute schema (`true`/`false`) reads as typeless instead of crashing the check. - **One reader judges CSS syntax.** `revision_artifact._read_css`, the reader delivery rewrites sheets with, decides `css-syntax` for pages, messages, templates and declarative shadow roots alike; the walk check and delivery share (`structure.delivered_elements`/`delivered_sheets`) means a sheet the check skips is one delivery skips too. - **A declaration the browser drops is advice on a page.** `css-dropped` (for example `color: ;` or a stray `broken;`) no longer refuses a page: the browser ignores the declaration, the page renders the same outside Leaf, and the author sees the finding. A package's stylesheet still refuses it, since packages are maintained code (`layer._stylesheet`). `validation.md` says so. ## Checks The model tests for authored markup, the layer and registry contracts, media, vocabulary, document and layer inspection, module delivery and page inspection (885 passed, after merging current `main`), and `pnpm run check`. Codex reviewed each commit; its findings (the two CSS parsers disagreeing, a problem reported twice, the template and shadow-root walks diverging, a crash on boolean schemas, several missing layer facts merged into one finding) are fixed here. > _This was written by Claude Code on behalf of max-sixty_
max-sixty
added a commit
that referenced
this pull request
Oct 31, 2026
Main moved the playground's initial producer into widgets/playground-view.js (#4545), lets page CSS reach every control (#4490), draws presses from their actions (#4547, #4563), registers commands through lfCommands, and already lets a playground run with no lf-playground-control. The PR's prose about offer() and data-controls, its relaxed control check and its deleted initial/vendor producer files take main's side. What stays from the PR is actions="page", now built in the Lit view: - playground-view.js draws no actions bar under actions="page", and no rail unless controls are written there; the instruction renders after the stage, where it was written. `give({submit, reset})` takes the page's buttons, and render writes the submission's words into the page's button from the same template Leaf's own submission uses (submit-label, then Undo choice). - lf-playground.js's registerActions hands the buttons to the view and sets the playground's commands then, since a Decision command needs its control: the 1 key, Alt+0 and On me's arrival reach the page's buttons. A page that never calls registerActions still fails after first presentation. - The copy control and popover wiring run only when Leaf draws the popover. - The PR's test and corpus fixture pass the contributor editor main's registerContributor now requires. Behavior from main kept: the submit no longer disables while a submission is in flight (#4516), so a page's button follows the same rule.
max-sixty
added a commit
that referenced
this pull request
Nov 5, 2026
…5549) A `closed` options group (#4490) never draws the Another option field, but two places still acted as if it would. The stylesheet reserves the Add cell's height until the widget draws it, so the next block stays put through upgrade. That reserve keyed only on the cell being absent, so every closed group kept an empty row of about 33px under its last option. The reserve now skips `[closed]` groups; a closed multiple-choice group still holds Done's row until Done is drawn. The stylesheet keeps its own statement of the rule because it has to reserve the row before the widget's script runs. `lf-options` also reserved a binding number for the field whenever the group stood outside the chrome, a second copy of the rule that decides whether the field is offered. That copy missed `closed`, so a closed group of three options showed Done as 5, skipping a 4 nothing pressed. The reservation now reads the addition's own `offered`, the one place that rule is stated in script. `test_a_closed_group_answers_only_from_its_options` now checks that the group ends at its last cell and that Done's badge reads 4. On main it fails both ways (33px of empty space, Done as 5). > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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's cascade already yields to page CSS; what got in the way of an agent writing ordinary HTML and CSS was checks, messages, instructions and a few runtime overrides. A survey of the theme and runtime CSS, validators, page-script obligations, widget frames and the authoring references, plus ports of three standalone pages, found them; this removes or narrows each one that guarded nothing a user relies on.
Behavior that changes
read-as-changedrender check and the requirement to mark script words withgeneratedElementare gone. A paragraph holding an inline preserving widget, such as a gloss, is now compared (it was skipped, on main too). A kept widget's interior stays paired across live revisions (pairInterior).covered-wordscompares where letters reach, from the font's metrics, for untransformed horizontal HTML text (other text keeps its whole rect), and skips a faintaria-hiddendecoration. New advice,unreduced-motion: with reduced motion set, page content still animating.!importantrule that outranked every page stylesheet to an ordinary rule in the last layer,lf-state, so it stops every theme, package and widget declaration and the page's own rules win. Leaf's chrome and controls keep an!importantguard.page/is captured, so page code can fetch any page file in a served revision, relative to a module underpage/(new URL("./data.json", import.meta.url)). Hidden files are left out. A symlink out ofpage/is refused even when nothing names it, and the refusal of HTML and unknown suffixes underpage/is gone. A document-relativefetch("page/…")still 404s, and an export embeds the files but page code can't fetch them there.lf-options closedleaves out the "Another option" field.title,lang,dir,aria-*and anydata-*outsidedata-lf-*.page/; a bare module name needs a full URL;outside-mainnames only the outermost elements;past-columnnamesdata-width.Instructions
SOUL.mdgains "Primitives, not a template", at the maintainer's direction.page-authoring.mdgains "Style the page": a page's own design is ordinary CSS; restyle the whole page through theme tokens on:root(a palette onbodyleaves Leaf's surfaces on their own grounds);bodyis Leaf's, so the grid goes onmain; how a reset or app shell keeps--lf-foot-room.page-behavior.mdgains "A page script", the four things a page script owes; only widget authors are sent tomodule-authoring.md.page-layout.mddocumentsdata-boundas the scroll box that keeps the reader's place.Checks
Focused model and browser tests for each change, every browser test that opens a comparison,
pnpm run test:runtime,pnpm run check.brief-document-needs-no-outlineandpage-arrangement-uses-layoutson claude-code, merge base against this tree, two repeats: 8/8, every candidate run read the new section. Three Codex review rounds; each finding is fixed and pinned by a test.