Skip to content

fix(ui): host color still reaches widget text — --foreground is never declared #262

Closed

Description

@sydevs-bot

Summary

src/styles/host-reset.css:62 restates color on the widget's root as
color: hsl(var(--foreground)). --foreground is declared nowhere — not in src/, not by
the runtime palette engine, not by Radix Colors. So the declaration is invalid at computed-value
time, color computes to unset, and because color inherits, the widget's root takes the host
page's color instead.

That is the exact failure #156 and #236 exist to prevent, surviving in one of the six properties
host-reset.css is there to pin. A host's body { color: … } still tints every line of widget
copy that no Tailwind text-* utility covers.

Found incidentally while fixing the troubleshooting row in #261.

Approach

Measured on the shipped bundle, built from cab731c:

  • dist/assets/sheet-*.js emits .sy-atlas{--sy-frame-h:100dvh;color:hsl(var(--foreground));font-family:…;letter-spacing:normal;text-align:start;text-transform:none;word-spacing:normal}.
  • --foreground appears exactly once in the whole of dist/ — that reference. There is no
    declaration anywhere in the output, so nothing supplies it at runtime either.
  • src/config/theme/palette.ts:194-200 — MANAGED_VARS covers --{role}-on, --{role}-1…12
    and --background. applyPalette never writes --foreground.
  • There is no @property --foreground registration: scripts/assert-css-scoped.mjs reports 62
    registrations and allows only the --tw- prefix, so an unregistered custom property has no
    typed initial value to fall back to.

The name that does exist is the Tailwind theme token --color-foreground: var(--gray-12)
(src/styles/globals.css:277), which is why text-foreground works while the root declaration
does not. The bare --foreground looks like a leftover from the channel-format scheme the brand
ramps still use (hsl(var(--primary-9))).

Decide between the two honest fixes and apply one:

  1. color: var(--color-foreground) — reuses the token the rest of the sheet resolves colour
    through. Note --color-foreground resolves to --gray-12, a Radix hex, so it must not be
    wrapped in hsl().
  2. Declare --foreground beside the other root tokens in the :root, .light, .light-theme block
    (src/styles/globals.css:289) in the channel format hsl() expects, with a .dark
    counterpart.

Prefer 1 — it adds no token and cannot drift from the ramp. Check the dark mode either way:
--gray-12 already flips through @radix-ui/colors/gray-dark.css.

⚠ src/styles/ is in securityReview.triggerPattern (.claude/workflow.json), so the fix
triggers a branch-level security review.

Acceptance criteria

  • The widget's root color resolves to a real colour in the shipped stylesheet, in both light
    and dark mode.
  • A host page setting body { color: … } does not change any widget text.
  • No declaration in the emitted CSS references a custom property that nothing declares.
  • docs/embedding.md's "Two things still cross" list stays true of the shipped sheet — it
    names color as a restated property, which is only honest once this is fixed.

Verification checklist

  • pnpm build, then grep -o -- '\.sy-atlas{[^}]*}' dist/assets/sheet-*.js shows a color
    value that needs no undeclared variable.
  • pnpm build, then confirm no var(--…) in the emitted sheet names a property absent from
    the same output.
  • A spec pins the root color declaration, so a token rename cannot silently re-break it. The
    existing src/config/theme/palette.defaults.test.ts is the nearest precedent for a gate of
    this shape.
  • Verify in a browser against a host page that sets body { color: red } — a node spec cannot
    see invalid-at-computed-value-time, since that is resolved by the CSS engine. Use
    pnpm review:embed.
  • pnpm lint && pnpm typecheck && pnpm test:run pass.

Notes

Why no gate caught it. assert-css-scoped.mjs checks that every rule is confined to
.sy-atlas, which this rule is. Nothing checks that a declaration's var() references resolve.
The widget looks correct on any host that sets no color, which is most of them, so the symptom
is invisible until it is not.

This is not the same bug as #236. #236 was about host selectors outranking the widget's;
the shadow root fixed that. This is the inherited-property half, which #236 deliberately kept
host-reset.css for — and that half has been a no-op for color the whole time.

src/styles/host-reset.css's own header states the intent: "Restating them here is what makes the
widget the root of its own world." For color it does not.

🤖 Written by the sydevs autonomous loop — see what this is

Activity

  1. added theissue type on Oct 9, 2026
  2. added
    proposal
    on Oct 9, 2026
  3. Ardnived commented on Oct 10, 2026

    @Ardnived
    Contributor

    @sydevs-bot implement

  4. removed
    proposal
    on Oct 10, 2026
  5. moved this from Proposed to Approved in SYDevelopers Technical Roadmapon Oct 10, 2026
  6. added
    bot:working
    on Oct 10, 2026
  7. sydevs-bot commented on Oct 10, 2026

    @sydevs-bot
    ContributorAuthor

    🤖 no session running

    recent dispatches
    • 17:17Z implement · attempt 1 · session · done
    • 17:17Z implement · attempt 1 · session

    Written by the sydevs dispatcher. Sessions never edit this comment.

  8. removed
    bot:working
    on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    High

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions