Skip to content

test: wait for the call tree's toggle to settle before toggling it again - #7510

Merged
leaf-agent merged 1 commit into
mainfrom
fix/issue-7503
Nov 28, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/issue-7503

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

The browser-call copy of test_evidence_close_folds_room_but_retires_controls_immediately toggled the call tree's details several times in a row, and some toggles were undone. lf-call-diff draws through Effect UI, which controls open. After a toggle event, Effect UI writes the Model's open back one animation frame later. If the next toggle lands before that frame, it is overwritten with the Model's older value, and the browser merges the two pending toggle events into one that reports no change.

The test now waits for rendered before each toggle that follows another toggle. The reading right after each toggle is still immediate, so the test still checks that opening is instant and that closing retires the controls at once. Neither the media emulation nor the CSS transition was involved. The trace shows the reopen coming from Effect UI's restore frame (restoreSoon in @effect/ui's html/internal/dom.ts).

Verification on this runner: the base failed 6 of 6 runs of the node id, at the third and fourth toggles. With the change it passed 16 of 16 runs, plus 12 of 12 copies through leaf-dev suite flake --cpu-throttle 6 --load 2. All four parametrizations pass.

A user who toggles twice within that window loses the second press the same way. That product defect lives in Effect UI and also reaches lf-toc. It is tracked in #7509, since Effect-TS/ui isn't taking issues during its move into the Effect monorepo.

Closes #7503 — automated triage

test_evidence_close_folds_room_but_retires_controls_immediately[browser-call]
toggled the call tree's details several times in a row. lf-call-diff draws
through Effect UI, which treats `open` as controlled: after a `toggle` event
it writes the Model's `open` back in the next animation frame
(`restoreSoon` in @effect/ui's html/internal/dom.ts). A toggle made before
that frame is overwritten with the Model's older value, and the browser
merges the two pending `toggle` events into one that reports no change, so
the press is lost. Recorded in the page: Enter closed the details at 79 ms,
the restore frame set `open = true` at 95 ms, and the one `toggle` that
followed reported `open`.

Each toggle's own reading is still taken right after it; the test now waits
for `rendered` before the next toggle, which lets the restore frame pass.
Locally the test failed 6 of 6 runs before and passed 16 of 16 after, and
12 of 12 copies at 6x CPU throttle with 2 busy loops.

Closes #7503
@leaf-agent
leaf-agent merged commit 5aa90a6 into main Nov 28, 2026
8 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-7503 branch November 28, 2026 08:04
leaf-agent added a commit that referenced this pull request Nov 28, 2026
…necessary

test_evidence_close_folds_room_but_retires_controls_immediately again presses
each toggle right after the last, as a user can. The comment that explained the
waits described the write-back race this branch fixes, so it no longer held.
leaf-agent added a commit that referenced this pull request Nov 28, 2026
…gle left it (#7515)

Effect UI treats a `details`' `open` as controlled and writes the
Model's value back one animation frame after each `toggle`. When the
user toggled the same `details` again before that frame, the write-back
undid the second toggle, and the browser merged its queued `toggle` into
one reporting no change, so the Model never heard of it. That dropped
the second of two quick presses on `lf-call-diff`'s roots and `lf-toc`'s
contents disclosure, which both draw through Effect UI and keep `open`
in their Model.

A pnpm patch to Effect UI's host (`build/@effect__ui.patch`, applied the
same way as the existing Plot and Pierre patches) records the state each
node's latest `toggle` reported. Its restore skips a `details` whose
`open` differs from that state, because a `toggle` for that node is
still queued and its own restore follows once the Model hears it. A
Model that refuses the toggle still gets its value written back on that
later restore. Dialogs and popovers take their own restore branches and
are untouched. The only rebuilt bundle is `browser/vendor/effect-ui.js`.
The patch should go once Effect UI ships the fix upstream. Effect-TS/ui
isn't taking issues while it moves into the Effect monorepo, so nothing
has been filed there.

`test_a_second_toggle_before_the_next_frame_holds` presses a call-tree
root twice, with the second press in a frame callback that runs just
before Effect UI's write-back. It then waits for the second `toggle` and
a frame its listener queues, which runs after the restore Effect UI
queued for that toggle, asserts the event reports the press's own
change, and reads `open` once after `rendered`. It failed 4 of 4 runs on
the unpatched bundle, each at the event's state, and passed 5 of 5 with
the patch. `test_render_toc_disclosure.py` on Chromium (14) and `pnpm
run test:runtime` (1237) pass.

This also removes the `rendered` waits #7510 added to
`test_evidence_close_folds_room_but_retires_controls_immediately` and
its comment explaining them, which described the race this patch fixes.
That test again presses each toggle right after the last, and it passed
3 of 3 on Chromium and Firefox after the removal.

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

1 participant