Skip to content

Let a page draw a playground's Save and Reset - #4478

Merged
max-sixty merged 6 commits into
mainfrom
agent-aeea2a9081ca1101d
Oct 31, 2026
Merged

max-sixty merged 6 commits into
mainfrom
agent-aeea2a9081ca1101d

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

A page that draws its own decision instrument inside lf-playground can now draw the Save and Reset buttons too, so Leaf adds no rail or actions bar beside it.

We rebuilt a hand-designed shadow-scale workshop as a Leaf page. The instrument came out close to the original, but the playground's rail and separate actions box pulled it back toward a settings form. (Main has since fixed the other two problems that rebuild hit: page CSS now reaches every control, and a playground no longer needs an lf-playground-control.)

  • actions="page". The page passes its own buttons to playground.registerActions({submit, reset}) in declare. playground-view.js then draws no actions bar, and draws a rail only for controls written there; the instruction (lf-playground-output) renders after the stage, where it was written, for the page to show or place. The buttons become the controls of the playground's existing commands, so the 1 key, Alt+0 and arrival from On me reach them. The view writes the submit button's words (submit-label, then "Undo choice") from the same template its own submit uses, so they always say what a press will do. The recorded choose event is unchanged.
    • It is markup rather than only the call because the playground draws as the page parses, before page scripts run. A default would draw the bar and then remove it, moving the page as it loads, and would make every form-like playground write its own buttons.
    • A page with actions="page" that never calls registerActions fails after first presentation with a message naming the fix, so page check reports it instead of leaving the user unable to answer. A playground arriving after first presentation, such as one in a thread message, isn't checked, because there's no settled point to wait for.
    • The commands are set only once the buttons arrive, since the keyboard runtime refuses a Decision command with no control.

Lost for page-drawn buttons, as for any button written in page markup: they aren't Go-to targets, and they print.

tests/fixtures/pages/page-drawn-playground.html, the shadow-scale workshop itself, puts actions="page" in the corpus.

No runtime, widget-api.js, event-log or protocol change; everything is in the playground package. Checked: the playground browser tests (two new, plus presets, instruction, submit, undo and the no-control contributor test), tests/runtime/playground-view.test.mjs, the playground/registry/instructions model tests including the every-declared-attribute corpus floor, pnpm run check:browser, and a keyboard-only probe of the fixture (Save → "Undo choice" on 1, withdraw on a second 1, Alt+0 resets, no console errors).

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

max-sixty and others added 3 commits October 27, 2026 00:07
A playground no longer refuses to start without an lf-playground-control: a
preview whose script declares contributor slices and an instruction provider is a
whole playground.

A playground marked actions="page" draws no rail of actions. Its page builds
its own submission and Reset as ordinary buttons, which the page's CSS styles,
and hands them over with playground.registerActions({submit, reset}). They
become the controls of the playground's commands, so the digit, Alt+0, On me's
arrival and availability reach them, and the playground writes the submission's
words (submit-label, then Undo choice) and records the choice as before. The
instruction stays where lf-playground-output is written. The choice is markup,
not only the call, because the initial drawing is the first paint: a bar drawn
there and withdrawn when the script registered would move the page as it loads.

The full-height and narrow playground grids keep the bar's row implicit, so a
playground without one leaves no empty row; bundled playgrounds render as before.

