Repository navigation
Let one widget indicate part of another (experimental) - #1129
Merged
Merged
Conversation
Add `indicate(owner, attribute, key)` to the widget API: a widget marks the
elements a key addresses under the widget its declared `x-refers` attribute
names, in place of what it last marked there, and `null` clears. The runtime
paints the union of every driver's elements with `data-lf-indicated` and
`aria-current="true"`, never scrolls, focuses, reveals, hydrates or announces,
and resolves standing indications again on `lf-layout`. It is browser state
like hover: nothing is logged or published. Marked experimental in its module
header and in the packages.md subsection heading.
`lf-code` answers the hook with its `hi` grammar (`lfElementsFor("3-5,8")`),
states its rendered lines with `layoutChanged`, and gives an indicated line an
accent gutter bar, number and wash, distinct from an `hi` line. marks.css
carries a zero-specificity accent outline for everything else.
Contract changes:
- One key space for x-refers verbs: `addressedElements(source, key)` resolves
the target's `lfElementsFor` hook, else a registered visual part id, else a
projected datum key. `navigateToDatum` now travels to the first element it
returns, so it also reaches visual parts and hook-addressed parts.
- `referencedProjection` resolves in the owner's own authored document first,
then the page's main, matching the server's request check (thread markup
before page). It used to search the whole document, so a page element won
over the owner's own message and another message's markup could answer.
`authoredScope` moves to passages.js beside `elementById`, which gains a
root argument.
- The undeclared-attribute TypeError is shared by both verbs
(`requireReference`).
- `data-lf-indicated` joins PAGE_PAINT_ATTRIBUTES.
- The `x-refers` $keys entry no longer claims the runtime renders every value
as a followable reference; it names the two verbs and the resolution scope.
- packages.md gains "Following a reference" (scope, key space,
navigateToDatum moved from External or derived data, and "Indicating
(experimental)"), and a behavior module's disconnect duty now includes
clearing its indication.
Tests: new tests/runtime/indication.test.mjs (scope precedence, union and
replace bookkeeping, re-resolution on lf-layout, argument errors) and
test_a_widget_indicates_lines_of_a_code_block_without_moving_the_page in
test_render_widgets.py. No existing test moved.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
reviewed
Sep 24, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The indication paint takes ownership of a target widget’s aria-current state.
An indication wrote aria-current="true" on each marked element and removed the attribute when the mark moved, which erased a target's own state such as lf-toc's aria-current="location". The runtime now writes data-lf-indicated alone; the driver's narration says what the mark means. The runtime test asserts a target's aria-current survives being marked and unmarked, and the browser test reads marked lines by data-lf-indicated only. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Sep 24, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 27, 2026
`indicate()` (`browser/runtime/indication.js`, experimental since #1129) let one widget mark elements in another that it names through `x-refers`. Its only caller was `examples/rust-sort`'s film, which lit the Rust line each step executes in the `lf-code` excerpts beside it, and an inline script on the page scrolled that line into view. This PR removes the API, as Max decided. **What users lose:** rust-sort no longer lights or scrolls to the source line the current step executes. The film, its narration, inputs and commentable parts are unchanged. ## What goes - `indication.js`, its export from `widget-api.js`, the `data-lf-indicated` paint attribute in `page-paint.js`, the default contour in `marks.css`, `lf-code`'s indicated-line face (`code.css` and the generated `theme.css`), the dependency-cruiser entry, the "Indicating (experimental)" section of `module-reading.md`, and the tests of indication itself: its union and per-driver keys, re-resolution on layout, lf-code's indicated face, and rust-sort following the line. - Mentions of `indicate` in the `x-refers` description in `browser/registry.json`, and in comments in `references.js`, `stylesheets.js`, `floating-panel.css`, `annotation-marks.css` and `lf-code.js`. - In rust-sort: the follow-the-line script, the film's `sort-code`, `head-code` and `merge-code` attributes and their `x-refers`, the `sort-step` event that nothing listens to any more, `sort.js`'s `LINES` table and the per-step `line` names it mapped. The collapse() clauses now match by `key` instead of a `c-` line name. `lf-code` keeps `lfElementsFor`, which `navigateToDatum` reads through `addressedElements`. ## Tests kept Some tests that went with `indicate()` also held code that stays. They are kept: - `indication.test.mjs`'s tests of `referencedProjection` (message before page, never another message; a keyed reference in its own scope) move unchanged to `tests/runtime/references.test.mjs`. Its undeclared-attribute test now calls `requireReference` directly. `navigateToDatum` (`anchor-travel.js`) and widget data inputs (`data.js`) both use these functions. - The lf-code excerpt test asserted `lfElementsFor`'s rows through the removed `point()` driver. It now reads `#walk.lfElementsFor(key)` directly: `1507-1550` gives rows `1507`, `1508-1549`, `1550`; `1520` gives the elided row `1508-1549`; `3` gives none. Bug-back, each change reverted after: making `referencedProjection`'s keyed branch ignore scope, making its id lookup skip the referrer's own message, or making `requireReference` a no-op each fails one test in `references.test.mjs`. Making `lfElementsFor` return `[]` fails the excerpt test. ## Protocol bump: 29 → 30 `layer-registry.md`, "Page protocol", says whoever removes a `widget-api.js` export bumps the number, because a vendored module that imports it breaks. That happens here, so `$events.protocol` in `browser/runtime/kernel-registry.json` moves to 30, one past the 29 that #3897 landed with. Main's rust-sort, served by this branch's runtime, fails to start: ``` uv run leaf-dev probe .tmp/base/examples/rust-sort.html --base \ --do 'focus:#sort-film .sort-scrub' --do press:ArrowRight ... --js '<collect [data-lf-indicated] through shadow roots>' base (main runtime): indicated ["while start > 0 && compa…"] worktree: "leaf: page failed to start: The requested module '…/runtime/widget-api.js' does not provide an export named 'indicate'" ``` (`.tmp/base/examples/` holds main's `rust-sort.html` and `rust-sort.page/`, from `git archive`.) With the bump, an older page is re-vendored by the session holding it instead of failing to start. The new rust-sort on this branch starts with no console errors, and stepping the film works. ## Tests run - On the merge with main: `pnpm run check` (runtime 673 pass); `test_render_pages.py -k sort` and `test_code_and_documents.py -k 'sort or excerpt or code_line'` (4 pass) - Earlier: `pnpm run test:runtime` (560 pass), `pnpm run check:browser` (committed bundles match a fresh build) - `tests/browser/test_render_pages.py` and `tests/journeys/test_render_pages.py -k sort` (4 pass) - `tests/browser/widgets/test_code_and_documents.py -k 'excerpt or code_line'` (2 pass; `-k excerpt` re-run after the review fixes) - `tests/model/test_interact_product.py`, `test_product_page.py`, `test_interact_layer.py`, `test_claims.py`, `interact_contract/test_layer_contract.py`, `test_registry_door.py`, `test_data_contracts.py` (447 pass) - `tests/model/test_interact_document.py -k declared_attribute` (1 pass) Not run: the full suite. Rust-sort's first screen changes (on main, the film's first step lights `while end > 0 {` in the source pane), so the landing pass ran `wt refresh-previews`, which recaptured every catalog still from this tree after its last merge of main and moved the `leaf-assets.json` pin and the README's image URLs to `max-sixty/leaf-assets@6ad7cc888`. Started from the survey's commit `a4fff17e0` on `grind/s-maintenance-survey`, rebased onto current main with the kernel rebuilt. On top of it, this PR removes the rust-sort leftovers the survey kept (attributes, `x-refers`, `sort-step`, `LINES`), fixes the page's description and lede that still said the source "follows along", and bumps the protocol. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.
One widget can now point at part of another: an animation marks the source lines it is executing in a code block beside it, without either widget naming the other's tag. Experimental.
indicate(owner, attribute, key)joins the widget API besidenavigateToDatum. It marks the elementskeyaddresses under the widget thatowner's declaredx-refersattribute names, replacing what that owner last marked there;nullclears. The runtime paints the union of every driver's elements withdata-lf-indicatedand nothing else, leaving a target's own ARIA state (such aslf-toc'saria-current="location") alone, so one driver never clears another's mark, and resolves standing indications again onlf-layout. It never scrolls, focuses, reveals, hydrates or announces, and nothing is logged or published: it is browser state, like hover. A driver clears its indication indisconnectedCallback. It is marked experimental in its module header and in the packages.md subsection heading, and kept out of SKILL.md and author guidance.lf-codeanswers in itshigrammar (lfElementsFor("3-5,8")), states its rendered lines withlayoutChanged, and draws an indicated line with an accent gutter bar, number and wash, distinct from anhiline. marks.css carries a zero-specificity accent outline for any other target.Contract changes:
x-refersverbs:addressedElements(source, key)asks the target's optionallfElementsForhook, else a registered visual part id, else a projected datum key.navigateToDatumtravels to the first element it returns, so it now also reaches visual parts and hook-addressed parts.referencedProjectionresolves in the owner's own authored document first, then the page'smain, matching the server's request check (thread markup before page). It used to search the whole document, so a page element won over the owner's own message.authoredScopemoves to passages.js besideelementById, which gains a root argument.TypeErroris shared by both verbs (requireReference).data-lf-indicatedjoinsPAGE_PAINT_ATTRIBUTES.x-refers$keysentry no longer claims the runtime renders every value as a followable reference; it names the two verbs and the resolution scope.navigateToDatummoved from "External or derived data", and "Indicating (experimental)"), and a behavior module's disconnect duty now includes clearing its indication.Tests: new
tests/runtime/indication.test.mjs(scope precedence, union and replace bookkeeping, a target'saria-currentsurviving a mark, re-resolution onlf-layout, argument errors) andtest_a_widget_indicates_lines_of_a_code_block_without_moving_the_pageintest_render_widgets.py. No existing test moved.Exercised on a page-authored driver and target as well: a merge-sort film marking named lines across two quoted Rust functions through a page element's
lfElementsFor, with the mark following playback, the page holding still, and removing the film clearing the mark.🤖 Generated with Claude Code