Repository navigation
fix: style shadow-tree widgets in Firefox - #4295
Merged
Merged
Conversation
Every widget styled through a package's widget-shadow.css (the diff package's, lf-file-editor and lf-file-tree) drew with no package styles in Firefox: a diff showed bare line-number buttons over unshaded monospace text. #4205 composed those sheets as `@scope (:host(:is(...))) to (<foreign widgets>)`, and Firefox applies no rule in a `:host`-rooted scope that has a `to` limit, even one that matches nothing (Firefox 158.0.1 stable and Playwright Firefox 155; Chromium and WebKit apply it). The document scope's limit works in all three. The shadow scope now has no limit. A shadow tree holds only what its own module built, so it has no nested widget's authored content for the limit to protect; no bundled module puts a foreign widget there. The document boundary is unchanged, and packages.md now says it applies in the document. The CSS scope contract tests in tests/browser/threads/test_layout.py ran only in Chromium; both now run in Firefox and WebKit too. With the limit restored, the shadow test and test_rings' Firefox diff-focus test fail. That Firefox test had failed on main since the first completed run after #4205, and its cause issue read the failure as a focus problem, since the assertion names only the element it waited on. A failing browser test now saves a screenshot of each page it held under .tmp/test-results/screens/, which CI already uploads, and tests/AGENTS.md says to look at it before diagnosing. Closes #4218 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
leaf-agent
approved these changes
Oct 26, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The focused WebKit document-scope case passed its styling assertions but reported Fetch API cannot load …/api/user-view due to access control checks at teardown. I reproduced the same error against main at ce843aa with only this PR’s test parametrization copied over, so it does not withhold approval under the repository’s inherited-failure policy.
This was referenced Oct 26, 2026
leaf-agent
added a commit
that referenced
this pull request
Oct 27, 2026
The package CSS scope test changes the page's registry, forcing a document reload. WebKit reports a caught fetch rejection from the departing document as a native page exception while the replacement loads; the health collector then fails teardown even though the revised page passes its CSS assertions. This also reproduces on a plain HTML page without Leaf, using a caught fetch while the next document's response is held. Use the existing `restarting` span for this deliberate executable-layer replacement, ending after revision 2 and its CSS boundaries are asserted. Document that application of the helper. This preserves the cross-engine scope coverage added by #4295 and changes no runtime behavior. Validation: the original WebKit case reproduced the reported teardown error locally. Holding the revision navigation reproduced it with the server still running; that controlled case passed with the span and failed again with the span removed. The final package scope test passes in Chromium, Firefox and WebKit (3 passed). Closes #4333 — automated triage Co-authored-by: leaf-agent <[email protected]>
This was referenced Oct 27, 2026
leaf-agent
added a commit
that referenced
this pull request
Oct 27, 2026
Failure screenshots added in #4295 used a local five-second timeout, so the suite's shared-deadline check rejected the helper. Capture now explicitly uses `SERVED_TIMEOUT_MS`, including for watched pages that bypass `readable()`. Screenshots remain bounded and best-effort; closed pages and Playwright failures retain their existing handling. The reported `test_a_wait_takes_the_suites_deadline` failed before this change and passes after it. A direct Chromium probe also saved a nonempty screenshot and skipped a closed page. Python compilation and the whitespace check pass. Closes #4370 — automated triage Co-authored-by: leaf-agent <[email protected]>
max-sixty
added a commit
that referenced
this pull request
Oct 27, 2026
`page init` wrapped every package sheet in a generated `@scope (<package tags>) to (<foreign widgets>)`, rooted at `:host(...)` in shadow trees, so authors wrote `:scope` for "my widget" and Leaf kept a package's rules off widgets nested inside its own. That generated CSS is what Firefox mis-evaluated in #4295, and it guarded cases nothing exercised: every class the bundled packages name is already package-prefixed. Leaf now places each sheet in its cascade tier and rewrites none of its rules. Package sheets name their widgets: `lf-tabs .lf-tabstrip` in the document, `:host(lf-diff.lf-rendered) .x` in a shadow tree. A codemod made the ~570 `:scope` edits; an authored `@scope (html[data-lf-interactive] :scope)` keeps its native meaning, now rooted at the widget it styles. widget-shadow.css still reaches both trees. The theme-shadow.css role goes: a theme reaches shadow trees through the custom properties they inherit. The diff's palette and geometry no longer load twice, since the document rule already sets them on the host. Behavior: a package's rules now reach a foreign widget nested inside its widgets, which no bundled rule does. Measured by reading 42 computed properties on every element, shadow trees included, across 17 examples in Chromium and 7 in Firefox, main against this change, two examples differ, both toward what their package declares. A visual review's capture shot now takes the `margin: 0` its package declares (it had kept 10px from the default package through scope proximity). A deck's open card now drops its first and last child's outer margins, as the deck's rules say; the generated limit had stopped those rules at the card, an `lf-ask` from another package. The diagram's negative end margin lost specificity to the layer's trim of a frame's last margin and now names `:last-child` to keep it. Tests: the contract test for the generated boundary goes with it; the shadow confinement test now writes `:host(lf-own-tree) span` and still runs in every engine; the theme-shadow test goes. No protocol bump: a page vendored earlier keeps its composed sheets, which the runtime doesn't read differently. Deleting `page-sheets.js`, the runtime rewriting of page CSS, follows in its own PR. > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 <[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.
Every widget styled through a package's widget-shadow.css (the diff package's, lf-file-editor and lf-file-tree) drew with no package styles in Firefox: a diff showed bare line-number buttons over unshaded monospace text. #4205 composed those sheets as
@scope (:host(:is(...))) to (<foreign widgets>), and Firefox drops a:host-rooted scope whole for many limits, this one among them, even when the limit matches nothing (Firefox 158.0.1 stable and Playwright Firefox 155; Chromium and WebKit apply it). The same limit on the document scope works in all three.The shadow scope again has no limit, as before #4205. A package's widget-shadow.css therefore reaches everything its widgets' shadow trees hold, including core views placed there, such as a diff's threads and the widgets in their messages; no bundled module puts a foreign widget there itself. The document boundary is unchanged. packages.md now says the boundary is the document's, and that a nested
@scope (html[...] :scope)condition works only in widgets.css, since a shadow tree's rules can't see the document.The CSS scope contract tests in tests/browser/threads/test_layout.py ran only in Chromium; both now run in Firefox and WebKit too. With the limit restored, the shadow test and test_rings' Firefox diff-focus test fail. That Firefox test had failed on main since the first completed run after #4205, and its cause issue read the failure as a focus problem, since the assertion names only the element it waited on. A browser test that fails, in its body or through the problems its browser fixture asserts at teardown, now saves a screenshot of each page it held under .tmp/test-results/screens/, which CI already uploads, and tests/AGENTS.md says to look at it before diagnosing.
Closes #4218