Repository navigation
fix(Theme): the page root follows the reader only through reset.css, so Core's stylesheet leaves a host's scheme alone - #12247
Conversation
…Core's stylesheet leaves a host's scheme alone
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
Owner decision (engineering owner, covering this pull request): the root |
|
/approve-spec f07213a |
|
/approve-spec 913798a |
There was a problem hiding this comment.
Changes requested: taking the root rule out of Core's stylesheet works as intended, but three problems need fixing first.
useTheme()returnslighton a page that declares<meta name="color-scheme" content="light dark">and loads noreset.css, although Chromium and Firefox draw that page and itssystemThemes dark for a dark reader, so charts and canvas paint light on dark (useTheme.ts:245-247); read the meta when the root computesnormal, and add a Chromium case for it.- A theme's
@darkcomponent blocks still followprefers-color-scheme, so on a page withoutreset.cssa dark reader gets those dark overrides on a light page, which contradictsarchitecture:theme-compilationINV18 and the changeset's "never turns dark"; make those blocks follow the page's scheme, or amend INV18, thedefineThemedocs and the changeset to match. - The description says the changeset drops
@astryxdesign/build, but the head still names it on line 3, so please correct that bullet.
The amended AST-080, Theme and theme-application records are approved at this head, and no public API changes. The inline comments give the details, plus one non-blocking wording note.
Claims and files checked
Review mode: full; reason: no-earlier-review
Claims (description):
- At the base, Core's stylesheet sets an unforced root to follow the reader: verified (base
source-stylesheet.jsroot block; base capture shows the root computinglight dark). - At the base, an app with Core's stylesheet but no reset turns dark for a dark reader: verified (base capture).
- Core's stylesheet now carries no reset block: verified (head
astryx.cssbuilt here; layer and source-build tests pass). - A system Theme takes the page's scheme: the reader's with the reset, the host's when set, light on a root that names none: verified for the CSS (head captures).
useTheme()matches the CSS in each case: false on a page that declares its schemes with a color-scheme meta element (Chromium and Firefox captures).- An app without the reset can follow the device by importing it or setting the root's scheme: verified (with-reset capture; reset rule).
- A host that sets the root dark still gets dark system Themes: verified (unchanged unit test for a root that names only dark).
- The three records are amended as described: verified (head text).
- The build constant and the core option are gone: verified (diff; tests pass).
- The changeset drops the build package: false (the changeset still names it on line 3).
- The new setup case keeps the root
normalin both modes: consistent with the test code; not run here. - The Chromium cases behave as listed: the dark-reader cases with and without the reset are reproduced in this review's captures; the unchanged cases were not run.
- The theme unit tests and the build tests pass: verified (58 and 16 passed).
- No new public API: verified (API generator, no rows).
- No internal context in public text: verified.
Claims (changeset):
- A system Theme takes the surrounding page's scheme, so a dark host gets dark inside: verified (unit tests).
useTheme()anduseSyntaxTheme()resolve system to the root's scheme, light when it names none, else the device: false for a meta-declared page.- Under a forced Theme a system Theme follows the device: verified (capture).
- A scheme the app sets on the root decides: verified (unit tests).
useSyntaxTheme()follows a forced Theme: verified (it readsuseTheme().mode).- The reset makes the root follow the device: verified (reset rule; capture).
- Without the reset and with no root scheme, the page stays light and an Astryx widget never turns dark: false for a theme with dark color-mode blocks (fixture capture).
- Core's stylesheet sets no scheme on the root: verified.
Files:
.changeset/theme-system-follows-host-scheme.md: findings 2 and 3.docs/architecture/theme-application.md: finding 1 (the new "the page then draws light" reading).docs/specs/AST-080-package-stylesheets/spec.md: non-blocking wording note.docs/specs/components/theme/Theme.spec.md: clear.internal/vibe-tests/setup-test/setup-canonical.test.ts: clear.packages/build/src/next.turbopack.test.mjs: clear.packages/build/src/source-stylesheet.js: clear.packages/build/src/source-stylesheet.test.mjs: clear.packages/core/src/theme/Theme.doc.mjs: clear.packages/core/src/theme/Theme.tsx: clear.packages/core/src/theme/__tests__/ThemeColorScheme.a11y.chromium.spec.ts: finding 1 (no meta case, no hook-mode check without the reset).packages/core/src/theme/useTheme.test.tsx: clear.packages/core/src/theme/useTheme.ts: finding 1; stale comment note.scripts/build-css.layers.test.mjs: clear.scripts/build-css.mjs: clear.
|
|
||
| - Core, Lab, Rich Text, and Charts export one stylesheet each with every rule | ||
| inside `@layer astryx-base`, besides Core's FR3 root block in `reset`. Non-Core stylesheets omit the Core variable | ||
| - Core, Lab, Rich Text, and Charts already export one stylesheet each with every |
There was a problem hiding this comment.
Non-blocking: "already export" is temporary project status in a Current-state impact line. "Core, Lab, Rich Text, and Charts export one stylesheet each …" says the same in the present tense.
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| lab/DialogHeroHeader | 89.4 kB (+162 B) · 372 B CSS (0) | — | — · — · — |
| Markdown | 203.8 kB (+147 B) · 22.0 kB CSS (0) | — | — · — · — |
| lab/Comments | 371.2 kB (+147 B) · 2.5 kB CSS (0) | — | — · — · — |
119 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| lab/ListInput | 94.3 kB (+146 B) · 922 B CSS (0) | — | — · — · — |
| Lightbox | 146.7 kB (+143 B) · 12.0 kB CSS (0) | — | — · — · — |
| Toast | 104.4 kB (+143 B) · 11.1 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 364.3 kB (+143 B) · 2.4 kB CSS (0) | — | — · — · — |
| Overlay | 23.6 kB (+139 B) · 3.9 kB CSS (0) | — | — · — · — |
| charts/Chart | 239.0 kB (+128 B) · 516 B CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 300.1 kB (+6 B) · 454 B CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 115.0 kB (+5 B) · 1.1 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 174.2 kB (+5 B) · 1.9 kB CSS (0) | — | — · — · — |
| richtext/RichTextView | 282.7 kB (+5 B) · 2.3 kB CSS (0) | — | — · — · — |
| Carousel | 74.9 kB (+3 B) · 11.7 kB CSS (0) | — | — · — · — |
| MultiSelector | 101.9 kB (+3 B) · 17.8 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 97.1 kB (+2 B) · 13.3 kB CSS (0) | — | — · — · — |
| DropdownMenuCheckboxItem | 28.6 kB (+2 B) · 7.3 kB CSS (0) | — | — · — · — |
| FileInput | 74.3 kB (+2 B) · 11.7 kB CSS (0) | — | — · — · — |
| MoreMenu | 107.9 kB (+2 B) · 18.9 kB CSS (0) | — | — · — · — |
| SideNavCollapseButton | 66.1 kB (+2 B) · 10.8 kB CSS (0) | — | — · — · — |
| SideNavHeading | 82.8 kB (+2 B) · 12.1 kB CSS (0) | — | — · — · — |
| Table | 120.4 kB (+2 B) · 19.7 kB CSS (0) | — | — · — · — |
| TopNavHeading | 82.3 kB (+2 B) · 12.0 kB CSS (0) | — | — · — · — |
| TopNavMegaMenu | 76.3 kB (+2 B) · 12.7 kB CSS (0) | — | — · — · — |
| Typeahead | 88.1 kB (+2 B) · 13.5 kB CSS (0) | — | — · — · — |
| lab/ChatEmojiPicker | 113.9 kB (+2 B) · 773 B CSS (0) | — | — · — · — |
| lab/Schedule | 114.9 kB (+2 B) · 3.9 kB CSS (0) | — | — · — · — |
| Button | 65.2 kB (+1 B) · 10.8 kB CSS (0) | — | — · — · — |
| ButtonGroup | 44.1 kB (+1 B) · 3.7 kB CSS (0) | — | — · — · — |
| ChatComposerTokenElement | 82.5 kB (+1 B) · 12.1 kB CSS (0) | — | — · — · — |
| ChatDictationButton | 65.8 kB (+1 B) · 10.9 kB CSS (0) | — | — · — · — |
| ChatSendButton | 65.6 kB (+1 B) · 10.8 kB CSS (0) | — | — · — · — |
| ContextMenuItem | 35.5 kB (+1 B) · 7.1 kB CSS (0) | — | — · — · — |
| DateInput | 200.3 kB (+1 B) · 18.0 kB CSS (0) | — | — · — · — |
| DropdownMenu | 107.7 kB (+1 B) · 18.9 kB CSS (0) | — | — · — · — |
| MobileNavToggle | 65.5 kB (+1 B) · 10.8 kB CSS (0) | — | — · — · — |
| Selector | 113.4 kB (+1 B) · 18.7 kB CSS (0) | — | — · — · — |
| SelectorOption | 24.1 kB (+1 B) · 6.7 kB CSS (0) | — | — · — · — |
| SideNav | 121.4 kB (+1 B) · 12.2 kB CSS (0) | — | — · — · — |
| TextArea | 67.0 kB (+1 B) · 9.4 kB CSS (0) | — | — · — · — |
| Thumbnail | 69.6 kB (+1 B) · 12.4 kB CSS (0) | — | — · — · — |
| Timestamp | 27.0 kB (+1 B) · 11.1 kB CSS (0) | — | — · — · — |
| ToggleButton | 92.3 kB (+1 B) · 10.9 kB CSS (0) | — | — · — · — |
| Tokenizer | 104.5 kB (+1 B) · 20.4 kB CSS (0) | — | — · — · — |
| lab/EmojiPicker | 92.7 kB (+1 B) · 751 B CSS (0) | — | — · — · — |
| lab/TransferList | 112.4 kB (+1 B) · 1.2 kB CSS (0) | — | — · — · — |
| lab/TransferListSelector | 121.3 kB (+1 B) · 1.4 kB CSS (0) | — | — · — · — |
| AppShell | 97.9 kB (0) · 14.4 kB CSS (0) | — | — · — · — |
| Banner | 67.2 kB (0) · 11.3 kB CSS (0) | — | — · — · — |
| Calendar | 76.3 kB (0) · 11.4 kB CSS (0) | — | — · — · — |
| ChatComposerInput | 82.5 kB (0) · 12.1 kB CSS (0) | — | — · — · — |
| ChatLayoutScrollButton | 65.8 kB (0) · 11.0 kB CSS (0) | — | — · — · — |
| ChatToolCalls | 31.8 kB (0) · 8.5 kB CSS (0) | — | — · — · — |
| CheckboxList | 73.3 kB (0) · 7.8 kB CSS (0) | — | — · — · — |
| CheckIndicator | 8.5 kB (0) · 681 B CSS (0) | — | — · — · — |
| CodeBlock | 80.7 kB (0) · 12.2 kB CSS (0) | — | — · — · — |
| CommandPalette | 78.1 kB (0) · 12.8 kB CSS (0) | — | — · — · — |
| CommandPaletteInput | 33.1 kB (0) · 7.6 kB CSS (0) | — | — · — · — |
| ComplexSelector | 77.9 kB (0) · 12.7 kB CSS (0) | — | — · — · — |
| DateRangeInput | 99.5 kB (0) · 13.3 kB CSS (0) | — | — · — · — |
| DateTimeInput | 223.8 kB (0) · 19.8 kB CSS (0) | — | — · — · — |
| DrawerHeader | 68.3 kB (0) · 13.8 kB CSS (0) | — | — · — · — |
| DropdownMenuItem | 27.8 kB (0) · 6.9 kB CSS (0) | — | — · — · — |
| DropdownMenuRadioItem | 28.7 kB (0) · 7.3 kB CSS (0) | — | — · — · — |
| FieldLabel | 55.6 kB (0) · 5.8 kB CSS (0) | — | — · — · — |
| FieldStatus | 10.1 kB (0) · 3.6 kB CSS (0) | — | — · — · — |
| Icon | 8.3 kB (0) · 681 B CSS (0) | — | — · — · — |
| IconButton | 65.2 kB (0) · 10.8 kB CSS (0) | — | — · — · — |
| InfoTip | 50.6 kB (0) · 5.4 kB CSS (0) | — | — · — · — |
| ListItem | 79.3 kB (0) · 12.1 kB CSS (0) | — | — · — · — |
| NumberInput | 77.7 kB (0) · 12.2 kB CSS (0) | — | — · — · — |
| Popover | 98.9 kB (0) · 15.2 kB CSS (0) | — | — · — · — |
| PowerSearch | 307.3 kB (0) · 25.6 kB CSS (0) | — | — · — · — |
| RadioList | 61.0 kB (0) · 7.4 kB CSS (0) | — | — · — · — |
| RadioListItem | 76.3 kB (0) · 10.7 kB CSS (0) | — | — · — · — |
| SegmentedControl | 102.3 kB (0) · 6.9 kB CSS (0) | — | — · — · — |
| SideNavItem | 77.2 kB (0) · 11.9 kB CSS (0) | — | — · — · — |
| Slider | 114.7 kB (0) · 8.9 kB CSS (0) | — | — · — · — |
| Step | 31.6 kB (0) · 5.6 kB CSS (0) | — | — · — · — |
| Stepper | 66.9 kB (0) · 10.9 kB CSS (0) | — | — · — · — |
| Switch | 109.1 kB (0) · 10.0 kB CSS (0) | — | — · — · — |
| TabList | 47.5 kB (0) · 6.5 kB CSS (0) | — | — · — · — |
| TabMenu | 79.1 kB (0) · 11.9 kB CSS (0) | — | — · — · — |
| TextInput | 72.9 kB (0) · 12.0 kB CSS (0) | — | — · — · — |
| ToggleButtonGroup | 41.4 kB (0) · 3.7 kB CSS (0) | — | — · — · — |
| Token | 29.6 kB (0) · 4.9 kB CSS (0) | — | — · — · — |
| TopNav | 78.2 kB (0) · 11.8 kB CSS (0) | — | — · — · — |
| TreeList | 46.2 kB (0) · 5.9 kB CSS (0) | — | — · — · — |
| lab/CommentPin | 60.5 kB (0) · 1.2 kB CSS (0) | — | — · — · — |
| lab/NavigationScreen | 85.0 kB (0) · 1.5 kB CSS (0) | — | — · — · — |
| lab/NavigationStack | 85.0 kB (0) · 1.5 kB CSS (0) | — | — · — · — |
| lab/TabBar | 83.6 kB (0) · 1.8 kB CSS (0) | — | — · — · — |
| lab/TabBarItem | 3.9 kB (0) · 1.8 kB CSS (0) | — | — · — · — |
| lab/TabBarMoreList | 102.1 kB (0) · 1.8 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditor | 306.1 kB (0) · 2.6 kB CSS (0) | — | — · — · — |
| BaseTypeahead | 78.6 kB (−1 B) · 11.7 kB CSS (0) | — | — · — · — |
| ChatComposer | 84.8 kB (−1 B) · 12.9 kB CSS (0) | — | — · — · — |
| ChatLayout | 88.5 kB (−1 B) · 11.4 kB CSS (0) | — | — · — · — |
| CheckboxInput | 69.2 kB (−1 B) · 10.2 kB CSS (0) | — | — · — · — |
| CheckboxListItem | 80.1 kB (−1 B) · 12.1 kB CSS (0) | — | — · — · — |
| Collapsible | 29.0 kB (−1 B) · 4.5 kB CSS (0) | — | — · — · — |
| ContextMenu | 102.2 kB (−1 B) · 18.8 kB CSS (0) | — | — · — · — |
| DialogHeader | 68.1 kB (−1 B) · 12.4 kB CSS (0) | — | — · — · — |
| InputGroup | 61.2 kB (−1 B) · 7.9 kB CSS (0) | — | — · — · — |
| Pagination | 124.3 kB (−1 B) · 19.1 kB CSS (0) | — | — · — · — |
| ProgressBar | 12.0 kB (−1 B) · 6.4 kB CSS (0) | — | — · — · — |
| TableSelectionToolbar | 75.5 kB (−1 B) · 14.1 kB CSS (0) | — | — · — · — |
| TimeInput | 175.1 kB (−1 B) · 17.0 kB CSS (0) | — | — · — · — |
| lab/DiffViewer | 93.4 kB (−1 B) · 2.1 kB CSS (0) | — | — · — · — |
| lab/SelectableCardGroup | 69.0 kB (−1 B) · 162 B CSS (0) | — | — · — · — |
| DropdownMenuSubMenu | 78.7 kB (−2 B) · 10.5 kB CSS (0) | — | — · — · — |
| Field | 59.6 kB (−2 B) · 7.3 kB CSS (0) | — | — · — · — |
| MobileNav | 76.5 kB (−2 B) · 11.4 kB CSS (0) | — | — · — · — |
| TableCell | 103.5 kB (−2 B) · 19.2 kB CSS (0) | — | — · — · — |
| AlertDialog | 128.9 kB (−3 B) · 15.5 kB CSS (0) | — | — · — · — |
| lab/PageControl | 78.2 kB (−3 B) · 709 B CSS (0) | — | — · — · — |
| Citation | 20.8 kB (−4 B) · 4.4 kB CSS (0) | — | — · — · — |
| Link | 56.5 kB (−4 B) · 7.1 kB CSS (0) | — | — · — · — |
| lab/TourStep | 93.5 kB (−4 B) · 691 B CSS (0) | — | — · — · — |
| ChatMessageMetadata | 20.5 kB (−5 B) · 4.1 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 103.1 kB (−5 B) · 19.0 kB CSS (0) | — | — · — · — |
| TopNavMenu | 81.8 kB (−6 B) · 12.0 kB CSS (0) | — | — · — · — |
Package size:
- @astryxdesign/build 34.5 kB packed (−359 B); no new dependencies
- @astryxdesign/core 7.63 MB packed (+1.1 kB); no new dependencies
Wide change (shared styles: packages/core/src/theme/Theme.tsx, packages/core/src/theme/defineTheme.ts, packages/core/src/theme/useTheme.ts): add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
…em root's @dark blocks are documented as following the reader
|
/approve-spec 9c6a532 |
There was a problem hiding this comment.
Changes requested: the record amendments are approved at this head and the earlier meta, @dark and description findings are resolved, but one new problem fails CI.
- The two new
pollcallbacks inpackages/core/src/theme/__tests__/ThemeColorScheme.a11y.chromium.spec.ts(lines 231 and 257) return a promise without beingasync, so the Lint check fails with two@typescript-eslint/promise-function-asyncerrors; write.poll(async () => hookModes(page))as lines 149 and 163 already do.
Two non-blocking notes: useTheme() still differs from Chromium for an empty color-scheme meta placed before a valid one and for a meta added outside <head> after load, and the useTheme.ts file header and the useTheme JSDoc still describe the old fallback to the system preference. No public API changes.
Claims and files checked
Review mode: full; reason: spec-record
Claims (description):
- At the base, Core's stylesheet sets a root with no forced mode to follow the reader: verified (the base's built stylesheet begins with that rule).
- At the base, an app that loads Core's stylesheet without the reset turns dark for a dark reader: verified (base capture, root computes
light dark). - The root rule now lives only in the reset, and Core's stylesheet has no reset block: verified (head stylesheet built here; layer and source-build tests pass).
- A system Theme takes the page's scheme: the reader's with the reset, the host's when it sets one, light when the root names none: verified (head captures; unit tests).
useTheme()resolves system the same way, to light on a root that names no scheme and to the preference when it names both: verified (unit tests; captures).useTheme()reads the page's color-scheme meta when the root names none, as browsers do: verified for a meta in the head that names one or both schemes; differs for an empty meta placed first and for a meta added outside the head (non-blocking).- An app without the reset can follow the device by importing it or setting the root's scheme: verified (capture with the reset).
- A host that sets the root dark still gets dark system Themes and a dark
useTheme(): verified (unchanged unit test for a root that names only dark). - The four records are amended as described: verified (head text).
- The build constant and the core option are gone: verified (diff; build tests pass).
- The changeset still names the build package: verified (line 3).
- The new setup case keeps the root
normalin both modes and fails with the rule restored: consistent with the test code; not run here. - The Chromium cases behave as listed: the dark-reader cases with and without the reset, and with a meta, reproduced in this review's captures; the other cases are unchanged and were not run.
- The
useThemeunit cases behave as listed: verified (pass on the head; the two new cases fail on the base). - The theme unit tests, build tests and knowledge check pass: verified (1818, 16 and the knowledge check pass here).
- ESLint passes on the changed files: false in CI's strict mode (two errors, lines 231 and 257 of the Chromium spec).
- No new public API: verified (API comparison, no rows).
- No internal context in public text: verified.
Claims (changeset):
- A system Theme takes the scheme of the page around it, so a dark host gets dark inside: verified (unit tests).
useTheme()anduseSyntaxTheme()resolve system to the scheme the root names, light when it names none, else the device: verified, with the meta read the changeset states at its end.- Under a forced Theme a system Theme follows the device: verified (capture).
- A scheme the app sets on the root decides: verified (unit tests).
- The reset makes the root follow the device, and Core's stylesheet sets no root scheme: verified.
- Without the reset and with no declared scheme the page, tokens and
useTheme()stay light, while a theme's own@darkstyles still follow the device: verified (fixture capture). - To follow the device, import the reset or set the root's scheme: verified.
useTheme()reads the page's color-scheme meta as the browser does: verified with the two edge cases above.
Files:
.changeset/theme-system-follows-host-scheme.md: clear.docs/architecture/theme-application.md: clear.docs/architecture/theme-compilation.md: clear.docs/specs/AST-080-package-stylesheets/spec.md: non-blocking wording note (line 246).docs/specs/components/theme/Theme.spec.md: clear.internal/vibe-tests/setup-test/setup-canonical.test.ts: clear (not run).packages/build/src/next.turbopack.test.mjs: clear.packages/build/src/source-stylesheet.js: clear.packages/build/src/source-stylesheet.test.mjs: clear.packages/core/src/theme/Theme.doc.mjs: clear.packages/core/src/theme/Theme.tsx: clear.packages/core/src/theme/__tests__/ThemeColorScheme.a11y.chromium.spec.ts: blocking Lint finding.packages/core/src/theme/defineTheme.ts: clear.packages/core/src/theme/useTheme.test.tsx: clear.packages/core/src/theme/useTheme.ts: non-blocking meta edge cases and stale comments.scripts/build-css.layers.test.mjs: clear.scripts/build-css.mjs: clear.
… scheme; async poll callbacks
|
/approve-spec 871dac2 |
There was a problem hiding this comment.
Approved pending CI: the CI run on this head stopped before its build and test jobs because CI was full, so it needs a re-run before merge.
The change does what it says: without reset.css the page root stays normal, and system Themes and useTheme() stay light for a reader who prefers dark. The earlier Lint failure on the two poll callbacks is fixed.
Non-blocking:
useTheme()still differs from Chromium for a color-scheme meta that names only an unknown scheme (Chromium stops there and draws light;useTheme()reads a laterdarkmeta) and for a meta added outside<head>after load.- The comment at
useTheme.ts:221-223and the "already export" line in the package stylesheet record's Current-state impact still use the old wording.
Claims and files checked
Review mode: incremental; reason: none
changed rules (0): none
Claims:
- The changeset: a
systemTheme takes the scheme of the page around it, so a host's dark page makes it dark (verified:Theme.tsx:386-393declares no scheme for a rootsystemTheme; Chromium host-root case in the spec). - The changeset:
useTheme()anduseSyntaxTheme()report the same mode (verified:SyntaxTheme.tsx:99-101readsuseTheme().mode). - The changeset: a
systemTheme resolves to the root's one scheme, light when it names none, else the device's setting, and follows the device under a forced Theme (verified:useTheme.ts:264-286; Chromium captures). - The changeset: an app that sets the root's scheme decides what a
systemTheme shows (verified:useTheme.ts:271-273). - The changeset:
reset.cssmakes the root follow the device, and Core's stylesheet, prebuilt or source-built, sets no root scheme (verified:reset.css:91;source-stylesheet.js:412-421; build tests 16/16). - The changeset: without
reset.cssand a declared scheme the page, tokens anduseTheme()stay light while a theme's@darkstyles still follow the device (verified: Chromium captures; theme compiler unchanged). - The changeset: to follow the device, import
reset.cssor setcolor-scheme: light darkonhtml(verified: the root rule inreset.css; a root or meta naming both schemes draws dark for a dark reader). - The changeset:
useTheme()reads the page's color-scheme meta as the browser does (verified, apart from two rare meta shapes noted above). - The changeset still names the build package (verified: changeset line 3).
- Core's stylesheet carried the root rule before this change, so a host without
reset.cssturned dark for a dark reader (verified: basesource-stylesheet.js:424-438; base capture computeslight dark). - The root rule now lives only in
reset.css; the constant and thecoreoption are gone (verified: head build sources; packages/build returns exactly to its state before the earlier change). useTheme()resolvessystemto the root's one scheme, else the meta, else light, and reads the meta through its observer (verified:useTheme.ts:264-286,:294-314,:339-367).- The package stylesheet, Theme, theme-application and theme-compilation records are amended as described (verified: the diff of the four records).
- Theme's comments and docs, and the
defineThemedocs, say whatreset.cssand asystemroot do (verified:Theme.tsx:283-284,:382-386;Theme.doc.mjs:78,:120;defineTheme.ts:193-198). - The new setup case keeps the root
normalin both modes withoutreset.css(read, not run:setup-canonical.test.ts:183-195,:243-248). - The Chromium spec covers the host root, a linked host stylesheet, both readers with and without
reset.css, a meta naming both schemes and a forced dark root (verified: spec lines 136-264; the no-reset, reset and meta cases reproduced in Chromium). - The
useThemeand build tests cover the cases listed (verified:useTheme.test.tsx:394-442; UI suite 1,819 passed; build tests 16/16). - No new public API (verified: API generator, 0 rows in every published package).
- No internal context in public text (verified: residue scan of the diff, commits, title and body).
- Testing: the
core/themeUI run has 1,817 tests (stale: 1,819 at this head, non-blocking). - Lint and typecheck pass (verified: strict ESLint 0 errors on the changed files; Core's declaration build succeeds; CI Lint green).
Files:
.changeset/theme-system-follows-host-scheme.md: clear.docs/architecture/theme-application.md: clear.docs/architecture/theme-compilation.md: clear.docs/specs/AST-080-package-stylesheets/spec.md: non-blocking wording note (line 246).docs/specs/components/theme/Theme.spec.md: clear.internal/vibe-tests/setup-test/setup-canonical.test.ts: clear (not run).packages/build/src/next.turbopack.test.mjs: clear (not run).packages/build/src/source-stylesheet.js: clear.packages/build/src/source-stylesheet.test.mjs: clear.packages/core/src/theme/Theme.doc.mjs: clear.packages/core/src/theme/Theme.tsx: clear.packages/core/src/theme/__tests__/ThemeColorScheme.a11y.chromium.spec.ts: clear (Lint fixed).packages/core/src/theme/defineTheme.ts: clear.packages/core/src/theme/useTheme.test.tsx: clear.packages/core/src/theme/useTheme.ts: non-blocking meta edge cases and one stale comment.scripts/build-css.layers.test.mjs: clear.scripts/build-css.mjs: clear.
| for (const meta of document.querySelectorAll(SCHEME_META)) { | ||
| const content = meta.getAttribute('content') ?? ''; | ||
| const fromMeta = oneScheme(content); | ||
| if (fromMeta !== undefined) { | ||
| return fromMeta; | ||
| } | ||
| if (/(^|\s)normal(\s|$)/i.test(content)) { | ||
| return 'light'; | ||
| } | ||
| } |
There was a problem hiding this comment.
Non-blocking: HTML takes the first color-scheme meta whose content is a valid color-scheme value, and a lone unknown name such as content="foo" is valid. With that meta before one that says dark, Chromium stops at the first and draws the page and its system Themes light, while this loop skips it and useTheme() reports dark. Stopping at the first meta whose content parses as a color-scheme value (normal alone, or names with an optional only), and resolving it to light when it names neither scheme, matches the browser.
Stack: #12247 → #12250, #12270
User impact
Since the fix that makes a
systemTheme take the page's scheme, Core's stylesheet (astryx.css, and the stylesheet a source build emits) also sets the page root tocolor-scheme: light darkwhen the root has no forced mode. An app that loadsastryx.csswithoutreset.css, and names no scheme of its own, now turns dark for a reader whose device is set to dark: the page canvas, native controls and any host text without its own color flip, while host elements with explicit colors keep them (a white card on a now-dark page). Installing Astryx must leave a host's own styles alone, and a light host page with an Astryx widget should stay light, widget included.Problem and solution fit
astryx.csscarries@layer reset { :where(html:not([data-theme])) { color-scheme: light dark; } }, the same rulereset.csshas. An app that keeps its own preflight leaves outreset.csson purpose, but it still loadsastryx.css, so the rule reaches its root.reset.css), and the setup check's rule is that installing Astryx changes none of the host's own styles or color-mode behavior.The root rule now lives only in
reset.css, as before that fix. Core's stylesheet carries noresetblock again. AsystemTheme still declares no scheme and takes the page's: withreset.cssthat is the reader's preference; under a host that sets the root's scheme, the host's; and on a root that names none, light, as the page draws.useTheme()resolvessystemthe same way, so charts match the CSS: to the one scheme the root names, to light when it names none (normal), and to the reader's preference when it names both. An app withoutreset.cssthat wants to follow the device importsreset.css, or setscolor-scheme: light darkonhtml. An artifact viewer that draws its frame dark sets the root's scheme itself, so asystemTheme still turns dark there.Expected behavior and authority
spec:AST-080FR3, amended back in this PR: Core, Lab, Rich Text and Charts each export one stylesheet with every rule inside@layer astryx-base, besides Core'sreset.css; none emits aresetblock of its own.component:ThemeFR2, amended in this PR: the page root's scheme islight darkfromreset.css, or one the host sets; with neither, the page is light. Its verification row names the without-reset.csscase as staying light.architecture:theme-applicationINV7, amended in this PR:useTheme()resolvessystemto the scheme the page draws in, the root's, else the page's color-scheme meta, else light, as the wrapper's CSS does.architecture:theme-compilationINV18, amended in this PR: under a root mode other thanlightordark, a color-mode block follows the reader's preference.reset.cssonly, so that Astryx content matches the page it sits in.Smallest restoration
packages/build/src/source-stylesheet.jsandscripts/build-css.mjs: Core's block no longer begins with a root block (theCORE_ROOT_BLOCKconstant and thecoreoption are gone).packages/core/src/theme/useTheme.ts: a root that names no scheme resolvessystemto light;Theme.tsxandTheme.doc.mjssay thatreset.cssmakes the root follow the reader.spec:AST-080FR3, FR7, the ordering rule and its current-state line;component:ThemeFR2 and its verification row;architecture:theme-applicationINV7 and its verification row.reset.cssfollows the device; it still names the build package, whose source build sets no root scheme.useTheme()reads the page's<meta name="color-scheme">when the root names no scheme, as browsers do, and its root observer watches that meta.architecture:theme-compilationINV18 and thedefineThemedocs say that under asystemroot a@darkblock follows the reader's preference: that is the page's scheme whenever the page follows the reader, and on a page that names no scheme it still applies for a dark reader.Evidence
setup-canonical.test.ts: the plain Tailwind host, which names no scheme, loadsastryx.cssalone (noreset.css, no theme stylesheet) and adds an Astryx button. The root's computedcolor-schemestaysnormalin the light and the dark reader runs, and the host shows no regression. With the root rule put back intoastryx.css, the case fails (light darkinstead ofnormal). The standard install and the guest-contained install still pass.ThemeColorScheme.a11y.chromium.spec.ts(Chromium): the host's dark root still makes system Themes anduseTheme()dark (the artifact-viewer case, kept), also when the host's scheme arrives in a linked stylesheet; reader light: all light; reader dark withreset.css: system Themes dark; reader dark withoutreset.css, on a root that names no scheme: the root isnormal, system Themes light, and the system Theme under a forced light Theme follows the reader (dark); a root Theme that forces dark keeps the page dark.useTheme.test.tsx: a root that names none resolvessystemto light; a color-scheme meta that names both lets the preference decide, one names that scheme; a root that names both, or an engine that reports no scheme, leaves the preference to decide.ThemeColorScheme.a11y.chromium.spec.ts: withoutreset.css, a page whose color-scheme meta names both schemes is dark for a dark reader, in the CSS and inuseTheme(); without it,useTheme()reports light as the CSS does.build-css.layers.test.mjsandsource-stylesheet.test.mjs: Core's stylesheet is the order line and oneastryx-baseblock again;next.turbopack.test.mjsfindsreset.css's chunk as before.Scope
Components: Theme; Core's stylesheet (
astryx.cssand the source build)Writing rubric results
R1 narration: none; the FR2, FR3 and INV7 sentences state what the stylesheets, Theme and
useTheme()do.R2 research: none in the records.
R3 evidence: the verification rows cite the tests that hold each case, not a change.
R4 rejected alternatives: none added.
R5 change references: none.
R6 open questions: none touched.
R7 project status: AST-080's current-state line states what the packages export, with no root block. INV18 states what a system root's blocks do now, with no plan in it.
Testing
pnpm exec vitest run --project ui packages/core/src/theme(1817 tests).pnpm exec vitest run --project node scripts/build-css.layers.test.mjs packages/build/src/source-stylesheet.test.mjs.ASTRYX_CANONICAL_SETUP_BROWSER=1 pnpm vitest run internal/vibe-tests/setup-test/setup-canonical.test.ts --project node --maxWorkers=1(the new case, the standard s1 install and the guest-contained install; the new case also fails with the root rule restored toastryx.css).pnpm storybook:build, thenpnpm exec playwright test ThemeColorScheme(Chromium).pnpm check:knowledge; coretsc; Prettier and ESLint on the changed files.