Repository navigation
Give data-bound widgets their value as .value and take their drawn data from marks and a drawn event - #3982
Merged
Conversation
…d drawn out
Not for landing. lf-text-document no longer calls this.data() or projectData:
- Data in: its x-data input names `property: "value"`, and LeafElement sets
`.value` to the delivered value (null with no data) in willUpdate.
- Data out: the widget marks drawn items with data-lf-datum and dispatches
`drawn` with detail {value}. LeafElement finds the newest snapshot it set
with that value and stamps the marks through projectMarked, so a draw that
lands after a newer value arrived keeps the revision it drew.
- Settling: a claim settles on updateComplete; the widget extends it with
getUpdateComplete instead of drawing(). Dependent DOM readers still wait on
Lit's own completion only.
projectData and drawing() stay for the other four callers. The landing
version moves them, deletes both, documents the contract in module-*.md and
bumps the protocol.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # dist/kernel/runtime/bundle-answer.js
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # browser/runtime/data.js # browser/runtime/leaf-element.js # dist/kernel/kernel.json # dist/kernel/runtime/bundle-answer.js # skills/leaf/references/module-state.md # tests/browser/startup/test_projected_data.py
leaf-agent
reviewed
Oct 25, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
Holding a primitive value can turn a valid widget drawing into a failure after eight source replacements; the provenance guarantee needs to cover primitive contracts too.
A report retires only the primitive values set before the one it names, instead of keeping the last eight set. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
previously approved these changes
Oct 25, 2026
# Conflicts: # dist/kernel/kernel.json # dist/kernel/runtime/widget-api.js
leaf-agent
approved these changes
Oct 25, 2026
leaf-agent
added a commit
that referenced
this pull request
Oct 25, 2026
A reconnect cleared a bound diff's completed refusal even though its source was unchanged: `LeafElement.update()` removed the error box, then `lf-diff.updated()` correctly skipped parsing the same source. The diff now skips the whole update for unchanged evidence. Leaf delivers bound properties before `shouldUpdate`, allowing that gate to read the current value while retaining its subscription to later deliveries. Interrupted preparation still retries, and a corrected bound patch replaces the refusal. The reconnect regression fails on main and passes here. Extended coverage checks recovery after a new bound value, interrupted preparation for both inline and bound patches, and retained finished rows. The held-parser test now releases its response before awaiting completion, preserving #3982's guarantee that `updateComplete` includes asynchronous drawing. The runtime test checks gating on delivered values and subsequent delivery after a skipped draw. Validation: five focused browser cases pass; `pnpm run check` passes, including all 559 runtime tests and the Worker checks. Rebuilt the committed kernel. A served `worktree-diffs` comparison against `4f51fe9fe50ad8d418cafcb5e78397b1604387bd` reaches presentation with the same 53 code requests (50 JavaScript requests), 61 additional JavaScript bytes, and no layout shifts in either arm. The added code puts delivery before the update decision; it adds no resource dependency. Closes #3986 — automated triage Co-authored-by: leaf-agent <[email protected]>
This was referenced Oct 25, 2026
leaf-agent
added a commit
that referenced
this pull request
Oct 25, 2026
The deferred provenance test still read the diff widget's removed `.snapshot` property after #3982 moved bound data to `.value`. Both retained and current manifest reads now use `.value`, preserving the assertions that an old manifest is refused and the current manifest loads its replacement payload. The focused browser test failed on main with `loadDeferred(app.py) needs a source value Leaf delivered` and passes after this change (1 passed). No runtime behavior changes. Local Ruff checks could not run because Ruff is absent from this environment. Closes #4092 — automated triage Co-authored-by: leaf-agent <[email protected]>
leaf-agent
added a commit
that referenced
this pull request
Oct 25, 2026
…te (#4103) A bound diff could move the paragraph below it by 355px after Leaf reported its initial presentation complete. Lit leaves `hasUpdated` false after an update skips drawing while data is unread, so the first signal-driven retry could start without a presentation ticket. Its asynchronous `updateComplete` then held no barrier. `LeafElement` now claims each connected update at its draw gate when it has no existing ticket. This preserves the asynchronous drawing guarantee introduced in #3982 while retaining the bound-value gating in #3929 and #3987. The external resolution behavior and shift tolerances are unchanged. The new runtime regression fails before the fix and passes afterward. The reported browser case reproduces the 355px shift before the fix and passes afterward, both normally and with 6× CPU throttling. The data-readiness failure case, all 562 runtime tests, and `pnpm run check` pass. Rebuilt the committed kernel. A served `worktree-diffs` comparison against the base loads the same 53 code requests through upgrade and initial server presentation, with 107 additional code bytes (17 JavaScript bytes) and no layout shifts in either arm. The added claim makes readiness wait for drawing already underway; it adds no resource dependency. Closes #4097 — automated triage Co-authored-by: leaf-agent <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Oct 27, 2026
Before Leaf travels to a target (a comment's anchor, a search hit, an
obligation), it reveals what holds it. It used to dispatch its own
`lf-reveal` event on every ancestor, with `{target, mayReveal, present,
replacedView}`, so a widget that folds content had to import a Leaf
contract to open for Leaf's travel, and separately listen for
`beforematch` to open for the browser's find. This is the next slice of
#3833: `reveal()` now does what the browser's find-in-page and fragment
navigation do (the HTML standard's ancestor revealing algorithm), so a
widget written as plain HTML opens for both.
## The contract
- `reveal()` walks the target's ancestors outside-in. It opens a closed
`<details>`, opens a closed popover (which the browser's find leaves
shut), and at an element `hidden="until-found"` fires `beforematch` and
removes the attribute, as the browser does. Checked in Chromium and
Firefox: `beforematch` bubbles and the browser removes `hidden` after
it.
- `replacedView`, which makes travel place the target at once instead of
scrolling from the old view's offset, is derived: it is true when a
sibling of the revealed element became hidden during the dispatch, as a
tab set hides the panel it leaves. A disclosure that hides nothing
scrolls as before.
- `present(promise)` is gone. `ready` joins the `updateComplete` of each
Lit element holding what was revealed, so a widget whose switch finishes
later extends its own `updateComplete`, the hook #3982 adopted for
settling.
- `mayReveal` stays the caller's check between steps; no listener needed
it, since listeners now run synchronously.
## Widgets
- `lf-tabs`, `lf-deck`, `lf-trace-compare`, `lf-options-settled` already
hid with `hidden="until-found"` and listened for `beforematch`; their
`lf-reveal` listeners are deleted. A settled options group used to open
on any reveal passing through it; it now opens only for a target inside
a folded option, so travel to the group's own row, already shown, leaves
it shut.
- `lf-visual-review` hides an unchosen case with `hidden="until-found"`
in place of `aria-hidden`, and opens it on `beforematch`. Its cases
share one grid cell so choosing another moves no control, so its CSS
keeps the box laid out (`content-visibility: visible`) and hides it with
`visibility`, as before; the browser's find still skips it.
- `lf-gloss` lets reveal open its tip popover and pins it on
`beforetoggle` when anything but the gloss opened it.
- `lf-diff` hides a file the filter leaves out with
`hidden="until-found"` instead of a `display: none` class, and clears
the filter on `beforematch`. Behavior change: the browser's find now
reaches text in a filtered-out file and clears the filter, as `g v`
already did.
- The thread transcript, which is runtime code, keeps folded messages
`hidden`: thread reading takes a message an until-found box would leave
as shown and would land on it rather than on its fold. It registers its
fold's opener with the runtime-internal `revealedBy`, which `reveal()`
calls.
- `lf-suggestion` no longer forces an immediate margin update on reveal;
`test_the_obligation_walk_lands_on_a_suggestion_the_reveal_just_opened`
passes without it.
`module-scroll-and-motion.md` ("Travel and history") states the new
contract, and the `view-reveal-arrival` eval's rubric follows it. I
didn't score the reference change: it replaces an API description rather
than rewording a rule.
## Protocol 33 → 34
A page vendored at 33 has `lf-visual-review`, `lf-gloss` and `lf-diff`
modules that wait for an `lf-reveal` event this runtime no longer sends,
so travel into a hidden case, tip or filtered file would stop opening
it.
## Tests
- `pnpm run test:runtime` (682 pass), `pnpm run check:browser`, `pnpm
run test:browser`, pre-commit, and the model and process tiers (2147
pass).
- 42 focused browser tests by node id over tabs, deck, trace comparison,
settled options, glosses, visual review, diff filtering and `g v`,
thread folds and summaries, obligation walks, Go-to and thread travel,
plus the visual-review journey and export tests (25).
- Tests that used `lf-reveal` as a hook to hold a reveal (`test_go_to`,
`test_obligation_walk`, `test_on_panel`, `test_code_review`) now hide a
holder with `hidden="until-found"` and hold its `updateComplete`.
- Selectors that read `.lf-vr-case[aria-hidden="false"]` or the
`lf-diff-filtered` class read `:not([hidden])` instead.
- `test_a_widget_first_paints_the_box_it_presents[diff-closing-a-panel]`
and `[diff-in-a-phone-column]` fail identically on main 37e9061.
- An independent review found no correctness bug; its points on the
replaced-view rule, popover dialogs, visual review taking only its own
`beforematch`, stale prose and a vacuous Go-to assertion are folded in.
Refs #3833
> _This was written by Claude Code on behalf of max-sixty_
This was referenced Oct 31, 2026
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.
Every data-bound widget now takes its bound value through a plain element property and reports what it drew with plain attributes and a
drawnevent, soprojectData,this.data()anddrawing()are gone. This is the first slice of #3833's direction A: a contract moves to a platform form where that form is at least as good on Leaf pages alone.The contract
x-datainput names the elementpropertyLeaf sets ("property": "value"in every bundled widget). Before each update the delivery moves,LeafElementsetsthis.valueto the delivered value, ornullwhile the source has none. An input the markup leaves unbound, such as an inlinelf-diff, is left to the widget and whoever else hosts it. An input without aproperty(lf-num's, which has no module) is read by no module.data-lf-datum, and optionallydata-lf-identity,data-lf-datum-labeland the newdata-lf-origin-path(a JSON array naming the datum's place in the value, whichlf-diff,lf-call-diff,lf-traceandlf-visual-reviewneed). It then dispatchesdrawnwith{value}. Leaf finds the snapshot that supplied that value and stamps the marks with its source, revision and origin (projectMarked,projection/data.js). Core stays widget-agnostic: a mark belongs to the nearest element whose tag declaresx-data.WeakMapfrom value to snapshot is exact and lasts as long as the widget holds the value. That covers a held reading (HeldReadingin the command-hub example) however many newer values arrive. A primitive value, such as a text document's string, has no identity, soLeafElementkeeps the one the widget last reported and every one set since, and a report retires only the values set before the one it names: a widget can report a value it still holds or a later one still drawing, but not go back to an older one after reporting a newer one. Equal primitive values share a revision, a digest of the value. This replaces the prototype's last-eight list, which failed a widget holding a string past eight deliveries.{value: null}, or an unbound input, stamps words no bound value supplied, with no source.drawnnames exactly one bound property, the one whose items it marked, since a seat's stamp carries one source and revision. This is the ruleprojectDataalready imposed (one snapshot per call, each call replacing the seat's datums);module-state.mdstates it.updateCompletedoes, which a widget whose drawing finishes after the render extends withgetUpdateComplete, as any Lit element does; a rejection is the update's failure and is reported once. Dependent DOM readers still wait on Lit's own completion. A widget sets its pending-work promise on every update so a finished failure doesn't fail later draws.loadDeferred(value, key)takes the manifest value the widget drew and finds its revision the same way, refusing a value Leaf didn't deliver.Widgets moved:
lf-text-document,lf-diff,lf-call-diff,lf-visual-review,lf-trace,lf-file-tree(this.dataanddrawing()only), the three example widgets (lf-atlas-tree,lf-repo-feed,lf-pr-brief) and thelf-test-treefixture.lf-diffandlf-tracekeep the nodes they marked, so they take a mark off a node they keep once it stops showing data (a closed file's retained lines, a trace part the playhead left).lf-repo-feed's live-explored feed reports{value: null}, since no source supplied it.What changes for authors
revision,runorupdated, only its value.lf-pr-briefkeyed its Markdown wait on[revision, run]and now uses the value's identity.x-data. Several tests projected derived datums from plainHTMLElements without it; they now declare an unbound input. No shipped widget did that.module-state.md("Bound data and projections", new "Marking drawn data"),package-data.mdandmodule-authoring.mddescribe the new contract, and the$data,x-dataandx-awaits.recordsdescriptions in the kernel registry follow. Thewidget-controller-lifetimeeval's rubrics name the new calls. I didn't score the reference change withevals/: it replaces an API description rather than rewording a rule.Protocol 25 → 26
A page vendored at 25 has widget modules that import
projectDatafrom/runtime/widget-api.jsand callthis.data()andthis.drawing(), all gone, and a registry whosex-datainputs name noproperty, so its widgets would read nothing.layer-registry.md("Page protocol") calls for a bump when a name a vendored module imports is gone. The bump changes$events.protocoland the baseline's number only.Builds on #3929
#3929 (draw a data-bound widget only once the page has read its data) merged while this was in progress, and this branch merges it. They compose: its
awaitsDatagate inshouldUpdateruns beforewillUpdate, so.valuestays at its default until the page has read its data, and itsdata-unreadruntime test now reads.value.Tests
pnpm run test:runtime(552 pass) andpnpm run check:browser.-n0: the prototype's late-draw test; per-widget stamps across a source replacement forlf-call-diff(test_call_diff_projects_stable_commentable_rows),lf-visual-review(test_visual_review_ignores_a_late_load_from_superseded_evidence) and a newtest_trace_parts_carry_the_recording_and_place_they_were_drawn_from;lf-diff's draft and anchor across a replacement and its lazy files' origins (test_code_review.py); comments following datums across replacements intest_projected_data.py,test_comment_targets.pyandtest_targets.py; thread surfaces, file tree, the PR brief and worktree examples, and the widget quality checks for every bundled package.test_a_declared_external_projection_must_receive_its_snapshotis deleted with the guard it tested. The old async-provenance runtime test is replaced by the late-draw test, which checks the same lookup in a stricter order.The
ui-review-detectioneval fixtures keep their own stubbedprojectData: they are frozen bundles that never import Leaf'swidget-api.js.Refs #3833