Skip to content

Show the playground's page script whole, and let its members take digit-first names and ids - #3952

Merged
max-sixty merged 5 commits into
mainfrom
authoring/playground-script-names-ids
Oct 25, 2026
Merged

max-sixty merged 5 commits into
mainfrom
authoring/playground-script-names-ids

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Playground authors on the configuration task spent their first turn reconstructing the page script from Leaf's source and repairing page check refusals that protected nothing. This change shows the script whole and lifts those refusals.

  • The page script, whole. "Stateful previews" in packages/playground/instructions/author.md named registerInstructionProvider, subscribe, PAGE_INTERFACE, present() and whileConnected but never showed how a page script reaches the playground. It now gives the complete script from examples/alert-thresholds.html and says what to adapt. Claude Code (Opus 5.5), first turn, 3 authors per arm, interleaved: grep/sed calls into Leaf's source 6, 7, 7 against 0, 0, 0; tool calls 29, 39, 31 against 17, 14, 28; native minutes mean 4.4 against 3.5; cost $1.25, $1.48, $1.35 against $0.98, $0.85, $1.21.
  • Names may start with a digit. A control's name, a setting's and value's for and the values keys took ^[a-z][a-z0-9-]*$, while every id in the layer takes ^[a-z0-9][a-z0-9-]*$. A name only becomes a JSON key, a data-playground-NAME attribute and a --playground-NAME property. 2 of 3 Claude Code authors on main named the payments alert's controls 5xx-threshold and were refused.
  • id on controls, choices and presets. page-authoring.md asks for a stable id on each element a user points at, but these three declared none. All 4 Codex (Sol 6.1) authors in the validation run gave their controls ids, were refused, and stripped them with a regex. The examples now carry ids on a control, a choice and a preset, for the corpus floor.
  • --playground-choice-columns on plain choices. The property set only rich candidates' columns; a plain choice control kept its auto-fit grid. In 24 configuration samples the author looked the property up in Leaf's CSS, and 13 of 78 pages ended with rules against the generated .lf-playground-choices class. Plain choices now read the property with their old auto-fit default.

Overlap: #3898 also edits packages/playground/instructions/author.md and theme.css (Send placement); the two touch different rules.

Checks run: pnpm run test:runtime (550 pass); uv run pytest tests/model/test_interact_product.py and the corpus-floor test in tests/model/test_interact_document.py; tests/browser/widgets/test_playgrounds.py -k "candidates_keep_previews or notification_playground or authored_defaults_draw" (4 pass); pre-commit over the diff.

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

max-sixty and others added 5 commits October 25, 2026 07:42
"Stateful previews" named `registerInstructionProvider`, `subscribe`,
`PAGE_INTERFACE`, `present()` and `whileConnected` in prose, but never showed how a
page script reaches the playground, so authors reconstructed it from Leaf's source.
The section now gives the complete script, from `examples/alert-thresholds.html`, for
a preview that draws what the values decide and writes its own instruction, and
says what to adapt; the prose keeps the lifetime rules the code embodies.

First turn of the configuration task, Claude Code (Opus 5.5), 3 authors per arm,
interleaved, base 4c0cc3fa9 against this change:

- grep/sed calls into the runtime and playground source: 6, 7, 7 against 0, 0, 0
- native minutes: 3.9, 5.2, 4.1 (mean 4.4) against 3.6, 2.8, 4.0 (mean 3.5)
- tool calls: 29, 39, 31 against 17, 14, 28
- cost: $1.25, $1.48, $1.35 against $0.98, $0.85, $1.21

A served copy of a candidate page painted every alert's outcome and the
instruction from the example's pattern. The plain HTML authors of the same first
turn took 1.7, 2.2 and 4.6 minutes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A playground control's `name`, a setting's and value's `for`, and the submitted
`values` keys required a leading letter (`^[a-z][a-z0-9-]*$`), while every id in
the layer, the playground's own included, takes `^[a-z0-9][a-z0-9-]*$`. A name only
becomes a JSON key, a `data-playground-NAME` attribute and a `--playground-NAME`
property, all valid with a leading digit, so the narrower pattern bought nothing.

