Skip to content

Make the dynamic-widget example live and add controlled authoring evaluations - #4299

Merged
max-sixty merged 12 commits into
mainfrom
codex/dynamic-widget-example
Oct 28, 2026
Merged

max-sixty merged 12 commits into
mainfrom
codex/dynamic-widget-example

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

This turns the dynamic-widget gallery example into a live comparison: type one high-level request and start Leaf component composition and HTML/CSS/JavaScript generation concurrently. It removes the earlier recorded experiment sections and exposes the exact request, instructions, generated source, output tokens, and generation/render timing. HTML, CSS, and JavaScript are shown in separate highlighted source blocks.

The supporting runtime changes let mountSample(frame, {source}) render a generated Leaf document using the existing isolated sample lifecycle, bind lf-text-document to a widget's published document, and let independent inference requests overlap without holding the shared HTTP worker limit. Feature-gallery examples and focused interaction tests cover these contracts.

The developer tooling adds HTML, compiled JSON, and Adaptive Cards authoring experiments, plus a controlled one-response HTML/JSON comparison with matched components and behavior. It retains initial failures and repair costs separately; the retained small batch does not establish a general speed or reliability ranking.

This is an early attempt at dynamic widgets and needs work. The live example waits for complete responses and starts each run fresh. “Preview ready” measures startup, not task correctness. The Leaf catalog composes existing behavior; it cannot create a countdown timer. Streaming, retaining the last working preview, and broader quality evaluation remain outside this change.

Validation after integrating current main: pnpm run check; 696 runtime tests; 22 focused sample/inference tests and 10 subtests; two document-binding browser tests; nine developer-eval smoke tests; a model-free end-to-end Leaf, JSON, and Adaptive Cards run with successful format/page/interaction checks and matching phone-sized captures; all four controlled HTML/JSON fixtures passing parsing, Leaf validation, and operated interactions; desktop/mobile demo probes using retained real model responses; independent integration and source-readability review. Live model benchmarks were not rerun merely for this PR.

This was written by Codex on behalf of max-sixty

Render generated Leaf source through the sample API alongside sandboxed HTML. Start both generations concurrently, keep only the current attempt, and expose readable prompts, source and timings. Remove the inference lock and fixed HTTP worker limit so model calls do not block ordinary page requests.
# Conflicts:
#	dist/kernel/kernel.json
#	src/leaf/samples.py
leaf-agent
leaf-agent previously approved these changes Oct 26, 2026
leaf-agent
leaf-agent previously approved these changes Oct 26, 2026
leaf-agent
leaf-agent previously approved these changes Oct 28, 2026
leaf-agent
leaf-agent previously approved these changes Oct 28, 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.

Sample creation is broken for both existing templates and generated documents: the package-copy loop overwrites the newly introduced content variable, so index.html receives the last package file instead of the sample's HTML. The focused sample tests reproduce HTTP 400 with “invalid sample” for both paths. Keep the document bytes in a separate variable through the final write; the paired suggestions below do that.

Comment thread src/leaf/samples.py Resolved
Comment thread src/leaf/samples.py Resolved
leaf-agent
leaf-agent previously approved these changes Oct 28, 2026
@max-sixty
max-sixty merged commit 241557e into main Oct 28, 2026
5 checks passed
@max-sixty
max-sixty deleted the codex/dynamic-widget-example branch October 28, 2026 18:46
leaf-agent added a commit that referenced this pull request Nov 1, 2026
The dynamic-widget builder reset hidden flags and source/error text on
every generation attempt, even when those values already stood in the
DOM. Repeated attempts therefore triggered the unchanged-write watch in
the navigation journey. The builder now uses the public `keepsHidden`
and `keepsText` helpers for its imperative presentation writes, avoiding
redundant mutations while retaining the same displayed states.

This preserves the live comparison introduced by #4299, including fresh
generation attempts and both output formats. No runtime, layout, labels
or test assertions change.

Verification:
`tests/journeys/test_render_navigation.py::test_presses_and_fills_leave_no_element_naming_stale_keys[dynamic-widgets]`
reproduced all six reported findings before the fix and passes after it
(13.45 s). `node --check` passes. The existing journey supplies
regression coverage; live model generation and macOS were not exercised
locally.

Closes #4937 — automated triage

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Nov 5, 2026
…widget formats, run UI review on Promptfoo's hooks (#5442)

An experiment is now a folder under `evals/` holding a Promptfoo config,
with no `leaf-dev` command of its own. This change writes that rule into
`dev/AGENTS.md`, retires the widget-format experiment, and moves UI
review detection onto Promptfoo's own setup and teardown hooks.
`leaf-dev` goes from 30 commands to 28 (`eval-widget-formats` and
`eval-ui-review` are gone), `leaf-dev eval --condition` loses `json`,
`adaptive` and `formats`, and the `adaptivecards` dev dependency goes.
Net change: +633 / −2,573 lines, of which Python code is +64 / −1,531.

## The rule

`dev/AGENTS.md`, "Experiments": the catalog (`evals/<task>/case.yaml`)
runs through `leaf-dev eval`, and any other question put to a model is
an experiment, a folder under `evals/` with a `pnpm run eval:<name>`
script. Its arms are providers, its samples tests and its graders
assertions. Setup and summaries for the declared tests go in
`beforeAll`/`afterAll`, and setup that produces the tests runs in the
script before Promptfoo. A new comparison is another provider, never a
`--condition` value. A mechanism stays in its experiment's folder until
a second experiment needs it. Code names a model only through `MODELS`,
`JUDGE_MODELS` and the new `COMPARED_MODELS` in `arms.py`. Node code
reads them through `dev/leaf_dev/arms.mjs`, which runs `python -m
leaf_dev.arms`.

