Skip to content

Draw lf-motion as an Effect UI component - #7397

Merged
max-sixty merged 6 commits into
mainfrom
effect-ui-motion
Nov 27, 2026
Merged

max-sixty merged 6 commits into
mainfrom
effect-ui-motion

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Requested by Maximilian · project thread

Ports lf-motion from Lit to an Effect UI component and deletes motion-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). renderFrame is a prop. Post-commit DOM work is two mounts: DriveStudy on 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); OfferPlay on the button draws its symbol and declares the Play command. An onAnimationFrame subscription 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 new KeepInTab command.

Shared modules (kept small):

  • effect-widget.js: properties (element properties that are props, as BrowserHost.defineElement's are) and members (element properties over the Model: get reads it, set sends a message). These carry renderFrame and currentTime. A property the page set before the tag was defined is taken at upgrade, so either module may load first.
  • Effect UI vendor entry adds HtmlSubscription. (KeepInTab, the lazy application.js import, the offerAttributes export and Mount/Queue/Stream came with Draw lf-timeline as an Effect UI component #7400.)

Styling. The transport is styled with lf-motion::part(...) in defaults.css, so it looks the same off Leaf (portable.css holds package defaults, and shadow trees get no styles there). lf-motion sets --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:

  • Stills for motion-controls (default, phone, dark) and playground-inline-end are pixel-identical (0 px). The only style diff is the transport moving from a light-DOM div.lf-motion-transport into the shadow root as div.lf-motion-study.
  • A failing frame's box stands in the shadow root, under the transport, rather than as a light-DOM child. The Play label may read Pause for one microtask flush before a first frame that throws turns it back.
  • If a study is detached mid-play and put back, it resumes at the last resting time the tab kept (pause, seek, speed), not where it was detached. currentTime on a detached study still reads where it stopped.
  • lf-inspect pauses the study from anywhere inside it. User input pauses it only inside the previews, as before.
  • The element's duration getter is gone (nothing used it).

Tests. New tests/runtime/lf-motion-story.test.mjs covers update (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

This was written by Claude Code on behalf of max-sixty


Generated by Claude Code

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
leaf-agent previously approved these changes Nov 27, 2026

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#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
leaf-agent
leaf-agent previously approved these changes Nov 27, 2026
leaf-agent
leaf-agent previously approved these changes Nov 27, 2026
@max-sixty
max-sixty merged commit 89f45d0 into main Nov 27, 2026
6 checks passed
@max-sixty
max-sixty deleted the effect-ui-motion branch November 27, 2026 18:28
max-sixty pushed a commit that referenced this pull request Nov 27, 2026
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
max-sixty added a commit that referenced this pull request Nov 27, 2026
<!-- 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]>
max-sixty added a commit that referenced this pull request Nov 27, 2026
… 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.
max-sixty added a commit that referenced this pull request Nov 27, 2026
… 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_
max-sixty added a commit that referenced this pull request Nov 28, 2026
`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_
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.

3 participants