Skip to content

Port lf-tabs and lf-parts to Effect UI - #7585

Merged
max-sixty merged 11 commits into
mainfrom
agent-a0d7c28df5f1e3fd5
Nov 29, 2026
Merged

max-sixty merged 11 commits into
mainfrom
agent-a0d7c28df5f1e3fd5

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

Moves the tab set, and a page's parts under their own tag, from Lit to an Effect UI component defined with defineWidget (packages/default/widgets/lf-tabs.ts). Base and head stills of every tab and part state match exactly. On leaf-dev bench tabsets, load CPU rises 12% at 256 sets, with unchanged growth.

Each act (arrival, press, step, reveal, edge press, resize) is a message whose update returns a Command: OpenPanel switches the panels through keepView and does what the act does to the strip; ShowTab and PageStrip do the rest. They reach the strip and tabs by ref (Renderer.Refs), so the Story test sees each act's Command. One Mount listens, for beforematch, the strip's size and the set's place in main. The Effect UI bundle now exports Renderer and Option (5.4 KB gzipped).

Changed behavior: a set out of the page past the disconnect microtask draws its strip anew when put back, and a set whose place in main changes after arrival no longer says lf-layout for it. The tab keys are four rows rather than two with routes. Stylesheets reach the strip through the box (> [data-lf-gen] .lf-tabstrip).

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

The tab set, and a page's parts under their own tag, are now an Effect UI
component defined with defineWidget, in TypeScript, and the Lit TabSet is gone.
The strip draws in defineWidget's light box before the authored panels, under a
view node of no layout, so its keys (`Keys`) stay the strip's own scope rather
than the whole set's. The Model holds the open panel, the tab focus is on, the
underline's travel, and a count of openings; one Mount dresses the panels,
shows the open one through keepView, hears `beforematch`, and keeps the strip's
measured marks and its landing within the strip. The set still records no
action.

What it made easier: which panel a press, step or reveal opens, when the
underline travels, and every word a queue row says of its panel are now plain
functions under a Story test (tests/runtime/lf-tabs-story.test.mjs).

What changed for users: the keyboard reference lists the steps as four commands
(Previous, Next, First and Last tab, each with all its keys) where it listed a
"walk the tabs" and a "first / last" command with routes; the bindings are the
same. A set no longer marks itself `lf-rendered`, which nothing but tests read;
those tests wait for the strip instead.

Stylesheets and tests reach the strip through the box (`> [data-lf-gen]
.lf-tabstrip`), the boxes pass `--lf-full-height` on to the strip, and the
parts' layout names its members as what isn't the box. The readiness test waits
for the flush a key draws in. leaf-dev bench gains `tabsets`, a page of n boxed
tab sets.

@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 port looks sound to me: it adds no package-interface names (leaf-dev interface --base), and on the new tabsets bench page, load CPU rises about 12% at 256 sets, with growth unchanged (exponent 1.12 on both base and head, three rounds). But the test job is red on three tests that this change causes:

  • tests/model/test_theme_tokens.py::test_a_bundled_package_names_only_the_names_of_leaf_s_its_references_declare reports packages/default/widgets/lf-tabs.js: lf-margin-entry-icon. Lit's actionTemplate("on-me") supplied that class by default, so the old source never wrote it out. The port writes it in the package's own source (inline below).
  • tests/journeys/test_render_widgets.py::test_a_side_list_is_a_queue_beside_the_item_it_opens fails with "moving the tab set replaced its retained answer row", plus a watch finding, unchanged write: class on lf-tabs#queue.lf-ring-frame. The check removes #queue, waits for a MutationObserver callback, then reinserts it. defineWidget's disconnectedCallback tears down a widget that is still disconnected after its microtask, so the reinserted set mounts fresh: its tab rows are new nodes, and #arrive adds lf-ring-frame again. The assertion protects the lifetime contract from #1929 (keep a widget across a move within one mutation batch). defineWidget keeps a widget only across moveBefore. So either move the set with parent.moveBefore(queue, next), or drop the identity check and say in the commit that removing and reinserting a set now redraws its strip. The guard suggested inline clears the unchanged write either way.
  • tests/journeys/widgets/test_tabs.py::test_a_strip_marks_its_open_tab_by_the_way_it_runs fails on row["ground"] == row["frame"]. Its mark script reads frame: getComputedStyle(strip.parentElement).backgroundColor (outside the diff). parentElement is now the strip's view node, which has no background, where before it was the set. Reading strip.closest('lf-tabs, lf-parts') compares what the test compared before.

Both inline suggestions edit lf-tabs.ts, so lf-tabs.js needs rebuilding with them.

Comment thread packages/default/widgets/lf-tabs.ts Resolved
Comment thread packages/default/widgets/lf-tabs.ts Resolved
…rame mark

