Repository navigation
Draw lf-activity as an Effect UI component - #7399
Conversation
lf-activity now draws through defineWidget, in its own light DOM as before,
and activity-view.js and its Lit test go. The component's Model is what the
reader did (open, and the rows shown when they closed it); its props are
Leaf's readings, with the rows HeldReading gives an open feed.
- widget-services.js gains OpenThread (threadActions.open by thread id) and
ShowHeld, which shows what an element's HeldReadings hold back
(held-news.js, showHeldReadings).
- defineWidget's inputs take a second argument, reread, for inputs no signal
carries: a print media change, a HeldReading letting go, the Markdown parser
arriving.
- The tab memory is written by a RememberReading mount.
- A widget link keeps a tabindex ("0" or "-1") rather than losing it, since
Effect UI removes attributes before it sets them and Chromium blurs an <a>
the moment it has neither href nor tabindex.
- The vendor bundle exports Mount and Stream.
- The view's one root is a display: contents wrapper, so the bound list's
selector is a descendant one.
tests/runtime/activity-view.test.mjs, which drove the Lit view directly, is
replaced by Story tests of the update; the browser and journey tests keep the
node-identity, focus and live-target behaviour it covered.
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.
withAttributes re-implements a method Effect UI's builder already has: ElementBuilder.attrs(record) sets each entry and removes an undefined one, and the vendored bundle ships it. The inline suggestions call it directly. The same helper also sits in lf-tally.js, and #7397 adds a third copy to lf-motion.js. Every Effect UI widget that applies pressAttributes/offerAttributes can use .attrs(...), so it's worth switching all three at once rather than letting the copy spread through the series.
This PR also overlaps #7400 in effect-widget.js. That PR mounts a light widget into a display: contents box that defineWidget adds itself. This PR gives lf-activity its own display: contents root (div.lf-activity-feed) because "an Effect UI view has one root". If both land, the feed sits inside two nested contents boxes. Whichever lands second should decide which box stays, and the data-lf-bound .lf-activity-list descendant selector depends on that choice. #7397 and #7395 each add a properties option to defineWidget too, so those two will also conflict there.
…unts; set press marks with .attrs widget-services.js loads in any document, so OpenThread and ShowHeld import host/application.js, records/thread/held-news.js and records/thread/state.js dynamically, started when leafServices first runs, so a press finds them loaded. lf-activity and lf-tally set pressAttributes through the builder's .attrs rather than a local reduce over .attr. 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 lazy host() import in widget-services.js doesn't keep anything from loading. obligationActions is still imported statically from ./host/application.js, and application.js itself imports both records/thread/held-news.js and records/thread/state.js through its static graph. So any document that loads an Effect UI widget loads all three modules at import time, as it did before this push. That makes the comment's claim that "a page with no such widget never loads them" false. Meanwhile OpenThread and ShowHeld became Effect.promise around an import that is already resolved.
Either option keeps the code honest. The suggestions below take the first:
- Move
obligationActionsintohost()as well, which does what the commit message says it wants. - Go back to the static imports and drop
host().
…d's contents box - RememberReading writes through KeepInTab, the tab store's one write route on main, which the mount reaches as a service. - defineWidget now mounts a light widget in a display: contents box of its own, so lf-activity's root is a plain block and its display: contents rule goes. - OpenThread imports the host modules as it runs, as main's widget-services.js header requires. ShowHeld keeps held-news.js once its first call loads it, so a later reveal draws in the microtasks after its press. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V22NWd3erndyoj2G9LEP7y
`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
This changes the package interface (
AGENTS.md, "Growing the package interface"). It adds two Command services and a second argument todefineWidget'sinputs.lf-activitynow draws as an Effect UI component throughdefineWidget, in its own light DOM as before.activity-view.jsand its Lit test are deleted.How it's split
inputsholds the Leaf side. It words the server's history, runs the feed'sHeldReading, and reads print media and the tab memory. It returns the current reading, the held one, the baseline and the row targets that stand in this document. TheHeldReadingregion is the list and the empty line. A shut list is hidden, so nothing holds it.ShowHeld, and a click on a thread row runsOpenThread. ARememberReadingmount writes what the feed draws to the tab store throughKeepInTab, which it reaches as a service. That presentation moves with the props as well as the Model, so a mount follows it rather than anupdate.Shared modules changed
widget-services.jsgains two services.OpenThread({id})looks the thread up by id and callsthreadActions.open.ShowHeldshows everyHeldReadingthe element owns (held-news.js,showHeldReadings, through a per-owner registry that the constructor fills). Both import their host modules as they run, as the module's header requires.ShowHeldkeepsheld-news.jsafter its first call, so a later reveal draws in the microtasks after its press rather than a module load later.effect-widget.js: the signature becomesinputs(element, reread).rereadmoves a signal that the watch reads, so the inputs are read again, still tracked. It covers inputs no signal carries: a print media change, aHeldReadingletting go, and the Markdown parser arriving. Without it the widget can't redraw on those.Visible or behavioral differences
leaf-dev stills --base origin/main --state activity-feedreports 0 px changed. The styles diff lists only the two boxes now between the element and its notice, list and empty line: thedisplay: contentsboxdefineWidgetmounts a light widget into, and the view's one root, a plain block. The bound list's selector is now a descendant selector to match.tabindex="0"where it had no tabindex before. Effect UI removes attributes before it sets them, and Chromium blurs a focused<a>as soon as it has neitherhrefnortabindex.test_activity_held_targets_follow_the_current_document[patched]caught this.Tests
tests/runtime/lf-activity-story.test.mjs: Story tests of the notice (open, close, open onto held news) and of a thread row.tests/browser/projection/test_activity.py,tests/journeys/projection/test_activity.py,test_activity_held_targets_follow_the_current_document(both cases), plustest_render_projection.py,test_revision_patches.py,test_current_location.py,test_workers.py,test_status.py,test_modules.py,test_previews.pyandtest_widget_quality.py. Firefox wasn't installed locally.pnpm run checkand pre-commit.test_activity_held_targets_follow_the_current_document[fresh]fails locally about half the time on this branch and on main alike. Its 180-frame window ends near 2.9 s, and the feed first draws at about 2.7 s on both, so the window often closes before the feed has drawn.🤖 Generated with Claude Code
https://claude.ai/code/session_01V22NWd3erndyoj2G9LEP7y
Generated by Claude Code