Skip to content

References: list every package function by section, and teach a widget by its protocol - #7006

Merged
max-sixty merged 6 commits into
mainfrom
agent-a86b1c67873937aed
Nov 24, 2026
Merged

max-sixty merged 6 commits into
mainfrom
agent-a86b1c67873937aed

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

An author new to Leaf now finds every function widget-api.js exports from one list, and learns a widget as the redesign made it: a custom element Leaf drives by properties and events. This is the references step of the package-interface redesign, scoped by its aim rather than by its old target of one 4,000-word file.

What changed

  • One index. module-authoring.md opens with the protocol in a paragraph, then lists every export under the section that describes it. tests/runtime/widget-api.test.mjs holds that list to the exports and each entry to its section. It replaces the check that every export is named somewhere in the nine files.
  • LeafElement taught once. Three files taught the class's setup, render, record, takeBack and defer, which its header in the library also documents. The references now speak in the protocol's terms, and one section of module-plain-elements.md says what the class is, when a widget extends it, where it draws, and that its header is its contract.
  • Arguments the references left out: says (drawn, until), readObligations (byId), rowWalk (position, steps), tabStore (read, keys, where), restorePlace (intent), shownWindow (viewport), and pushEntry and replaceEntry (state).
  • Sentences fresh authors were stuck on: the library module named wherever a sentence said only "the library"; how a plain page serves what a portable widget imports; an attribute's value is a string; an owned tag's example sits in its holder; how to print $keys; an authored starting value answers an awaits; an event's promise is its complete property.

The nine module-*.md files hold 25,419 words, against 25,424 before. The index, the left-out arguments and the class's one section went in; the class's teaching in module-authoring.md and module-state.md and two lists that repeated the protocol came out.

Measurement

Before and after, six agents on Sonnet that had never seen Leaf's code each built one package from the shipped skill alone, barred from browser/, src/, packages/ and tests/. A second agent then used each widget in a headless browser, since the render check draws a page and presses nothing.

Before After
Packages passing package check and page check with --render 6 of 6 6 of 6
Behaviours their tasks name that work in a browser 23 of 23 23 of 23
Places an author was stuck or guessed 43 38
Reference words opened 117,600 109,000
Authors who read Leaf's source 1 1

The first revision cut the class to a pointer at its header. Every author then wrote a plain HTMLElement, and one widget passed both checks with dead handlers, since Lit's standalone render doesn't bind an @event handler to the element. The text now says when a widget extends the class and how a standalone render binds handlers. The two tasks whose result had changed ran again on that text, and the After column counts those two reruns with the other four from the first revision.

Both source reads were of the library's rank.js, for rankAt's arguments. A ranked list can't record a move without that function, and the references name library modules without describing their functions.

Leaf's own suite, base beside head on Claude Code: widget-controller-lifetime 6 of 8 and 8 of 8, widget-list-keeps-focus 4 of 5 and 5 of 5, thread-widget-actions 1 of 3 and 3 of 3. An earlier head scored 1 of 5 on the first of these until two sentences came back: a LeafElement reads a bound property in render(), and places retained nodes there. widget-list-keeps-focus's criterion now also passes a list drawn by the state setter that Leaf calls before the lf-action dispatch returns. shared-contribution-actions fails on both arms, 0 of 3 each.

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

…tocol

The module references taught `LeafElement`'s `setup`, `render`, `record`,
`takeBack` and `defer` in three files, though the class is a library module
whose header is its contract. They now teach a widget by the protocol alone
(properties in, events out) and give the class one section that says what it
is, when a widget needs it, and where its contract is.

module-authoring.md opens with the protocol in a paragraph and a list of every
export of widget-api.js under the section that describes it.
tests/runtime/widget-api.test.mjs holds the list to the exports and each entry
to its section, in place of the check that every export is named somewhere.

Also: the arguments and members the references left out (`says`,
`readObligations`, `rowWalk`, `tabStore`, `restorePlace`, `shownWindow`,
`pushEntry` and `replaceEntry`), exact library modules where a pointer named
only the library, and the sentences six fresh authors were stuck on.

@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 references now give an author two rules for when a widget extends LeafElement, and the rules disagree. module-authoring.md, "The interface", and the first sentence of module-plain-elements.md, "LeafElement", say a widget that draws with Lit extends the class. But module-plain-elements.md opens with a widget that draws with Lit on a bare HTMLElement, and the last paragraph of that section bases the choice on page readings: "Only the class follows a page reading, so a widget that draws from one extends it." An author who copies the opening example breaks the rule the index states, and an author who follows the index can't tell why the example is allowed.

The two suggestions below keep the push toward the class and make the page-reading rule the required one, so the opening example becomes an allowed case instead of a counterexample. If the intent is that every Lit widget extends the class, the other fix is to say that the opening example shows the bare protocol, not the recommended form.

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