Skip to content

Commit a6fcf15

Browse files
max-sixtyclaude
andauthored
Repair the three nightly tests the interaction gallery left red (#359)
Three nightly tests have been red on `main` since #341, and nightly runs after `main` moves, so PR CI and `wt merge` both stay green while nobody sees them. All three are the same seam: the live interaction gallery injects its playback row from the runtime and leaves the authored page owning it. **The ring census.** The page drew `outline: var(--here-ring)` on the injected presses without naming the ring, so the floor below divided by a population short of it. It was drawing the ring twice over: `offer` marks those buttons `data-lf-offer="button"`, so the theme's pressable floor already carries the hand, the hover tint, the disabled treatment, and a ring that names itself. The page's copies are gone and the floor's answer stands alone. No other authored page in the corpus draws the layer's ring. **The control-row sweep.** The row is a control row nothing had declared. Declaring it means proving it holds still, and it did not: the toggle rewrites its own word as a demo runs — Loading…, Play, Pause, Played — so pressing Replay moved the button beside it, and the live status line changed length on the same line as both presses. The toggle now reserves the width of every word it can say, through `reserve`, the layer's own helper, called where the runtime builds the row — `scripts/corpus.py` copies each source's `<main>` and none of its `<head>`, so a rule in the gallery's head would not reach the generated corpus, which is the page this sweep actually walks. The status line stands under the two presses at every width rather than only on a phone; reserving its width instead would hold the row open at the width of its longest sentence. `interaction-playback` is the new archetype; an archetype may now name an `example`, because a demo is a scenario the module names rather than markup the synthetic stability page can compose, so its proof runs on the gallery itself. Replay is the press for the same reason the diff's review press is: the button that has to hold still is the toggle, and pressing Replay is what sends it through every word it has. **The injected-surfaces walk.** The gallery's own counts had moved on: #341 added a live undecided suggestion and a second stored version, and merging `main` brought the playground package's ask, so the walk now sees thirteen asks and three version rows. `tests/test_site.py` asserted the status line's `margin-left: 0` at 390px, which the layout change makes vacuous; it now reads the invariant that replaced it. ## Checks `uv run pre-commit run --all-files` is clean, and `uv run pytest tests --run-nightly` passed whole — 2096 tests — on this branch before `main` moved under it. On the merged tree that full run reports 11 failures. A paired control, a detached checkout of `ca4ac82d` with none of this branch on it, fails 10 of the same tests, so they arrived with the eight PRs that landed while the first run was going. The eleventh, `test_a_failed_preview_bootstrap_hears_the_replacement_server[theme.css]`, passes on its own here and on the control: a flake in a 27-minute run. The three tests this PR is about pass. Nightly is red on `main` for two reasons this PR does not reach, both worth someone's attention: - the playground package's Reset, Copy instruction and Apply card share rows and match no archetype, so `test_the_composed_corpus_declares_every_control_row_archetype` fails on `main` for that reason now instead; - `.lf-resolve.lf-icon-action` (#347) has the left edge of its focus ring under `.lf-react-trigger` (#349) in the ship-review thread, two independent PRs whose rows now overlap by two pixels, which `test_every_ring_the_layer_draws_is_shown_whole_somewhere_in_the_corpus` reports as 2 faults over 714 stops. Plus pre-existing reds in `test_render_anchors`, `test_render_export`, `test_render_projection` and `test_render_widgets`, all present on the control. **#340 is the standing fix for the shape of this: nightly modules a PR touches never run before it lands. ## Overlapping PRs **#353 repairs the same three readings, and opened while this branch's first suite was running. It took the `reserve` route from the start, which is where this one has now arrived; it also rehomes the scenarios' `#bg-motion-*` lookups onto the stage, which this does not. One of the two should close, and which is Max's call. ## Note for #351 **#351 deletes this same block of gallery CSS and rehomes none of it, which would leave the injected buttons without their pill shape or their `--aim-floor` aim target. Whichever lands first, the other conflicts here. > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Q7ZBoNLYxFVhWgDsXH1RTx --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
1 parent d6bb623 commit a6fcf15

5 files changed

Lines changed: 59 additions & 30 deletions

File tree

‎examples/developer/feature-gallery.html‎

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@
174174
margin-top: 14px;
175175
}
176176

