Repository navigation
Have lf-code place the line it follows at once, without the glide and the rest - #6896
Conversation
…requests as invoker commands
…position, move invoker docs
# Conflicts: # browser/runtime/check-api.js # src/leaf/structure.py
… type the docs' invoker button
Each bound reader read one page-wide signal, so every arriving producer made every reader resolve its name again: producers times readers on load and on a revision. The signal is now kept per name (an id, or a keyed member's unique attribute), and an arrival or departure moves only the names the element answers to.
A reader copied and compared every output it reads on each change its producer said, so a large value held beside one that changes often cost each reader its whole size per change: 5.8 ms a drag step with 10,000 events beside a selection. A producer holds a new value to change one, as the shipped text already asked, so the object it held at the last reading is now taken as unchanged without reading into it (0.05 ms). A value that cannot be copied names its producer and contract.
A reference typed by a package's role table went earlier on this branch; a plain
reference then accepted any element, so lf-call-diff's diff could name a heading and
its links went nowhere. A reference now says what kind of target it needs in the
vocabulary a reader's input already uses: {contract} names any widget holding a value
of that contract, whatever its tag or package. lf-call-diff declares file-list.
The shipped text says how a module sends a request no button makes, with its element as the command's source, and how the target refuses one so the asker hears it. A browser test holds the two-package pair reading the recorded pick in an exported file.
lf-call-diff never reads its target's file-list: it sends the user to patch lines by keys only lf-diff answers, so a file tree holding a file-list passed the check and every link would have failed. Every reference that crossed packages in the trials read a value, which the reader's contract-bound input already types; the field had no other consumer. A reference names any element again.
Ports experiment 93b7128 onto the output rule: the film holds the slice.rs lines its step runs as its `playhead` property and says `change`; each lf-code names it in `for` and reads it through an `x-data` input of the `source-lines` contract, which the default package declares. - lf-code becomes a LeafElement, since Leaf hands inputs only to LeafElements; its source draw is the update's completion, replacing the pending-task event. It marks the rows the playhead addresses (`data-lf-at`) and glides the first to the middle of the box scrolling it, never the page. A line the playhead leaves at the next value moves nothing unless the playhead returns within two values or rests 500 ms. A press, wheel, touch or key inside the box stops the following, and one on the followed widget starts it again. Over the film's minute at its default speed the pane moves 42 times, where bringing each line in at the nearest edge moved it 179. - A data body's `<pre>` is now its `value`, as a `<textarea>`'s text is, rather than its one input's text: a data widget may take inputs besides `value`, which leave the `<pre>` alone (element-data.js, page check, registry check). lf-code could not take a playhead otherwise: page check refused its `<pre>` once `for` bound, and Leaf set the playhead to the code's text where nothing bound it. - `scrollIntoView` bounded `within` a box now places the destination there at `block` with `behavior`, as a reading region does; every existing caller passes nearest with no smooth scrolling, so none moves differently. `scrollersOf` joins portable-api.js, and `alreadyShown` moves there from widget-api.js. - The film's timeline cursor, which held the name `playhead`, is `timeHead`. Behavior changes: lf-code is a LeafElement on every page; a data widget's `<pre>` feeds only its `value` input.
…uctions `leaf page instructions --use <tag>` added a contract's instructions only for a tag that reads it (x-data), so an agent writing the widget that holds the value never got what the contract asks of it. It now selects from x-output too. The fixture pair's audience is `producer`, the name the diff, playwright and visual-review contracts already use for whoever supplies a value.
…of inputs Its own document keydown listener failed the register's pin on keydown listeners, and was a second reading of what document-inputs.js already keeps. It now observes that reading (onUserInput, which joins portable-api.js since the clock starts with a plain host's first portable import) and keeps to its four gestures.
Main renamed every registry key (`x-data` to `inputs`, `x-output` to
`outputs`, `x-refers` to `refers`, a tag's attributes under `attributes`),
moved Lit's names to /vendor/lit.js, declared per finding whether it refuses,
and yielded message checks stage by stage. The composition rule is carried
onto that format:
- `refers` maps an attribute to `{}` and nothing else. Main had already
dropped the keyed `{tag, key}` relation, so with `via`, `where` and `owns`
gone the reference schema is the empty object, and the reader's keyed
standing signal in data.js goes with it.
- An input reads the one output of its contract (`reference`, no `output`),
and an output is a property of its element named by `outputs`.
- packages/file-editor, new on main, called `publishOutput`; it now holds its
`files` and says `change`, as lf-diff does.
- `shows-reference` holds only that the attribute is one `refers` declares,
since a reference has one shape.
- The work-role check reads `attributes` and `verbs`; its finding words name
them. The command-hub test composes the example as a layer, since a verb now
needs its module.
- module-input.md keeps main's text: it stands 13 characters under the
30,000-character cap, so the pointer to invoker commands this branch added
there is dropped; package-data.md, which owns the topic, keeps it.
- The typed-reference advice and its two tests, new on main, are removed with
the relation they advised on.
The lit line is carried onto main's declaration format and main's reworked code block: - lf-code declares `inputs.playhead` and `refers.for`; the film declares `outputs.playhead`. The `<pre>` rule reads `inputs` and `content`. - Main names a block's language by `<code class="language-…">` inside the `<pre>` and gave lf-code a notes toolbar; both stand with the block as a LeafElement, and rust-sort's three excerpts keep `for="sort-film"`. - The lit line's colours use main's prefixed tokens (`--lf-accent`, `--lf-accent-tint`). - module-input.md keeps main's text, 13 characters under the size cap; that `onUserInput` loads off Leaf is said in module-scroll-and-motion.md, beside the other helpers lf-code follows a playhead with.
The review bot found the sentence still naming only `inputs`, against package-data.md and `instruction_selection`.
Six authors writing package pairs from the references found no route: `package check` reads one package, and `page init` refuses a page inside one. A page outside both that selects them by path takes the pair, and its render check draws it; run on the two fixture packages.
…ents here The review bot's finding: the header tied a default-package widget's rules to one example's numbers. Brought in at the nearest edge at each line, rust-sort's film moved its source pane 179 times in the minute its 453 steps play at the default speed, and the three rules bring that to 42. A one-step visit lasts 225 ms at the film's default speed and 450 ms at 1x, which REST (500 ms) outlasts; followed, each such visit took the pane away and straight back.
lf-code's instructions gained the `for` input on this branch, so `source-code-readable/lines-follow-a-widget` asks an author to make an excerpt show the line a page-owned stepper is on. Scored on 21 November against `fable-composition`, three samples an arm on Claude Code: 3/3 with the new instructions, 0/3 without. Every base author gave the stepper a `for` naming the excerpt and reached it from the stepper's module. The three other lf-code contexts of the task (`source-code-readable`, `tool-output-json`, `markdown-syntax`) passed 8/9 on head and 9/9 on base; the one head failure filled values the report had elided and used no lf-code. All 24 authors ran `leaf page instructions --use lf-code`, and none of the 18 ordinary code blocks gained a `for`. The three passing replies were installed as real pages: `page check` and one `page check --render` exit 0, and stepping each in Chromium marks the lines the stepper holds at every step.
# Conflicts: # browser/registry.json # browser/types/contract.d.ts # skills/leaf/references/package-data.md # src/leaf/findings.py # src/leaf/registry/widgets.py # src/leaf/validation/instances.py # tests/model/interact_contract/test_registry_door.py
# Conflicts: # browser/runtime/landing-scroll.js
# Conflicts: # browser/registry.json # browser/types/contract.d.ts # tests/model/test_interact_layer.py
…ing or reading the reader's hand A trial for a decision, not a change agreed to land: it swaps the follower #6008 gave lf-code for the simpler one built on widget-state-experiments (#6690), so the two can be measured on one tree. The follower. When the first marked line stands outside a band of the box that scrolls it, from 15% of the box's height to 70%, lf-code sets the box's scroll at once so the line stands a third of the way down. It no longer glides the line to the middle, waits 500 ms for the playhead to rest, or reads the reader's press, wheel, touch and key through `onUserInput`. Behavior that changed for the reader, and a recorded decision this reverses: - Once the reader has scrolled the pane, a marked line out of their view leaves the pane where they put it, as before. Following starts again at the first marked line that is in their view, where before it started again at their hand on the widget `for` names. The header had recorded that alternative as rejected, since it takes the pane from a reader who scrolled up to read as soon as the film lights a line beside them; this commit removes that statement with the code it described. - A press, key or touch in the pane that leaves a marked line in view no longer stops the following. - The pane jumps where it glided, and moves for a line the playhead leaves at its next value. What the resting follower alone needed, removed: `block` and `behavior` for a `within` box in `scrollIntoView` (landing-scroll.js), and `alreadyShown` and `onUserInput` as portable-api.js exports; both go back to widget-api.js, where lf-trace reads them. `scrollersOf` stays in portable-api.js, since the simpler follower also asks which box scrolls the line. The test `test_sort_source_lights_the_line_each_step_runs_and_holds_under_the_reader` keeps the line lit, in view, with room round it, the page unmoved and the pane held where the reader scrolled it. One assertion changed: after the reader steps the film with the pane scrolled away, the pane now stays with them, where it came back to the line. The test then has the reader scroll the lit line into view and step once, and asserts that a seek to a far line is followed again. Measured on this tree against a0c53fb (#6008's branch), the default film playing its minute at 1440x900 (`leaf-dev probe rust-sort --base a0c53fb --journey play.py`): in Chromium the pane moved 116 times over 97,196 px with the lit line in view the whole time, against 42 moves over 42,121 px, 76.0% in view and 667 ms longest hidden; in Firefox 116 moves over 98,467 px against 42 over 42,589 px. Stepped by key 60 ms apart, both lit the right line at all 451 steps; the line was in view at 451 against 398.
# Conflicts: # browser/runtime/portable-api.js # packages/default/widgets/lf-code.js # tests/browser/test_render_pages.py
…der's hand in the pane A second trial for the same decision, on top of the first. The first swap (191b58a) followed every line and stopped only once the reader had scrolled the pane and the mark was out of their view. A journey of the reader's hand (`.tmp/trial/hands.py`) showed what that takes: with the film playing, a reader who wheeled the pane to its top had it taken back 429 ms later, and one who clicked a line or pressed a key in it was followed on, 21 and 17 moves in the seconds after. This variant keeps the first swap's placement: when the first marked line stands outside 15% to 70% of the box that scrolls it, the block sets the box's scroll at once so the line stands a third of the way down. It takes #6008's rule for the reader's hand back in place of the first swap's own: a press, wheel, touch or key inside the box stops the following there, and the reader's hand on the widget `for` names starts it again. The header's record of the rejected alternative, following again once a marked line came into the reader's view, returns with it. The 500 ms rest, the glide and the `block`/`behavior` handling for a `within` box in landing-scroll.js stay out. The hand is read through `onUserInput` rather than listeners of the widget's own. The boxes whose input matters are an ancestor pane and another widget's element, neither of which lf-code owns, and three excerpts share one pane, so listeners of its own would be capture listeners on other owners' elements, kept per box and removed at disconnect. `onUserInput` is the document's one reading of the reader's inputs (module-input.md names it for a surface that must stop moving at a gesture). It hears each input on the window in capture, before a handler in the page can stop the event, and on a plain page too. It replaces the first swap's comparison of `scrollTop` with where the block last put it, which read any other scroll of the box as the reader's. So `onUserInput` stays a portable-api.js export, as on main, and the widget's `followed` record goes. Against main the core runtime differs by `alreadyShown` standing in widget-api.js rather than portable-api.js, since only the resting follower read it from a portable widget, and by landing-scroll.js without the `within` placement (+8 -11). The test keeps every assertion main's has, the press on the film that brings the pane back included; its docstring and one comment say "into view with room round it" where they said "to its middle".
# Conflicts: # browser/runtime/widget-api.js
… line A playhead value naming a line in an excerpt the page doesn't render moved the pane the excerpt stands in. Such a row has no box, so the follower read its place as the window's corner and set the pane's scroll from that. With one excerpt of rust-sort set to `display: none` and the pane following, each value naming a line in it moved the pane 341 px (`.tmp/trial/edges.py`, Chromium, reduced motion); with the excerpt under `content-visibility: hidden`, as Chromium leaves a closed disclosure's contents, one value took the pane from its top to its end, 1,753 px (`.tmp/trial/below.py`). `#follow()` now asks the browser whether the row is rendered (`checkVisibility`, browser/AGENTS.md, "The browser answers first") before it looks for the box that scrolls the row, and returns where it isn't. Both journeys now read 0 px a value. Main's resting follower has the same defect, 479 px a value in the first journey; this commit changes only the trial variant. The test hides the last excerpt while it stands below the pane's view, lights a line in it and asserts the pane's scroll is where it was. Without the fix that assertion read 270 against 0.
leaf-agent
left a comment
There was a problem hiding this comment.
One behavior change the description doesn't mention: the playhead's first value now scrolls the pane at load (inline).
…nothing The trial variant set the pane's scroll for the first playhead value a block received, where main's resting follower only marks it. A widget that finishes loading moves nothing the reader reads (browser/AGENTS.md, "The page holds still under the user's aim"), and with reduced motion rust-sort's film doesn't play itself, so that move would come at load with no gesture. On rust-sort the move didn't show: the film's first value reaches each block before its lines are drawn, so there was no row to bring into view, and the draw only marks. That order is a race between two modules' loading, not a rule. Handed its first value after its lines were in, a block scrolled its pane: in the test below, from 270 to 1831. `#follow()` now keeps whether the playhead has had a value (`#arrived`), which stands for main's `#moved === null`, and returns before placing the line when it hadn't. The check stands after the block registers its pane, so the reader's hand there counts from the first value on. The test appends a block below the pane's view, hands it a line as a plain host does, and asserts the line is marked with the pane where it stood; a second line is then followed into view. The film played for its minute in Chromium reads as before: 116 moves over 97,196 px with the lit line in view the whole time.
… line there A code block counted the reader's hand in its pane only once it had followed a line there, because it listed the pane as one to hold at its first follow. A reader who scrolled the source pane before rust-sort's film played had it taken at the film's second line: the pane went from 900 to 1728 in Chromium and to 1764 in Firefox on main, and stays at 900 here in both. The block now keeps which of the reader's gestures last had their hand on or inside each element, and follows unless their hand was in the pane after it was last on the widget `for` names. That replaces the list of panes and the list of panes each followed widget restarts, so `lf-code.js` goes from 456 lines to 444. Behavior that changes: a hand on a followed widget restarts the blocks that name it, where it restarted every block in the pane. The test's arrival case, a plain block with no `for`, relied on the old sharing, so it now runs on a freshly opened page.
…current API Main's follower is still the resting one #6008 landed; it moved its imports to the library and landing-scroll.js gained a glide's aim (#6904). Three files conflicted, each resolved to main's text with this branch's change made again: - packages/default/widgets/lf-code.js: main's imports, with `alreadyShown` and `scrollIntoView` dropped. `setScroll` left the package API (#6951), so the follower writes the pane's scroll with the browser's own `scrollTo`, asking `scrollMoves` (lib/scroll-range.js) first, as module-scroll-and-motion.md asks of a writer that may name the position its box holds. A line out of the band at an end of the pane is such a write. - browser/runtime/landing-scroll.js: `innerMoves` loses its `block` again and a `within` box lands at once, nearest. The glide's aim (`landingAim`) and the boxes a landing steers ask `innerMoves` without it. - browser/runtime/widget-api.js: main's exports, plus `alreadyShown`, which portable-api.js no longer exports and lf-trace reads. skills/leaf/references/module-scroll-and-motion.md merged clean and named `setScroll`; it names `scrollTo` now.
leaf-agent
left a comment
There was a problem hiding this comment.
With within, scrollIntoView now ignores block and behavior: every box inside it, within included, reveals the item at the nearest edge with an instant move (innerMoves always passes "nearest", and land is called with "instant"). The reference paragraph still opens with scrollIntoView(target, {block, behavior}) and now says nothing about within dropping them, so a package author who passes {block: "center", behavior: "smooth", within: list} gets a nearest jump with no warning. Every caller in the tree passes block: "nearest", so the code is fine. Only the reference misleads, and the inline suggestion fixes it.
…nd behavior
The review of this pull request found the scroll reference still opening with
scrollIntoView(target, {block, behavior}) while a landing given within now reveals
the item at each box's nearest edge at once. Every caller in the tree passes
block: nearest, so only the reference misled.
Co-Authored-By: Claude <[email protected]>
lf-codenow places the line it follows at once, a third of the way down its pane, whenever the line leaves the pane's middle band, in place of gliding it to the middle and then resting half a second. As on main, the first value a block is handed only marks its line, since an arrival moves nothing. It still stops when the reader scrolls, clicks or presses a key in the pane, and follows again at their hand on the followed widget, read throughonUserInputas before. The lit line is then in view all the time the film plays, where the resting follower had it in view 76% of the time and hidden for up to 0.7 s.What it removes: 45 lines of
lf-code.js(490 to 445), the 500 ms rest and its timer, and theblockandbehaviorhandling for awithinbox thatlanding-scroll.jscarries for this one caller, in the three places it now passes them.alreadyShownleaves the portable exports and is one line inwidget-api.js, wherelf-tracereads it. The follower writes with the browser'sscrollTo.It also fixes two defects main's follower has. A playhead value naming a line in a code block the page isn't rendering, as in a closed
<details>or an unchosen tab, moved the pane by hundreds of pixels a value (0 to 1783 for a closed<details>); the follower now askscheckVisibilityfirst and leaves the pane alone. And a reader who scrolled the pane before the film had run a line there had it taken at the film's second line, because a block listed its pane as one to hold only at its first follow: on main the pane goes from 900 to 1728 in Chromium and to 1764 in Firefox, and here it stays at 900 in both. A block now keeps which of the reader's gestures last had their hand on or inside each element, and follows unless their hand was in the pane after it was last on the widgetfornames. That replaces the two lists of panes.To weigh. The pane moves 116 times in the film's minute against 42, about 2.3 times as far, and each move is a jump where the resting follower glided. A reader who Tabs into the pane, which neither follower counts as a hand in it, is followed 14 or 15 times in 5 s against 3 or 4. A hand on a followed widget now restarts only the blocks that name it, where it restarted every block in the pane; rust-sort's blocks all name the film. This is a choice about how the pane moves, and Max chose this follower on 24 November after watching both.
Tests. The browser test gains a playhead naming a line in an unrendered block, which main's follower fails, and a wheel in the pane before the film has run a line, which this branch's earlier commits fail; that second assertion reads before main's follower ends its rest, so it does not catch main's. Its arrival case, a plain block with no
for, relied on the film's press restarting the whole pane, so it now runs on a freshly opened page; the other assertions are unchanged. Measured again on the merge with main at fdb4ffa, in Chromium and Firefox at 1440×900: the page never moved, and after a wheel, a click or a key in the pane the follower made 0 moves. Stepped by key in Chromium, the right line was lit and in view at all 451 steps, against 397 on main.pnpm run check:browserandpnpm run test:runtimepass.