Repository navigation
Let lf-worktree own its disclosure, and teach the gate authored bodies - #3859
Merged
Merged
Conversation
Authors now write a worktree's evidence directly inside `<lf-worktree>` and set `open` on it for the first useful snapshot. The initializer builds the native `<details>`, the summary and path Leaf writes from the member's attributes, and a plain body that the author's evidence moves into. Before, the author wrote the `<details>` and the initializer put its summary and path inside it, among the author's own elements, which the render gate reports as apparatus among authored content: every member of `examples/developer/worktree-diffs.html` failed `test_page_fixture_renders[worktree-diffs]`. The gate needed a rule it lacked: a box a module builds is the module's, and the page's ownership resumes at the box inside it that holds the authored children. Initializers get one new tool for this, `authoredBody(box)`, which moves every child of the host into `box` and records it. Three readers use that record: - The render gate (`framing.js`, `moduleOwnsBox`) treats everything in a markup host outside its authored body as the module's layout, and everything inside it as the page's. - The revision patch (`dom-children.js`) writes, places and orders a host's children inside its authored body, so a moved body no longer makes the host atomic. Before, any revision to a host whose module had moved its children rebuilt the host. - `x-patch: members` (`version.js`, `reachesMembers`) compares only the host's own attributes when its children are in an authored body, since the module reads none of them. A revision that edits, adds or re-attributes the evidence therefore patches in place and keeps the nested `lf-diff` reader's filter and file folds, as the authored `<details>` did before. A revision that changes a member's attributes, such as its counts, still rebuilds the rows. A reader's toggle now outlasts that rebuild and a reload: the initializer keeps it in the tab store by host id, and the authored `open` applies only where the reader hasn't toggled the row. `lf-motion` already moved its children into a body of its own; it now builds that body with `authoredBody`, which changes nothing it does. The example's `.worktree-example-cases section` rule set `margin-block: 24px`, and the last section's end margin was trapped inside the cases disclosure's 8px inset. It is now `margin-block-start: 24px`. The example renders at the same geometry as before (checked with `leaf-dev probe` against the merge base). A shadow root holding the disclosure around a `<slot>` was the alternative. It needs no gate change, but initial drawings get no shadow stage, so the summary would appear only at upgrade. No protocol bump: `authoredBody` is an additive initializer tool, and a page vendored earlier keeps its own `lf-worktree` initializer and registry, which don't use it. Tests: the gate fixture above; the `lf-worktree` browser test, which now edits an evidence attribute in place and rebuilds the rows with an attribute change, checking the reader's open and closed rows survive; the `lf-motion` browser tests; new runtime tests for `authoredBody` and for patching inside an authored body; `pnpm run test:runtime` and `pnpm run check:framework`. Closes #3811 > _This was written by Claude Code on behalf of max-sixty_ Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
previously approved these changes
Oct 25, 2026
# Conflicts: # dist/kernel/runtime/bundle-answer.js
leaf-agent
approved these changes
Oct 25, 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.
Authors now write a worktree's evidence directly inside
<lf-worktree>and setopenon it for the first useful snapshot. The initializer builds the native<details>, the summary and path Leaf writes from the member's attributes, and a plain body that the author's evidence moves into. Before, the author wrote the<details>and the initializer put its summary and path inside it, among the author's own elements, which the render gate reports as apparatus among authored content: every member ofexamples/developer/worktree-diffs.htmlfailedtest_page_fixture_renders[worktree-diffs].The gate needed a rule it lacked: a box a module builds is the module's, and the page's ownership resumes at the box inside it that holds the authored children. Initializers get one new tool for this,
authoredBody(box), which moves every child of the host intoboxand records it. Three readers use that record:framing.js,moduleOwnsBox) treats everything in a markup host outside its authored body as the module's layout, and everything inside it as the page's.dom-children.js) writes, places and orders a host's children inside its authored body, so a moved body no longer makes the host atomic. Before, any revision to a host whose module had moved its children rebuilt the host.x-patch: members(version.js,reachesMembers) compares only the host's own attributes when its children are in an authored body, since the module reads none of them. A revision that edits, adds or re-attributes the evidence therefore patches in place and keeps the nestedlf-diffreader's filter and file folds, as the authored<details>did before.A revision that changes a member's attributes, such as its counts, still rebuilds the rows. A reader's toggle now outlasts that rebuild and a reload: the initializer keeps it in the tab store by host id, and the authored
openapplies only where the reader hasn't toggled the row.lf-motionalready moved its children into a body of its own; it now builds that body withauthoredBody, which changes nothing it does.The example's
.worktree-example-cases sectionrule setmargin-block: 24px, and the last section's end margin was trapped inside the cases disclosure's 8px inset. It is nowmargin-block-start: 24px. The example renders at the same geometry as before (checked withleaf-dev probeagainst the merge base).A shadow root holding the disclosure around a
<slot>was the alternative. It needs no gate change, but initial drawings get no shadow stage, so the summary would appear only at upgrade.No protocol bump:
authoredBodyis an additive initializer tool, and a page vendored earlier keeps its ownlf-worktreeinitializer and registry, which don't use it.Tests: the gate fixture above; the
lf-worktreebrowser test, which now edits an evidence attribute in place and rebuilds the rows with an attribute change, checking the reader's open and closed rows survive; thelf-motionbrowser tests; new runtime tests forauthoredBodyand for patching inside an authored body;pnpm run test:runtimeandpnpm run check:framework.Closes #3811