Repository navigation
docs(comments): no comment claims the stylesheet lands in a host page - #269
Conversation
Both headers explaining the build-time scoping pass opened on a premise #236 retired: that the widget has no shadow boundary, and that `vite-plugin-css-injected-by-js` appends the sheet to the host document's `<head>`. The embed has had an open shadow root since #236, and the sheet is adopted into it rather than appended anywhere. A maintainer who checked the stated reason and found it false could reasonably delete a pass that is still load-bearing. Each header now carries both halves of the real reason. `scripts/assert-css-scoped.mjs` already had them, and it is the only file in the tree that did. The weaker half is that `main.tsx` adopts the same sink into `document` for the standalone shell, and the Ladle decorator does the same, so there `<html>` is the theme root and an unscoped selector still repaints the page around the widget. The load-bearing half is the embed's: collapsing `:root`, `html`, `body` and `:host` onto `.sy-atlas` is what gives the widget a root to match inside the shadow root, where no `html` element exists — without it Preflight and the whole palette never apply to the embed at all. The `#91` breadcrumb stays in both, since it is still why the invariant is mechanical. The two measured leaks that motivated that stay with it, with "while a host page silently changes" corrected to the page around the widget — that sentence carried the retired premise in the present tense. Comments only. `comment-fingerprint.mjs --base origin/main` reports the code hash identical, the protected census unchanged (K3 4→4, K4 2→2), and no comment displaced. Co-authored-by: Claude Opus 5 <[email protected]>
Review of the previous commit caught a false claim it introduced: that the standalone shell "and Ladle" adopt the sheet into the document. `adoptStyles` has two call sites — `Widget.tsx` (the shadow root) and `main.tsx` (the document). `sheet.ts` says it outright: Ladle is not in that path, because `.ladle/vite.config.ts` skips the injector and imports `globals.css` the ordinary way. Both headers now say the two boundary-less builds PUT the sheet on `<html class="sy-atlas">`, which is how `assert-css-scoped.mjs` words it and is true of each. Two claims were too strong. "The embed can no longer leak onto a host page" is wrong as stated, because `styles/fonts.ts` still puts its own `<style>` in `document.head` by design — the claim is now about this sheet. And "Preflight and the whole palette never apply to the embed" overstated the root collapse: Preflight's `*` and element rules match inside a shadow root unrewritten, so what the collapse is the only source of is the theme tokens, the palette, and Preflight's own `html`/`body` rules. Dropped "do not retire this pass on the boundary — it is functional now, not only defensive." It only parses as an answer to a reviewer of a diff, and the sentence before it already makes deletion obviously wrong. The theme block 70 lines below the header carried the same retired premise in `globals.css`, describing the rem hazard as applying "in a sheet injected into their head". The hazard is real and unchanged — a rem resolves against the host's root font size from inside the shadow root too — so only the mechanism clause moved. Co-authored-by: Claude Opus 5 <[email protected]>
Deploying sahajatlas-design with
|
| Latest commit: |
a543454
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0304a7a7.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://claude-docs-264-css-scope-sh.sahajatlas-design.pages.dev |
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff matches #264 — two files, comments only, all five acceptance criteria hold, and the false premise is gone. I verified the load-bearing half in source.
The open question is size. #264 asked both headers to state the rationale, and the result is the same two-halves argument in four files for +14 net comment lines, in a repo whose comment rule says compress. On #247 you called the equivalent "very unnecessary and is adding extra load to our documentation".
One stale copy escaped the sweep: src/AGENTS.md:17, which loads in every src/ session, still carries the sentence this PR corrected in the @theme block.
Findings
should-fix— a fourth copy of the rationale; point rather than restate (src/styles/globals.css:6)should-fix—src/AGENTS.md:17unswept and unfiled (src/styles/globals.css:83)consider— the weaker half names a protection the pass cannot give (scripts/postcss-scope-widget.mjs:10)consider— broken antecedent at "That is Tailwind's Preflight reset" (scripts/postcss-scope-widget.mjs:11)
What was checked
- New claims verified in source:
r2wc(Widget, { shadow: 'open' })(Widget.tsx:447),adoptedStyleSheets(sheet.ts:62-89), the scope class on<html>(index.html:9,.ladle/components.tsx:35), the rewrite rules (postcss-scope-widget.mjs:28-57).:rootmatches nothing in a shadow tree, andremdoes resolve against the document root from inside one. - Diff is comment-only.
#91and#236present in both files, and neither file has a⚠line to lose. - The sweep re-run with wider terms (
lands in a host page,appends our stylesheet) oversrc/ scripts/ docs/: the five filed rows, plussrc/AGENTS.md:17. - No contract surface touched:
docs/embedding.md,public/_headers, the CSP table. Built CSS unchanged. - Reviewer profile read.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
`That is` replaced `That includes` when the WHY block was rewritten, so the list read as the identity of a top-level selector rather than as what the sheet holds at that level. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Giy78iBRfNKJYU8eQkZhyS
The scoping pass's two-halves argument is stated in `scripts/postcss-scope-widget.mjs`, `scripts/assert-css-scoped.mjs` and `src/components/AGENTS.md`. A fourth full copy here buys a CSS author nothing the operational paragraph above it does not already give them, so the header now leads with that and names the file that owns the argument. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Giy78iBRfNKJYU8eQkZhyS
Deploying sahajatlas with
|
| Latest commit: |
a543454
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://024b2664.sahajatlas.pages.dev |
| Branch Preview URL: | https://claude-docs-264-css-scope-sh.sahajatlas.pages.dev |
|
Four threads, two commits, two filings. Lean gate green on Adopted and resolved
Filed on #270, not swept here — both left open for you
🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
|
@sydevs-bot fold #270 into this PR: every site in its body and its follow-up comment, including |
#236 put the embed behind a shadow boundary, so the built sheet is adopted rather than appended to a host `<head>`. Five comments still stated the old mechanism as the reason for the code they defend. Each conclusion survives; the reason is re-derived: - `fonts.ts` — the runtime-resolved URL is still required, because a relative `url()` in a constructed sheet resolves against the document base URL. Its own `<style>` in `document.head` is now named as the one place the old mechanism really does still apply. - `architecture.md` — the injector is still in the chain, with an `injectCodeFunction` that hands chunks to `src/styles/sheet.ts`. - `List.tsx` / `List.test.tsx` — the host `li` rule the resets defended against cannot match inside the shadow root, and the boundary-less builds have no host page. The resets are kept, for independence from preflight, which resets `ol, ul, menu` and not `li`. - `base.css` — `.sy-carousel` is still right, because `.swiper` is Swiper's class and would repaint every instance in the widget. The spec's test name carried the retired premise too, so the diff is not comment-only. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BCPr8RSx4XSWZfZQXVhcBt
`src/AGENTS.md:17` carried the twin of the `@theme` sentence this branch already corrected: "The stylesheet lands in a host page". It does not — the embed adopts it into a shadow root (#236). The #238 hazard is unchanged, because a `rem` resolves against the host document's root font size from inside the root too. This copy loads in every session that touches `src/`, so it is the higher-traffic of the two. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BCPr8RSx4XSWZfZQXVhcBt
Both files said the pass keeps an unscoped selector from repainting the page in the two boundary-less builds. The scope class sits on `document.documentElement` there (`index.html:9`, `.ladle/components.tsx:35`), so `:where(.sy-atlas) :is(main)` matches exactly what `main` matched — the prefix narrows no reach, and neither build has a host page to be confined from. One re-derivation, written to both files: the collapse onto `.sy-atlas` is what survives the boundary, and the prefix is uniform so the collapse and the keyframe namespacing are total and the gate can read the result out of the emitted bytes. Three claims went with it. The leak list enumerated what escapes onto a host page, and nothing does. `assert-css-scoped.mjs` still said Preflight and the whole palette never apply to the embed, which is too strong — Preflight's `*` and element rules match inside a shadow root unrewritten. The stray-asset note had the host page linking a file it never sees. `:host` is no longer attributed to Tailwind 3.4; the pin is 4.3.3 and a version in a comment only goes stale again. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BCPr8RSx4XSWZfZQXVhcBt
…laim `src/components/AGENTS.md:57` said the pass is what keeps the two boundary-less builds honest. The scope class is the document root there, so it is not — and this branch has just retired the claim in both scripts. The guide now points at `postcss-scope-widget.mjs` for the argument instead of restating it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01BCPr8RSx4XSWZfZQXVhcBt
|
#270 folded in. Four new commits on Adopted — the five sites in #270's body ( Decided — Open question — the keyframe claim is in the body, three options and a recommendation. Its No longer comment-only —
🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
.sy-atlasis what survives fix(ui): host CSS without !important still restyles widget text #236.## Open questionswith a recommendation.Change outline
The change is at claim level, so each view paraphrases what the comments now assert rather than listing edits. One claim per line.
Contract — the stated rationale for the scoping pass
scripts/postcss-scope-widget.mjs, theWHY (issue #91)block:scripts/assert-css-scoped.mjs, the header — the file #264 treated as the reference, and the one copy that already had the embed half right:src/components/AGENTS.md, the scoping bullet — the fourth copy, found by the docs-sync sweep:src/styles/globals.css, the file header (7bc0a72): the operational paragraph leads, and one sentence namespostcss-scope-widget.mjsas the argument's owner. No fourth restatement.The host-head premise — the five sites #270 filed, plus the one review found
Each conclusion survives. Only the stated reason changes.
Also corrected while there
scripts/postcss-scope-widget.mjs:65attributed:hostto "Tailwind 3.4's Preflight". The pin is4.3.3, so the version is dropped rather than bumped — a version in a comment only goes stale again.Preview
Nothing renders differently. The CSS diff is comments, which the minifier strips, so no emitted byte moves.
Test results
On
a543454:.claude/skills/pr-prep/check.sh— lint, typecheck, 1682 unit tests across 136 filescomment-lint.mjs— no banned phrasing addedcomment-fingerprint.mjs— 4 of 5 parsed files code-identical, 1 CODE CHANGED:List.test.tsx, whose test name carried the retired premise. Protected census grew, never shrank (K3 7→9, K4 9→10); no comment displaced. Markdown and CSS are not parsed by it.#270's grep (injected into the HOST,HOST document's <head>,into the host's <head>,lands in a host page,appends our stylesheet) oversrc/ scripts/ docs/: no matches⚠line survives, in all ten files (src/components/AGENTS.md13→13,assert-css-scoped.mjs2→2,fonts.ts3→3). Every#91breadcrumb survives;#236is added in six files.On
3310766, before the review commits:pnpm build, includingassert:css(1176 rules confined, 62@propertyallowlisted) andassert:maps. Not re-run since — every commit after it changes comment text, plus one test name. CI runs it.src/styles/,scripts/[^/]*css); no findings, and the content trigger matched no added lineManual verification
globals.cssandsrc/components/AGENTS.mddeliberately send you topostcss-scope-widget.mjsfor the argument, and nowhere else restates it.List.tsx: check you agree the resets stay. The old reason is gone, and the one written in its place is weaker — see## Open questionsif you would rather delete the classes.Open questions
The keyframe-namespacing rationale says a bare
@keyframes fadeIn"would hijack any host animation of that name". It appears three times:scripts/postcss-scope-widget.mjs(the rewrite list),src/styles/globals.css:563, and verbatim inscripts/assert-css-scoped.mjs. Keyframe names in a sheet adopted into a shadow root are tree-scoped, so the embed cannot reach a host's animations, and the shell and Ladle have no host. The namespacing is still needed; the stated reason is not the reason.The same shape sits next to it in
assert-css-scoped.mjs:144-150:@font-faceis exempted from the gate because "the font-family name is document-global, and the last definition wins", which it is — but a@font-faceinside a shadow root is never applied at all (src/styles/sheet.ts:21-24), so the hazard it names is unreachable for the embed too.@propertyat:156is the one of the three that is still exactly right: registration is per-document wherever the sheet is adopted.postcss-scope-widget.mjs, point the other two at itglobals.css.Recommendation: C, with A's re-derivation as the wording. The true reason is not a host page in either direction — it is that runtime-injected third-party CSS never reaches the pass, and lands in the same tree our sheet does. vaul shipped a bare
@keyframes fadeIn(patches/[email protected]) and Tailwind shipsspin/pulse, so namespacing ours is what keepsanimation: sy-atlas-fadeInresolving to our own definition and nothing else. The gate is what makes that mechanical. Say the word and it goes in this PR; otherwise it wants its own, since it is the third wording of the same claim andglobals.css:563is the only one of the three a CSS author reads.Notes for reviewer
List.tsxis the one place a decision was taken rather than a sentence rewritten. docs(comments): five more comments still say the stylesheet lands in the host's<head>#270 offered "state a true reason, or remove the code with it". The classes are kept: removing them changes rendered output, which wants a computed-style check in a browser (src/AGENTS.md's own rule), and this PR has no browser pass. The reason written in their place is honest about being narrower than the one it replaces.List.test.tsx's test name said "so host element rules cannot paint bullets". Renaming it is the only non-comment change in the branch, and the fingerprint reports it rather than hiding it.postcss-scope-widget.mjs, including the antecedent repaired in0d23201. It enumerated what escapes onto a host page at top level, and nothing does. The two measured leaks stay, re-dated.assert-css-scoped.mjslost its "weaker half" framing entirely, because the weaker half turned out not to be a reason. That file is also where docs(comments): the CSS scoping pass still says the widget has no shadow boundary #264's reference wording came from, so the two scripts now carry one paragraph instead of two readings of it.flattenCascadeLayersdocblock inpostcss-scope-widget.mjs:397still says a layered rule "loses to a host page's plainbutton { ... }" — the same host-wins premise, repeated atsrc/AGENTS.md:17. It reaches into feat(widget): de-brand the widget and keep host CSS out of it #156 andhost-reset.css, which is fix(ui): hostcolorstill reaches widget text —--foregroundis never declared #262's subject. Say the word and it moves into this PR.#270's own "Notes" item aboutpostcss-scope-widget.mjs:65is folded in; its keyframe acceptance criterion is the open question above, so it is the one boxCloses #270leaves unticked.Detail
What was verified, and how. The shadow root is real (
r2wc(Widget, { shadow: 'open' }),src/Widget.tsx:447); the sheet is a constructedCSSStyleSheetonadoptedStyleSheets(
src/styles/sheet.ts:62-89);vite.config.ts:269passesinjectCodeFunction, so nothing isappended to a
<head>;src/main.tsx:19,index.html:9and.ladle/components.tsx:35are thethree places
<html>carries the scope class — which is what makes the prefix inert in those twobuilds, since the scope class is then an ancestor of every element in the document.
Why the
Listresets survive the decision. Preflight's list rule isol, ul, menu { list-style: none }(node_modules/tailwindcss/preflight.css:202) and its universal rule zeroesmarginandpaddingon*, solist-none,m-0andp-0duplicate it exactly, and each<li>wouldinherit
nonefrom the<ul>without[&>li]:list-none. Against a host rule they are nowunreachable either way. What is left is specificity against an element rule inside OUR sheet:
swiper ships
.swiper { list-style: none }, in the same direction, and a future@importneednot be. That is the reason written into the file.
Why
fonts.tsis the one file where the old mechanism partly still applies.sheet.ts:21-24says
@font-faceis deliberately not in the adopted sheet, because a face registered inside ashadow root is never applied, and
fonts.tskeeps putting its own tag indocument.head. So theheader now distinguishes the two: the adopted sheet is appended nowhere, and this file's own
<style>really is in the host document.One claim that was checked and left alone.
assert-css-scoped.mjs:319says aremresolvesagainst the host's root font size. That is still true from inside the shadow root, which is the
same correction this PR made to the
@themeblock and tosrc/AGENTS.md:17.Closes #264
Closes #270
🤖 Generated with Claude Code
https://claude.ai/code/session_01BCPr8RSx4XSWZfZQXVhcBt