177+
/* Shape only. The runtime built these two, so the layer's own pressable rules
178+
already carry the hand, the hover tint, the disabled treatment, and the here
179+
ring that names itself to the ring census; a page drawing any of them again
180+
would be a second answer to a question the layer has already settled. */
177181
.interaction-gallery .interaction-control {
178182
min-height: var(--aim-floor);
179183
padding: 6px 13px;
@@ -182,26 +186,18 @@
182186
background: var(--card);
183187
color: var(--ink);
184188
font: 600 var(--t-6) / 1.2 var(--sans);
185-
cursor: pointer;
186189
}
187190

188191
.interaction-gallery
189192
.interaction-control:is(:hover, :focus-visible):not(:disabled) {
190193
border-color: var(--accent);
191194
}
192195

193-
.interaction-gallery .interaction-control:focus-visible {
194-
outline: var(--here-ring);
195-
outline-offset: var(--here-ring-gap);
196-
}
197-
198-
.interaction-gallery .interaction-control:disabled {
199-
color: var(--muted-2);
200-
cursor: default;
201-
}
202-
196+
/* Under the two presses rather than beside them, at every width. The runtime
197+
rewrites this line as the demo runs, and prose that changes length on the line a
198+
button stands on moves the row while the reader is aiming at it. */
203199
.interaction-gallery .interaction-status {
204-
margin-left: 5px;
200+
flex-basis: 100%;
205201
color: var(--muted);
206202
font: var(--t-6) / 1.4 var(--sans);
207203
}
@@ -298,11 +294,6 @@
298294
font-size: 13px;
299295
line-height: 1.4;
300296
}
301-
302-
.interaction-gallery .interaction-status {
303-
flex-basis: 100%;
304-
margin-left: 0;
305-
}
306297
}
307298

