Repository navigation
Convert lf-suggestion, lf-trace, lf-diff and lf-visual-review to LeafElement - #2912
Merged
Merged
Conversation
A prototype of a Lit-first widget contract, measured on five widgets before deciding whether to convert the rest. `LeafElement` (runtime/leaf-element.js) is a LitElement base class whose render() reads through collected readers (its reading and state, a bound data source through `this.data(input)`, asks, reports, the time) and draws again when any of them moves. It owns the widget's render region: a move claims it inside the publication, the next update that draws settles the claim as it commits, and a failed update settles it with the fail-soft box in the render root. It draws nothing while away, holds through the controller's defer() and a drag, gates on an incomplete startup reading, and holds the data version for a tag that declares x-data. Bound data moves only as state application delivers it, as a watchData subscription's staged paint does. A reading of presentation proof (`proofReading`), such as the new `reportsReady` narration gate, draws again without claiming, since a claim would move that proof. Converted: lf-atlas-worker and lf-atlas-tree (command hub, and the corpus copies), lf-options, lf-board, lf-file-editor, and the work fixtures lf-test-worker and lf-test-tree. The controller's subscribe/renderState path and watchData stay for the widgets not converted; the controller's defer() and an ancestor's remount refresh reach a LeafElement through `drawsItself`, and both share `widgetMounted`. Behaviour change: converted widgets draw on the microtask after the publication that moves their reading, not during it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…every failure An update settles the claim it started with; a claim its own reads make while it runs is the next update's. A draw queued as the element left waits for its return even before the arrival batch reports the departure. A failure in the gate or after the draw is reported and shown once, rather than swallowed. Accepted data claims the element's region inside the publication that accepts it and draws at delivery, as a watchData subscription's staged ticket does. The ownership test runs with LeafElement widgets too, covering a remounted part whose owner places it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
While any widget held a drag, every LeafElement, every controller subscription and the document-wide projection pass held new state until the last hand was down. Now only the widget whose drag moves its own nodes holds its drawing, through its controller's defer() (lf-board already did); the hand still holds back a new revision and an undo, which would replace the nodes under it. Other widgets draw foreign state during a drag: a draft above a board that grows mid-drag moves the board 174px under the pointer, and the drop still records the move Sortable made. This deletes the drag waiters in LeafElement and the controller, the projection's drag gate and its deferral reading, watchDragRelease, and the framework's PRESENTATION_HELD, whose only producer was that gate. Tests that asserted the page-wide hold now assert the new behaviour or, where the hold was their subject (a report held behind a body drag, the drag release's projection wake), are deleted. TODO.md gains an unconfirmed item: let Lit's SignalWatcher follow a widget's reads once Leaf's publication is TC39 signals. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # skills/leaf/assets/runtime/semantic-state.js
# Conflicts: # skills/leaf/packages/file-editor/widgets/lf-file-editor.js
…aim after updated A failed draw replaced the render root's children with the fail-soft box, so a widget that paints retained nodes, as lf-options paints its authored options, had nothing to draw on afterwards: the next reading removed the box and left the options gone. The box now stands at the head of the render root beside what the element drew, and the next update that draws takes it away (`placesFailure` in widget-upgrade.js, which a LeafElement registers). The same placement takes a rejected `present()` preparation and a module's own `failSoft(this, …)`, which had replaced a shadow widget's whole stage and detached its render root. A `setup()` that throws shows its failure and the element draws nothing after it, so lf-file-editor-style builds need no catch of their own. An update's claim now moves at its gate and settles once Lit has run all of it, `updated` included; a failure anywhere, `willUpdate` too, rejects it rather than the coordinator recording a commit before work after the draw failed (leaf-agent's finding). A draw nested in another's `updated` with no claim of its own fails the enclosing one. The hold is one flag, since the controller's `defer()` refuses a second, and the refresh is a private method rather than a symbol. lf-file-editor.js takes prettier's indentation after the merge of #2867. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…raw's failure its own A draw that failed under a claim was reported only by the presentation coordinator, as "Presentation failed", with no widget named. The element now reports it as the widget's own failure before rejecting the claim, so the agent that wrote the widget can find it, and a failure on a claim the coordinator has since retired is still reported. A nested draw's failure no longer rethrows into the enclosing update: Lit's catch there cleared the update a nested publication had queued. Each draw settles its own claim. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…fails leaf-agent's suggestion: a draw that updated() starts at once, as lf-file-editor's paint() may, and that fails with no claim of its own now rejects the enclosing update's claim rather than letting it record a commit beside a fail-soft box. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…he render check lf-draft, lf-playground, lf-call-diff, lf-text-document, lf-atlas-task (both copies), lf-pr-brief (both copies), lf-test-task and the seated-ask, drift and relative page fixtures now draw in render() from what they read, with their one-time build in setup(). Behaviour is unchanged. lf-playground no longer catches its own build failure, which LeafElement shows. A widget whose draw starts asynchronous work holds it with controller.present(): lf-text-document starts its highlighting and preview from updated(), and lf-pr-brief waits for the Markdown renderer once a delivery before drawing its template. A LeafElement declaring x-data now holds the page's data version on both its widget regions, render and preparation, so the version is not stamped before that work lands. The render check's relativeReplays replays a LeafElement through redraw(), which draws the reading again outside any claim and Lit's schedule and throws what fails; renderState widgets still replay through renderState. A startup test covers a widget presenting its authored state offline and the log's on recovery. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent's finding: redraw() ran updated(), whose work may start asynchronous preparation, as lf-text-document's does, which claims the widget's presentation and lands after the synchronous check reads the page. The replay now draws the render alone, the part that states the widget's complete state, as renderState did. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
#2898 branched before #2889 committed the kernel, so it landed runtime and widget edits without the kernel rebuild check:browser compares against. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # skills/leaf/kernel/kernel.json # skills/leaf/kernel/leaf.js
…Element Every widget now draws through LeafElement except lf-diff's inline patch. A LeafElement draws at once inside the publication when a reading it follows moves, as the controller's paint did, so it draws before any renderer the publication schedules: lf-suggestion measures the slot it folds before the layer marks it retired. A connection still draws on Lit's microtask, and a move before it joins that draw. drawing(work) holds an update's claim until asynchronous drawing it started from updated() lands, as watchData's awaited callback held the data version: lf-text-document's highlighting and preview, lf-pr-brief's Markdown load and highlighting, and lf-diff's patch rendering. It replaces joining the data version on the widget's preparation region, which waited on anything a widget prepares, held shot images included. A LeafElement that shows a shadow stage over its host shows a failure as that stage, as any shadow widget does; one with a light or nested render root keeps the box beside what it drew. dataReader returns one copy per delivery, so a widget tells a new delivery by identity. lf-trace and lf-diff read their data in render() and show a new delivery from updated(); lf-diff forgets a rendering a departure cut short, so the return draws it again, and loses a renderState nothing called. lf-visual-review draws its template from render(), paints its inspection after a draw for the review state as renderState did, draws nothing for a failed source until another arrives, and drops the defer() its own draws no longer need. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…claimed update #2900 put LeafElement updates in the parent-ordered presentation queue, which runs every widget before the document-wide renderers, so lf-suggestion's fold measures its slot before the layer retires it without drawing inside the publication. A move draws in that queue again. drawing(work) on an update no move claimed, as lf-diff's retry after a cut rendering and lf-pr-brief's draw after its Markdown loads are, claims the region for the work, so presentation and the data version still wait for it. The two claim sites share one #claim(). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Codex's finding: a nested update with drawing but no claim of its own claimed the region afresh, superseding the enclosing update's claim, so the enclosing drawing stopped holding presentation. It now joins the enclosing claim. Several drawing() calls in one update all hold it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # skills/leaf/kernel/kernel.json
leaf-agent
previously approved these changes
Oct 14, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
previously approved these changes
Oct 14, 2026
# Conflicts: # skills/leaf/kernel/kernel.json
leaf-agent
previously approved these changes
Oct 15, 2026
# Conflicts: # skills/leaf/assets/widgets/lf-suggestion.js # skills/leaf/kernel/kernel.json
leaf-agent
approved these changes
Oct 15, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 15, 2026
…#2919) Deletes the widget paint routes `LeafElement` replaced: the controller's `subscribe` and the `renderState` it called, and `watchData`. Every widget draws as a `LeafElement` since #2912, so this leaves one way for a widget to draw what it reads. ### Runtime - `widget-controller.js` keeps `read`, `dispatch`, `defer` and `present`. Its subscriptions, total render, render region and `readingPaint` route go. `defer()` holds a `LeafElement`'s drawing and refuses any other owner; an ancestor's remount refreshes the `LeafElement`s around it. - `data.js` loses `watchData` and its per-subscription presentation; the data version waits on the regions `LeafElement`s join (`joinDataDelivery`). - The render check's replay (`render-checks/replay.js`) replays through `redraw()` alone, and its findings name `render()`. - `leaf package new` scaffolds a widget as a `LeafElement`. - `LeafElement` puts its fail-soft box after what it drew, so nothing it drew moves for the box, and keeps the box when the same failure repeats. A `drawing()` that rejects reports a failure naming the widget. A widget that leaves while a `drawing()` is unfinished draws again on return, as a `watchData` subscriber whose paint was cut short did; before this, the return stamped its region and data version with the drawing still pending. ### Docs `module-state.md` and `module-authoring.md` teach `LeafElement` as the way a widget draws: `this.state`, `this.data(input)`, `drawing()`, `updated()`. The Upgrade and connection recipes build a widget in `setup()` and keep `once()` for other custom elements. Registry descriptions and the event-log page say `render()` and `this.data` where they said `renderState` and `watchData`. ### Tests The runtime tests of `watchData` move to `LeafElement` widgets where they protect behaviour a widget still has (its own binding, a superseded asynchronous draw not stamping the newer data version, an unchanged source waiting for its drawing, an asynchronous projection keeping its captured provenance); the ones about `watchData`'s own lifecycle go. A new runtime test holds the unfinished-drawing return (it failed before the fix, drawing once instead of twice). A browser test holds the first state read and checks that a widget's reading is already its whole authored state, so `LeafElement`'s incomplete-reading gate does not hold it at startup (the header had named startup as that gate's case; it is a revision's replacement before its document is adopted). The browser tests' inline widgets draw as `LeafElement`s. The `widget-controller-lifetime` eval's first two rubrics judge `LeafElement` render reads in place of `subscribe` and `watchData`. `TODO.md`'s TC39 signals item records the assessment now that there is one class: adopting Lit's `SignalWatcher` would save about fifteen lines of `#follow` but has no hook for claiming the widget's region, and the projection and version paints still read Preact signals, so it waits on a new trigger. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[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.
Converts the last four widgets on the controller's
subscribe/renderStateroute orwatchDatatoLeafElement:lf-suggestion(kernel),lf-trace(playwright package),lf-diff(diff package; its inline patch stays onreadingPaint) andlf-visual-review(visual-review package). After this, no widget subscribes to its controller or callswatchData; a following PR deletes those routes, the tests' inline widgets that still use them, and the module-authoring references.LeafElementdrawing(work)holds an update's claim until asynchronous drawing it started lands, aswatchData's awaited callback held the data version:lf-text-document's highlighting and preview,lf-pr-brief's Markdown load and highlighting, andlf-diff's patch rendering. An update no move claimed (a retry, a draw after a load) claims the region for the work. This replaces joining the data version on the widget's preparation region (Convert ten more widgets to LeafElement, and replay LeafElements in the render check #2898), which waited on anything the widget prepares, held shot images included.LeafElementwhose render root is its host but that shows a shadow stage shows a failure as that stage, as any shadow widget does; one with a light or nested render root keeps the box beside what it drew (placesFailurenow answers whether it placed the box).this.data(input)returns the same copy until the next delivery, so a widget tells a new delivery by identity.lf-suggestionmeasure the slot it folds before the layer retires it.Widgets
lf-suggestion:setup()holds the once-only build;connectedCallback/disconnectedCallbackre-offer and unregister its margin contribution;render()draws the outcome, then refreshes the margin as its subscriber did. A paint fault is now reported as the widget's own (<lf-suggestion id="…"> failed: …).lf-traceandlf-diffread their data inrender()and show a new delivery fromupdated().lf-diffforgets a rendering a departure cut short, so the return draws it again, and loses arenderStatenothing called (it declares no state).lf-visual-reviewdraws its template fromrender()rather thanrender(…, this), paints its inspection after a draw for the review state asrenderStatedid, draws nothing for a failed source until another arrives, and drops thedefer()its own draws no longer need.Tests
The widgets' browser selections pass (visual review 38, diff 183, trace 28, documents and PR brief 32, drafts 72, options 52, outbox 27). Runtime tests cover
drawing()on a claimed and an unclaimed update. Failures in those selections that also fail onorigin/mainat 58f8a06, not caused here:test_suggestion_controls_stay_out_of_the_column,test_widget_controller_owns_presentation_across_values_and_lifetimes,test_local_work_chrome_does_not_take_its_holder_gesture,test_refused_reply_retains_its_live_foot,test_a_large_diff_filters_and_navigates_lazy_files,test_file_editor_saves_quietly_and_preserves_inflight_edits,test_a_mechanical_revision_failure_leaves_accepted_publication_ready,test_a_refused_action_waits_for_a_live_gesture_before_reconciling, and teardown "unchanged write" errors from main's write watch.