Skip to content

Draw lf-activity as an Effect UI component - #7399

Merged
max-sixty merged 3 commits into
mainfrom
effect-ui-lf-activity
Nov 27, 2026
Merged

max-sixty merged 3 commits into
mainfrom
effect-ui-lf-activity

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

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 to defineWidget's inputs.

lf-activity now draws as an Effect UI component through defineWidget, in its own light DOM as before. activity-view.js and its Lit test are deleted.

How it's split

  • The Model holds what the reader did: whether the feed is open, and which rows it showed when they closed it. The closed notice counts arrivals against those rows.
  • inputs holds the Leaf side. It words the server's history, runs the feed's HeldReading, 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. The HeldReading region is the list and the empty line. A shut list is hidden, so nothing holds it.
  • A click on the notice runs ShowHeld, and a click on a thread row runs OpenThread. A RememberReading mount writes what the feed draws to the tab store through KeepInTab, which it reaches as a service. That presentation moves with the props as well as the Model, so a mount follows it rather than an update.

Shared modules changed

  • widget-services.js gains two services. OpenThread({id}) looks the thread up by id and calls threadActions.open. ShowHeld shows every HeldReading the 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. ShowHeld keeps held-news.js after 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 becomes inputs(element, reread). reread moves a signal that the watch reads, so the inputs are read again, still tracked. It covers inputs no signal carries: a print media change, a HeldReading letting 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-feed reports 0 px changed. The styles diff lists only the two boxes now between the element and its notice, list and empty line: the display: contents box defineWidget mounts 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.
  • A link to a destination that exists now carries 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 neither href nor tabindex. test_activity_held_targets_follow_the_current_document[patched] caught this.
  • When a reading moves, the feed redraws in Effect UI's microtask flush rather than inside the setter. For printing, I expect the print media listener's microtasks to run before the print layout, but I haven't checked it with a real print.
  • A feed that leaves the page and comes back starts a fresh Model on its new mount, so it reopens or stays shut as the tab store last recorded it.

Tests

  • tests/runtime/lf-activity-story.test.mjs: Story tests of the notice (open, close, open onto held news) and of a thread row.
  • In Chromium: tests/browser/projection/test_activity.py, tests/journeys/projection/test_activity.py, test_activity_held_targets_follow_the_current_document (both cases), plus test_render_projection.py, test_revision_patches.py, test_current_location.py, test_workers.py, test_status.py, test_modules.py, test_previews.py and test_widget_quality.py. Firefox wasn't installed locally.
  • pnpm run check and 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

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


Generated by Claude Code

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
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.

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.

Comment thread packages/default/widgets/lf-activity.js Resolved
Comment thread packages/default/widgets/lf-activity.js Resolved
Comment thread packages/default/widgets/lf-activity.js Resolved
…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 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.

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 obligationActions into host() as well, which does what the commit message says it wants.
  • Go back to the static imports and drop host().

Comment thread browser/runtime/widget-services.js Resolved
Comment thread browser/runtime/widget-services.js Resolved
Comment thread browser/runtime/widget-services.js Resolved
…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
@max-sixty
max-sixty merged commit 0738902 into main Nov 27, 2026
6 checks passed
@max-sixty
max-sixty deleted the effect-ui-lf-activity branch November 27, 2026 18:06
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