Repository navigation
fix: keep a details toggled twice within a frame where the second toggle left it - #7515
Conversation
…gle left it Effect UI writes the Model's `open` back onto a controlled `details` one animation frame after each `toggle`. A second toggle made before that frame was overwritten, and the browser merged its queued `toggle` into one that reported no change, so lf-call-diff's roots and lf-toc's contents disclosure dropped the second press without a sign. A patch to Effect UI's host records the state each node's latest `toggle` reported, and its restore skips a `details` whose `open` differs from it, since that node's `toggle` is still queued and its own restore follows. test_a_second_toggle_before_the_next_frame_holds fails on the old bundle and passes with the patch. Closes #7509
|
@leaf-agent The rapid-toggle regression reads
|
…e-toggled fold The rapid-toggle regression read `open` after two frames and a 50 ms timeout, which an unfinished second toggle could pass. It now waits for the second `toggle` event and a frame queued in its listener, which runs after the restore Effect UI's capture listener queued for it, asserts that event reports the press's own change, and reads `open` once after `rendered`. On the unpatched bundle it fails 4 of 4 runs at the event's state; with the patch it passes 5 of 5.
|
Done in 32fd818. The frame that injects the second click stays. The test no longer reads
On the unpatched bundle it failed 4 of 4 runs, each at the event's state ( |
leaf-agent
left a comment
There was a problem hiding this comment.
This PR fixes the race that the comment above test_evidence_close_folds_room_but_retires_controls_immediately's waits describes ("Effect UI writes the Model's open back in the frame after a toggle event, which undoes a toggle made before that frame"). Once it lands, that comment is false about the bundle Leaf ships. The description calls the waits harmless, but AGENTS.md, "Where instructions live", asks the tree to say what holds now. A reader would also take those four rendered(page) waits as still necessary and copy them into new tests. The description reports 4 of 4 passes without them, so I'm removing #7510's comment and waits in this PR. Each toggle in that test then follows the previous one immediately, the way a user's presses can.
…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.
…raws before its toggle (#7522) Effect UI writes a `details`' controlled `open` from two paths: the restore one frame after a `toggle`, and the render each message brings. #7515's patch (`build/@effect__ui.patch`) taught only the restore to wait while a press's `toggle` is still queued. A render in that gap still writes the Model's older `open` back. That undoes the press, and the browser merges the queued event into one reporting no change, so the Model never hears of the press. In `test_call_diff_projects_stable_commentable_rows`, the test folds the call tree's root and presses Enter on the root's location. When the Enter lands before the fold's `toggle`, the location's message redraws the tree and reopens the root. That is #7521's failure. The patch now sends both paths through one guard, `writeOpen`. It skips a `details` whose `open` differs from the state the host last knew for it. It also records each value the host writes or finds, so a node's first press is covered too. A Model that refuses a press still gets its value written back by the restore that the press's `toggle` brings. Dialogs and popovers take their own branches and are untouched. The only rebuilt bundle is `browser/vendor/effect-ui.js`. **Verification.** The new test `test_a_fold_redrawn_before_its_toggle_holds` folds a root and presses its location in one task, which forces the redraw ahead of the `toggle`. It failed 2 of 2 on main's bundle, where the `toggle` reported `open`, and it passes with the patch. The bundle from before #7515 fails the same forced ordering, so the race predates #7515, and #7515 left the render path unguarded. <details><summary>Other checks run</summary> - `test_call_diff_projects_stable_commentable_rows`: 24 of 24 under `leaf-dev suite flake --workers 4 --load 2`. Before the fix it failed about 1 in 25 locally, on Chromium, and the failure matched CI's capture: the patch line was focused and the root was open. - `test_render_toc_disclosure.py` together with the call-diff, toc, toggle and fold tests in `test_render_diff_controls.py`: 24 passed. - `pnpm run test:runtime`: 1237 passed. - `pnpm run check:browser` reproduces the committed bundle from the updated lock. </details> Closes #7521 — automated triage Co-authored-by: leaf-agent <[email protected]>
…7545) Leaf stops patching Effect UI. `build/@effect__ui.patch` (#7515, #7522) held one guard: the host skipped writing a `details`' controlled `open` while the user's `toggle` for it was still queued. Since #7542 no view controls `open`. `lf-call-diff` and `lf-toc` seed it with an attribute the view never changes, and `lf-worktree` writes an attribute only when its host's authored `open` changes. Effect UI writes an attribute only when the drawn value changes and never restores one, so the guard ran for no node. The rebuilt `browser/vendor/effect-ui.js` is byte-identical to the bundle before #7515. The race lives in the controlled idiom itself. The browser reports a fold with `toggle` a task after making it, and a draw or restore in that gap undoes the fold, even where the Model follows `toggle`. So a widget leaves a fold to the browser, and `effect-widget.ts`'s list of Effect UI's limits now says why. Max asked to avoid the patch ("it's much more likely we misunderstood something rather than the upstream needs patching"). The two race tests from #7515 and #7522 keep their assertions and pass on the unpatched bundle, 12 of 12 copies each under load; with the views from before #7542 put back, they fail. The `lf-call-diff`, `lf-toc` and `lf-worktree` browser tests, `pnpm run test:runtime` (1240) and `pnpm run check:browser` pass. > _This was written by Claude Code on behalf of max-sixty_
Effect UI treats a
details'openas controlled and writes the Model's value back one animation frame after eachtoggle. When the user toggled the samedetailsagain before that frame, the write-back undid the second toggle, and the browser merged its queuedtoggleinto one reporting no change, so the Model never heard of it. That dropped the second of two quick presses onlf-call-diff's roots andlf-toc's contents disclosure, which both draw through Effect UI and keepopenin 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 latesttogglereported. Its restore skips adetailswhoseopendiffers from that state, because atogglefor 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 isbrowser/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_holdspresses 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 secondtoggleand 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 readsopenonce afterrendered. 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.pyon Chromium (14) andpnpm run test:runtime(1237) pass.This also removes the
renderedwaits #7510 added totest_evidence_close_folds_room_but_retires_controls_immediatelyand 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