Repository navigation
fix(Theme): a theme's color-mode blocks under a system Theme that no Theme forces follow the page root's scheme - #12270
Conversation
|
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 Theme writes the scheme it draws in to |
|
/approve-spec b127d9f |
There was a problem hiding this comment.
Changes are needed before this can be approved.
Blocking findings:
- Under a
systemroot Theme both color-mode rules stay insideprefers-color-scheme(generateThemeRules.ts:1488-1493), so a dark reader on a page that draws light now gets neither the@darknor the@lightblock, contrary to the recorded owner decision that blocks follow the attribute, INV18's "in its mode the block wins", the title, the changeset and thedefineThemeJSDoc; apply a block fromhtml[data-astryx-scheme="<mode>"]without the media query, keep the query only while the attribute is absent and align INV18's wording, or, if the narrower rule is intended, narrow the title, changeset, JSDoc and INV18 to say blocks only stop applying in the other scheme. data-astryx-schemeis written outside an INV23 owner module (Theme.tsx:319,Theme.tsx:330,generateThemeRules.ts:1518), which CI's strict lint reports as three@astryx/no-raw-private-attributeerrors, and the changeset names the private attribute, which INV23 forbids.- During hydration the root Theme resolves from the server snapshots and writes
data-astryx-scheme="light"for a dark reader (Theme.tsx:387), switching off their@darkblocks onreset.csspages until a second render, so write the attribute only for a forced mode or a page that names one scheme. useResolvedSchemenow sits betweenuseTheme's JSDoc anduseTheme(useTheme.ts:453), so the built declarations ship the publicuseThemehook with no documentation.
The spec approval recorded for this head covers the direction, and a new push needs a fresh /approve-spec. CI's lint and test workflows have not run on this head because they run only for pull requests into main or release branches.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim: the root Theme writes the scheme it draws in to
<html>(forced mode, else the page's scheme, else the preference): verified (Theme.tsx:319,Theme.tsx:387; the newTheme.test.tsxcase passes). - Claim: a system root's block keeps its media query and also requires
<html>to name no other scheme, at no specificity: verified (generateThemeRules.ts:1490-1493). - Claim: on a page that draws light, a
@darkblock applies for no reader once the root Theme mounts: verified in Chromium. - Claim: the blocks now follow the page's scheme as the theme's colors do (title, changeset,
defineThemeJSDoc): false, the@lightblock is lost for a dark reader on a light page. - Claim: a client-rendered page never shows the other scheme: verified for client rendering; hydration writes
lightfirst for dark readers. - Claim: before the root Theme mounts, at a server-rendered first paint, the reader's preference decides as before: verified (no attribute until the layout effect).
- Claim: under a forced Theme a system Theme keeps the media query alone: verified (
generateThemeRules.ts:1494-1497,colorModeBlocks.test.ts). - Claim: the root Theme reads the page's scheme through the one shared root-scheme observer: verified (
useTheme.ts:363-369). - Claim: the attribute is a private data attribute: true, but INV23's owner-module rule is not met.
- Claim: maintainers decided this approach, including the first-paint behavior: verified (an engineering owner's decision and spec approval for this head).
- Claim: the theme unit tests pass (1819 tests): verified.
- Claim: the knowledge check, core typecheck and Prettier pass: verified.
- Claim: ESLint passes on the changed files: false under CI's strict mode (3 errors).
- Claim: the setup-check browser case and the Chromium Playwright specs pass: not run in this review.
- File
.changeset/theme-mode-blocks-follow-page.md: findings (overclaims "follow"; names the private attribute). - File
docs/architecture/theme-application.md: clear (INV6 rewording approved for this head). - File
docs/architecture/theme-compilation.md: INV18 approved for this head; its "applies where the reader's preference is its mode" clause needs aligning with the fix. - File
docs/specs/components/theme/Theme.spec.md: clear (FR4 rewording approved for this head). - File
internal/vibe-tests/setup-test/setup-canonical.test.ts: its theme has no@lightblock, so it cannot catch the lost light styles. - File
packages/core/src/theme/Theme.test.tsx: the nested-Theme assertion cannot fail (non-blocking). - File
packages/core/src/theme/Theme.tsx: findings (INV23 owner module; hydration write). - File
packages/core/src/theme/colorModeBlocks.test.ts: clear. - File
packages/core/src/theme/defineTheme.ts: the JSDoc overclaims that blocks follow the page. - File
packages/core/src/theme/generateThemeRules.ts: findings (media-gated blocks; INV23 owner module). - File
packages/core/src/theme/useTheme.ts: finding (displaceduseThemeJSDoc).
|
/approve-spec e96c58b |
There was a problem hiding this comment.
Changes are needed before this can be approved.
Blocking findings:
packages/core/src/theme/generateThemeRules.tsis not Prettier-formatted (the new import at lines 54-57 fits on one line), so CI's "Check formatting of changed files" step will fail and the description's "Prettier and ESLint on the changed files" does not hold; runpnpm exec prettier --write packages/core/src/theme/generateThemeRules.ts.packages/core/src/privateAttributes/scheme.tsis a new internal module thatTheme.tsxandgenerateThemeRules.tsimport, but no record names it or its exports, which the knowledge contract requires for any new shared internal module; name it in a record, for example in the Theme record's FR4 or theapplies_toof the theme-compilation record, with its usage and why no existing owner module serves.
An engineering owner approved the rewritten records for this head, and the four blocking findings of the previous review are fixed; the next head needs a fresh /approve-spec from an engineering owner (the author may record it as one). CI's lint and test workflows have not run here, because they run only for pull requests into main. Worth fixing in the same push:
- INV6's verification row in
docs/architecture/theme-application.mdstill cites the old title of the renamedTheme.test.tsxcase. - A host that sets
color-scheme: darkonbodyor on a container around the Theme, on a light root, now shows its dark readers the@lightblocks on dark colors; INV18 reads the root only, so either say so in the records or narrow the changeset's "as the theme's colors do".
Claims and files checked
Review mode: full; reason: spec-record
- Claim: on a page that names no scheme, a dark reader got the theme's dark component styles on the light page before this change: verified in Chromium on the base.
- Claim: the root Theme names the scheme it draws in on
<html>in a private attribute with its own owner module: verified (Theme.tsx:391-398,privateAttributes/scheme.ts; strict ESLint passes), but no record names that module. - Claim: the named scheme is the forced mode, or in
systemthe page root's scheme, else its color-scheme meta, else light: verified (useTheme.ts:262-275,Theme.test.tsx:136). - Claim: nothing is named while the reader's preference decides, hydration included: verified (a hydration run writes nothing on a
light darkroot). - Claim: an unforced
systemblock applies from the named scheme with no media query and keeps the media query while none is named: verified (generateThemeRules.ts:1493-1497,colorModeBlocks.test.ts, Chromium). - Claim: under a forced Theme a
systemTheme's blocks keep the media query alone: verified (generateThemeRules.ts:1498-1501, Chromium on the color-mode blocks story). - Claim: the root Theme reads the page's scheme through the shared root-scheme observer: verified (
Theme.tsx:391,useTheme.ts:363). - Claim: the maintainers decided the approach, including the first paint: verified (owner decision and spec approval for this head on the pull request).
- Claim: no new public API: verified (API surface generator: no rows for Core or the themes).
- Claim: the new setup check case keeps the dark block off the light host for a dark reader: assertions read (
setup-canonical.test.ts:1315-1374); not run here. - Claim: the new
Theme.test.tsxandcolorModeBlocks.test.tscases cover the attribute and the three rules: verified (they pass here and fail on the base); the nested-Theme assertion cannot fail. - Claim: the two Chromium specs pass unchanged: not run; their system-mode assertions hold in Chromium on the same story.
- Claim: the theme unit tests pass (1819): verified.
- Claim: the knowledge check and the core typecheck pass: verified.
- Claim: ESLint passes on the changed files: verified (strict mode).
- Claim: Prettier passes on the changed files: false (
generateThemeRules.ts:54-57). - Changeset claim: the blocks follow the page's scheme as the theme's colors do: verified for a scheme on the page root; not for a scheme set below it.
- Changeset claim: on a page that draws in one scheme that scheme's styles apply for every reader, on a page that follows the reader they follow the reader, and a server-rendered first paint follows the reader: verified (Chromium, hydration run).
- File
.changeset/theme-mode-blocks-follow-page.md: clear (see the note on a scheme below the root). - File
docs/architecture/theme-application.md: INV6 verification row cites an old test title. - File
docs/architecture/theme-compilation.md: clear (INV18 approved for this head). - File
docs/specs/components/theme/Theme.spec.md: clear (FR4 approved for this head). - File
internal/vibe-tests/setup-test/setup-canonical.test.ts: clear. - File
packages/core/src/privateAttributes/scheme.ts: no record names the module (blocking). - File
packages/core/src/theme/Theme.test.tsx: the nested-Theme assertion cannot fail (non-blocking). - File
packages/core/src/theme/Theme.tsx: clear apart from one comment that restates the code (non-blocking). - File
packages/core/src/theme/colorModeBlocks.test.ts: clear. - File
packages/core/src/theme/defineTheme.ts: clear. - File
packages/core/src/theme/generateThemeRules.ts: not Prettier-formatted (blocking). - File
packages/core/src/theme/useTheme.ts: clear (useResolvedSchemenow has one caller; non-blocking).
|
/approve-spec d0651d1 |
There was a problem hiding this comment.
Changes are needed before this can be approved.
Blocking findings:
- Miss:
packages/cli/clients/cli/commands/build-theme.color-mode-blocks.test.mjs(lines 73-75), the CLI build test the theme-compilation record cites for color-mode blocks, still expects the old single@media (prefers-color-scheme: dark)rule for asystemroot, so it fails against the three rulesgenerateThemeRules.tsnow writes (it passes on the base) and CI's node tests will fail; assert the three rules ascolorModeBlocks.test.tsdoes.
The previous review's blocking findings are fixed, and an engineering owner approved the rewritten records for this head; a new commit needs a fresh /approve-spec from an engineering owner, which the author may record as one. CI's lint and test workflows have not run here, because they run only for pull requests into main. Also worth a look:
- A host that sets
color-scheme: darkonbodyor on a container around the Theme, on a light root, now shows its dark readers the@lightblocks on dark colors; either say in the records that only the root and the meta count, or narrow the changeset's "as the theme's colors do".
Claims and files checked
Review mode: full; reason: spec-record
- Claim: before this change, a dark reader on a page that names no scheme got the theme's dark component styles on the light page: verified in Chromium on the base.
- Claim: the root Theme names the scheme it draws in on
<html>in a private attribute with its own owner module: verified (Theme.tsx:320,privateAttributes/scheme.ts; strict ESLint passes). - Claim: the named scheme is the forced mode, or in
systemthe page root's scheme, else its color-scheme meta, else light: verified (useTheme.ts:262-277,Theme.tsx:390-397,Theme.test.tsx:136). - Claim: nothing is named while the reader's preference decides, hydration included: verified (the
light darkcase inTheme.test.tsx, the null server snapshot atuseTheme.ts:367, Chromium). - Claim: an unforced
systemblock applies from the named scheme with no media query and keeps the media query while none is named: verified (generateThemeRules.ts:1490-1494,colorModeBlocks.test.ts, Chromium). - Claim: under a forced Theme a
systemTheme's blocks keep the media query alone: verified (generateThemeRules.ts:1495-1498,colorModeBlocks.test.ts). - Claim: the root Theme reads the page's scheme through the shared root-scheme observer: verified (
Theme.tsx:391,useTheme.ts:363). - Claim: the theme-compilation record names the owner module, says why no existing owner serves, and lists it in
applies_to: verified. - Claim: the observer, Theme behavior and verification rows, the summary row and the
defineThemedocs are updated: verified. - Claim: the changeset is a Core patch: verified.
- Claim: the maintainers decided the approach, including the first paint: verified (owner decision and spec approval for this head on the pull request).
- Claim: no new public API, default or interaction model, and the attribute is private: verified (API surface generator: no rows; strict lint).
- Claim: one defect is restored and unsettled tagalongs are removed: verified, apart from the behavior-neutral
useResolvedSchemeextraction. - Claim: public text carries no internal context: verified.
- Claim: the new setup check case keeps the dark block off a light host for a dark reader, and the earlier setup cases still pass: assertions read; not run here.
- Claim: the new
Theme.test.tsxcase covers both forced modes, a page that names no scheme, a page that names both, and a nested Theme: verified (passes here, fails on the base); the nested assertion cannot fail. - Claim: the
colorModeBlocks.test.tscases cover the three rules: verified (pass here, fail on the base). - Claim: the two Chromium specs pass unchanged: not run; their system cases sit under the Storybook preview's forced root, where the rule is unchanged.
- Claim: the theme unit tests pass (1819): verified.
- Claim: the knowledge check, the core typecheck, Prettier and ESLint pass on the changed files: verified.
- Claim: the records state behavior and carry no project status: verified.
- Changeset claim: the blocks follow the page's scheme as the theme's colors do: verified for a scheme on the page root; not for a scheme set below it.
- Changeset claim: on a page that draws in one scheme that scheme's styles apply for every reader, on a page that follows the reader they follow the reader, and a server-rendered first paint follows the reader: verified (Chromium, server snapshot).
- File
.changeset/theme-mode-blocks-follow-page.md: clear (see the note on a scheme below the root). - File
docs/architecture/theme-application.md: clear. - File
docs/architecture/theme-compilation.md: clear (the CLI build test its verification row cites now fails; see the blocking finding). - File
docs/specs/components/theme/Theme.spec.md: clear. - File
internal/vibe-tests/setup-test/setup-canonical.test.ts: clear (not run). - File
packages/core/src/privateAttributes/scheme.ts: clear. - File
packages/core/src/theme/Theme.test.tsx: the nested-Theme assertion cannot fail (non-blocking). - File
packages/core/src/theme/Theme.tsx: clear apart from one comment that restates the code (non-blocking). - File
packages/core/src/theme/colorModeBlocks.test.ts: clear. - File
packages/core/src/theme/defineTheme.ts: clear. - File
packages/core/src/theme/generateThemeRules.ts: the CLI build test for these rules was not updated and fails (blocking). - File
packages/core/src/theme/useTheme.ts: clear (useResolvedSchemehas one caller; non-blocking).
|
/approve-spec 259e35b |
There was a problem hiding this comment.
Changes are needed before this can be approved.
Blocking findings:
- Miss: on a host whose root
color-schemefollows the reader through aprefers-color-schememedia query, the rootThemenames the page's scheme once and does not re-read it when the reader's preference changes, becauseTheme.tsx(line 391) reads it through the shared store inuseTheme.ts, which watches DOM and stylesheet changes but not the preference query; after a live switch the theme's@lightand@darkblocks stay on the old scheme until a reload, so have that store also listen tomatchMedia('(prefers-color-scheme: dark)')changes, as the theme-application record says it does, and add a test that changes the preference with the page open.
The previous review's blocking finding is fixed, the records now say that only the page root's scheme counts, and an engineering owner approved the records for this head; a new commit needs a fresh /approve-spec from an engineering owner, which the author may record as one. CI's lint and test workflows have not run here, because they run only for pull requests into main. Also worth a look: the nested-Theme assertion in Theme.test.tsx cannot fail, and the useResolvedScheme extraction is not listed in the description.
Claims and files checked
Review mode: full; reason: spec-record
- Claim: before this change, a dark reader on a page that names no scheme got the theme's dark component styles on the light page: verified in Chromium on the base.
- Claim: the root Theme names the scheme it draws in on
<html>in a private attribute with its own owner module: verified (Theme.tsx:320,privateAttributes/scheme.ts; strict ESLint passes). - Claim: the named scheme is the forced mode, or in
systemthe page root's scheme, else its color-scheme meta, else light: verified (useTheme.ts:262-277,Theme.tsx:390-397,Theme.test.tsx:136). - Claim: nothing is named while the reader's preference decides, hydration included: verified (the
light darkcase inTheme.test.tsx, the null server snapshot atuseTheme.ts:367, identical Chromium frames on alight darkroot). - Claim: an unforced
systemblock applies from the named scheme with no media query and keeps the media query while none is named: verified (generateThemeRules.ts:1490-1494,colorModeBlocks.test.ts, the CLI build test, Chromium). - Claim: under a forced Theme a
systemTheme's blocks keep the media query alone: verified (generateThemeRules.ts:1495-1498,colorModeBlocks.test.ts). - Claim: the root Theme reads the page's scheme through the shared root-scheme observer: verified (
Theme.tsx:391); that observer does not watch the preference query (blocking finding). - Claim: the theme-compilation record names the owner module, says why no existing owner serves, and lists it in
applies_to: verified. - Claim: the observer, Theme behavior and verification rows, the summary row and the
defineThemedocs are updated: verified. - Claim: the changeset is a Core patch: verified.
- Claim: the maintainers decided the approach, including the first paint: verified (owner decision and spec approval for this head on the pull request).
- Claim: no new public API, default or interaction model, and the attribute is private: verified (API surface generator: no rows; strict lint).
- Claim: one defect is restored and unsettled tagalongs are removed: verified, apart from the behavior-neutral
useResolvedSchemeextraction. - Claim: public text carries no internal context: verified.
- Claim: the new setup check case keeps the dark block off a light host for a dark reader, and the earlier setup cases still pass: assertions read; not run here.
- Claim: the new
Theme.test.tsxcase covers both forced modes, a page that names no scheme, a page that names both, and a nested Theme: verified (passes here, fails on the base); the nested assertion cannot fail. - Claim: the
colorModeBlocks.test.tscases cover the three rules: verified (pass here, fail on the base). - Claim: the two Chromium specs pass unchanged: not run.
- Claim: the theme unit tests pass (1819): verified (1819 passed).
- Claim: the knowledge check, the core typecheck, Prettier and ESLint pass on the changed files: verified (knowledge check, Prettier, strict ESLint, Core build with declarations).
- Claim: the records state behavior and carry no project status: verified.
- Changeset claim: the blocks follow the scheme the page root draws in, its
color-schemeelse its color-scheme meta, and a scheme onbodyor a container does not count: verified at load; false after a live preference change on a host whose root scheme follows a media query (blocking finding). - Changeset claim: on a page that draws in one scheme that scheme's styles apply whatever the reader's device is set to: verified (Chromium, light root and dark host).
- Changeset claim: on a page that follows the reader the styles follow the reader as before, and a server-rendered first paint follows the reader: verified (Chromium, server snapshot).
- File
.changeset/theme-mode-blocks-follow-page.md: clear (its first sentence holds once the blocking finding is fixed). - File
docs/architecture/theme-application.md: clear. - File
docs/architecture/theme-compilation.md: clear. - File
docs/specs/components/theme/Theme.spec.md: clear. - File
internal/vibe-tests/setup-test/setup-canonical.test.ts: clear (read; not run). - File
packages/cli/clients/cli/commands/build-theme.color-mode-blocks.test.mjs: clear (fixes the previous blocking finding). - File
packages/core/src/privateAttributes/scheme.ts: clear. - File
packages/core/src/theme/Theme.test.tsx: note (the nested-Theme assertion cannot fail). - File
packages/core/src/theme/Theme.tsx: blocking finding (line 391); note (comment at lines 387-389). - File
packages/core/src/theme/colorModeBlocks.test.ts: clear. - File
packages/core/src/theme/defineTheme.ts: clear. - File
packages/core/src/theme/generateThemeRules.ts: clear. - File
packages/core/src/theme/useTheme.ts: blocking finding (the shared store at lines 328-345 has no preference listener); note (useResolvedScheme).
|
/approve-spec d85ed63 |
There was a problem hiding this comment.
Changes requested: the scheme now stays current when a reader switches preference with the page open, which fixes the earlier blocker, but two small fixes remain before approval.
packages/core/src/theme/useTheme.ts:346-354adds its ownmatchMedia('(prefers-color-scheme: dark)')change listener instead of calling the sharedwatchMediaQueryfromutils/coarsePointer.ts, which already drifts by dropping its olderaddListenerfallback; callwatchMediaQuery(window, '(prefers-color-scheme: dark)', notifyRootSchemeChange)and stop it inrootScheme.stop.- Miss: the changeset (line 5) and the title say every
systemTheme's blocks now follow the page root's scheme whatever the reader prefers, but asystemTheme inside a Theme that forces light or dark still follows the reader (generateThemeRules.ts:1495-1498), so add "that no Theme around it forces to light or dark" to both.
Non-blocking: the nested-Theme assertion at Theme.test.tsx:179-188 cannot fail, the INV6 verification row credits useTheme.test.tsx with the preference re-read that Theme.test.tsx proves, and the comment at Theme.tsx:387-389 restates the code.
Claims and files checked
Review mode: full; reason: spec-record
- Claim: blocks under a root system Theme follow the root's scheme, else its color-scheme meta, and a body or container scheme does not count: verified (
useTheme.ts:262-275, Chromium probe). - Claim: on a page that draws in one scheme the blocks of that scheme apply whatever the reader prefers: verified for a root system Theme; false for a system Theme under a forced Theme (finding 2).
- Claim: on a page that follows the reader the blocks follow the reader as before: verified (probe, no attribute written).
- Claim: at a server-rendered first paint, before the root Theme mounts, the reader's preference decides: verified (server snapshot is null,
useTheme.ts:375). - Claim: at the base a dark reader on a page that names no scheme got dark component styles: verified (base probe,
@darkblock on the light page). - Claim: the root Theme names the scheme in a private attribute owned by
privateAttributes/scheme.ts, and names none while the reader decides, hydration included: verified (Theme.tsx:320,:390-398). - Claim: an unforced system block applies from the named scheme with no media query, from the media query while none is named, and with the media query alone under a forced Theme: verified (
generateThemeRules.ts:1490-1498,colorModeBlocks.test.ts:34-50). - Claim: the root Theme reads the page through the shared root-scheme store, which re-reads on a preference change: verified (
Theme.tsx:391,useTheme.ts:346-354; the new test fails on the previous head). - Claim:
useResolvedSchemeholds the resolutionuseTheme()did inline: verified (useTheme.ts:385-393,:494). - Claim: the records, their verification rows and the
defineThemedocs describe the change: verified, with the INV6 row's attribution noted. - Claim: a Core patch changeset: verified.
- Claim: the new setup case asserts the dark reader's button matches the light reader's on a host without
reset.css: verified by readingsetup-canonical.test.ts:1315-1374. - Claim: the new
Theme.test.tsxandcolorModeBlocks.test.tscases and the theme suite pass: verified (1,820 tests at this head, one more than the description's count). - Claim: the two Chromium specs pass unchanged, 15 cases: verified (15 passed).
- Claim: the owners decided the approach, including the first-paint behavior: verified (owner decision and exact-head spec approval).
- Claim: no new public API and no internal context in public text: verified (API generator 0 rows; scan clean).
- Claim: typecheck, Prettier, ESLint and the knowledge check pass: verified.
- File
.changeset/theme-mode-blocks-follow-page.md: finding 2. - File
docs/architecture/theme-application.md: non-blocking note on the INV6 row. - File
docs/architecture/theme-compilation.md: clear. - File
docs/specs/components/theme/Theme.spec.md: clear. - File
internal/vibe-tests/setup-test/setup-canonical.test.ts: clear. - File
packages/cli/clients/cli/commands/build-theme.color-mode-blocks.test.mjs: clear. - File
packages/core/src/privateAttributes/scheme.ts: clear. - File
packages/core/src/theme/Theme.test.tsx: non-blocking note on the nested assertion. - File
packages/core/src/theme/Theme.tsx: non-blocking comment note. - File
packages/core/src/theme/colorModeBlocks.test.ts: clear. - File
packages/core/src/theme/defineTheme.ts: clear. - File
packages/core/src/theme/generateThemeRules.ts: clear. - File
packages/core/src/theme/useTheme.ts: finding 1.
…ides it - A block applies from the named scheme with no media query; while none is named, the reader's preference decides (a page that follows the reader, and the first paint before the root Theme mounts). - The attribute has its owner module (privateAttributes/scheme.ts); the theme engine reads its selectors from there. - The root writes it only for a forced mode or a page that draws in one scheme, so hydration never names light for a dark reader. - useTheme's JSDoc sits on useTheme again.
…; INV6 row cites the renamed case
…he page root's scheme counts The record, the defineTheme docs and the changeset say a block follows the scheme the page root draws in (its color-scheme, else its color-scheme meta); a color-scheme on body or a container does not count.
…anges A host whose root color-scheme follows the reader through a media query changes scheme with no DOM change; the shared store now listens to the preference query too, so the root Theme names the new scheme. The nested Theme assertion now runs where the root names a scheme.
…ngeset names the forced-Theme case The nested-Theme check records every write of the root's scheme, so a nested write would fail it; INV6's row credits Theme.test.tsx with the preference re-read.
d85ed63 to
a090aca
Compare
|
/approve-spec a090aca |
There was a problem hiding this comment.
Approved pending CI: required CI has not finished on this head yet. Under a root system Theme that no Theme forces, a theme's @light and @dark component styles now follow the page's scheme, the new unit and CLI-build tests fail on the base and pass here, and an engineering owner approved the rewritten INV18, FR4 and INV6 for this head.
Non-blocking:
- The nested-Theme write log in
Theme.test.tsx(lines 181-204) still cannot fail, because its observer reads the attribute's final value after both layout effects; observing withattributeOldValue: trueand also recordingrecord.oldValuewould catch a nested Theme that writesdarkfirst.
Claims and files checked
Review mode: full; reason: rebase
- Claim: under a root
systemTheme with no forcing Theme around it, color-mode blocks follow the page root's scheme (rootcolor-scheme, else meta;bodyand containers do not count): verified,generateThemeRules.ts:1484-1498,useTheme.ts:265-287. - Claim: on a page that draws in one scheme, that scheme's block applies whatever the reader prefers: verified,
colorModeBlocks.test.ts, CLI-build test, Chromium fixture in both directions. - Claim: on a page that follows the reader, blocks follow the reader as before: verified, the unnamed rule keeps the media query (
generateThemeRules.ts:1491-1494). - Claim: at a server-rendered first paint, before the root Theme mounts, blocks follow the reader: verified, the server snapshot is null, so no attribute is written (
useTheme.ts:383-389). - Claim: under a Theme that forces a mode, a
systemTheme's blocks keep the media query alone: verified,generateThemeRules.ts:1495-1498. - Claim: the root Theme names its forced mode or the page's single scheme, and none while the reader decides or during hydration: verified,
Theme.tsx:387-395;Theme.test.tsxcases fail on the base. - Claim: the shared root-scheme store re-reads when the reader's preference changes: verified,
useTheme.ts:356-367through the sharedwatchMediaQuery; theTheme.test.tsxcase fails on the base. - Claim: a nested Theme that forces dark never changes what the root names: behaviour verified (
Theme.tsx:304-306), but the new test assertion cannot detect it (suggestion above). - Claim: records,
defineThemedocs and a core patch changeset describe the change, and the attribute has its owner module: verified; changeset and knowledge checks pass. - Claim: no new public API: verified, the API generator lists no rows for Core or the themes, and the themes' built CSS is unchanged.
- Claim: the existing Chromium specs for color-mode blocks and the Theme's color scheme pass unchanged: verified, 15 of 15 pass against CI's Storybook build of this head.
- Claim: the new canonical setup case passes for a reset-less host and a dark reader: not run here; its behaviour (a root that names no scheme draws light) is verified by
Theme.test.tsxand a Chromium fixture. - File
.changeset/theme-mode-blocks-follow-page.md: clear. - File
docs/architecture/theme-application.md: clear. - File
docs/architecture/theme-compilation.md: clear. - File
docs/specs/components/theme/Theme.spec.md: clear. - File
internal/vibe-tests/setup-test/setup-canonical.test.ts: clear (read, not run). - File
packages/cli/clients/cli/commands/build-theme.color-mode-blocks.test.mjs: clear. - File
packages/core/src/privateAttributes/scheme.ts: clear. - File
packages/core/src/theme/Theme.test.tsx: non-blocking, nested write log cannot fail. - File
packages/core/src/theme/Theme.tsx: clear; optional comment rewrite at lines 282-285. - File
packages/core/src/theme/colorModeBlocks.test.ts: clear. - File
packages/core/src/theme/defineTheme.ts: clear. - File
packages/core/src/theme/generateThemeRules.ts: clear. - File
packages/core/src/theme/useTheme.ts: clear;useResolvedSchemeis a refactor with one caller.
| } | ||
| } | ||
| }); | ||
| watcher.observe(document.documentElement, {attributes: true}); |
There was a problem hiding this comment.
Non-blocking: this write log still cannot fail. Both layout effects run before the observer callback, and the callback reads getAttribute(), the root's final light, so a nested Theme that writes dark first is never recorded (a variant of Theme.tsx whose nested branch writes dark still passes this case). Observing with attributeOldValue: true and also pushing record.oldValue would catch it:
watcher.observe(document.documentElement, {
attributes: true,
attributeOldValue: true,
});| * - the scheme the root Theme draws in, when its mode forces one or the page | ||
| * draws in one (`privateAttributes/scheme.ts`), so a theme's color-mode | ||
| * blocks under a system root follow the page; with neither, none is named | ||
| * and the reader's preference decides. |
There was a problem hiding this comment.
Non-blocking (comment style): this bullet is one sentence of about 40 words. A shorter form keeps the reason:
* - the scheme the root Theme draws in (`privateAttributes/scheme.ts`): its
* forced mode, or the one scheme the page draws in. With neither, it names
* none, and the reader's preference decides.
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Lightbox | 147.6 kB (+29 B) · 12.0 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 365.3 kB (+25 B) · 2.4 kB CSS (0) | — | — · — · — |
| lab/Comments | 372.2 kB (+24 B) · 2.5 kB CSS (0) | — | — · — · — |
119 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| charts/Chart | 239.9 kB (+22 B) · 516 B CSS (0) | — | — · — · — |
| Markdown | 204.7 kB (+21 B) · 22.0 kB CSS (0) | — | — · — · — |
| Toast | 105.2 kB (+19 B) · 11.1 kB CSS (0) | — | — · — · — |
| lab/DialogHeroHeader | 90.2 kB (+16 B) · 372 B CSS (0) | — | — · — · — |
| lab/ListInput | 95.1 kB (+16 B) · 922 B CSS (0) | — | — · — · — |
| Table | 121.2 kB (+8 B) · 19.7 kB CSS (0) | — | — · — · — |
| Collapsible | 29.0 kB (+6 B) · 4.5 kB CSS (0) | — | — · — · — |
| Calendar | 77.1 kB (+5 B) · 11.4 kB CSS (0) | — | — · — · — |
| ContextMenu | 102.9 kB (+4 B) · 18.8 kB CSS (0) | — | — · — · — |
| ChatLayoutScrollButton | 66.6 kB (+3 B) · 11.0 kB CSS (0) | — | — · — · — |
| Overlay | 23.6 kB (+3 B) · 3.9 kB CSS (0) | — | — · — · — |
| RadioListItem | 76.3 kB (+2 B) · 10.7 kB CSS (0) | — | — · — · — |
| TabMenu | 79.8 kB (+2 B) · 11.9 kB CSS (0) | — | — · — · — |
| Timestamp | 30.5 kB (+2 B) · 11.1 kB CSS (0) | — | — · — · — |
| TopNav | 79.0 kB (+2 B) · 11.8 kB CSS (0) | — | — · — · — |
| TopNavHeading | 83.1 kB (+2 B) · 12.0 kB CSS (0) | — | — · — · — |
| Banner | 68.0 kB (+1 B) · 11.3 kB CSS (0) | — | — · — · — |
| BaseTypeahead | 79.3 kB (+1 B) · 11.7 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 97.8 kB (+1 B) · 13.3 kB CSS (0) | — | — · — · — |
| ChatDictationButton | 66.6 kB (+1 B) · 10.9 kB CSS (0) | — | — · — · — |
| DateInput | 201.0 kB (+1 B) · 18.0 kB CSS (0) | — | — · — · — |
| DropdownMenu | 108.3 kB (+1 B) · 18.9 kB CSS (0) | — | — · — · — |
| DropdownMenuItem | 27.8 kB (+1 B) · 6.9 kB CSS (0) | — | — · — · — |
| FieldLabel | 55.6 kB (+1 B) · 5.8 kB CSS (0) | — | — · — · — |
| IconButton | 66.1 kB (+1 B) · 10.8 kB CSS (0) | — | — · — · — |
| MobileNavToggle | 66.3 kB (+1 B) · 10.8 kB CSS (0) | — | — · — · — |
| NumberInput | 78.5 kB (+1 B) · 12.2 kB CSS (0) | — | — · — · — |
| Pagination | 125.3 kB (+1 B) · 19.1 kB CSS (0) | — | — · — · — |
| Popover | 99.7 kB (+1 B) · 15.2 kB CSS (0) | — | — · — · — |
| PowerSearch | 308.3 kB (+1 B) · 25.6 kB CSS (0) | — | — · — · — |
| SideNavCollapseButton | 66.8 kB (+1 B) · 10.8 kB CSS (0) | — | — · — · — |
| SideNavHeading | 83.5 kB (+1 B) · 12.1 kB CSS (0) | — | — · — · — |
| SideNavItem | 77.9 kB (+1 B) · 11.9 kB CSS (0) | — | — · — · — |
| Switch | 109.2 kB (+1 B) · 10.0 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 103.9 kB (+1 B) · 19.0 kB CSS (0) | — | — · — · — |
| TextArea | 67.1 kB (+1 B) · 9.4 kB CSS (0) | — | — · — · — |
| Thumbnail | 70.5 kB (+1 B) · 12.4 kB CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 115.9 kB (+1 B) · 1.1 kB CSS (0) | — | — · — · — |
| lab/TourStep | 94.3 kB (+1 B) · 691 B CSS (0) | — | — · — · — |
| lab/TransferListSelector | 122.2 kB (+1 B) · 1.4 kB CSS (0) | — | — · — · — |
| AlertDialog | 129.7 kB (0) · 15.5 kB CSS (0) | — | — · — · — |
| Button | 66.0 kB (0) · 10.8 kB CSS (0) | — | — · — · — |
| ButtonGroup | 44.1 kB (0) · 3.7 kB CSS (0) | — | — · — · — |
| ChatComposerTokenElement | 83.2 kB (0) · 12.1 kB CSS (0) | — | — · — · — |
| ChatMessageMetadata | 20.5 kB (0) · 4.1 kB CSS (0) | — | — · — · — |
| ChatToolCalls | 33.6 kB (0) · 8.5 kB CSS (0) | — | — · — · — |
| CheckIndicator | 8.5 kB (0) · 681 B CSS (0) | — | — · — · — |
| Citation | 20.8 kB (0) · 4.4 kB CSS (0) | — | — · — · — |
| CommandPaletteInput | 33.1 kB (0) · 7.6 kB CSS (0) | — | — · — · — |
| ComplexSelector | 78.5 kB (0) · 12.7 kB CSS (0) | — | — · — · — |
| ContextMenuItem | 35.5 kB (0) · 7.1 kB CSS (0) | — | — · — · — |
| DateRangeInput | 100.2 kB (0) · 13.3 kB CSS (0) | — | — · — · — |
| DateTimeInput | 224.5 kB (0) · 19.8 kB CSS (0) | — | — · — · — |
| DrawerHeader | 69.1 kB (0) · 13.8 kB CSS (0) | — | — · — · — |
| DropdownMenuCheckboxItem | 28.6 kB (0) · 7.3 kB CSS (0) | — | — · — · — |
| FieldStatus | 10.1 kB (0) · 3.6 kB CSS (0) | — | — · — · — |
| Icon | 8.3 kB (0) · 681 B CSS (0) | — | — · — · — |
| InfoTip | 50.6 kB (0) · 5.4 kB CSS (0) | — | — · — · — |
| Link | 56.6 kB (0) · 7.1 kB CSS (0) | — | — · — · — |
| ListItem | 79.3 kB (0) · 12.1 kB CSS (0) | — | — · — · — |
| MoreMenu | 108.6 kB (0) · 18.9 kB CSS (0) | — | — · — · — |
| ProgressBar | 12.0 kB (0) · 6.4 kB CSS (0) | — | — · — · — |
| SegmentedControl | 102.3 kB (0) · 6.9 kB CSS (0) | — | — · — · — |
| SideNav | 122.2 kB (0) · 12.2 kB CSS (0) | — | — · — · — |
| Step | 31.6 kB (0) · 5.6 kB CSS (0) | — | — · — · — |
| TableCell | 104.1 kB (0) · 19.2 kB CSS (0) | — | — · — · — |
| TableSelectionToolbar | 76.3 kB (0) · 14.1 kB CSS (0) | — | — · — · — |
| TabList | 47.5 kB (0) · 6.5 kB CSS (0) | — | — · — · — |
| TextInput | 73.6 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) | — | — · — · — |
| TopNavMegaMenu | 77.2 kB (0) · 12.7 kB CSS (0) | — | — · — · — |
| TopNavMenu | 82.6 kB (0) · 12.0 kB CSS (0) | — | — · — · — |
| TreeList | 46.2 kB (0) · 5.9 kB CSS (0) | — | — · — · — |
| lab/ChatEmojiPicker | 114.7 kB (0) · 773 B CSS (0) | — | — · — · — |
| lab/CommentPin | 60.5 kB (0) · 1.2 kB CSS (0) | — | — · — · — |
| lab/EmojiPicker | 93.4 kB (0) · 751 B 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/PageControl | 78.2 kB (0) · 709 B 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) | — | — · — · — |
| lab/TransferList | 113.2 kB (0) · 1.2 kB CSS (0) | — | — · — · — |
| AppShell | 98.5 kB (−1 B) · 14.4 kB CSS (0) | — | — · — · — |
| ChatComposer | 85.5 kB (−1 B) · 12.9 kB CSS (0) | — | — · — · — |
| ChatComposerInput | 83.2 kB (−1 B) · 12.1 kB CSS (0) | — | — · — · — |
| ChatLayout | 89.2 kB (−1 B) · 11.4 kB CSS (0) | — | — · — · — |
| ChatSendButton | 66.4 kB (−1 B) · 10.8 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) | — | — · — · — |
| DialogHeader | 68.9 kB (−1 B) · 12.4 kB CSS (0) | — | — · — · — |
| DropdownMenuSubMenu | 78.7 kB (−1 B) · 10.5 kB CSS (0) | — | — · — · — |
| Field | 59.6 kB (−1 B) · 7.3 kB CSS (0) | — | — · — · — |
| MobileNav | 77.3 kB (−1 B) · 11.4 kB CSS (0) | — | — · — · — |
| MultiSelector | 102.7 kB (−1 B) · 17.8 kB CSS (0) | — | — · — · — |
| Slider | 114.7 kB (−1 B) · 8.9 kB CSS (0) | — | — · — · — |
| TimeInput | 175.8 kB (−1 B) · 17.0 kB CSS (0) | — | — · — · — |
| ToggleButton | 93.2 kB (−1 B) · 10.9 kB CSS (0) | — | — · — · — |
| Tokenizer | 105.3 kB (−1 B) · 20.4 kB CSS (0) | — | — · — · — |
| Typeahead | 88.9 kB (−1 B) · 13.5 kB CSS (0) | — | — · — · — |
| lab/DiffViewer | 94.1 kB (−1 B) · 2.1 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditor | 306.9 kB (−1 B) · 2.6 kB CSS (0) | — | — · — · — |
| richtext/RichTextView | 283.5 kB (−1 B) · 2.3 kB CSS (0) | — | — · — · — |
| Carousel | 75.8 kB (−2 B) · 11.7 kB CSS (0) | — | — · — · — |
| CheckboxList | 73.3 kB (−2 B) · 7.8 kB CSS (0) | — | — · — · — |
| FileInput | 75.0 kB (−2 B) · 11.7 kB CSS (0) | — | — · — · — |
| RadioList | 61.0 kB (−2 B) · 7.4 kB CSS (0) | — | — · — · — |
| SelectorOption | 24.1 kB (−2 B) · 6.7 kB CSS (0) | — | — · — · — |
| Stepper | 67.7 kB (−2 B) · 10.9 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 175.0 kB (−2 B) · 1.9 kB CSS (0) | — | — · — · — |
| lab/SelectableCardGroup | 69.0 kB (−2 B) · 162 B CSS (0) | — | — · — · — |
| CodeBlock | 81.5 kB (−3 B) · 12.2 kB CSS (0) | — | — · — · — |
| DropdownMenuRadioItem | 28.7 kB (−3 B) · 7.3 kB CSS (0) | — | — · — · — |
| Selector | 114.3 kB (−3 B) · 18.7 kB CSS (0) | — | — · — · — |
| InputGroup | 61.2 kB (−4 B) · 7.9 kB CSS (0) | — | — · — · — |
| CommandPalette | 78.1 kB (−5 B) · 12.8 kB CSS (0) | — | — · — · — |
| lab/Schedule | 115.5 kB (−5 B) · 3.9 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 301.1 kB (−7 B) · 454 B CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 7.64 MB packed (+2.3 kB); no new dependencies.
Wide change (shared styles: packages/core/src/theme/Theme.tsx, packages/core/src/theme/defineTheme.ts, packages/core/src/theme/generateThemeRules.ts, and 1 more): add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
User impact
Under a
Themeinsystemmode that no Theme around it forces to light or dark, a theme's own@darkand@lightcomponent styles followed the device's light or dark setting throughprefers-color-scheme, while the theme's colors follow the scheme the page draws in. On a page that names no scheme (noreset.css, nocolor-schemeon the page root and no<meta name="color-scheme">), the page draws light, so a reader whose device is set to dark got a light page with dark component styles on it: for example a button with its dark background on a light page.Problem and solution fit
systemroot is written inside@media (prefers-color-scheme: …). A media query sees the device's setting, not the scheme the page draws in.reset.css.When the scheme is decided, the root
Themenow names it on<html>in a private attribute (architecture:public-component-apiINV23, owner moduleprivateAttributes/scheme.ts): its forced mode, or insystemthe one scheme the page draws in (the page root's, else the page's color-scheme meta, else light for a page that names none). It names none while the reader's preference decides: on a page that follows the reader (reset.css, or a root or metacolor-schemethat names both schemes), and during hydration, so a server-rendered page never names light for a dark reader. A block under asystemroot under no forced Theme applies from the named scheme with no media query, so on a page that draws light the@lightblock applies for every reader and the@darkblock for none. While no scheme is named, it applies from itsprefers-color-schemequery as today. Under a Theme that forces a mode, asystemTheme follows the reader's preference (component:ThemeFR2), so its blocks keep the media query alone. The root Theme reads the page's scheme through the one shared root-scheme observeruseTheme()already owns.Expected behavior and authority
architecture:theme-compilationINV18, amended in this PR: under a root mode other thanlightordarkand no Theme that forces one, a block follows the scheme the page draws in, which the root Theme writes to<html>; before that, the reader's preference decides; under a forced mode, a system root follows the reader's preference.component:ThemeFR4, amended in this PR: the outermost Theme also writes the scheme it draws in to<html>(none while the reader's preference decides) and removes it on unmount; a nested Theme never changes<html>.architecture:theme-applicationINV6, amended in this PR: the rootsystemTheme is one of the consumers of the shared root-scheme observer.Smallest restoration
packages/core/src/privateAttributes/scheme.ts(new): the attribute's owner module.setRootSchemewrites it, and the selector text the theme engine reads.packages/core/src/theme/useTheme.ts: the root-scheme hookuseTheme()already used is exported to the root Theme;useResolvedSchemeholds the resolutionuseTheme()did inline (forced mode, else the page's scheme, else the reader's preference); the shared root-scheme store also listens to the preference query, as INV7 says, so a root whosecolor-schemefollows the reader through a media query is read again when the reader's preference changes.packages/core/src/theme/Theme.tsx: the root Theme syncs the scheme with the other root attributes, only for a forced mode or a page that draws in one scheme.packages/core/src/theme/generateThemeRules.ts: thesystembranch of a color-mode block splits in three: from the named scheme with no media query, from the media query while none is named, and under a forced mode with the media query alone.theme-compilationlists it inapplies_to), INV6 and its verification row, Theme FR4, its summary row and its verification row, and thedefineThemedocs.@astryxdesign/corepatch.Evidence
setup-canonical.test.ts: the plain Tailwind host that names no scheme loads Core's stylesheet alone, and an Astryx button sits in a rootsystemTheme whose theme gives the button a dark background in a@darkblock. For a dark reader the root staysnormal, and the button's background is the one the light reader sees, not the dark block's. The earlier reset-less case, the standard install and the guest-contained install still pass.Theme.test.tsx: the root Theme namesdarkandlightfor those modes and removes the name on unmount; insystemit nameslighton a page that names no scheme and nothing on a page that names both (or whose scheme the engine does not report); a nested Theme that forces dark never changes what the root names; on a root that follows the reader through a media query, the root names the new scheme when the preference changes with the page open.colorModeBlocks.test.ts: the threesystemrules: from the named scheme with no media query, from the media query while no scheme is named, and under a forced mode.colorModeBlocks.a11y.chromium.spec.ts(the Theme's mode, system preference, nested Theme, media surfaces) andThemeColorScheme.a11y.chromium.spec.tspass unchanged: 15 cases in Chromium.Scope
Components: Theme; theme compilation of color-mode blocks
data-astryx-*attribute with its owner module,architecture:public-component-apiINV23.)Writing rubric results
R1 narration: none; INV18, INV6 and FR4 state what the compiler, the observer and the root Theme do.
R2 research: none in the records.
R3 evidence: the verification rows name the tests, not a change.
R4 rejected alternatives: none added.
R5 change references: none.
R6 open questions: none touched.
R7 project status: none; the first-paint behavior is stated as behavior.
Testing
pnpm exec vitest run --project ui packages/core/src/theme(1819 tests).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 reset-less case, the standard s1 install, guest-contained).pnpm storybook:build, thenpnpm exec playwright test ThemeColorScheme colorModeBlocks(Chromium).pnpm check:knowledge; coretsc; Prettier and ESLint on the changed files.