Repository navigation
Convert ten more widgets to LeafElement, and replay LeafElements in the render check - #2898
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
left a comment
There was a problem hiding this comment.
relativeReplays() compares the DOM immediately after redraw(), but redraw() calls updated(). For the converted lf-text-document, updated() starts show(), which awaits syntax and preview work before changing the DOM. The comparison therefore sees the old document and can report a clean replay even if that draw changes it later. The same path starts a new presentation claim during what redraw() describes as a draw outside any claim. Please make replay wait for the complete draw before comparing, and cover a widget whose asynchronous second draw changes its output.
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]>
|
@leaf-agent on the replay finding: For the stateful widgets the check does replay,
|
…Element (#2912) Converts the last four widgets on the controller's `subscribe`/`renderState` route or `watchData` to `LeafElement`: `lf-suggestion` (kernel), `lf-trace` (playwright package), `lf-diff` (diff package; its inline patch stays on `readingPaint`) and `lf-visual-review` (visual-review package). After this, no widget subscribes to its controller or calls `watchData`; a following PR deletes those routes, the tests' inline widgets that still use them, and the module-authoring references. ### `LeafElement` - **`drawing(work)`** holds an update's claim until asynchronous drawing it started 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. 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 (#2898), which waited on anything the widget prepares, held shot images included. - **Failures on a shadow stage.** A `LeafElement` whose 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 (`placesFailure` now answers whether it placed the box). - **One copy a delivery.** `this.data(input)` returns the same copy until the next delivery, so a widget tells a new delivery by identity. - Moves draw in #2900's parent-ordered widget queue, which runs every widget before the document-wide renderers; that is what lets `lf-suggestion` measure the slot it folds before the layer retires it. ### Widgets - `lf-suggestion`: `setup()` holds the once-only build; `connectedCallback`/`disconnectedCallback` re-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-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 (it declares no state). - `lf-visual-review` draws its template from `render()` rather than `render(…, this)`, 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. ### 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 on `origin/main` at 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. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Converts ten more widgets from the widget controller's
subscribe/renderStateroute andwatchDatatoLeafElement(#2869), and makes the render check's replay coverLeafElementwidgets.Converted
lf-draft,lf-playground(default and playground packages),lf-call-diff(diff package),lf-text-document(default package).lf-atlas-task(command hub, and the corpus copy),lf-pr-brief(PR walkthrough, and the corpus copy).lf-test-task, and the page-script fixturesseated-ask,driftandrelative.Each now draws in
render()from what it reads (this.state,this.reading,this.data(input)), with its one-time build insetup(). Behaviour is unchanged; the widgets' existing browser tests pass.lf-playgroundno longer catches its own build failure: asetup()that throws shows its failure throughLeafElement.Widgets that wait on asynchronous work start it with
controller.present():lf-text-documentstarts its existing highlighting and preview fromupdated(), andlf-pr-briefwaits for the Markdown renderer once a delivery, then draws a Lit template and highlights after the draw. For that, aLeafElementwhose tag declaresx-datanow holds the page's data version on both its widget regions, render and preparation (joinDataDeliveryindata.js), so the version is not stamped before highlighting or a preview frame lands.Render check
relativeReplays(render-checks/replay.js) replays aLeafElementthrough its newredraw(), which draws its render alone again, outside any claim and outside Lit's schedule, and throws what fails (notupdated(), whose work may start preparation that lands after the synchronous check reads the page); arenderStatewidget still replays throughrenderStateuntil the rest are converted. Therelativefixture, now aLeafElement, still yields both relative-render findings.Tests
test_a_widget_presents_its_authored_state_offline_and_the_log_on_recovery(startup): anlf-optionspresents its authored state when the first read fails and draws the logged choice once a read succeeds.redraw()leaves the update a move queued, with its claim.Left for later PRs
lf-suggestion,lf-visual-review,lf-diffandlf-trace, the test files' inline widgets, the module-authoring references, and then the controller's paint route andwatchDatathemselves.lf-suggestion's fold measures the retiring slot before the layer marks it retired, which needs the widget to draw inside the publication, as the controller route did; that timing change toLeafElementcomes with it.