The references now say that a page script drawing the page's own interface
builds ordinary elements, which page CSS styles; the offer helpers build Leaf's
controls, which page CSS stays off.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A playground marked actions="page" whose page script never calls
registerActions left the user no way to answer, and nothing reported it. Now,
once the page first presents, after every whileInterfaceConnected declare has
run, such a playground fails with a message naming registerActions, which the
page's error report carries and page check fails on. A playground arriving
after that presentation (a revision applied in place, a message) has no
settled point of its own to wait for and is not checked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	packages/playground/initial/lf-playground.js
#	packages/playground/vendor/lf-playground-initial.js
#	packages/playground/widgets/lf-playground.js
leaf-agent
leaf-agent previously approved these changes Oct 27, 2026
The corpus floor (test_every_declared_attribute_and_enum_stands_in_an_example)
failed on the new attribute. The fixture is the shadow-scale workshop that
motivated the change: a page-drawn instrument with its own Save and Reset.
leaf-agent
leaf-agent previously approved these changes Oct 27, 2026
max-sixty added a commit that referenced this pull request Oct 27, 2026
…y candidate (#4482)

Records two leads from comparing Maggie Appleton's planning demos with
Leaf's playgrounds, without changing Leaf.

- `notes/comparisons.md` gains a section on GitHub Next's Chopin and her
talk [Planning with Agents](https://maggieappleton.com/planning-agents):
the closest product framing to Leaf's we've found, a shared plan
document with decisions recorded in place, and four hand-designed demos
that each give one decision its own instrument. It also records what our
same-task experiment showed: Leaf's standard path builds a settings
form, and Leaf's frame got in the way of a copied instrument, which
#4478 and #4479 address.
- `notes/dependency-candidates.md` is a new list of libraries worth
considering, starting with DialKit. A prototype measured its cost: 26 KB
gzipped, redundant DOM writes that a fork fixes, and regressions when it
draws Leaf's existing controls. It is recorded as a lead for its easing,
spring and XY-pad editors. Leaf doesn't take the dependency in this
change.
Main moved the playground's initial producer into widgets/playground-view.js
(#4545), lets page CSS reach every control (#4490), draws presses from their
actions (#4547, #4563), registers commands through lfCommands, and already
lets a playground run with no lf-playground-control. The PR's prose about
offer() and data-controls, its relaxed control check and its deleted
initial/vendor producer files take main's side.

What stays from the PR is actions="page", now built in the Lit view:

- playground-view.js draws no actions bar under actions="page", and no rail
  unless controls are written there; the instruction renders after the stage,
  where it was written. `give({submit, reset})` takes the page's buttons, and
  render writes the submission's words into the page's button from the same
  template Leaf's own submission uses (submit-label, then Undo choice).
- lf-playground.js's registerActions hands the buttons to the view and sets
  the playground's commands then, since a Decision command needs its control:
  the 1 key, Alt+0 and On me's arrival reach the page's buttons. A page that
  never calls registerActions still fails after first presentation.
- The copy control and popover wiring run only when Leaf draws the popover.
- The PR's test and corpus fixture pass the contributor editor main's
  registerContributor now requires.

Behavior from main kept: the submit no longer disables while a submission is
in flight (#4516), so a page's button follows the same rule.
@max-sixty max-sixty changed the title Let a page draw a playground's actions, and need no playground control Let a page draw a playground's Save and Reset Oct 31, 2026
leaf-agent
leaf-agent previously approved these changes Oct 31, 2026
max-sixty added a commit that referenced this pull request Oct 31, 2026
…t recipes (#4479)

The playground's author guide now tells authors what the user is doing
and what makes a tuning surface good, instead of where to put each
control. On a shadow-scale task, authors given the new guidance build a
tuning instrument where main's authors build a form of multiplier
sliders.

A fresh agent following Leaf's instructions on that task produced a
correct settings form: every setting a percentage of today's token, so
the shadow layers being decided never appeared. Its report quoted the
rules that drove that. "Write each item's controls inside
`lf-playground-preview` beside that item" moved 6 of its 8 controls into
the preview, and the copied-DOM rule steered it off hover-to-raise.

**What changed**

- `packages/playground/instructions/author.md` opens with a new section,
"What the user is doing": they settle something they will live with by
changing it and watching. Four considerations follow: the thing being
decided takes the space; controls show the values the build receives; a
parameter with a shape (a curve, a layer stack) gets a drawn instrument,
kept as a contributor slice; outcomes update beside the setting that
produces them.
- Three rules became considerations with their reasons:
- control placement: within sight of what it changes, with an inspector
when many settings would crowd the subject;
- when to wire an interaction: where trying it tells the user more than
seeing its states;
- the copied-DOM rule: the real component stays required when its own
behavior is compared.
- The shared-state rules all stay, now with their reason. "One Pointer
Events controller with pointer capture" is dropped: it came with the
feature, not with a failure (`e43bae13a`).
- `skills/leaf/references/page-layout.md`: Leaf's control classes give a
native control its face, and a control drawn for the task is the page's
own design, pointing at `page-authoring.md`'s "Style the page", which
main now carries.
- Kept as contracts: rail versus preview placement and the submitted
values (the registry states both), one selection surface, configuration
kept apart from the inspection case, presets as whole designs,
candidates aligned in rows, stable keys and ids. Each is backed by an
eval or the registry.

**Evals** (Claude Code, base vs this branch; every counted run opened
the changed file)

| Case | Runs per arm | Base | Branch |
|---|---|---|---|
| `playground-tunes-what-ships` (new): shipped values in view | 4 | 1/4
| 4/4 |
| `playground-tunes-what-ships`: cards lead the screen | 4 | 0/4 | 2/4 |
| `playground-controls-stand-by-their-item` | 2 | 2/2 | 2/2 |
| `playground-case-is-independent` | 2 | 2/2 | 2/2 |
| `brief-document-needs-no-outline` | 2 | 2/2 | 2/2 |
| `playground-presets-are-whole-designs`: judgment | 4 | 3/4 | 2/4 |

The presets failures on both arms come from presets that don't set the
format control, in a passage this branch doesn't touch. That case's rail
check failed 8/8 on both arms because its rubric contradicted the guide;
the rubric is fixed here, but no run has been graded with it yet. The
remaining "cards lead" failures are card layouts clipped at 1120–1280px
on both arms.

This overlaps #4478 in `author.md`, around the paragraph on the
instruction's output. Whichever lands second merges the other.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	packages/playground/instructions/author.md
#	packages/playground/widgets/lf-playground.js
#	packages/playground/widgets/playground-view.js
@max-sixty
max-sixty merged commit 2c080bb into main Oct 31, 2026
4 checks passed
@max-sixty
max-sixty deleted the agent-aeea2a9081ca1101d branch October 31, 2026 22:14
max-sixty added a commit that referenced this pull request Nov 1, 2026
…eep presets (#4875)

The shadow-scale tool from #4478, a playground whose page draws its own
instrument and its own Save and Reset, is now a catalog example, and it
gains Flat, Soft and Deep presets drawn by the page.

- **Catalog:** `tests/fixtures/pages/page-drawn-playground.html` moves
to `examples/shadow-scale.html`, its only copy, and `docs/examples.html`
lists it as "Design tokens · Tune a shadow scale" after Panel motion.
The example still carries `actions="page"` for the corpus floor test.
Its catalog still is published to `leaf-assets`; the refresh recaptured
every preview, so the pin also moves the README's demo images.
- **Presets with no Leaf change:** `lf-playground-preset` sets only
`lf-playground-control`s, so a playground whose settings are all
contributor slices had no presets. The page can already provide them:
each chip passes a whole scale to the slice handle's `set`, the
playground records the press as one `tune` that Undo takes back whole
(#4845), Enter and Space reach it as a native button, and the page sets
`aria-pressed` on the chip whose value matches `get()`. Rejected:
letting `lf-playground-setting` carry a slice's JSON plus a hand-over
for page-drawn preset buttons, which would be a second API for what
`set` and `get` do.
- **Guidance:** five lines in
`packages/playground/instructions/author.md` say how.
- **Example writes:** the example now writes `aria-pressed` through
`keeps`, including its existing level and layer buttons, since the suite
refuses writes that change nothing and no browser test had loaded this
page before.

`test_a_page_drawn_preset_sets_its_whole_slice_as_one_gesture` applies
Deep by pointer and Flat by Enter, checks each records exactly one
`tune` and shows pressed, and that two Undos step back to Deep, then
Soft. That test, #4478's two page-actions tests, the catalog metadata
test, the corpus floor test, `check:browser` and `page check --render`
on the example pass.

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

---------

Co-authored-by: Claude Opus 5.5 <[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