Repository navigation
Port lf-options to Effect UI as the first decorating widget - #7417
Conversation
lf-options and each lf-option now draw Leaf's controls in shadow roots of their own, with the author's options shown through a slot. The light DOM keeps only the page's record: `selected`, the options each `add` creates, and `hidden="until-found"` under a closed settled group. The theme restyles the controls through shadow parts (`mark`, `key`, `ref` on an option; `cell` with `settled`, `another` or `done` on the group's cells), and styles/options-shadow.css holds how one control stands against another inside a root. The module header states the pattern for lf-tabs and lf-board. Shared changes: defineWidget takes `properties` (host-set props, as `state` is) and `statics` in place of `lfPatch`, and says lf-commands on the element; widget-services adds TakeBack and RememberForTab; controls.js exports offerAttributes and selectableAttributes; the effect-ui entry exports Mount, Queue and Stream. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V22NWd3erndyoj2G9LEP7y
leaf-agent
left a comment
There was a problem hiding this comment.
tests/browser/test_render_options_settled.py::test_a_reconnected_settled_obligation_restores_its_comparison_reading fails on this head and passes on main. I ran it twice on 491bb41 and on the merged tree, with the same result each time: TypeError: Cannot read properties of null (reading 'textContent') at the detached-paint assertion. Once #views is removed, defineWidget's disconnectedCallback closes the group's root a microtask later, so the detached #transport shadow root holds only its <style> and no .lf-settled-diff. The selector change in this PR can't find a drawing that's no longer there.
#2376 added that assertion to show that a detached consumer stops following the comparison. Closing the root on disconnect now guarantees that, so the assertion no longer protects anything. With it removed, the reconnection half passes locally: the settled row comes back, with no stale Δ and the tab's count cleared. The inline suggestion drops it.
Separately, #7395 and #7397 each add their own properties option to defineWidget in effect-widget.js. #7397 also adds members, and both keep a value set before the element upgraded, which this version doesn't. Whichever lands first sets the shape. The others then rebase onto it rather than merging a second version. For lf-option the pre-upgrade case doesn't arise, since it is defined before lf-options in the same module.
…w tree - lf-option gets its own module (widgets/lf-option.js) and `shadow` in the registry, so the page's readings, Go-to's controls among them, search its root. - Preview hears a pointer's arrival from `pointermove` too: the platform sends the document no `pointerover` for a move between two nodes of one shadow tree, so Add showed no preview from the add field. - defineWidget moves a property set before the tag upgraded into the props, so a group in a thread message tells its options their faces. - The group keeps its added options and their marker across remounts, the settled row names the options it controls as elements (`ariaControlsElements`), and the add field's words remember the user's own pick rather than every projected one. - Tests read option internals through their shadow roots; the press reader counts `selectableAttributes`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V22NWd3erndyoj2G9LEP7y
defineWidget takes main's `properties`, and its own version goes. The group keeps its tab state with main's `KeepInTab`, and `statics` replaces the `lfPatch` option, lf-motion's call included. Before the module defines a group, the reserve for Add and Done stands, keyed on `:defined`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V22NWd3erndyoj2G9LEP7y
leaf-agent
left a comment
There was a problem hiding this comment.
The code looks ready. The description doesn't yet: the squash merge makes it main's commit message, and three of its claims no longer match the diff since the rebase onto #7395 and #7397:
- "The settled row has no
aria-controls" no longer holds.#controls()inlf-options.jssetsrow.ariaControlsElementsto every option, added ones included, andtest_a_settled_obligation_reconciles_added_options_into_its_disclosurechecks that. The row keeps its relation to the options, now through element reflection. - "Shared modules changed" lists changes this PR no longer makes.
propertiesondefineWidget,offerAttributes/selectableAttributesincontrols.js, and theMount/Queue/Streamexports inentry.mjsare already onmain. Ineffect-widget.js, this PR's changes are nowstaticsreplacinglfPatch,lf-commandsdispatched on the element, and moving a property set before upgrade into the props. - What's new in this push is missing.
lf-optionis its own module with a declared root, andpreview.jsnow treats apointermoveonto a new node inside a shadow tree as an arrival. The second changes hover previews on every page, so it belongs in the message.
A promise that read the add field off the document never resolved, which hung the card-seats test. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V22NWd3erndyoj2G9LEP7y
Giving lf-option a module made the page reading treat it as opaque, which fences every child, so a quote in an option lost its neighbours and its section. The option writes nothing between its light children (its controls stand in its shadow root), which is what `verbatim` declares. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V22NWd3erndyoj2G9LEP7y
…7433) <!-- claude-projects-attribution: {"github_login":"max-sixty"} --> _Requested by **Maximilian** · [project thread](https://claude.ai/code/project/chan_01HAT2svakg1fTA5kitqhX9w?thread=cmsg_01HAT2svakg1fTA5kitqhX9wERfAJinBvZtiP4jvQpWkPy)_ Converts the rest of the runtime that the Effect UI port doesn't hold to TypeScript, following #7429: - dom, readings, records, features, host and annotations - the top-level modules age, bootstrap, check-api, prepaint, stage-integration, validation and widget-api These stay JavaScript: - the port's modules: `dom/box-motion`, `dom/css-anchors`, `annotations/annotation-overlay/`, `effect-widget`, `widget-services` and `portable-api` - `annotations/preview.js`, until the port's #7417 lands **What runs doesn't change.** With comments ignored, each compiled `.js` parses to the same program as the JavaScript it replaces on main, apart from two modules: - `records/thread/address.js`: `claim` is now an arrow, which carries the type a JSDoc `@type` gave the function. Nothing calls it before its definition. - `host/state-application.js`: the copy-on-write of the authored and descriptor maps goes through one `writable` helper. It copies on a reading's first write to a map, as before. Other changes: - A class declares each field it assigns as `declare x: T`, with the type TypeScript inferred from the JavaScript. The strip erases these declarations. - A type is exported only where another module imports it, in this batch and in #7429's modules. - The `.ts` files carry #7426's changes to `bootstrap`, `prepaint`, `records/carry` and `host/application`, merged in at the TypeScript level. Checks run: - `tsc` over `browser/types/tsconfig.json` and both Worker projects - `check:browser`, `test:runtime` (1199 pass), `test:browser`, `test:worker` - `tests/model`: all pass except the bound-file permission test, which fails when the suite runs as root - every pre-commit hook on the changed files An independent review of the conversion found no behaviour change, and its type-level and doc-comment findings are fixed here. --- _Generated by [Claude Code](https://claude.ai/code)_ Co-authored-by: Claude <[email protected]>
main now compiles preview.js from preview.ts, so the change lives in the source; the Python files take ruff format. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V22NWd3erndyoj2G9LEP7y
… and member sets draw (#7434) Four fixes to the Effect UI adapter's foundations, found while reviewing the Effect UI work. - **Production build.** `build/vendor.mjs` set no `production` condition, so `@effect/ui`'s `#dev` and `#hot` imports resolved to its development builds: every page with an Effect UI widget shipped the hot-reload and devtools code, and each mount read `sessionStorage` and scanned every live root. The row now builds with `conditions: ["production"]`. `/vendor/effect-ui.js` drops from 595,034 to 580,769 bytes (196,227 to 190,967 gzipped), with `Scheduler` added to its exports. - **Scheduler.** A gesture's Command ran in the gesture's task only because the scheduler `Effect.runSync` creates for each mount stays in the root's context, which keeps Effect UI from installing its time-sliced `HtmlScheduler`. Mounted with `runFork`, a probe's Command ran eleven tasks later behind 50 ms of other roots' work. `defineWidget` now provides a synchronous `MixedScheduler` itself, so the timing is the adapter's choice (`BrowserHost.mountEffect`'s docs name this as supported). - **Members.** A member set before the element connected was dropped, and one set before the tag was defined left an own property hiding the accessor, so a page that set `lf-motion`'s `currentTime` before the study connected lost the seek. The adapter now holds the message for the next root, as it already kept early `properties`. A member set also announced no `pending-task` or `lf-commands` for the redraw it causes; it now draws the way a set of props does. On a shadow widget, `lf-commands` still leaves from the shadow root, where Leaf ignores it; #7417 moves it onto the element, so this leaves that line alone. - **`lf-motion`'s entry** promised that a seek draws its frame synchronously, which the widget's port (#7397) stopped doing. Nothing that seeks relies on it, so the entry now says the widget draws the latest time's frame before the next frame. Nothing a user sees changes. #7417 also edits `effect-widget.js`, in other lines. Tests: `pnpm run test:runtime` (1,201 pass; the two new member tests fail without the fix), `pnpm run check:browser`, and the tally (`test_a_tally_counts_its_regions_obligations_and_walks_them`), timeline and motion browser and journey tests. Codex reviewed each commit; its findings are folded in. > _This was written by Claude Code on behalf of max-sixty_
…ther tab moves them (#7425) A widget's declaration now lists, under a new key `facts`, the static functions of its class whose values the page keeps, each with the JSON Schema of its value. Each act and undo carries the values as `facts`, replacing the top-level `answered` from #7325. Where the widget's state or markup moves without a gesture of the tab's own (a version, a `restated` mark, another tab's act), a tab showing the newest version works the facts out again (`host/widget-facts.js`) and posts a new bookkeeping event, `facts`, with the values that differ from the kept ones and `through`, the seq of the reading it worked from. It wakes no one. The server keeps each widget's latest values, lapses them when a version restates the widget's decisions, reads `answered` from them, serves them per view, and `leaf page state` shows them on each element. A widget that declares `awaits` must list `"answered": {"type": "boolean"}`. Page protocol 63. This closes what #7325 left open: a checklist given a new step asks again with its decided steps kept, and restating a picked option of a `multiple` group after Done asks again. When two tabs act at once, the page takes up the word they agree on once one tab reports it, if that word reopens the question. If they agree it is answered, the question asks until Done is pressed again (first rule below). Rules that keep a stale word from overriding a fresh one (`obligations.widget_facts`, `event_contracts._facts_event_error`): - A `facts` event may say a question is open again but never that it is answered (`obligations.told_facts`): an answer is the user's act, and its word travels on that act. So when a version restates the pick the user made in place of an earlier one, and the earlier pick decides the widget again as it did before this PR, the question still asks. The cost is a question that asks until Done is pressed again, although every tab works out that it is answered. Two cases reach it: - A version removes the one option Done didn't cover. - Tab B picks a and presses Done on {a, b}, while tab A, which has seen neither act, picks a. A's act lands last carrying `answered: false`. Every tab then works out true, `told_facts` drops that word, and the question waits on Done again. - A gesture or undo made on a version older than the one the kept facts were said on leaves those standing, so a tab still on v1 can't answer a question v2 reopened. An undo now names the revision it was made on (`revision`, optional on the record), as an action does. - Admission refuses a `facts` event naming an older revision, or worked out before a gesture or another word on the widget landed (`stale-facts`), so a word sent just before a press can't land after it. It also refuses one that changes nothing, so tabs that agree leave one event. A tab says a word again only after such a refusal, once the widget moved, or after a send that never arrived, and it looks at a widget again when a reading, a version or one of its own gestures leaving the ledger moves it. What a user sees differently: `lf-options multiple` records on Done the options it covered and the picks among them, and answers only while Done stands on the set the group shows. So a pick the user changes after Done also waits on Done again, where before it stayed answered: a user unpicking after Done and a version taking a pick back leave the same widget state. Worth weighing: Leaf still says `answered` for a class with no `static answered`, so a plain element asks without one. A value stays stale while no tab shows the version that moved it, the cost the C design accepted. Root `AGENTS.md`'s "Responsiveness" is unchanged: a press still answers in its own task. An Effect UI widget lists its fact statics in `defineWidget`'s `statics`, which it assigns to the class as it does `lfPatch`, so lf-options, now on Effect UI (#7417), keeps `static answered` there and `widgetFacts` finds it. `uv run leaf-dev interface --base`: Declaration keys: adds `facts`. Tests: model tests for each case above and for undeclared facts, invalid values and `page state` showing facts; runtime tests for lf-options' rule and `reportFacts`; the browser and journey tests that post events or read answers, obligations or restatements, by node id. > _This was written by Claude Code on behalf of max-sixty_
…7450) <!-- claude-projects-attribution: {"github_login":"max-sixty"} --> _Requested by **Maximilian** · [project thread](https://claude.ai/code/project/chan_01HAT2svakg1fTA5kitqhX9w?thread=cmsg_01HAT2svakg1fTA5kitqhX9wAWrHoDSUn5ogNyh9ijmSrr)_ Two tests have failed on main since #7417 moved lf-options' drawn controls into the group's shadow root. This PR fixes the code behind one and updates the other test. - **The comparison's settled-options view** (`test_a_change_ends_where_a_disclosure_does[settled-options]`). `version.ts` found a disclosure's view through its control's `aria-controls` ids, and searched only the light DOM. The settled row now stands in the shadow root and names its options through `ariaControlsElements`. That left a settled group's options with no view, so a change ran past them. `viewOf` now maps each controlled element to its control and searches shadow roots too (`queryAllUnder`). - **The bare-labels layout test** (`test_a_group_of_bare_labels_reads_as_a_question_about_the_page`). It counted the group's light children, which no longer include the "another" cell the group draws in its shadow root. It now counts the shadow `cell` parts too. **Checks**: both tests pass, in both params of the disclosure test. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01V22NWd3erndyoj2G9LEP7y > _This was written by Claude Code on behalf of max-sixty_ --- _Generated by [Claude Code](https://claude.ai/code)_ Co-authored-by: Claude <[email protected]>
…ermost nodes A second review of 6372e42 found two more defects against the merge base and one cost the branch could also remove. A. A form answers `shadowRoot` with its controls of that name, so a form holding inputs named `shadowRoot` handed a RadioNodeList to `treesUnder`, whose `querySelectorAll` threw and lost the batch. `openRoot` (lib/shadow-tree.ts) now reads the platform's own `shadowRoot` getter, which answers for an element of any window, and `seenRoot` (arrivals.ts) and `declaredRoot` (shadow.ts) read through it. Runtime test: an owner inside such a form connects when the form arrives. happy-dom has no named properties on a form, so the test gives the form the browser's answer as its own; it fails on 6372e42. B. `partScopes` (readings/passages.ts) filtered every live stage for each part, so the page reading cost parts x stages. It now finds a part's declared trees from the part down (`treesUnder(root, declaredRoot)`), and the declared trees under what any of their slots shows, which is what `readingUnder(stage.host, root)` admitted through a slot. It no longer admits a declared stage inside a root that is not a declared stage, whose words the page reading's walk never enters. Runtime test: a part reads the declared tree of a host one of its slots shows; it passes on 6372e42 and fails without the slot step. C. A batch that names nested additions, as a script appending elements one inside the last, walked each record's node, so every later addition was walked again: 992 elements visited for 32 nested elements and 4,032 for 64 on 6372e42. `read` now walks an added node only when none of its composed ancestors is among the batch's added nodes, and likewise a removed node among the removed ones. Runtime test: each of the nested elements' owners connects, and doubling the chain about doubles the elements visited (62 then 126). D. Queries under an element now list the declared roots in tree order, where the merge base listed them in enrollment order; queries of the document keep enrollment order. No caller depends on the order: `queryAllUnder`'s scoped callers filter, map, test with `some` or collect into a set (projection data, a control's label barriers, the ids a change names), `pageQueryAll`'s one `find` asks the document, and the `arriveBatch` owners (reach, code-copy) treat each element alone. No change. E. `matching`'s comment and the arrivals.ts header now say that a closed root is entered only once it is a stage, as `adoptShadowStage` makes one. That function is Leaf's own; `widget-api.js` exports only `shadowStage`, which builds an open stage, so a stage inside a page script's or a package's own closed root is heard only by records of its own. `leaf-dev bench asks document --input click --input key --input tab --input scroll --sizes 256 --rounds 2 --base` (base c21e060, main with #7417), CPU ms at 256, load average 8-22 during the run: asks load 16968 -> 1933, click 64.4 -> 35.4, key 11.1 -> 6.1, tab 39.4 -> 23.6, scroll 13.1 -> 5.0 document load 550 -> 588, click 20.8 -> 21.4, key 7.9 -> 7.3, tab 18.4 -> 16.9, scroll 7.8 -> 7.1
…#7446) Leaf's runtime found the shadow roots ("stages") it needed by scanning every live stage on the page, so its cost per change grew with how many stages the page holds. #7417, now on `main`, gives every `lf-option` a stage of its own, which exposed it: on `leaf-dev bench asks` at 256 questions (1,024 options), `main` takes 15.5 s of main-thread CPU to load, against 1.1 s before #7417, and a keystroke takes 14.5 ms and a wheel step 13.6 ms against a 12 ms budget. With this change, load is 1.73 s, a keystroke 6.2 ms and a wheel step 5.1 ms. On `main`'s own `prose` and `document` pages it measures no change. - `matching` (`dom/arrivals`) walks down from each added node, through every open root and stage under it, instead of climbing from every stage's host. The walk, `treesUnder` (`lib/shadow-tree`), keeps a list rather than recursing, so no depth of nesting overflows the stack; reach's sweep, the page reading's forgetting of parts and the render checks' `openRoots` now use it too. - `shadowRootsIn` (`dom/shadow`), asked of anything smaller than the document, finds the declared roots among that root's own elements rather than filtering every stage. - The selection capture asks the platform once with no roots, then again with only the declared roots its ends came back beside, instead of handing it every root on every key, wheel step and press. The press check hands it only the selected range's own tree. `pageShadowRoots` loses its last callers and goes. One case answers differently from `main`: a stage inside a closed shadow root that is not itself a stage, which a page's script or a package would have to build. No walk from above can enter a closed root, so moving that root's host no longer re-offers what the stage holds. `adoptShadowStage` would enroll such a root, but `widget-api.js` doesn't export it, so `dom/arrivals` states the limit instead. Scoped queries also list stages in tree order rather than enrollment order; no caller reads that order. And author markup and code that shadow a DOM property reach the walks as they reach every reader of author elements: a form control named `childNodes` hides a selection's end in a stage beside it, and a `shadowRoot` getter that throws runs wherever a walk reads it. A script that builds a deep nest in the document one element at a time costs more than on `main`: 256 nested elements appended one by one in one task deliver in 19.6 ms against 4.7 ms, since each record's walk reads every descendant's root where `main` ran a native query; both grow with the square of the depth. What remains of #7417's load cost is linear, mostly inserting each stage's styles. Found while reviewing the Effect UI work, for which Max asked; Codex reviewed each round. The walks read a host's root as `shadowRoot` answers and keep only a root whose host is that element, so a closed stage a widget hands out is read as before, and a form's control of that name or a root forwarded from a child is not taken for one. Tests: `pnpm run test:runtime` (1,218 pass), `pnpm run test:worker`, `pnpm run check:browser`, and 199 focused browser tests. New tests cover an owner in a stage inside another stage, in a stage behind an open root that is no stage, in a form with a control named `shadowRoot`, and 10,000 nested stages, a closed stage its host hands out, hosts whose `shadowRoot` answers `false` or a child's root, as well as a query under a host made in another window and a press on words in a host that stands first in a table. > _This was written by Claude Code on behalf of max-sixty_
`browser/AGENTS.md` gains "Renderers", which names both renderers (a
bundled widget is a `LeafElement` or a `defineWidget` component, and the
chrome draws with Lit) and the rule Max picked ("Port by the rule
above") on the Effect UI direction review page on 27 November 2026.
Under it, a port deletes the Lit view it replaces, and a service it adds
calls the same owner as its `widget-api.js` function. It names what it
made easier and benches a page full of its widget, base beside head,
within root `AGENTS.md`'s "Responsiveness" budgets. A widget that
decorates the author's children tries a light-DOM part first. The chrome
moves only once `@effect/ui` ships a release whose mount and component
APIs aren't experimental. A widget that can't meet the rule is the point
to stop and raise it. The section replaces the two statements that
prescribed Lit alone, `packages/AGENTS.md` points ports to it, and two
comments that contradicted it change: `lf-options.js` no longer calls
its shadow roots the shape of every decorating widget, and
`build/vendor.mjs` no longer says the chrome draws with Effect UI. The
bench item comes from #7417, which ported `lf-options` without one and
made a page of 1,024 options take 15.5 s to load (#7446 fixed the scan
behind that).
A temporary A/B scored it: headless Opus plans for porting `lf-tabs` and
for moving the Page Map dialog, three runs per arm per task, base text
beside this branch, judged by Opus and corrected by reading the quotes.
Base passed 3/3 on deleting the Lit view, 0/3 on naming what the port
made easier, 3/3 on benching base beside head, 0/3 on trying a light-DOM
part first, and 0/3 on holding the chrome back. Head passed 3/3 on every
one. Every base `lf-tabs` plan took shadow roots, citing the old
`lf-options` header line, and every base Page Map plan went ahead and
rewrote the Lit rule. Every head `lf-tabs` plan found that
`defineWidget` appends its light box after the authored children, where
a tab strip can't stand. Root `AGENTS.md` already sends both arms to
`leaf-dev bench`. The runs cost $23.86.
> _This was written by Claude Code on behalf of max-sixty_
… redraw and focus keys (#7517) #7417 moved `lf-options`' controls into shadow roots. Eight browser tests have failed on every push to `main` since. Three only read light-DOM nodes the port moved. The other four caught real regressions, and this PR fixes those in the code while keeping #7417's design. Each of the eight fails on `main` and passes here; the Back test passes in both Chromium and Firefox. **Regressions fixed** - **A quote landed in the half of a suggestion the user accepted away** (`test_a_label_in_a_retired_slot_leaves_the_page_with_the_slot`). The page reading reset `silenced` at every declared shadow root (`crossed` in `readings/passages.ts`). A retired slot therefore stopped silencing words that a widget inside it draws in its own root. #7417 moved the settled group's "Settled: …" label into such a root, so a comment on those words found them again and painted a mark there. Silence now carries across a declared root, and `settledAway` climbs out of shadow roots (`upFrom`) to find the slot. This rule predates #7417, which only exposed it. - **An option that a revision rewrote lost its mark and its pick** (`test_ideas_shortlist_survives_revision_and_can_reopen`). A revision replaces an option element whose words changed. The group's arguments stay the same, so `GroupLight.show` never reached the new node, which was left with no face, no mark and no `selected`. The group's state still held the pick. The group now draws again on its slot's `slotchange`. It also declares its key rows again, because their closures held the old option node. - **Back returned focus to the option rather than to its mark** (`test_back_returns_to_a_named_control_in_a_message_the_agent_rewrote`). Before the port, the mark was a light child of the option, and a focus key named it by its place inside the option. Now the mark is in the option's shadow root, and `nameIn` collapsed it into the option itself. `records/carry.ts` now looks for that place in the named element's shadow root after its light tree. On the page, such a place still counts only within the revision it was read in. So `test_a_restated_obligation_returns_a_user_to_the_question_not_to_a_control` still hands the obligation back after a revision. I first tried a `data-lf-carry` key on the mark, which broke that test, so I dropped it. **Already correct; the probes now reach the shadow roots** - `test_a_pin_keeps_clear_only_of_controls_the_user_can_see`: its last `button` was Add's submit, which is now in the group's shadow root. - `test_one_key_keeps_one_keyboard_face_across_the_page`: it reads the option's key badge through the locator. The badge's key face still matches the sequence chip's and the target picker's. - `test_a_wide_widget_stays_inside_a_box_that_frames_it`: the row's mark is read through its option's shadow root. - `test_an_obligations_digits_are_drawn_whole`: `CLIPPED_BY` and `INSIDE_ITS_OPTION` (`tests/render_cases_navigation.py`) now climb from the badge to the option that hosts its root. The digits are still unclipped, off the words and on one seat per form. <details><summary>Other checks</summary> - `pnpm run test:runtime` passes, and so does `pnpm run check`. - `tests/browser -k "option or obligation or pick"` passes, as does `-k "back or forward or carry or history"`, apart from `test_design_mode_reads_each_shape_of_control_into_the_anchor_its_routes_carry`. That one fails the same way on `main` at this run's base, which predates #7493's repair of it. - `-k "retired or settled or suggestion or revision"` shows two teardown errors (`unchanged write: aria-expanded` on the margin's More face, in `test_suggestion_actions_stay_reachable_through_a_decision_and_its_undo` and `test_a_decision_undone_leaves_every_suggestion_pin_where_it_stood`). Both also fail on `main` without this change. </details> Closes #7494 — automated triage --------- Co-authored-by: leaf-agent <[email protected]>
…ith repeat instead of keyed (#7541) #7420 drew the floating panel's stage with Lit's `keyed`, keyed by the opening, so each opening gets a fresh view node. When the key changes, `keyed` resets the part's committed value to a sentinel before the new value commits (`lit-html` 3.3's `directives/keyed.js`, also on Lit's `main`). So the old template instance never leaves the part's set of disconnectable children, and the `ref(declareView)` on that view keeps the whole closed view alive. Every view the panel drew stayed in memory. Opening and closing the versions menu kept about 61 nodes and one listener per round trip, which the closed-surfaces journey of `test_page_fixture_renders` reported on 50 corpus pages. The stage now draws a one-item `repeat` keyed by the opening, the primitive it used before #7420. `repeat` disposes the old item's part. Each opening still draws its view in a node of its own, so nothing the user sees changes. A comment at the site says why `keyed` isn't used there. **Verification** - `test_page_fixture_renders[alert-thresholds]` fails at the base with `the versions menu leaks nodes: [5302, 5363, 5424, 5485]` and passes here. `[feature-gallery]` passes too. - `[alert-review]` loses the leak finding but still fails on a resize finding that bisects to #7417. #7538 doesn't fix that one, so I filed it as #7540. - In an isolated probe on `alert-review`, six versions-menu round trips held 6613 → 7240 nodes at the base, and stay at 6878 here after the first trip. - `pnpm run test:runtime` (1237 pass), pre-commit, and 25 focused panel, Go-to and On tests pass. <details><summary>How the retainer was found</summary> I diffed two heap snapshots, taken around one round trip once the test harness had drained its own input records. Every old `.lf-fp-view[data-lf-route="versions"]` was retained by the panel's root part: `_$committedValue` → stage `ChildPart._$disconnectableChildren` (a `Set` that grows by one template instance per opening) → the instance's `ElementPart` → the view `<div>`. Other `keyed` sites in the tree (`records/thread/messages.js`, On's regrouping in `floating-panel.js`, `lf-diff`, the Playwright timeline) leak the same way only where a `ref` or another async directive sits under the key, and only when their key changes, which is far rarer than a panel view change. I left them alone. </details> Closes #7526 — automated triage Co-authored-by: leaf-agent <[email protected]>
…eview and render gate (#7538) #7417 moved `lf-options`' controls into shadow roots. Two readers still walked only the light DOM, and one test read the old shape. Three scheduled journeys have failed since. Each fails on `main` at `6313a6f59` and passes on this branch. #7417's design stays as it is. **Regressions fixed** - **A link preview of an option group listed no options** (`test_a_link_into_the_page_previews_where_it_points`, Chromium and Firefox). `membersPart` in `annotations/place-preview.ts` read the group's members through the page reading, which now enters the group's declared root. That root holds a single `display: contents` wrapper, so the preview found fewer than two like members. It then read the group as plain content, with no option marked chosen. A widget's members are its own children: the elements its answer names, whether it draws them in place or through a slot. The preview now reads those children. - **The render gate stopped seeing controls inside a widget's shadow root** (`test_the_render_gate_reads_a_page_that_scrolls_sideways_only_between_viewports`). `clippedControls` (`render-checks/reachability.js`) queried `document` for `[data-lf-offer]` and climbed by `parentElement`. It therefore missed every option mark, and an option row clipped by a fixed-height card showed up only as `clipped-content`. The check, which `page check --render` runs on agent pages, now collects offers from every open root (`openRoots`) and climbs the tree as it is drawn (`renderedParent`). It also reads a closed disclosure's summary as drawn (`renderedUnder`), so a clipped offer a widget draws in the summary's shadow root is reported, as a new browser test checks. The test expects `clipped-control` again. The 13 shipped examples that hold an option group raise no new `clipped-control` finding. **A test reading the old shape** - `test_an_aimed_press_does_only_what_the_outline_promised[ship-review]` reached its `existing mark` path by aiming at the group's Add field. That field now sits in the group's shadow root. `AIM_POINT` asked `document.elementFromPoint`, which answers the shadow host, so it skipped the field and every option mark. It now follows open shadow roots, as `AIM_CURSOR` beside it already did. With that change, ⌥-clicking the Add field again promises the marked group and comments on it. <details><summary>Other checks</summary> - `tests/browser/controls/test_previews.py`, `tests/browser/test_render_aim.py`, `test_trace_render_gate_restores_the_zoomed_time_window` and `test_a_shipped_log_replays_its_example_state` pass. - `test_page_fixture_renders` on the 13 option examples fails only on #7526's versions-menu leak (`closed surfaces`), as it does on `main`. - `pnpm run check` and `pnpm run test:runtime` pass. </details> Closes #7527 — automated triage --------- Co-authored-by: leaf-agent <[email protected]>
Requested by Maximilian · project thread
This PR ports
lf-optionsto Effect UI. It is the first decorating widget: one that wraps the author's own children rather than drawing everything it shows.lf-tabsandlf-boardare meant to follow the same shape, so the pattern is set out below and inlf-options.js's header ("How it is drawn: a decorating widget").The pattern
selectedon each picked option.lf-optionnodes eachaddin force creates.hidden="until-found"under a closed settled group.shadow: true). Author content shows through a<slot>.lf-optionis a small widget of its own, in its own module (lf-option.js). Its root holds the option's key badge, mark and § reference around its slot, so a mark stands inside its option's box.shadow: true). The page's readings search only declared roots, so without that Go-to's list of controls missed every mark.defineWidget'sproperties. The host sets the property the way Leaf setsstate, and a face set before the option upgraded (a group parsed in an inert document, as a thread message is) still counts.mark(pluspresswhere it takes a pick),keyandref.cell, plussettled,anotherordone.lf-options[multiple] > lf-option::part(mark)::before.lf-focus*part tokens.styles/options-shadow.css, loaded throughwidget-shadow.css.updateturns gestures intoRecordAction,TakeBackandKeepInTab.ShowChoice) does what only host code can: it writes the light-DOM record, states the key scope and thechoiceoutput, and turns host events (a click on an option's words,--choose,beforematch) into messages.AddField).Three cascade facts each decorating widget will meet, all handled in
options-shadow.css:--lf-option-in-row) has to be passed down to the slot.:host { --lf-reading-face: initial }would take the page's reading face off the author's slotted words. The chrome's.lf-uibox-sizingreset is document-only. The hosts restore both.Shared modules changed
browser/runtime/effect-widget.js(on top of main'spropertiesandmembers):staticsreplaces thelfPatchoption, soansweredandanswerWordscan be static too.lf-worktree,lf-worktree-diffsandlf-motionare updated to match.lf-commandsis now dispatched on the element. It was dispatched on the shadow root, whosecomposedPath()[0]is not an Element, so Leaf ignored it.browser/runtime/widget-services.js: addsTakeBack(anlf-undofor a verb).browser/runtime/annotations/preview.ts(and its compiled.js): a pointer's arrival is also heard frompointermove. The platform sends the document nopointeroverfor a move between two nodes of one shadow tree (the event, retargeted to the host as both target and related target, stops at the root), so Add showed no preview when the pointer came from the add field. A new test intest_previews.pycovers it.packages/default/registry.json:lf-optionsandlf-optiondeclareshadow: true, andlf-optiondeclaresverbatim: its module writes nothing between its light children, so the page reading (source/passages.py, the browser'sfencePassageParts) doesn't fence them and a quote in an option keeps its neighbours and section.tests/js_facts.mjs: the press reader countsselectableAttributes("button", …)as a selectable press, as it countsselectableOffer.Visible and behavioral differences
Element screenshots of every visible group on
review-a-plan,feature-galleryandalert-review, and of a fixture page taken through keyboard focus, the walk, Space, a pick, hover, Done, the add field (focused, typed, added) and the settled disclosure, matchmainpixel for pixel. The only differences are anti-aliasing and the timing of ring transitions. The remaining differences are:position: relative. Before, it became the containing block only while its digit showed. The digit now sits in the option's shadow root, where:has()on the host can't see it. This adds one positioned box per live card to Chromium's hit test.:defined. Those cells exist only in the shadow root, so the theme holds their room while the group is undefined rather than while they are missing from its children.ariaControlsElements), since an idref can't cross the shadow boundary. Itsaria-controlsattribute is gone.test_firefox_s_copy_of_a_group_builds_no_add_field's drag Firefox clones the range rather than copying the Document, so the test accepts either outcome. TheinWindowDocumentguard stays.lf-renderedclass.span.lf-pickinside the option's shadow root, not anlf-option-controlelement among the option's light children. Tests and dev states that reached it by child combinator orquerySelectornow go through the shadow root or Playwright's piercing selectors.Story tests (
tests/runtime/lf-options-story.test.mjs) cover the update logic: picks in single and multiple groups and the words each records, a pick of an added option, refusals, an asked pick, Done and its take-back, and the settled disclosure.🤖 Generated with Claude Code
https://claude.ai/code/session_01V22NWd3erndyoj2G9LEP7y
Generated by Claude Code