Skip to content

Let lf-worktree own its disclosure, and teach the gate authored bodies - #3859

Merged
max-sixty merged 3 commits into
mainfrom
fix/3811-worktree-owns-disclosure
Oct 25, 2026
Merged

max-sixty merged 3 commits into
mainfrom
fix/3811-worktree-owns-disclosure

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

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

max-sixty and others added 2 commits October 24, 2026 20:38
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
leaf-agent previously approved these changes Oct 25, 2026
# Conflicts:
#	dist/kernel/runtime/bundle-answer.js
@max-sixty
max-sixty merged commit 09d1e27 into main Oct 25, 2026
3 checks passed
@max-sixty
max-sixty deleted the fix/3811-worktree-owns-disclosure branch October 25, 2026 04:08
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.

ci-fix: worktree disclosure inserts controls among authored evidence

2 participants