On the configuration task's first turn, 2 of 3 Claude Code (Opus 5.5) authors on
main named the payments-5xx-rate alert's controls `5xx-threshold` and `5xx-action`,
were refused by `page check`, and renamed them before checking again. A fixture
with `name="5xx-threshold"` now passes `page check` and paints its derived value
through `subscribe`.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
page-authoring.md asks for a stable id on each Leaf element a user would point
at, but `lf-playground-control`, `lf-playground-choice` and `lf-playground-preset`
declared no `id`, so `page check` refused one as an additional property. Each
stays in the page as the visible box of its control, candidate or preset button,
so an id there is a working anchor, and the runtime's own ids
(`<playground>-<name>-input` and the like) sit on generated children.

On the configuration task, all 4 Codex (Sol 6.1) authors in tonight's validation
run (base and candidate alike) gave their controls ids, were refused ("Additional
properties are not allowed ('id' was unexpected)"), and stripped them with a
regex before checking again. A fixture with ids on a control and a choice passes
`page check`, and pressing the choice by its id updates the page script's
outcome.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
77f90772f declared `id` on `lf-playground-control`, `lf-playground-choice` and
`lf-playground-preset`, and the corpus floor
(`test_every_declared_attribute_and_enum_stands_in_an_example`) wants every
declared attribute on an example page. alert-thresholds.html now names its budget
control and today's 5xx threshold choice, and notification-playground.html its
routine-release preset; both still load clean and the ids resolve to the members.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The property set the columns only of rich candidates
(`.lf-playground-candidates > .lf-playground-choices`); a plain choice control, such
as a row of threshold choices, kept its auto-fit grid whatever the author set. In 24
of tonight's configuration samples the author looked the property up in Leaf's CSS
(1–4 calls each), as one did after setting `--playground-choice-columns: 1fr` on its
threshold controls and seeing nothing change, and 13 of 78 configuration pages ended
with rules written against the generated `.lf-playground-choices` class. Plain
choices now read the property with their old auto-fit default, and the author
instructions say it arranges rich and plain choices alike.

A fixture's plain choice control keeps its four auto-fit tracks by default and
draws one 414px column with `--playground-choice-columns: 1fr` set on the control;
the motion example's rich candidates keep their own rule.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit aa9a8f0 into main Oct 25, 2026
4 checks passed
@max-sixty
max-sixty deleted the authoring/playground-script-names-ids branch October 25, 2026 15:10
max-sixty added a commit that referenced this pull request Oct 25, 2026
…oice columns

#3952 had plain label choices read `--playground-choice-columns` on their
grid, and this branch turns that grid into a wrapping row, where the
property has no effect. The resolution keeps the row: label choices wrap
between whole labels with nothing for the author to set, which removes
the workaround #3952's authors reached the property for. Rich candidates
keep the property. author.md says the property arranges rich choices and
that plain label choices take no columns, so an author who sets it on a
row of thresholds is told why nothing changes.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 25, 2026
`page check` refused `class` and `style` on every widget, so authors
lost their styling hook on playground controls and rewrote their CSS
around the refusal.

A widget validated every attribute but the page allocations against its
declaration, and no declaration lists `class` or `style`, so
`class="thresholds"` on an `lf-playground-control` failed with
"Additional properties are not allowed ('class' was unexpected)". No
widget reads either attribute: the runtime adds its own classes with
`classList` and its custom properties with `style.setProperty`, beside
the author's, and Leaf's `lf-` classes stay refused as markers. The
validator now skips both, as it skips the allocations.

Measured on the configuration task's first turn: 2 of 3 Claude Code
(Opus 5.5) authors on main put a class on their playground controls,
were refused, and rewrote their CSS to select by `[name$="-threshold"]`
before checking again. Across every stream that night the schema
refusals authors hit on playground members were `class` (8 samples), a
leading-digit name (9), `id` (5) and `style` (2); #3952 lifts the name
and `id` refusals, and this lifts the other two.

Checks run: `uv run pytest tests/model/test_interact_product.py
tests/model/test_interact_document.py
tests/model/test_interact_layer.py` (447 pass); pre-commit over the
diff.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 25, 2026
…horing-effort campaign (#3960)

The arrangement executor pinned every author's `page check --render` to
the fixed 1280×720 window, so authors fought a constraint Leaf doesn't
impose in use. This PR stops that, and records the 2026-10-24
authoring-effort campaign in `notes/agent-usability-evals.md`.

**Unpinned author render checks.** `arms.environment` pins the render
check's window for every child so a judged page's verdict doesn't depend
on who last viewed it, and that pin also reached the authors. In the
width phase the user states a 1600×1000 window, but the browser user
first opens the page in the comment phase, so every render check kept
reading 1280×720 ("fixed, pinned by LEAF_RENDER_VIEWPORT"). In 8 of 12
Claude Code Leaf width revisions the author hunted for a way out: it ran
`LEAF_RENDER_VIEWPORT=1600x1000 leaf page check` (a ValueError), grepped
Leaf's source for the variable, unset it, and took its own screenshots.
In use the check reads the window the user's browser last reported, so
this cost came from the harness. Leaf authors now run unpinned, and
after the first handoff the executor opens the page once at the run's
first window, as the user who said "I'll open it" would, until the page
records the view. The harness's own checks keep the pin. Configuration
workflow, Claude Code (Opus 5.5), 5 samples after the change: render
checks after the handoff read 1600×1000, "the user's window"; no call
named the variable (0 of 5, against 4 of 6 before); width-phase minutes
2.1, 2.0, 2.2, 2.2, 2.8 against 2.6, 2.8, 1.6, 1.9, 1.9, 4.9; 4 of 4
judged samples passed. One sample's scratch cleanup failed with
"Directory not empty" on its state home after the Stop hook was killed
(137); the next 3 ran clean.

**The notes section** ("Authoring effort, 2026-10-24") records where a
Leaf author's first turn spent time an HTML author's didn't, the repair
for each sink with its before and after counts (#3952, #3954, #3956,
#3959), the full-workflow validation on Claude Code and Codex, the
record review's measured cost, and the decision-overclaim observation
with the reader split behind #3959's wording change. The per-cycle log
and scripts stay in the campaign worktree's `.tmp/overnight/`.

Overlap: #3913 also edits `dev/leaf_dev/arrangement_eval.py` (task
selection, not the render pin), and #3898, #3901, #3913 and #3923 each
add to `notes/agent-usability-evals.md`; whichever lands second takes a
textual merge.

Checks run: `dev/tests/test_evals.py` and
`dev/tests/model/test_eval_discover.py` (3 pass); an import of
`leaf_dev.arrangement_eval`; pre-commit over the diff. The executor
change itself was exercised by the campaign's 5 post-change workflow
samples, not rerun here.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 25, 2026
A playground's label choices (`kind="choice"` with no preview) sat in
equal grid cells, so any label longer than its share of the row wrapped
inside itself. In a fresh Opus 5.5 configuration page at 1600x1000, on
an alert card about 450px wide, "over 1% (today)", "over 800 ms (today)"
and "Page on-call (today)" each broke onto two lines while half the card
stood empty. The author first tried `--playground-choice-columns`, which
reaches only rich candidates, and in its next revision overrode the
cells with `display: flex` in a `data-controls` sheet to get one-line
labels.

Label choices now run in a wrapping row, as a form's radios do, and wrap
between labels. A label wider than the whole row still wraps on its own.
Rich candidates keep their grid. In the rail, two short choices now sit
together at the start instead of at the rail's two halves.

Evidence (local, in the campaign worktree
`/Users/maximilian/workspace/leaf.agent-a10f091f355e3a600`):
- `.tmp/overnight/c1/config-choices-base.png` and
`.tmp/overnight/c1/config-choices-after.png` show the saved
configuration page on main's runtime and on this change's.
- The stills playground-controls, choice and text are in
`.tmp/stills/run-dp1pi0c2`.

Checks, on this branch cherry-picked onto current main:
- `tests/browser/widgets/test_playgrounds.py`,
`tests/browser/controls/test_rings.py` and
`tests/browser/controls/test_theme_and_device.py` with `-k "choice or
candidates or preset or narrow"`: 8 passed.
- `pnpm run test:runtime`: 550 passed.
- pre-commit passes.

#3952, which landed first, had plain label choices read
`--playground-choice-columns` on their grid. That grid is now this
change's wrapping row, where the property has no effect, so the merge
keeps the row and drops #3952's plain-choice columns: rich candidates
keep the property, and `packages/playground/instructions/author.md` now
says the property arranges rich choices and that plain label choices
take no columns. #3898 also edits `packages/playground/theme.css`, but
not the choice rules.

> _This was written by Claude Code on behalf of max-sixty_

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 25, 2026
#3952 made `--playground-choice-columns` arrange plain label choices as
it does rich candidates: in 24 configuration samples, authors looked the
property up in Leaf's CSS, and 13 of 78 pages ended with rules against
the generated `.lf-playground-choices` class. #3953 then made plain
label choices a wrapping row that breaks between whole labels, since
equal grid cells broke "over 1% (today)" across two lines in a card with
room to spare. Its merge kept the row and dropped #3952's behavior, so
on `main` plain choices ignore the property while rich candidates honor
it, and `packages/playground/instructions/author.md` says plain choices
take no columns.

Now both hold. Plain label choices are a wrapping row by default. When
the property is set on the choice control or its parent, plain and rich
choices both take its value as their grid columns, through one rule in
`packages/playground/theme.css`. A plain face starts its cell at its
words' width, so a label wraps only where its column is narrower than
it.

A `var()` fallback can't turn the plain row's flex box into a grid, so
the rule sits in `@container style(--playground-choice-columns)`, which
asks the group's parent, the control, whether the property is set. The
boolean style query matched in Chromium 153, Firefox 155 and WebKit
26.6; `if()` failed in Firefox 155, which is why the change doesn't use
it. Rich candidates keep their auto-fit default when the property is
unset. The rule's `:scope` (the control) outweighs that default, and a
quoted playground still reads the property on its candidates directly.
`author.md` now says plain choices wrap between whole labels by default
and that the property arranges either kind.

A new browser test,
`test_plain_choices_wrap_between_whole_labels_until_the_author_sets_columns`,
checks both states. It fails on `main`, where the property leaves plain
choices in one row.

Evidence (local, `.tmp/cols/evidence/` in this change's worktree): a
fixture with long labels in a 28rem card, `leaf-dev probe --base` crops.
- `main-default-row.png` and `fix-default-row.png` match. "over 1%
(today)" and "Open a ticket for the payments team" stay on one line and
wrap between labels.
- `main-columns-set.png`: with `repeat(2, minmax(0, 1fr))` and
`repeat(3, minmax(0, 1fr))` set, the choices stay in a row.
- `fix-columns-set.png`, and `fix-columns-set-firefox.png` from Firefox:
the same choices sit in two and three columns. A label wraps only where
it's wider than its column.
- `motion-playground` (rich, with the property and its narrow-screen
media query) computes the same columns and gap on both arms. `leaf-dev
stills` for playground-choice, playground-choice-phone-dark,
playground-controls, playground-controls-phone, quoted-playground and
motion-controls reports 6 of 6 states unchanged.

Checks:
- `tests/browser/widgets/test_playgrounds.py`,
`tests/browser/controls/test_rings.py` and
`tests/browser/controls/test_theme_and_device.py` with `-k "choice or
candidates or preset or narrow or playground"`: 27 passed. The
`playground` term matched the module name, so this ran all of
`test_playgrounds.py`.
- `pnpm run test:runtime`: 550 passed.
- `pnpm run check:browser` is clean. The CSS is hand-written and has no
generated copy.
- pre-commit passes.

> _This was written by Claude Code on behalf of max-sixty_

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 25, 2026
…Connected (#4004)

A playground's page script repeated about 15 lines of lifecycle in four
examples (`alert-thresholds`, `code-comparison`, `data-explorer`,
`notification-playground`) and in the playground's author instructions,
which #3952 made show the script whole: wait for `PAGE_INTERFACE` and
hold presentation with `present()`, declare slices and the instruction
provider once per lifetime behind a flag, subscribe on each connection,
reconnect at once, and ignore the `PAGE_INTERFACE` a revision applied in
place dispatches again. This gives that lifecycle one owner and cuts
every copy over to it.

```js
whileInterfaceConnected(playground, {
  declare: () => playground.registerInstructionProvider(instruction),
  connect: () => playground.subscribe(paint),
});
```

`declare()` runs once, before the first `connect(signal)`; the first
connection waits for `PAGE_INTERFACE` and holds presentation until
`connect` has run, a reconnection runs it at once, and the cleanup
`connect` returns runs as the element leaves.

**Where it lives.** The brief asked for a helper in the playground
package, but a page script can't reach one:
`revision_artifact.resolve_dependency` admits only `/page/` modules and
`PUBLIC_MODULES` (`widget-api.js` and Floating UI) from authored code,
and a method on `lf-playground` can't be called before the widget
upgrades, which is the wait the helper exists to hide. The helper is
generic instead: it names no widget, so it lives in the runtime beside
`PAGE_INTERFACE` (`runtime/presentation.js`) and is exported from
`widget-api.js`. `module-authoring.md`, "Startup and presentation",
documents it, and the playground's author instructions show the short
form. Making package modules importable from pages would be a new
public-module mechanism, which this doesn't need.

**No protocol bump.** The change adds a `widget-api.js` export and
removes or changes none; `layer-registry.md`, "Page protocol", keeps the
number for additive public APIs, and pages vendored earlier keep running
their long form against the same playground methods.

`tests/runtime/interface-connected.test.mjs` covers the lifecycle: one
declaration, connection at the page interface, none again on a later
one, cleanup on departure, an immediate reconnection, and a view that
left before the page interface. Removing the "already connected" guard
fails it.

Checks: `pnpm run test:runtime` (561 pass), `pnpm run check:browser`,
pre-commit; `tests/browser/widgets/test_playgrounds.py -k
"control_written_in_the_preview or rail_stays_in_view or
short_workspace_shows_more or code_reader_design_comment or
notification_playground or undoing_a_playground_choice"` (7 pass);
`leaf-dev probe` on the four examples shows each provider's instruction,
the contributors' paint and no console errors. Nothing visible changes,
so no stills or preview refresh.

> _This was written by Claude Code on behalf of max-sixty_

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 26, 2026
Playground presets with stable ids had no box for an element comment to
outline: `display: contents` removed the member's box, and its generated
button is chrome that the shared geometry reading correctly excludes.
Give each preset an inline flex box, so pointing at the member has a
real outline target. This preserves #3952's intent that authors can give
presets stable ids.

The notification playground render-gate test fails on main in both color
schemes and passes with this change. The narrow-screen test for long
preset labels, preset application and Reset also passes. `pnpm run
check` passes, including the runtime tests.

Desktop and phone `leaf-dev stills` comparisons of `playground-controls`
are unchanged, independently reviewed. A served base/head probe measures
the same 119.25×32 button at the same coordinates; the preset now
occupies that box too. Startup requests and JavaScript bytes are
unchanged; the stylesheet adds 232 bytes before presentation to supply
the outline target from first paint.

Closes #4244 — 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