`leaf-dev eval --model` stays. A person running the catalog passes it,
and Promptfoo's run store shows 33 runs between 23 October and 1
November that used it, 24 of them with `gpt-6-sol`.

## Widget formats, retired

#4299 added this experiment to ask whether an agent writes a Leaf widget
more reliably as HTML or as an equivalent JSON tree. All four of its
runs predate its merge on 28 October, and none has run since. Removed:
`eval_widget_formats.py`, `widget_format_eval.py`,
`evals/widget-formats/`, the `json`/`adaptive`/`formats` conditions with
`preflight_formats` and their branches in `authoring_eval.py`, its test,
and its README passages. The `format-valid` and `interaction-proven`
checks and the `format_output`/`interaction` metadata fields existed
only for those conditions.

**To restore it:** bf2650b, `main` as this merged, is the last commit
that holds it.

```
git checkout bf2650b -- dev/leaf_dev/commands/eval_widget_formats.py dev/leaf_dev/widget_format_eval.py evals/widget-formats
```

Then bring back its conditions in `dev/leaf_dev/commands/eval.py` and
`dev/leaf_dev/authoring_eval.py`, and `adaptivecards` in `package.json`,
from the same commit.

## UI review as a config

`evals/ui-review-detection/promptfooconfig.mjs` is the whole experiment.
A column is `MODEL/ARM`: the four reviewers the command offered (each
harness's author and judge pin, plus Fable in `COMPARED_MODELS`) on each
of four arms (`no-tools`, `browser`, `discovery`, `code-only`).
Promptfoo's own `--filter-providers`, `--filter-pattern` and `--repeat`
replace the command's `--model`, `--condition`, `--mode` and `--repeat`.
A bare run takes every column; the command's default was Sol on two
arms. Each test's vars are `{prompt, candidate}`, which stay the same
from run to run, so Promptfoo's viewer and `--filter-failing` match rows
across runs.

`hooks.mjs:beforeAll` copies the public fixtures and the pinned timeline
bundle. It then captures each selected candidate's labelled views and
source and asserts the frozen contrast on each, so a broken fixture
stops the run before a model is called. Last, it seeds the judge's Codex
login. `afterAll` retires the seed and writes and prints each column's
counts. The candidate's browser answers requests from the copied site by
Playwright routing, which replaces the loopback server and its
private-path probe. The captures now use the same Node Playwright build
as the reviewer's browser tool.

Dropped with the command:
- **Run records:** the copy of every input in the run directory,
`frozen-hashes.json`, `integrity.json`, `environment.json`, `run.json`
and the fixture sha256 table. Git and the lockfile hold those inputs,
and the run's description names its commit (`git describe --dirty`).
- **`--prepare-only`:** replaced by `node --test
dev/tests/node/test_ui_review_setup.cjs`, which runs the real setup on
all ten candidates.
- **The no-tools discovery arm:** no run ever used it, and it needed its
own unobservable-target rule in the grader.

## Other fixes in touched files

- **Control legibility:** its reader and judge take their models from
`arms.py`, its column shows the pinned model, and its config sets
`sharing` and `cache` itself.
- **The plain-HTML control:** it now needs an `index.html` to count as
page-valid. Before, an empty page directory passed on the static
server's 404 page.
- **Type check:** the smoke test imports the config and hooks, so the
tools type check (`build/tsconfig.json`) now reaches `provider.mjs` too.
JSDoc names the SDK types it passes; behavior is unchanged.

## What I ran

- **Command vs config, same sample.** I ran the old command and the new
config on the covered-controls pair: Sol on `no-tools` and `browser`,
Opus on `browser`, and Sol on `discovery` and `code-only` for the
defect. That is 8 cells each. Every cell has an identical request
digest, image count and native harness on both sides, and every cell got
the same detection and false-alarm grade. The no-tools and code-only
arms sent the same input token counts (4,192 and 3,745), so their inputs
were byte-identical. Browser arms differ only in the model's own
operation count. One config sample (Opus/browser, control) had an
unsupported observation: the reviewer overstated which messages it had
copied.
- **Captures.** The command's and the hook's ten packets: 25 of 30
screenshots byte-identical, and 5 differing by at most 19 pixels
(channel delta ≤10) inside one hover region. The command's own two runs
differ in the same image the same way.
- **After the final edits and the merge of `main` (Pi 1.5.0):** `pnpm
run test:evals`, Sol on `no-tools` and `code-only` (both graded, no
login seed left behind), and the control-legibility reader and judge on
one sample.
- **Tests.** `uv run pytest dev/tests/test_evals.py -n0`, selecting the
tests the removal touches, `pnpm run check:tools` and `check:browser`,
and pre-commit on every changed file.
- **CI.** CI's one failure,
`tests/model/test_receipts.py::test_ack_rearm_reports_when_its_only_page_transfers_after_selection`,
was a `JSONDecodeError` reading a session record. It passes 3 of 3
locally, and this change touches nothing under `src/` or `tests/`.

`pnpm run eval:legibility` stops in its capture step on `main` as well.
`evals/control-legibility/actions.json` doesn't match `ACTIONS` in
`browser/runtime/icon-paths.js`: `back`, `delete`, `menu` and `move`
have no line, and `done` has a line but no action. This change touches
none of those files.

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

2 participants