Skip to content

Drop the Effect UI patch: no view controls a details' open any more - #7545

Merged
max-sixty merged 2 commits into
mainfrom
agent-a0998acdda8645d14
Nov 28, 2026
Merged

max-sixty merged 2 commits into
mainfrom
agent-a0998acdda8645d14

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

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

`build/@effect__ui.patch` (#7515, #7522) held one guard and nothing else:
Effect UI's host skipped writing a `details`' controlled `open` while a
`toggle` for it was still queued. It covered only the controlled path,
`.open()` or `.prop("open")`, which Effect UI writes on every draw and
again in the frame after each `toggle`. Since #7542 no view writes `open`
that way. lf-call-diff and lf-toc seed it with an `.attr` the view never
changes, and lf-worktree writes an `.attr` from its host's authored
`open`. Effect UI writes an attribute only when the view's value differs
from the last draw's (`patchAttrs`) 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 the patch fixed lives in the controlled idiom itself, which
lf-call-diff and lf-toc used before #7542: `.open(model.open)` with a
`toggle` handler the Model follows. The browser reports a fold with
`toggle` a task after making it. A write in that gap, from a draw a
message brings or from the restore an earlier `toggle` queued, undoes the
fold, and the browser merges the queued `toggle` into one that reports no
change. `value` and `checked` have no such gap, since `input` and
`change` fire inside the gesture. Leaf's rule gives a fold to the
browser, so the fix was to stop controlling it, as #7542 did, rather than
to change the host. effect-widget.ts's list of Effect UI's limits now
says that a Model following `toggle` loses the fold too.

lf-worktree keeps its binding. Its `open` changes only when a revision
changes the host's authored `open`, and the write then lands where the
user's press already left the fold or replaces a fold the user never
changed. Its fold is also kept per tab through `data-lf-open-key`
(prepaint.ts, `keepDisclosure`), which sets `open` through the node, a
write a draw of a controlled `.open()` could undo.

Evidence, all on the unpatched bundle:

- A page with one Effect UI `details`: the controlled idiom lost the
  press in both races (Chromium: second press 0 of 5 held, press then
  redraw 0 of 5; Firefox 1 of 5 and 0 of 5). `.attr("open", "")` held
  5 of 5 in both, and the patched bundle held 5 of 5 in all four cases.
- Leaf's views from before #7542 fail
  `test_a_second_toggle_before_the_next_frame_holds`,
  `test_a_fold_redrawn_before_its_toggle_holds` and
  `test_call_diff_projects_stable_commentable_rows`. The views on main
  pass them, 12 of 12 copies each under `leaf-dev suite flake --workers 4
  --load 2`, as does lf-toc's
  `test_contents_disclosure_keeps_its_links_focus_and_open_state`.
- The lf-call-diff, lf-toc and lf-worktree browser tests (18 and 12
  subtests), `pnpm run test:runtime` (1240) and `pnpm run check:browser`
  pass.

The two race tests keep their assertions. Their comments described the
patch's write-back of the Model's `open`, and now describe the window
each one guards.

> _This was written by Claude Code on behalf of max-sixty_
@max-sixty
max-sixty merged commit 74dd35c into main Nov 28, 2026
8 checks passed
@max-sixty
max-sixty deleted the agent-a0998acdda8645d14 branch November 28, 2026 19:15
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