Repository navigation
Keep a frame in a diff thread loaded through revisions in WebKit - #3852
Merged
Merged
Conversation
Each revision of a diff unloaded any iframe in its line threads in WebKit: the frame stayed connected with a null contentWindow. `show()` cleared the host's light DOM with `this.replaceChildren()` on every rendering, and WebKit's `replaceChildren()` on a shadow host unloads every frame in its shadow tree, even with no child to remove. Removing each child with `remove()` keeps them, as Chromium and Firefox do in every form. The TODO blamed this on lf-diff moving outlets beside redrawn rows. A MutationObserver over the diff's shadow root showed the outlet of a surviving datum keeps its node and parent through a redrawn own line, an added line and a file inserted before it; outlets move only when their datum disappears. So lf-diff leaves that TODO item's list, and the WebKit gap is recorded in notes/browser-support.md. test_a_diff_revision_leaves_a_line_thread_where_it_stands runs in Chromium and WebKit; WebKit fails it with the old clear. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Takes main's TODO.md, whose backlog moved to GitHub issues in #4090. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
max-sixty
marked this pull request as ready for review
October 27, 2026 05:15
leaf-agent
approved these changes
Oct 27, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 27, 2026
Resolves lf-diff.js and notes/browser-support.md against #3852's squashed copy by keeping this branch's side: shadowStage clears the host, so lf-diff's local child-by-child clear goes. Rebuilds dist/kernel from main's. Co-Authored-By: Claude Opus 5.5 <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Oct 27, 2026
`shadowStage` now clears the host's light children itself, child by child. Three widgets cleared their own host with `replaceChildren()`; in WebKit that unloads every iframe in the host's shadow tree (#3852 fixed only `lf-diff`). The `replaceChildren()` calls in `lf-diff.js`, `lf-file-editor.js` and `lf-file-tree.js` are gone, along with #3852's local workaround in `lf-diff`, so a widget has nothing to remember. `notes/browser-support.md` now names `shadowStage` as the one place a host is cleared. `dist/kernel` is rebuilt for `shadow-stage.js`. Call (reversible): the clear is unconditional (option a). An `x-shadow` widget slots none of its authored children, and sparing slotted ones depended on a slot existing at stage time, which the documented stage-a-container-then-render pattern breaks. `skills/leaf/references/module-authoring.md` ("Shadow stages and styles") now says the stage removes authored children, so a widget reads them first. Every in-tree caller already does: the three widgets above, the runtime's failure box for a staged widget (`widget-upgrade.js`), and the feature gallery's `lf-conversation-workspace`, which authors no children. Tests: the two `passage-boundaries` tests that slot content now add it after staging, and the first asserts the words exist so its `doesNotMatch` is not vacuous. Ran after merging main: `pnpm run check` (runtime 668 pass), `tests/browser/widgets/test_diffs.py -k line_thread_where_it_stands` (Chromium and WebKit), and the file-editor, file-tree and diff-revision selections of `test_render_files.py`, `test_render_diff_controls.py` and `test_diffs.py`. Not run: a WebKit test for `lf-file-editor` or `lf-file-tree` frames. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In WebKit, a frame in a diff line thread now keeps its document when the patch changes. Before this, every revision unloaded it: the iframe stayed connected but its
contentWindowwent to null. Chromium and Firefox were never affected.#4014, "Stop moving live content between parents", blamed this on
lf-diffmoving thread outlets beside redrawn rows. That isn't what happens on current main. I watched the diff's shadow root with a MutationObserver through several kinds of revision: one that redraws the thread's own line, one that adds a line after it, and one that puts another file before it, each for a line thread and a file thread, from both an inline patch and a manifest. In every case the outlet kept its node identity and no childList record removed it.replaceFileContentalready patches the existing.lf-diff-rows, andsetChildrenleaves the outlet in place. An outlet only moved when its datum disappeared (a line inserted above it shifted the numbers, or the file became metadata-only). There the thread has to leave its line anyway, so I didn't build the rows-stable refactor; it would change no behavior.The frame was unloaded by
show()callingthis.replaceChildren()on the host every time it rendered, to drop the authored<pre>placeholder. I patched DOM methods to find the call after whichcontentWindowwent null, and it was this one. In Playwright WebKit 26.6,replaceChildren()on a shadow host unloads every iframe in its shadow tree, even when the host has no children.textContent = ""does the same when it has some. Removing each child withremove()keeps the frames. Chromium 153 and Firefox 155 keep them in all three cases (minimal repro across the three engines, 2026-10-24).lf-diffnow removes its light children one by one.Changes:
packages/diff/widgets/lf-diff.js: the host's light DOM is cleared child by child instead of withreplaceChildren().tests/browser/widgets/test_diffs.py: newtest_a_diff_revision_leaves_a_line_thread_where_it_stands, run in Chromium and WebKit. It sets up a line thread whose agent reply holds an iframe, then sends a revision that redraws that line and adds a file before it. It asserts that the outlet is the same node, the frame's window is the same, and noloadevent fired. With the fix reverted, WebKit fails it ([True, None, 0] != [True, True, 0]) and Chromium passes.notes/browser-support.md: a known-gap entry for the WebKit behaviour.Calls Max may reverse:
.lf-diff-rowsper file for its whole life, adetailskept across rendering states), because the measurements found no outlet move for it to remove.replaceChildren()call sites. They run on hosts without a shadow root, or once at setup before anything stands in the stage. Thesource === nullpath inlf-diffclears the stage anyway.Ran: the new test before and after the fix,
tests/browser/widgets/test_diffs.pyandtests/browser/test_render_diff_controls.pyin full (52 passed), and the-k "diff or patch"selection oftests/browser/threads/test_seated_threads.py,tests/browser/test_render_anchors.py,tests/browser/projection/test_code_review.pyandtests/browser/projection/test_revision_patches.py(73 passed).Not verified: Safari itself (only Playwright's WebKit build), and selections across a revision in WebKit.
Part of #4014:
lf-diffleaves its list of places that move live nodes, and three remain.On landing, update #4014: "Four places" becomes three; drop the
lf-diffclause.