Skip to content

Reveal travel targets through beforematch instead of lf-reveal - #4500

Merged
max-sixty merged 3 commits into
mainfrom
widget-plain-html-status
Oct 27, 2026
Merged

max-sixty merged 3 commits into
mainfrom
widget-plain-html-status

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

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 Give data-bound widgets their value as .value and take their drawn data from marks and a drawn event #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

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 32 → 33

A page vendored at 32 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) and `pnpm run build:browser`.
- 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.

Refs #3833
# Conflicts:
#	dist/kernel/kernel.json
#	dist/kernel/runtime/bundle-data.js
leaf-agent
leaf-agent previously approved these changes Oct 27, 2026
@max-sixty
max-sixty merged commit a5e8dad into main Oct 27, 2026
4 checks passed
@max-sixty
max-sixty deleted the widget-plain-html-status branch October 27, 2026 20:54
max-sixty added a commit that referenced this pull request Oct 27, 2026
`layoutChanged(el)` dispatched `LAYOUT` with a `detail.present(promise)`
hook and returned the joined promise, so a caller could wait for
listeners' asynchronous layout work. No listener in the tree calls
`present`, so the returned promise was always already resolved, and the
callers that passed it along (lf-tabs' view switch, lf-deck's `#show`,
lf-trace-compare's `#draw`, the merge film's repaint) waited on nothing.
The last real consumer of a similar promise, `lf-reveal`'s `present`,
went with #4500.

`layoutChanged` now only dispatches the event and returns nothing; those
callers stop returning or collecting it, and lf-tabs' Back/Forward claim
awaits its switch instead of chaining `.then` on it.
`module-authoring.md` says to call `layoutChanged` rather than await it.

No protocol bump: a module vendored earlier that awaits the result or
collects it in `Promise.all` keeps working, and no bundled module calls
`.then` on it.

Part of #3833, which asks that a widget import from Leaf only what no
standard form expresses.

Three browser tests used `detail.present` to hold a tab switch's layout
completion. `test_a_tab_layout_completion_preserves_native_navigation`
is deleted, since a tab switch now completes in its own task and the
window it tested no longer exists;
`test_resume_writing_reveals_page_editor_from_a_covering_panel_and_keeps_back`
and
`test_an_obligation_walk_glides_within_a_view_and_opens_other_tabs_at_the_question`
keep their landing assertions without the hold.

Tests: `pnpm run test:runtime` (682), `pnpm run check:browser`, and 16
browser tests by node id over tab switching and history, the deck, trace
comparison and travel into tabs and visual parts.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Oct 27, 2026
A closed fold in a thread's transcript hid its messages with plain
`hidden`, so the browser's find-in-page skipped their words. Leaf's own
travel reached them only through `revealedBy`, an internal opener
registry in `widget-elements.js` whose only user was the transcript.
#4500 had kept that second mechanism because thread readers asked
`checkVisibility()`, which is true for an element hidden until found,
since it keeps its own box.

Folded messages are now `hidden="until-found"`, and each listens for
`beforematch` to open its fold. Find-in-page, text-fragment links and
Leaf's `reveal()` therefore all open a fold the same way, and
`revealedBy` is deleted.

`geometry.js` gains `showsContents(node, options)`, which is
`checkVisibility` but false for an element hidden until found. The
readers that asked whether a message shows now use it: `messages.js`
`shown`/`hidden`, `reply-landing.js` `returnTurn`, `transcript.js`
`foot` and the fold-away check, `floating-panel.js` `fitAnswer`, the
margin card's last shown message, and `anchor-travel.js`
`returnToFragment`, which wrote the same test by hand. `presented` uses
it too. A CSS rule drops the margin of an empty folded box.

Behavior change: ⌘F now finds and opens folded thread messages,
including progress behind a run's face.

Part of #3833. No protocol bump: `widget-api.js` exported neither
`reveal` nor `revealedBy`.