The On Me symbol a side list's row shows wore `lf-margin-entry-icon`, Leaf's
margin class, which Lit's actionTemplate supplied by default and the port wrote
out; it now wears a class of the package's own, sized as before by tabs.css.
Arriving sets `lf-ring-frame` only where it is missing, so a set that mounts
again writes nothing unchanged.

Two journeys read through the strip's new parents: the queue's move puts the
set back before the microtask in which defineWidget closes a root that left the
page, which keeps its rows, and the strip's frame is the set the strip stands in.
A set taken out of the page past that microtask draws its strip anew when it
returns, as every defineWidget widget does.
leaf-agent
leaf-agent previously approved these changes Nov 29, 2026
…s helpers

The Mount measured the strip and wrote what it found onto it (aria-orientation,
whether a side list's list is a reading region, whether the strip is a root
header). It now sends that measure as `ResizedStrip`, and the view draws the
three marks, as lf-timeline draws its measured ruler, so the Mount writes no
node the view drew but a run's landing room.

The arrows come from `rowArrows`, the closed panels leave the tab order through
`rove`, and the layout and walk events through `layoutChanged` and `WALK`. A
step's landing reader is one per panel id, so a draw that changes nothing the
keys name states no new scope. Only a tab set arriving in or leaving `main`
reads the inputs again, and the room a set keeps before its strip draws asks
only whether its box stands (`:has(> [data-lf-gen])`), which Chromium answers
without walking the set's panels.

The queue journey moves the set elsewhere in the page and back, each move a
mutation batch of its own, which keeps its rows without a write that changes
nothing.
leaf-agent
leaf-agent previously approved these changes Nov 29, 2026
The press at a strip's edge scrolled the strip from a listener the Mount added,
an effect no message stood for. It now sends `PressedStripEdge`, which the Model
counts as one more act on the strip, and the Mount pages the names as it follows
the count, so a Story test sees the press. The page happens in the flush that
draws the press, before the next frame, so the strip test reads it after a task.
rowArrows is typed as a pair, so the defaults the destructuring gave were dead.
leaf-agent
leaf-agent previously approved these changes Nov 29, 2026
A Mount diffed the args each draw gave it and acted on what changed, so the
Model counted the user's acts only for the Mount to tell an act from a redraw.
Each act is now a message whose update returns the Command for it: `OpenPanel`
for the arrival, a press, a step and a reveal (it dresses the panels, shows the
open one through keepView, takes the closed ones out of the tab order, says a
step's place, brings the tab into view, highlights a reveal, opens a pinned box
at its start and says the layout changed), `ShowTab` as the strip resizes, and
`PageStrip` for a press at the strip's edge. Each reaches the strip and its tabs
by their refs once the act's draw has committed (`Renderer.Refs`), and the
authored panels through the props. The count is gone from the Model, and the
Mount only listens: it hears `beforematch` and measures the strip.

The Story test now checks the Command each act returns. The page's Effect UI
bundle exports `Renderer` and `Option`, which the Commands name: 5.4 KB more
gzipped (192.0 to 197.3 KB), 4.2 KB of it `Renderer`'s namespace.

A set whose place in `main` changes after it arrives updates its
`data-lf-page-views` mark at its next opening, and no longer says `lf-layout`
when that change moves its panels into or out of the page's flow.

Two stills states drive what the Commands do: a queue stepped by key
(`queue-step-keyboard`) and a boxed set's tab pressed while its strip is pinned
(`boxed-tab-pinned-press`).
A revision that takes away the first tab set in `main` makes a later one the
page's navigation. That set now says so (`data-lf-page-views`) as its place
changes, through the listening Mount, rather than at its next opening, so its
open panel is named in the address and Back and Forward reach its panels before
the user presses a tab. A browser probe that removes the first of two sets saw
the mark arrive only with this change.

The header no longer says disconnecting ends a reveal's highlight, which nothing
does since the highlight left the Mount; effect-widget's header says a reveal
within one box goes through a Command that finds its node by ref. `rowFacts`
takes the counts of an unasked panel from one constant, and `Tab` takes the
facts it passes to `rowFacts` whole.
leaf-agent
leaf-agent previously approved these changes Nov 29, 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.

Merging squashes with the PR description as main's commit message, so the behavior changes the branch's commits name don't reach main as they stand. Two of them are worth carrying into the description:

  • A set left out of the page past the disconnect microtask now draws its strip anew on reinsertion (0eb5f07).
  • A set whose place in main changes after it arrives no longer reports lf-layout when that change moves its panels into or out of the page's flow (96df45e).

A key row only sends its message now: `OpenPanel` lands the user on the tab a
step opened (`focusDestination`), after the panels switch and before the tab
comes into view. The table of landing functions, one per panel id ever seen and
kept so a redrawn row kept its identity, is gone. The readiness test now checks
that a step leaves focus on the tab it opened.

