Repository navigation
Draw lf-motion as an Effect UI component - #7397
Conversation
lf-motion's transport is now an Effect UI component drawn into the element's shadow root, with a slot for the authored previews; the Lit view (motion-view.js) is gone. The Model holds the clock (time, speed, playing) and what the page reports back; the author's renderFrame is a prop; one mount on the slot draws each frame and seeks, plays, pauses and reads the recordings; an onAnimationFrame subscription runs the illustrations' clock; the play button's mount draws its symbol and declares the Play command. Shared changes: - effect-widget.js: `properties` (element properties that are props, as defineElement's are) and `members` (element properties over the Model: get reads it, set sends a message), for renderFrame and currentTime. - widget-services.js: `KeepInTab` service for the tab store; NextOnMe loads host/application.js lazily so the module loads off Leaf, which the portable lf-motion needs. - controls.js exports `offerAttributes` for views that build fields. - effect-ui vendor entry adds Mount, Queue, Stream, HtmlSubscription. The transport is styled through ::part from defaults.css, so it keeps its look on a page without Leaf, and the study keeps the page's reading face for its previews. Tests: the failure box and first-paint checks read the shadow root; the revision test no longer asserts a light-DOM transport. 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.
#7395 (lf-file-tree) also adds a properties option to defineWidget in effect-widget.js, written separately and with different behavior. Its version also takes a value set before the element upgraded (Object.hasOwn(this, name) in the constructor, then delete) and mounts when a property is set before any root exists. This PR's version does neither, so if a page module assigns renderFrame before lf-motion is defined, the own property hides the accessor and the study never gets its frame function. The module header promises that "either module may load first". #7395 also imports navigateToDatum from host/application.js statically in widget-services.js, which would undo the lazy import that keeps lf-motion loading on a plain page. Whichever PR lands second should take the other's properties (with the upgrade handling) rather than keep two versions, and keep the application.js import lazy.
A page module that sets an element property before defineWidget runs leaves an own property that hides the accessor. The constructor now moves such a value into the props, and a property set on an element with no root mounts it, as a state set does. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V22NWd3erndyoj2G9LEP7y
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V22NWd3erndyoj2G9LEP7y
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V22NWd3erndyoj2G9LEP7y
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V22NWd3erndyoj2G9LEP7y
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V22NWd3erndyoj2G9LEP7y
Takes main's effect-widget.js whole: #7397's `properties` option, with its pre-upgrade capture, replaces this branch's, and lf-file-tree names `value` through it. The vendor entry exports HtmlCommand beside main's HtmlSubscription. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V22NWd3erndyoj2G9LEP7y
<!-- claude-projects-attribution: {"github_login":"max-sixty"} -->
_Requested by **Maximilian** · [project
thread](https://claude.ai/code/project/chan_01HAT2svakg1fTA5kitqhX9w?thread=cmsg_01HAT2svakg1fTA5kitqhX9wAWrHoDSUn5ogNyh9ijmSrr)_
Ports `lf-file-tree` from Lit to an Effect UI component around Pierre
Trees.
**Shape.** The component draws only the empty state and one container. A
stream Mount, `DrawTrees`, owns the Trees instance on that container:
- It feeds Trees each new file list and `current` file from the Mount's
args stream.
- It sends back two Messages: `OpenedFile` when the reader opens a file,
and `CountedRows` when the number of rows Trees shows changes. "No
matching files." reads that count.
Trees still owns paths, sorting, search, folder expansion, focus,
selection and virtualization, as on main (`search: true`). What the
reader types in Trees' search lives in Trees' model, which the Mount
keeps across redraws. The rows keep `role="tree"` keyboard navigation,
the `files.open` and `files.walk` key scopes on the focused row, and
Leaf's reveal of a keyboard-reached row. Trees draws only while there
are files, as on main, so it measures its scrollbar gutter on a laid-out
container. Story tests cover `update`
(`tests/runtime/lf-file-tree-story.test.mjs`).
**Shared modules (kept minimal):**
- `effect-widget.js`: unchanged; the widget names `value` through
#7397's `properties` option.
- `widget-services.js`: adds `NavigateToDatum`, the Command form of
`navigateToDatum`. It, `NextOnMe` and `OpenThread` reach Leaf's
application through a new `host/mounted.js`, which `mountApplication`
sets and which imports nothing. A page Leaf doesn't serve still loads
none of the application. A call runs in the task of the input that
asked. With a dynamic `import()` in the service instead, the datum
reveal landed after the click's rendering had settled. The shift watch
reported that as a move without input
(`test_file_tree_opens_current_diff_files_by_pointer_and_keyboard[patch]`).
**Visible differences:** none found. `leaf-dev probe file-tree --base
origin/main --shot` matches main at rest and with "conf" typed in the
search, apart from anti-aliasing on one corner pixel of the frame.
**Checks:**
- `pnpm run check` passes, as do the runtime Story tests.
- WebKit and Firefox aren't installed here, so their parametrizations
didn't run.
- Here,
`test_file_tree_opens_current_diff_files_by_pointer_and_keyboard` stops
at its first `expect(search).to_have_value("")` on origin/main as well
as on this branch, and the two behave the same at that step. CI ran it.
🤖 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]>
… a frame A member set sent its message to the root, whose redraw lands in Effect UI's next flush, but announced no `pending-task` and no `lf-commands` after it, and a set held for a root's mount announced `lf-commands` before the held value had drawn. A member set now goes the way a set of props does: the drawing settles a `pending-task`, and `lf-commands` follows it. The runtime test of a held set checks what the host sees when `lf-commands` fires. `lf-motion`'s registry entry told authors that assigning `renderFrame` draws the current frame at once and that every seek calls it synchronously. Since the widget moved to Effect UI (#7397) it draws a microtask later, before the next frame, which nothing that seeks relies on; the entry now says that.
… 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_
`leaf-dev interface --base` now reports the names the Effect UI ports made available to packages. Before this change it read functions from `widget-api.js` and `portable-api.js` alone, so it reported nothing for them. Run on each port's own commit against its parent, it now reports additions for every one of #7374, #7378, #7397, #7399, #7400 and #7395. For example, against the commit before #7374 it lists `/runtime/effect-widget.js`, `/runtime/widget-services.js` and `/vendor/effect-ui.js` as modules, `defineWidget`, `widgetProps` and the eight `widget-services.js` exports as functions, and Effect UI's 16 exports. The census now reads every module `$public-modules` lists outside the library, with each module's exports, including the vendored ones. It also reads every mark any reference gives, which adds 21 documented marks it missed, such as `data-lf-focus-visible`, and the chrome parts `package-themes.md` lists. Root `AGENTS.md`'s "Keep the package interface small" now names the public modules and their exports as part of the interface, and the references that gave Lit as the only way to follow a page reading, or `widget-api.js` as the only module to import, now name the Effect UI forms too. What the move to Effect UI keeps and retires is left to the guidance change that states Max's call on it. To weigh: a vendored module's exports count as names, so a Lit bump that adds an export shows as an addition. A widget's own `part` names are its package's, so the census doesn't count them. A function's options count as part of that function, so `--base` doesn't list them. Asked for by Max from the parts-column-scroll page and in the session. Codex reviewed five rounds. Tests: `dev/tests/model/test_interface.py`, `tests/runtime/widget-api.test.mjs`. Evals: `widget-controller-lifetime` and `widget-ratings-recorded-by-leaf`, 12/12 on both arms. > _This was written by Claude Code on behalf of max-sixty_
Requested by Maximilian · project thread
Ports
lf-motionfrom Lit to an Effect UI component and deletesmotion-view.js.Design. A decorating widget (
shadow: true): the transport draws in the shadow root and a<slot>shows the authored previews. The Model holds the clock (time, speed, playing) and what the page reports (reduced motion, whether recordings stand in the study, a refused playback, a frame that threw).renderFrameis a prop. Post-commit DOM work is two mounts:DriveStudyon the slot draws the frame at the clock's time and seeks, plays, pauses and reads the videos (its own rAF loop while recordings play);OfferPlayon the button draws its symbol and declares the Play command. AnonAnimationFramesubscription runs the illustration clock; window blur and tab hiding are subscriptions; input inside the previews is heard on the slot. The clock's resting time and speed go to the tab store through a newKeepInTabcommand.Shared modules (kept small):
effect-widget.js:properties(element properties that are props, asBrowserHost.defineElement's are) andmembers(element properties over the Model:getreads it,setsends a message). These carryrenderFrameandcurrentTime. A property the page set before the tag was defined is taken at upgrade, so either module may load first.HtmlSubscription. (KeepInTab, the lazyapplication.jsimport, theofferAttributesexport andMount/Queue/Streamcame with Draw lf-timeline as an Effect UI component #7400.)Styling. The transport is styled with
lf-motion::part(...)indefaults.css, so it looks the same off Leaf (portable.cssholds package defaults, and shadow trees get no styles there).lf-motionsets--lf-reading-face: inherit, because a declared shadow root resets the reading face on:host, which would strip the page's look from the slotted previews.Differences:
motion-controls(default, phone, dark) andplayground-inline-endare pixel-identical (0 px). The only style diff is the transport moving from a light-DOMdiv.lf-motion-transportinto the shadow root asdiv.lf-motion-study.currentTimeon a detached study still reads where it stopped.lf-inspectpauses the study from anywhere inside it. User input pauses it only inside the previews, as before.durationgetter is gone (nothing used it).Tests. New
tests/runtime/lf-motion-story.test.mjscoversupdate(clock, end, interruption, seek and clamp, recordings' clock, nothing to play, draw failure, reduced motion). Browser tests: the failure box locator and the first-paint check now read the shadow root, and the revision test drops its light-DOM-transport assertion. Passing locally:tests/browser/widgets/test_motion.py,tests/journeys/widgets/test_motion.py,tests/smoke/test_plain_page.py,pnpm run check.🤖 Generated with Claude Code
https://claude.ai/code/session_01V22NWd3erndyoj2G9LEP7y
Generated by Claude Code