Tests: new
`tests/browser/threads/test_summaries.py::test_the_browser_s_search_and_leaf_s_travel_open_a_closed_fold`,
which follows a same-page text-fragment link (the browser's find reveal,
which Playwright can't press) and then a fragment link (Leaf's travel).
It fails with plain `hidden` restored. Also `pnpm run test:runtime` (682
passed), `pnpm run check:browser`, and 33 focused browser cases over
folds, summaries, progress, Next unread, read state and fragment return.
One of them,
`test_progress_disclosure_keeps_its_words_visible_beside_margin_paging[311-True]`,
fails identically with the original runtime.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 2, 2026
)

`dist/kernel/kernel.json` lists one module hash per line, sorted by
path. Git treats changes to two touching lines as one conflict, so a
runtime PR conflicted with `main` whenever `main` changed a module whose
path sorts next to one the PR changed, even though each line was right
for its own module. The kernel build now writes a blank line between the
entries, a layout prettier leaves alone, and those merges are clean. The
record's content is unchanged.

### How much it helps

I replayed the 455 merges of `main` into PRs #4500 to #5045 with `git
merge-tree`, rendering each side's `kernel.json` in both layouts:

- `kernel.json` conflicted in 257 of them.
- In 216, both sides had changed the same module. Those still conflict,
and should: the merged module is source no build has read. In 127 of
them the source merged cleanly, so the kernel conflict is what makes the
PR build and test the merged code before it lands.
- The other 41 were conflicts between neighbouring modules, and all
merge cleanly in the new layout. In 30 of them `kernel.json` was the
only conflict, so those merges become clean outright.
- For each of those 30, rebuilding the merged tree's kernel with that
tree's own build script reproduced the textual merge byte for byte. A
control rebuild of the PR side reproduced its committed kernel each
time.

Clean merges of `main` go from 145 to 175 of the 455.

### Cost

`kernel.json` gains a blank line per entry. When this lands, each open
runtime PR conflicts once on the new layout, resolved as any kernel
conflict is (`build/AGENTS.md`).

### Checks

`check:browser` passes, as does `build/runtime-bundle.test.mjs`.
`read_runtime` parses the new file and serves the kernel.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Nov 15, 2026
…reveal listener

The detail example gave every section a gist, Timeline included, though the
author instructions now name a timeline the argument has summarized as a
section to leave without one; so the shipped example never showed a section
folding. Its Timeline paragraph is no longer a gist: at Skim the section
folds behind the ⋯ after the decision, whose preview names "Timeline", and
the page draws 4 marks where main draws 5 (`leaf-dev probe detail --base`).

The dial listened for `lf-reveal` on each folded block, which nothing has
dispatched since #4500 moved travel to `beforematch`; the listener and its
mention in the header are gone.

The `lf-dial` x-instructions now say a page long enough that a reader
might want "only a quick pass", as the author instructions do, and the
author instructions fold the rule for which headings stay at Skim into the
bullet about sections that contribute nothing.
max-sixty added a commit that referenced this pull request Nov 15, 2026
#5588)

Skim kept every heading, and the detail package told authors to open
every section with a gist, so Skim was always one heading plus one
paragraph per section, and leaving a section's gist out left its heading
standing over nothing. Now a heading stays at Skim only when a lede or
gist follows it before the next heading of its rank or above, so a
section with no gist folds away whole, heading included. This holds in
`<section>` markup, in flat markup and for a heading inside a
`<header>`, since the dial reads forward in document order from the
heading.

Each gap in what Skim shows takes one ⋯, whatever structure holds the
folded blocks: a gist-less section joins the folded rest of the section
before it, so nested sections fold as flat ones do. Pressing the ⋯
unfolds the whole gap. Pointing at a ⋯ whose gap holds a heading, by
pointer, Tab or a held finger, shows a preview of "Show the rest" with
the outermost folded headings listed below it, so a skimmer can see
which sections lie behind it before pressing. The folded sections are
named only there, not on the page, since Skim shows only the passages
the author chose. The dial no longer listens for `lf-reveal`, which
nothing has dispatched since #4500 moved travel to `beforematch`.

The detail author instructions, the `lf-dial` `x-instructions` and the
`.gist` description now say what Skim is for: the page's argument and
anything the reader must act on, reading in order. They list what the
author weighs to get there: who reads the page, gists that make sense on
their own and read as one account, early material often carrying more
weight, an owed `lf-ask` that must not be missed, and sections that can
contribute nothing. The one-gist-per-section rule is gone. The Skim
button's tooltip, the package table in `packages.md` and two catalogue
blurbs no longer describe Skim as one gist per section. The detail
example's Timeline no longer has a gist, so at Skim it folds behind the
⋯ after the decision, whose preview names it.

## Using it

A scratch incident report with an `lf-dial` and five sections (Impact,
Cause, How we found it, Fix, Follow-ups), where only "How we found it"
has no gist, switched to Skim by every route Leaf gives: a pointer click
on Skim, Tab from the page's start (one press lands on the dial) then ←,
the go-to key `g` and the hint over Skim, and a tap at phone width
(390×844). On main (merge base dd48de4) and on this branch alike,
every route reached the same Skim state.

| | main | this branch |
| --- | --- | --- |
| "How we found it" at Skim | its heading over a lone ⋯ | folded whole |
| Marks under Cause's gist | one ⋯ | one ⋯, holding the rest of Cause
and "How we found it" |
| What that ⋯ previews | "Show the rest" | "Show the rest", then "How we
found it" |

At Skim the page now reads: title, lede, then the Impact, Cause, Fix and
Follow-ups gists under their headings, with the open decision in the Fix
gist. Pressing the ⋯ under Cause shows Cause's rest and "How we found
it" together and puts focus on the first paragraph shown. The detail
example draws 4 marks at Skim where main draws 5, its last previewing
"Timeline".

## Scoring the instruction change

No case under `evals/` covered `lf-dial`, so this adds
`skim-carries-the-argument`: an author turns a postmortem into a page
with `lf-dial` for a payments lead who skims it and owes a choice
between two fixes. The postmortem holds three kinds of material she
doesn't need on a quick pass: background on how the gateway pool works,
which the instructions don't name, and a minute-by-minute timeline and
the investigation's method, which they do. One judge reads the h1, lede
and gists in order and asks whether they give the failure, its cost, the
cause and the decision; the other fails a page that gives any of those
three a gist.

Claude Code, 4 runs per arm (`leaf-dev eval run
skim-carries-the-argument --harness claude-code --base --repeat 4`).
Every run used `lf-dial` and read its arm's detail author instructions.

| Judge | main (dd48de4) | this branch |
| --- | --- | --- |
| Skim reads as one account with the decision (`skim-reads-coherently`)
| 4 of 4 | 4 of 4 |
| No gist for the background, timeline or investigation
(`skim-folds-what-it-skips`) | 0 of 4 | 2 of 4 |

On main every author gave the timeline and the investigation a gist, as
"Open each section with its gist" says. On this branch no author gave
the investigation a gist, and the two failures each gave the timeline
one saying how long finding the host took. No author on either arm gave
the background a gist: four merged it into the cause's body, three put
it in a closed `details`, and one gave it its own section with no gist,
which folds at Skim. So the background doesn't separate the arms, and
the instructions' named example, the timeline, is where this branch
still falls short. Every author on both arms marked the decision's
`lf-ask` `.gist`. An earlier run of the case without the background
scored main 0 of 4 and this branch 4 of 4 on the skipping judge.

When the request said "a detail dial" without naming `lf-dial`, 5 of 8
authors (4 on main, 1 here) built their own dial from radio buttons and
CSS and never opened the package list in `references/packages.md`, so
the case names `lf-dial`.

## Verification

- `tests/browser/widgets/test_dial.py` (5 tests) passes.
`test_a_section_without_a_gist_folds_whole` covers a nested `section`
with no gist, a top-level one, a flat `h2`/`h3` run and a heading inside
a `header`; it asserts one ⋯ per gap, what the Cause gap's ⋯ previews
and that pressing it shows both folded sections. It fails on main, where
the gist-less headings stay visible.
- `pnpm run check:browser` passes, and `dev/tests/test_evals.py -k
catalog` builds the new case.
- The ⋯ preview was checked in Chromium by pointer, Tab and a held
finger, and in Firefox by the reviewer. Not checked: WebKit, and the
`test_page_holds_still` journey, whose dial pages read only the detail
example's Cause section.

Closes #5539

---------

Co-authored-by: leaf-agent <[email protected]>
Co-authored-by: Maximilian Roos <[email protected]>
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.

2 participants