`TrackStrip` reads the panels of the latest draw from `changes` rather than
those of its first. Nothing replaces a panel's node while the set stays drawn
today, since a revision that changes the members replaces the set, so this
removes a dependence on that rule rather than a visible defect.

The set's props no longer take `state`, which Leaf sets only on a widget whose
tag declares verbs, and the tabs declare none.
# Conflicts:
#	browser/runtime/effect-widget.js
#	browser/runtime/effect-widget.ts
@max-sixty
max-sixty merged commit b9b4884 into main Nov 29, 2026
7 checks passed
@max-sixty
max-sixty deleted the agent-a0d7c28df5f1e3fd5 branch November 29, 2026 06:35
leaf-agent added a commit that referenced this pull request Nov 29, 2026
The reach pass gave back any `tabindex="0"` on a scroll candidate that
stopped scrolling or fit, including one another owner wrote. Since lf-tabs
moved to Effect UI (#7585), its arrival roves the open panel's stop after
the reach pass has recorded the panel as a candidate, so the next reach
paint removed it: the open panel of a tab set lost the Tab stop lf-tabs
gives it, and the write watch reported `null -> 0 -> null` as an unchanged
write of `tabindex` on the panel (test_a_double_click_on_the_rendered_copy_
types_at_its_line_in_the_editor, on every run after #7585).

`returnStop` now acts only on a box wearing the pass's own mark, and
`lendStop` leaves a `0` another owner wrote alone, as the header of
`mayScroll` already said the pass does. A runtime test covers a surface
that stops scrolling with another owner's stop on it.
leaf-agent added a commit that referenced this pull request Nov 29, 2026
… the editor's line instead of typing into the previewed table (#7604)

Two fixes for
`test_a_double_click_on_the_rendered_copy_types_at_its_line_in_the_editor`.

**A tab set's open panel kept losing its Tab stop to the reach pass
(`browser/runtime/dom/reach.ts`).** Since #7585 ported lf-tabs to Effect
UI, its arrival roves the open panel's `tabindex="0"` after the reach
pass has already recorded the panel as a scroll candidate. On its next
paint, `returnStop` took that `0` back, as it did any `0` on a
candidate. So the open panel lost the Tab stop lf-tabs gives it, and the
write watch reported `null → 0 → null` as `unchanged write: tabindex on
lf-tab#…--preview`. That failure reproduces on every run at main
`1026a7485` and at #7585 (`b9b4884d1`), and never at its parent
`6e1977ac0`. It turned this PR's `test` job red once main was merged in.
`returnStop` now gives back only a stop wearing the pass's own
`data-lf-lent-reach-stop` mark, and `lendStop` leaves alone a `0` that
another owner wrote. The header of `mayScroll` already said the pass
"takes back only that". A new runtime test in
`tests/runtime/reach.test.mjs` fails without the change and passes with
it.

**The test's keystroke reflowed the previewed table (macOS teardown
shift).** To show where the double-click left the caret, the test typed
`Z` at the start of `| x | gamma |`. That gave the Markdown preview's
table a new first cell, so its columns reflowed. lf-text-document draws
that redraw after native `await`s, which `input_work_watch.js` doesn't
follow (`tests/AGENTS.md`, "Browser errors"). So on a slow runner the
reflow landed outside the keystroke's window and was reported as `#text
in th … moved without input by (2, 0)px`. The test now presses Shift+End
and asserts the selection is the whole line, which shows the same caret
position and changes nothing the preview draws. The underlying limit,
that the input watch can't attribute a redraw drawn after a native
`await`, is left as easy to fix as before.

<details><summary>Evidence</summary>

- Reach fix, Linux: the test passes at the merged head; at main without
the fix it errors on the unchanged `tabindex` write.
`test_tab_reaches_the_open_panel_and_no_closed_one`,
`test_a_scrolling_tab_panel_keeps_nested_headers_on_its_edge` and the
two borrowed-stop tests in `test_render_aim.py` pass. The full runtime
suite passes (1296 tests), and the browser type check is clean.
- Keystroke fix, Linux with Chromium slowed 4x (`leaf-dev suite flake
--cpu-throttle 4`): before the change, 3 of 4 copies fail with the same
report on a `td` of that table; with this change, 6 of 6 pass.
- Keystroke fix, macOS (`ci` dispatches with `flake`): at main
`6313a6f59`, 4 of 12 copies error
([46168668757](https://github.com/max-sixty/leaf/actions/runs/46168668757));
on this branch before the merge with main, 18 of 18 pass
([46235315494](https://github.com/max-sixty/leaf/actions/runs/46235315494)).

</details>

Refs #7532 — automated triage

---------

Co-authored-by: leaf-agent <[email protected]>
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.

2 participants