Repository navigation
fix(ui): host color still reaches widget text — --foreground is never declared - #273
Conversation
…ed property
`host-reset.css` restated `color` as `hsl(var(--foreground))`, and `--foreground`
was declared nowhere — not in `src/`, not by the runtime palette engine, not by
Radix Colors. An undeclared custom property makes the whole declaration invalid
at computed-value time, so `color` computed to `unset` and, being inherited, the
widget's root took the host page's `color` instead.
That is the failure the file exists to prevent, in one of the six properties it
pins, and it had never worked. Measured in Chromium against the built sheet, with
a host page setting `body { color: red }`: widget copy computed `rgb(255, 0, 0)`
in both light and dark before, and `rgb(32, 32, 32)` / `rgb(238, 238, 238)` after.
`color: var(--color-foreground)` reuses the token the rest of the sheet resolves
colour through, so it cannot drift from the ramp. It resolves to `--gray-12`, a
Radix hex, which is why it must not be wrapped in `hsl()` like the brand ramps
beside it, and which flips for dark mode through Radix's own dark file.
No gate could see this. `assert-css-scoped.mjs` asks where a rule applies, never
whether its values resolve, and the widget looks correct on any host that sets no
`color` — most of them. `host-reset.test.ts` closes it for all six properties:
every bare `var()` on the root must resolve through the real token files in both
modes, the root `color` must land on a literal hex, and the restated set must
match the list `docs/embedding.md` publishes to hosts.
Fixes #262
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…et declares Issue #262's defect was invisible to five gates. `assert-css-scoped.mjs` asks where a rule applies, never whether its values resolve; lint, typecheck and the unit lane see CSS as text. So `color: hsl(var(--foreground))` shipped as a no-op for as long as `host-reset.css` had existed. Adds check 5 to `assert-css-scoped.mjs`: every fallbackless `var()` in an emitted sheet must name a property that sheet declares. It covers all 1,176 rules and 750 references, not the 6 declarations one file's spec can reach. It reads the EMITTED sheet, and no source-level check can stand in for it: Tailwind 4 tree-shakes `@theme`, so `--container-3xs`, `--radius-3xl` and `--leading-loose` are all declared in `globals.css` and absent from every emitted sheet. `--color-foreground` ships only because `text-foreground` still has a call site — a source gate would call this fix sound right up to the commit dropping that call site, which is #262's own shape one level up. `RUNTIME_SET_PROPERTY` allowlists the four prefixes a pinned library's own JS sets (`--sx-`, `--yarl__`, `--swiper-`, `--radix-`), named so the exemption stays visible, as `ALLOWED_FONT_FAMILIES` and `ALLOWED_PROPERTY` already are. A non-vacuity guard fails the gate if the detector ever matches nothing, in the style of the three guards beside it. Verified by reintroducing the defect and rebuilding: the gate names `--foreground <- .sy-atlas { color }` and exits 1. Dropping the swiper prefix reports its 10 references; breaking the detector trips the non-vacuity guard. `host-reset.test.ts` keeps only what the emitted sheet cannot answer — that the restated set matches the promise `docs/embedding.md` publishes to hosts, in both directions, and that `color` is stated in the format its token carries, since `hsl(#202020)` resolves and still computes to nothing. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying sahajatlas with
|
| Latest commit: |
22dd6ef
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://162f14c1.sahajatlas.pages.dev |
| Branch Preview URL: | https://claude-fix-262-host-reset-co.sahajatlas.pages.dev |
Deploying sahajatlas-design with
|
| Latest commit: |
22dd6ef
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c335a575.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://claude-fix-262-host-reset-co.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 one-line fix is right, and the cascade argument behind it holds: postcss-scope-widget.mjs collapses :root, @theme and Radix's ramps onto .sy-atlas itself, so var(--color-foreground) resolves on the element the declaration sits on, in both modes. Check 5 earns its place — the harm is measured, the ticket asked for it, and src/ genuinely cannot answer the question.
The spec is where the diff outgrows the ticket. 80 of its 137 lines re-model the cascade in source to assert that one value is not hsl(#…), where the ticket asked for a pin on the declaration. docs/embedding.md needed no edit — its restated-property list was already the promise this fix makes true — and the CHANGELOG entry names the host-visible change honestly.
Findings
should-fix— the spec's token resolver re-models the cascade for one assertion (host-reset.test.ts:101).should-fix—?? '(none declared)'lets both format tests pass if the declaration is deleted (host-reset.test.ts:127).consider— check 5'sdeclaredset is per sheet; properties resolve per element (assert-css-scoped.mjs:224).consider— the #262 rule is stated five times across 261 added lines (src/AGENTS.md:19).
What was checked
Read whole: host-reset.css, host-reset.test.ts, assert-css-scoped.mjs, postcss-scope-widget.mjs (collapse rules, THEME_CLASSES), globals.css 15–46 and 200–310. Ticket #262's two options against the one taken. docs/embedding.md:996–1005 against the guide-pin regex — it matches, and the six properties agree. 28 text-foreground call sites, so the @theme retention the fix leans on is not thin. The CHANGELOG entry sits under [Unreleased].
Not run: pnpm build and the unit lane. This checkout has no node_modules, so every claim above is read from source.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
`ROOT.get('color') ?? '(none declared)'` is the `read() ?? fallback` shape
`docs/testing.md` names: delete the `color:` line from `host-reset.css` and
both format assertions still passed, because the placeholder matched neither
`BARE_VARS` nor `DOUBLE_WRAPPED`. Only the sibling guide pin caught it.
Proven able to fail: with the declaration deleted, the two format tests now
go red naming the missing property.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016tig3NCeXEnxzWvPU6nYYj
`tokens()`, `ramps()` and `resolve()` were a second, source-level model of the cascade — 80 of 137 lines, reading `@radix-ui/colors`' file layout out of `node_modules` — to assert one thing about one declaration. Whether the chain resolves is check 5's question, asked of the emitted sheet across 1,176 rules; what is left here is the format, and the format is structural. Two assertions replace it: `color` is a bare `var(--x)`, so no colour function can wrap a token that already holds a whole colour; and `@theme` states that token bare, so it is not a channel triplet. Mode drops out — `@theme` has no modes, and the light and dark values differ only in the ramp the gate already reads. Each proven able to fail at its own site: `hsl(var(--color-foreground))` fails the first, `var(--color-primary-9)` the second, a renamed token the `@theme` lookup, and a deleted declaration both. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_016tig3NCeXEnxzWvPU6nYYj
`declared` was rebuilt per sheet, but a custom property resolves per ELEMENT, and all three injected sheets style the same `.sy-atlas` subtree. So a token one sheet declares already reaches a reference in another, and the per-sheet set made that a build failure. Measured on this build: our own CSS all lands in one sheet today, because every file funnels through `globals.css`; the other two sheets are Schedule-X's and the lightbox's. So nothing fails today. But a component-scoped `.css` file in a lazily-loaded component — the shape both library sheets already have — would chunk separately, and the first `var(--color-divider)` in it would block every build, with all three remedies the message offers wrong for it. Proven both ways by injecting a scoped rule into the calendar chunk's emitted sheet: `var(--color-divider)` fails the per-sheet version and passes the pooled one, and `var(--nowhere-declared)` fails both. #262's own defect, reintroduced in `host-reset.css` and rebuilt, still fails the pooled gate naming `--foreground <- .sy-atlas { color }`. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_016tig3NCeXEnxzWvPU6nYYj
It stood in the checks list, `unresolvedVars`' jsdoc, the CSS comment, the spec header and `src/AGENTS.md` — around 100 of 261 added lines of prose for a one-line fix. Two sites carry it now: the AGENTS.md paragraph, where an author meets the rule, and the gate's failure message, where a build does. The rest keep a `#262` breadcrumb and the one fact that is local to them — at the declaration, that `--gray-12` is a hex and must never be wrapped. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_016tig3NCeXEnxzWvPU6nYYj
|
All four review findings adopted, one commit each, pushed as 4e5209a.
Lean gate green: lint, typecheck, 1684 tests across 137 files. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
The note read as if `color: var(--color-foreground)` were itself invalid at computed-value time, which is what #273's review asked about. It names the two edits that would void it instead, and says what happens when one lands. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FFQehyBUPiDdwjWyBazEwu
|
One thread from your review. Adopted as a comment fix, pushed as 1780cdd.
The declaration stays, and I left the thread open for you to settle. Comment-only: no declaration changed, so the build gate reads the same emitted CSS. Lean gate green — lint, typecheck, 1684 tests across 137 files. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
The note described this ticket's implementation rather than the file's long-term constraints, which is what #273's review asked. Nothing it carried is lost: `host-reset.test.ts` pins `color` as a bare token and pins that token's `@theme` value as an unwrapped colour, check 5 of `assert-css-scoped.mjs` fails a rename to an undeclared property, and `src/AGENTS.md` states the rule for an author. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014rKg8Qr3La5ik1bEMK9iAt
|
One thread from your review. Adopted, pushed as 22dd6ef.
Nothing it carried was prose-only, so nothing is lost. The PR body's one sentence pointing at that comment now points at the spec instead. Comment-only: the emitted sheet is byte-identical, so the build gate reads the same CSS. Lean gate green — lint, typecheck, 1684 tests across 137 files. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
host-reset.cssrestatedcolorthrough--foreground, declared nowhere, so the declaration was invalid and the host'scolorinherited in.Change outline
Behaviour — the one-declaration fix
--foregroundappears exactly once in the whole repo, and once in all ofdist/: this reference. Nothing declares it insrc/, in the runtime palette engine, or in Radix Colors..sy-atlas { src/styles/host-reset.css --sy-frame-h: 100dvh; - color: hsl(var(--foreground)); # invalid at computed-value time + color: var(--color-foreground); # -> --gray-12 -> #202020 / #eeeeee font-family: var(--sy-font-sans, …) # unaffected: has a fallback letter-spacing / text-align / text-transform / word-spacing }--color-foregroundis the tokentext-foregroundalready compiles to, so the root restatement and every utility that overrides it now read one source of truth. It resolves to a Radix hex, not the channel triplet the brand ramps carry —host-reset.test.tspins that distinction, since getting it wrong is silent.Contract — the gate that was missing
Checks 1–4 of
assert-css-scoped.mjsall ask can a rule reach a host page. Nothing asked does what we ship resolve.Flow — why the gate reads
dist/and notsrc/Measured, not assumed: those three tokens are in
globals.css's@themeand in no emitted sheet. A source-level gate would call this very fix sound right up to the commit that drops the lasttext-foregroundcall site — #262's own shape, one level up.Files — what each spec is now for
Preview
Branch alias: https://claude-fix-262-host-reset-co.sahajatlas.pages.dev — a fresh deploy follows this push. Nothing visual changes on a host that sets no
color, which is most of them; the observable change needs a host page that setsbody { color: … }.Test results
src/styles/host-reset.test.ts)pnpm build, includingassert:css(1,176 rules, 750 var() references resolved) andassert:mapspnpm size: ✓ standalone 308.9/318 KiB, loader 2.8/3.5, embed 310.7/318 — CSS-only change, no movementEvery assertion was proven able to fail
Per
docs/testing.md, a new assertion is not finished until it has gone red. Each was reintroduced at the site that caused it:color: hsl(var(--foreground))+ rebuild--foreground <- .sy-atlas { color }, exit 1var()on a token declared in no sheetvar()on a token declared in another sheetcolor: hsl(var(--color-foreground))color: var(--color-primary-9)@themestates ithsl(var(--primary-9))color: var(--color-renamed-away)@themelookup, by name, not a silent passcolor:line deletedword-spacingfrom the CSSword-spacingfrom the doc--swiper-allowlist prefixBARE_VARso it matches nothingManual verification
Already done in a browser, since no node spec can see invalid-at-computed-value-time. Chromium against the built sheet, adopted into a real shadow root, on a host page setting
body { color: red }:rgb(255, 0, 0)rgb(255, 0, 0)❌rgb(255, 0, 0)❌rgb(255, 0, 0)rgb(32, 32, 32)✓rgb(238, 238, 238)✓Worth a second pair of eyes on a real host page via
pnpm review:embedif you want it confirmed outside a synthetic harness.Notes for reviewer
var()s in the emitted output name properties nothing we ship declares, and every one belongs to a pinned third party whose own JS sets the value:--sx-*(Schedule-X),--yarl__*(lightbox),--swiper-*,--radix-*-trigger-width. They are allowlisted by prefix with the library named. Judgement worth checking:--radix-is allowed as a prefix rather than the two exact names in use, since Radix sets all of its runtime properties from JS.--foregroundamong the triplets the runtime palette engine writes, when--gray-12is a fixed Radix ramp and not themeable at all.@media/@supports, or in any of the three injected sheets. A token supplied only under a condition, or only once a lazy chunk has loaded, is a subtler defect than this gate is for, and a false positive here blocks every build./^#[0-9a-f]{6}$/) — reverted to asserting the negative. Radix shipscolor(display-p3 …)overrides, so a hex-shaped assertion would red on an upstream move tooklchwith nothing wrong here.globals.css's@thememixes 44hsl(var(--x))channel tokens with 28 barevar(--x)hex tokens, and the four semantic tokens split 2–2. Whoever wrotehsl(var(--foreground))was reading the lines above it correctly, so this mixed convention is the proximate cause. The spec now encodes the convention forcoloralone. Unifying it means either discarding Radix's P3 overrides or makingpalette.tsemit complete colours — both are projects.Detail
Why no gate caught the original.
assert-css-scoped.mjschecks that every rule is confined to.sy-atlas, which this rule was. Lint, typecheck and the unit lane treat CSS as text. And the widget looks correct on any host that sets nocolor— most of them — so the symptom was invisible until it wasn't.Not the same bug as #236. #236 was host selectors outranking ours, which the shadow root fixed. This is the inherited-property half that #236 deliberately kept
host-reset.cssfor, and that half had been a no-op forcolorthe whole time. The security pass independently confirmed the cascade point that makes the fix sound:postcss-scope-widget.mjscollapses:rootand the theme classes onto.sy-atlas, so both tokens are declared on that element, and an element-level declaration beats anything a host ancestor inherits down.That same cascade point is why check 5 pools across sheets. A custom property resolves per element, and all three injected sheets style the same subtree, so a token one sheet declares already reaches a reference in another. Measured on this build: zero references are satisfied only that way, because our own CSS all funnels through
globals.cssand the other two sheets are Schedule-X's and the lightbox's. A component-scoped.cssfile in a lazily-loaded component — the shape both library sheets already have — would have blocked every build on its firstvar(--color-divider).What the spec does NOT do. It does not re-model the cascade. An earlier version read
@radix-ui/colors' file layout out ofnode_modulesto resolvecolorto a hex in both modes; the resolution half is check 5's question, asked of the emitted sheet, so what is left is structural:colormust be a barevar(--x), and@thememust state that token bare rather than wrapped in a colour function. That is the whole of how@themetells a channel triplet from a whole colour.Spec internals. It uses
postcss, already a devDependency and already imported from a Vitest spec here, rather than hand-rolled regex CSS parsing — which removed a[^}]*body match that breaks on any nested block, a line-anchor trick that depended on Radix's own indentation, and comment stripping that would have eaten a/*inside a string. "Top-level children only" is structural in postcss and formatting-independent. It also importsWIDGET_SCOPE_CLASSfromsrc/lib/scope.tsrather than hard-coding.sy-atlas, which was a third copy of that string sitting outside the drift gatepostcss-scope-widget.test.tsalready maintains.docs/embedding.mdneeded no edit — its "Two things still cross" list already namedcoloras a restated property, which is simply now true. The new spec pins that list in both directions, so the prose and the sheet can no longer drift.Security review: no findings. Six surfaces checked and ruled out, including whether a tenant palette could reach the new token (
MANAGED_VARScovers neither--color-foregroundnor--gray-12, and every runtime-written value is regenerated numerically throughcolord, so no CSS value injection is available).Reuse opportunity noted, not taken. Four files each hand-roll their own CSS block reader (
palette.defaults.test.ts,MapFrame.test.tsx,postcss-scope-widget.test.ts, and this spec). Consolidating them touches three files outside this diff, so it is not this PR's; separate Vitest module graphs cannot share the read anyway, so the win is maintenance, not speed.A
docs/testing.mdupdate is arguably owed for the new build gate, but that file documents the two test lanes and this is a build gate, sosrc/AGENTS.mdgot the rule instead, beside the existing "an ungenerated class fails silently" paragraph it is a sibling of.Closes #262
🤖 Written by the sydevs autonomous loop — see what this is
🤖 Generated with Claude Code
https://claude.ai/code/session_019WpZQr9nAEj5swzqq9fkUV