308299
@media print {

‎skills/leaf/assets/runtime/interaction-gallery.js‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,25 @@
66
* or behavior cost for this developer surface. */
77

88
import { onMotionPreferenceChange, reducedMotion } from "./motion.js";
9-
import { el, offer } from "./widget-elements.js";
9+
import { el, offer, reserve } from "./widget-elements.js";
1010

1111
class StaleDemo extends Error {}
1212

13+
// Every word the toggle can say, out here because the row reserves the width of all of
14+
// them before it says the first. The button rewrites its own word as a demo runs, and
15+
// Replay stands beside it, so a word that costs a different width moves the control the
16+
// reader is aiming at. Reserved by the runtime rather than by the page, because the
17+
// runtime is what injects this row: the page it is injected into may carry no rule for
18+
// it at all, which is exactly the case in the generated corpus.
19+
const TOGGLE_WORDS = {
20+
idle: "Loading…",
21+
ready: "Play",
22+
playing: "Pause",
23+
paused: "Play",
24+
finished: "Played",
25+
error: "Unavailable",
26+
};
27+
1328
const ARRIVAL_PAUSE = 900;
1429
const POINTER_TRAVEL = 1400;
1530
const RESULT_PAUSE = 1200;
@@ -309,6 +324,8 @@ export function installInteractionGallery() {
309324
status.setAttribute("aria-live", "polite");
310325
controls.append(toggle, replay, status);
311326
tabs.before(controls);
327+
// After the row is in the document, which is where a width can be measured at all.
328+
reserve(toggle, Object.values(TOGGLE_WORDS));
312329
let active = null;
313330
let onScreen = false;
314331

@@ -322,14 +339,7 @@ export function installInteractionGallery() {
322339

323340
function renderControls() {
324341
if (!active) return;
325-
const words = {
326-
idle: "Loading…",
327-
ready: "Play",
328-
playing: "Pause",
329-
paused: "Play",
330-
finished: "Played",
331-
error: "Unavailable",
332-
};
342+
const words = TOGGLE_WORDS;
333343
toggle.textContent = words[active.state];
334344
toggle.disabled = ["idle", "finished", "error"].includes(active.state);
335345
replay.disabled = active.state === "error";

‎tests/test_render_controls.py‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,19 @@ def ceiling(limit, approvals):
195195
"coverage": ".lf-diff-review",
196196
"target": "#stable-diff .lf-diff-review",
197197
},
198+
{
199+
# The gallery's playback row. The runtime injects Play/Pause and Replay beside
200+
# the authored demos and rewrites the toggle's own word as a demo runs, so what
201+
# the row has to prove is that the word costs the button no width. Replay is the
202+
# press for that reason: the toggle is the button that has to hold still, and
203+
# pressing Replay is what sends it through every word it has. `example` because
204+
# a demo is a scenario the module names rather than markup a page can compose,
205+
# so the mechanism stands on the gallery and nowhere a synthetic page reaches.
206+
"name": "interaction-playback",
207+
"example": FEATURE_GALLERY,
208+
"coverage": ".interaction-controls > button",
209+
"target": "[data-interaction-replay]",
210+
},
198211
)
199212
CONTROL_ROW_PRESS = (
200213
"button, summary, select, "
@@ -1585,9 +1598,15 @@ def test_forced_colors_restore_a_real_outline_to_shadow_focused_fields(browser,
15851598
)
15861599
def test_each_control_archetype_holds_its_neighbours_still(browser, serve, archetype):
15871600
"""Each row mechanism holds its other controls still across its causal transition."""
1601+
# The synthetic page composes every mechanism a page can author, and carries the
1602+
# standing comment the margin Button's row is made of. An archetype naming an example
1603+
# is one no page can compose, so its proof runs where the mechanism lives.
1604+
example = archetype.get("example")
15881605
page, errors = open_page(
15891606
browser,
1590-
serve(
1607+
serve(example)
1608+
if example
1609+
else serve(
15911610
CONTROL_STABILITY_PAGE,
15921611
events=[
15931612
{

‎tests/test_render_navigation.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def test_the_feature_gallery_exercises_the_injected_core_surfaces(
100100

101101
page.locator(".lf-asks").click()
102102
asks = page.locator("button.lf-asks-row")
103-
expect(asks).to_have_count(11)
103+
expect(asks).to_have_count(13)
104104
expect(asks.first.locator(".lf-asks-kind")).to_have_text("ask")
105105
expect(asks.first.locator(".lf-asks-says")).to_contain_text(
106106
"Which map should the sample team carry?"
@@ -133,7 +133,7 @@ def test_the_feature_gallery_exercises_the_injected_core_surfaces(
133133
page.locator(".lf-threads-toggle").click()
134134

135135
page.locator(".lf-version").click()
136-
expect(page.locator(".lf-version-menu .lf-version-row")).to_have_count(2)
136+
expect(page.locator(".lf-version-menu .lf-version-row")).to_have_count(3)
137137
page.keyboard.press("Escape")
138138

139139
page.keyboard.press("?")

‎tests/test_site.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,16 @@ def test_the_interaction_gallery_drives_real_widgets(serve, browser):
567567
).evaluate_all(
568568
"nodes => nodes.map(node => getComputedStyle(node).fontSize)"
569569
) == ["11.5px", "11.5px", "11.5px"]
570+
# The live line stands under the two presses at every width rather than beside
571+
# them, because the runtime rewrites it as the demo runs and prose that changes
572+
# length on a button's line moves the row while the reader is aiming at it.
573+
assert gallery.evaluate(
574+
"""gallery => {
575+
const toggle = gallery.querySelector('[data-interaction-toggle]');
576+
const status = gallery.querySelector('[data-interaction-status]');
577+
return status.offsetTop >= toggle.offsetTop + toggle.offsetHeight;
578+
}"""
579+
)
570580
expect(accept).to_have_attribute("data-lf-state", "accept")
571581
assert read_events(page_dir) == before
572582

@@ -591,7 +601,6 @@ def test_the_interaction_gallery_drives_real_widgets(serve, browser):
591601
assert gallery.locator("#bg-motion-board").evaluate(
592602
"board => getComputedStyle(board).gridAutoFlow === 'row'"
593603
)
594-
assert status.evaluate("status => getComputedStyle(status).marginLeft") == "0px"
595604

596605
replacement_installed = gallery.evaluate(
597606
"""gallery => {

0 commit comments

Comments
 (0)