Repository navigation
Drive a plain custom element as a widget: set its state and bound data, and hear lf-action - #6920
Merged
Merged
Conversation
A research arm of the package-interface design of 23 November, not for landing. It builds the smallest runtime change under which a custom element that extends HTMLElement and imports nothing from Leaf draws its recorded state, records an action with Undo working, is a question on On Me, offers its parts as comment targets and reads bound data. - element-integration.js hosts every element of a tag declaring `verbs` or `inputs` that is no LeafElement, once its module defines it: inside a claim on the element's render region it sets `state` (widgetState, widget-controller.js) and each bound input's property (ElementData), in the stack that moved the reading. - widget-controller.js hears `lf-action` and `lf-undo` at the document, finds the nearest recording widget on the event's path, sends through the existing dispatch, and sets `event.delivery` or cancels the event. - visual-parts.js reads `data-lf-part` marks for a visual that registers nothing. - leaf.js starts the host after the registry is adopted. widget-loader.js cannot: the import puts application.js inside the renderers' closure, which dependency-cruiser refuses. - The shortlist fixture is a plain HTMLElement on the protocol, with no import. LeafElement is unchanged and is skipped by the host. Checked with .tmp/plain/journey.py and cases.py under `leaf-dev probe` in Chromium and Firefox, 41 browser tests by node id (47 with parameters), the runtime's 1082 Node tests, and check:browser.
…ent-ae467342026f70f1b
…a, hear lf-action Leaf now drives any custom element whose tag declares `verbs` or `inputs`, and whose class is no `LeafElement`, from outside: it sets `state` and each bound input's property, hears `lf-action` and `lf-undo`, and reads comment targets from `data-lf-part` marks. `LeafElement` keeps its own wiring and the host skips it. Built from the trial on agent-add6c632a27118846 (8fbd379), with these changes: - A tag is watched once its class is defined, and a tag whose class extends `LeafElement` is never watched. - Nothing is set until the reading holds every verb and bound data has been read, as a `LeafElement` gates its draws, and a written data body is set in that pass. - A setter that throws is owed again in the next pass and no longer stops the other sets; the failure box stands after the element's content, in its shadow root where it has one, unless the element places its own. - Drawing a setter announces with `pending-task` holds the render claim, so the data version and an element with no id wait for it. The trial's read of `updateComplete` is gone. - `delivery` alone says an event was sent; an unsent event is no longer cancelled. - `state` is immutable, carries no `unavailable`, and says `undoable` on each unit of a verb with per-part units; `lf-undo` on such a verb names the unit. - A mark under a visual standing inside another is the inner visual's, and a marked visual's kept readings are made again when Leaf says `layoutChanged` after its sets.
leaf-agent
reviewed
Nov 24, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The two items the description lists as open both sit in the path an agent follows from the new reference. So they should be fixed, or tracked in an issue the maintainer accepts, before this lands rather than after:
- The render check refuses a correct marked visual.
visualPartProblemsreportsunregisteredwhenever a source has no registration and nodata-lf-partnode at check time. A plain visual whose marks depend on state, such as one that draws nothing until it has data or a list that's empty, then fails with "neither marked a part with data-lf-part nor called registerVisualParts". The page is correct, so the agent's likely next attempt is to switch toregisterVisualParts. That undoes whatmodule-plain-elements.mdandmodule-annotations.mdnow teach. (Inline below.) data-lf-partalready has another meaning. lf-chart writes Plot's group names into it (named.dataset.lfPart = labelinlf-chart.js, values such asbarandx-axis tick label, whichtest_charts.pyreads). Today the chart's registration hides those nodes frommarkedParts. But the same attribute now means a comment-target id in one place and a Plot group name in another. Any read that runs before the chart registers sees ids likebar, which itsprefixesdon't admit. Renaming the chart's attribute (it's a test hook, by its own comment) leaves one meaning per attribute.
PR #6894 also edits element-integration.js and module-authoring.md (quoted() off Leaf). Neither duplicates the other, but whichever lands second will need a rebase.
…ne meaning `page check --render` no longer reports a declared visual that offers no part (`visual-parts`, kind `unregistered`). With marks an empty inventory is a state a correct visual can be in, as a list with no rows is, and the check could not tell it from a mistake. An author whose module declares parts and offers none no longer hears of it from the check: the picture takes comments whole, and no part does. `unadmitted-parts` stays, and names a mark or a registered part the declaration's prefixes don't admit. `data-lf-part` now only marks a comment target. lf-chart keeps Plot's name for each group as `data-lf-plot`, and the primary reader says each part's kind as `data-lf-kind`.
leaf-agent
approved these changes
Nov 24, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 24, 2026
Step one of the package-interface redesign landed as #6920 and reworked the host the trial built. Where the two disagreed this takes main's host and re-applies what the class needs on top of it: hosting on `lf-connect`, parents-first `state` sets, a region for a `pending-task` no widget hears, `lf-hold`, and `attempt` on `lf-action`. `state` is never null now: Leaf cancels `lf-connect` where it will set `state`, and the class waits for it.
max-sixty
added a commit
that referenced
this pull request
Nov 24, 2026
#6936) `LeafElement` reached Leaf through wiring of its own. It now takes `state` and bound data as properties and speaks in events, as a plain element does, so one route drives both. Step two of the package-interface redesign, after #6920. What the diff doesn't show: - **Draw order is narrower.** A widget draws inside Leaf's set of its `state`, parents first; a redraw it starts itself has no promised order. - **Each class update is a `pending-task`**, holding rendering readiness as a preparation does. Six pages announce none at rest; a playing recording settles as often as on `main`. - **New names**, each in `module-plain-elements.md`: `lf-connect`, `lf-hold`, `attempt` on `lf-action`, `redraw()`. A class module now declares a bound input reactive and a shadow root with `static shadow`. - **One read went:** a class widget Leaf sets nothing on no longer asks for a document read as it connects. Max asked for the redesign and hasn't read this diff; a fresh agent reviewed it twice. Tests: `pnpm run check`, 142 browser tests, a four-widget journey matching `main` in Chromium and Firefox, and nine package-author cases twice (13 of 18, base 12). > _This was written by Claude Code on behalf of max-sixty_
This was referenced Nov 24, 2026
leaf-agent
added a commit
that referenced
this pull request
Nov 24, 2026
…mounts (#7024) Since #6920, Leaf drives any custom element whose tag declares `verbs` or `inputs` from early in boot (`hostDeclaredElements` in `browser/leaf.js`), well before `mountApplication`. A widget whose class a page's own script defines, as the published-capture journey's `lf-options` is, can finish its first draw in that gap. Its `widgetMounted` call then reached the application facade's `invalidateDom`, which threw `Leaf application has not been mounted`, and the render harness's error collector failed the page. Any page that defines a declared widget in its own script would fail `page check --render` the same way. Before the mount no document-wide presenter is registered, and each presents the document as it then stands once the mount registers it, so a request to present the page again has nothing to reach. The facade's `invalidateDom` now resolves without work until the application exists. An `lf-defer` hold that ends before the mount reaches the same facade and gets the same answer. Both cases of `tests/journeys/test_live_shell_artifact.py::test_a_browser_executes_the_published_capture_with_live_api_routes` (`[False]` from source modules, `[True]` bundled) errored at teardown on `main` and pass with the change. `pnpm run check:browser`, `pnpm run test:runtime` (1115 pass) and the `state`/`record` cases in `tests/browser/test_plain_elements.py` pass. `journeys/` doesn't run on pull requests, so this PR's CI won't run the fixed test. Closes #7019 — automated triage Co-authored-by: leaf-agent <[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.
A widget that records had to extend
LeafElement. Leaf now drives any other custom element whose tag declaresverbsorinputs: it setsstateand each bound input's property, hearslf-actionandlf-undo, and reads comment targets fromdata-lf-partmarks, so the module needs none of Leaf's helpers (module-plain-elements.md).LeafElementkeeps its own wiring, which the host skips, until step two moves it onto this route; the two aren't meant to coexist.page check --renderno longer reports a declared visual that offers no part, a state marks make legitimate. An author who declares parts and offers none hears nothing; the picture takes comments whole.data-lf-parthas one meaning:lf-chart's Plot group names move todata-lf-plot, the primary reader's kind todata-lf-kind.Max approved the redesign and hasn't read this diff; a fresh agent reviewed it. Tests:
pnpm run check, pre-commit, 129 browser tests, the fixture in Chromium and Firefox.