Skip to content

Give a playground control's generated label an lf- id, so a comment on its words names the control - #6043

Merged
leaf-agent merged 1 commit into
mainfrom
fix/issue-3985-playground-label-id
Nov 15, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/issue-3985-playground-label-id

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

#6040 gave each playground control's visible label span the id <playground>-<name>-label, so that the input could be named with aria-labelledby. Anchoring treats any id that doesn't start with lf- as an authored target (ADDRESSABLE in browser/runtime/anchor-resolution.js). So Alt-aiming at a control's label words targeted that generated span instead of the authored lf-playground-control, and a comment there would anchor to an id the author never wrote. The span's id now starts with lf-, the prefix anchoring already leaves to generated ids, as toc-view's lent section ids and lf-gloss's tips use. aria-labelledby follows the new id, so #6040's preview behavior is unchanged.

test_a_comment_names_the_playground_member_it_points_at failed on main (CI run 43706688461 and locally at badc6f30a, with assert 'word-playground-word-label' == 'word') and passes with this change. #6040's own test_a_control_whose_words_stand_beside_it_previews_nothing and the playground and preview tests selected by -k "label or name or preview" (144 tests) pass too. The exception is the Firefox crash below.

This doesn't address the second failure #6040 introduced in the same run: test_playground_range_preserves_preview_focus_without_cancelling_native_drag[firefox_browser] crashes Firefox's content process (signal 11). A bisect over 74008ae53..0144d467a lands on #6040, and the crash stops when the range input goes back to aria-label. It is tracked separately.

Refs #3985 — automated triage

…n its words names the control

#6040 named each playground control by the visible span beside it through
`aria-labelledby`, and gave that span the id `<playground>-<name>-label`.
`ADDRESSABLE` takes any id not starting `lf-`, so Alt-aiming at a
control's label words targeted the generated span instead of the authored
`lf-playground-control`, and a comment there would anchor to an id the
author never wrote. The span's id now starts `lf-`, the prefix
anchoring already leaves to generated elements, as toc-view's lent ids and
lf-gloss's tips do.

Behavior restored: a comment aimed at a playground control's label words
names the control (`test_a_comment_names_the_playground_member_it_points_at`,
which failed on main at 0144d46 and passes now).

Refs #3985
@leaf-agent
leaf-agent merged commit 708e3d1 into main Nov 15, 2026
6 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-3985-playground-label-id branch November 15, 2026 13:16
leaf-agent added a commit that referenced this pull request Nov 15, 2026
…der Playwright 1.65 (#6045)

`test_playground_range_preserves_preview_focus_without_cancelling_native_drag[firefox_browser]`
has crashed Firefox's content process since #6040. The cause is
upstream. Playwright 1.65's role locator reads
`element.ariaLabelledByElements` in its isolated world, and Firefox
segfaults once the page's own world has read that property too
([microsoft/playwright#43967](microsoft/playwright#43967),
[Mozilla bug
2090055](https://bugzilla.mozilla.org/show_bug.cgi?id=2090055)).
Playwright has closed its issue as fixed by the next Firefox roll, but
every released Playwright up to 1.65.2 still ships `firefox-1572`. #6040
named the playground's range by `aria-labelledby`, so two page-world
reads now reach it:

- **Leaf's preview.** `labelsOf` and `markupName` in
`browser/runtime/preview.js` read `ariaLabelledByElements` when the
pointer or focus lands on the control. They now resolve
`aria-labelledby` by id in the control's tree, so a Leaf page never
reads that property in the page's world. Leaf sets no labelling elements
from script, so this finds the same elements and changes no behavior.
#6040's preview rule still holds:
`test_a_control_whose_words_stand_beside_it_previews_nothing` passes.
- **The test's own `dispatch_event`.** On a role locator,
`dispatch_event` resolves the accessible name in the page's world, and
the surrounding actions resolve it again in Playwright's world. That
crashes Firefox with no Leaf code involved. The test now dispatches
`pointercancel` through an element handle, which doesn't resolve the
name again.

Before the change, the Firefox variant crashed in 3 of 3 runs on main.
With only one of the two changes it still crashes. With both, it passes
3 of 3 locally, on main after #6043 as well. Both changes cite the
upstream issue in a comment, so they can be dropped once Playwright
ships the fixed Firefox.

<details><summary>Reproduction and checks</summary>

With no Leaf code, Playwright 1.65.0 and `firefox-1572` crash on `<span
id="l">Max</span><input type="range" aria-labelledby="l">` when
`page.evaluate("…ariaLabelledByElements")` and `get_by_role("slider",
name="Max").count()` both run, in either order. Either one alone passes,
and so does an id lookup followed by the role query. On a Leaf page,
hovering the range and then calling `get_by_role(...).count()` crashed
before the preview change and passes after it.
`role.dispatch_event(...)` followed by `role.count()` crashes whether or
not Leaf has read the property.

Passed: the three variants of the reproducing test, all of
`tests/browser/controls/test_previews.py`, and the playground tests that
select labels, take focus or hold a range press (139 tests). `pnpm run
check:browser`, `pnpm run test:runtime` (980 passed) and pre-commit on
the changed files also passed.

</details>

Closes #6044 — automated triage

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Nov 17, 2026
A playground's controls are now a native HTML form. The author writes
ordinary fields inside `lf-playground`, in an `<aside>` that is the
rail: a range or number input, a checkbox with `role="switch"`, a
`<fieldset>` of radios, a `<select>`, color and text inputs, `<output
for>` for a reading, and the page's own `<button type="submit">` (and
`type="reset"`). Everything else in the playground is the preview. The
child tags `lf-playground-control`, `-choice`, `-value` and `-preview`
go, with `x-within` and keyed `x-refers`, which only the playground
used; presets and the agent's task text (`lf-playground-output`,
`-preset`, `-setting`) keep their tags, since HTML has no element for
either.

Leaf reads fields by `name` inside one generated `<form>` around the
rail and preview, which scopes each playground's radio groups. `tune`
and `choose` record exactly as before; the browser's own value checking
replaces Leaf's range, step and colour checks, and numbers reach CSS
bare (`calc(var(--playground-radius) * 1px)`). What changes for users:
duplicate or unknown control names fail in the browser rather than in
`page check`, so a playground posted in a thread message is unchecked;
pressing a label's words operates its control, reversing #6040/#6043;
`g` no longer reaches playground fields; a quoted playground shows its
fields disabled rather than hiding them. Candidate cards draw from the
page's own CSS, 20 to 40 lines per example.

Max picked this ("score it on the 15 cases, then land it as built") on a
survey of places Leaf puts its own layer between authors and HTML.
Scored on the 15 playground eval cases against main, Opus 5.5 author and
judge: head passed 14 of 15, and `motion-design`, its one failure (a
claim about tap playback on the page's own script), passed 2 of 2 on a
rerun; base passed 12 of 15, failing three cases whose rubrics are
converted to the new markup. Tests: `pnpm run check`, `test:runtime`,
the focused model tests, every playground browser test, and 16 other
tests that use a playground. Source +501/−895, tests +441/−927.

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

1 participant