Skip to content

perf(theme): a component that knows its media side applies it without MediaTheme's backdrop measurement - #14302

Open
cixzhang wants to merge 9 commits into
mainfrom
perf/media-theme-static-surface
Open

cixzhang wants to merge 9 commits into
mainfrom
perf/media-theme-static-surface

Conversation

@cixzhang

@cixzhang cixzhang commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Stack: #14300 → #14302 → #14311 → #12410

Maintainer impact

MediaTheme imports its backdrop measurement for mode="auto", so every user of a fixed side pays for color parsing, contrast math and the side picker even though it never measures. A component that knows its side cannot apply a media side's theme scope without that cost: on a Button page, adding MediaTheme costs about 2.6 KB gzip. This splits the fixed-mode part into an internal module, so a component that knows its side pays only for the scope.

Stacked on #14300 (the backdrop measurement's cache key); it merges after it.

Intended invariant

MediaTheme's public API and behavior stay the same (component:MediaTheme FR1–FR3): for a fixed side it renders the same element, surface marker, dark-page side and text color, and mode="auto" measures and resolves fallback as before. Toast's card takes the side it resolves for its card (the side component:Toast FR13 picks from the theme until it measures the card, then the measured side), as before.

Change

  • New internal packages/core/src/theme/MediaThemeSurface.tsx: fixed-mode theme application. It renders one side's (dark, light or off) surface marker, the dark-page side MediaDarkPage names, and the side's text color, and measures nothing. Not exported from the theme barrel or the package.
  • MediaTheme resolves its side (measuring only for mode="auto") and renders MediaThemeSurface.
  • Toast renders MediaThemeSurface with the side it resolves for its card (the side component:Toast FR13 picks from the theme before measuring, then the measured side), in place of MediaTheme with that fixed side.
  • component:MediaTheme's Owns list names the module, its scope (fixed-mode theme application, used by MediaTheme and Toast), and that it is internal; architecture:theme-application's owning-code line names it and lists it in applies_to.

Evidence

First-load JavaScript, gzip, against #14300's head (base 1e0603c), each Core built with size:pages' buildCore and bundled with its measurePage (the size report's options); the internal module is measured through a temporary dist entry, since no package entry exports it:

Page Base Head Change
Button 67,474 67,474 0
Button + the fixed-mode surface — 67,701 +227 over Button (INV10 limit 307 B)
Toast 108,661 108,580 −81
Toast + Button 108,663 108,585 −78
MediaTheme alone 3,728 3,748 +20
Lightbox 144,363 144,388 +25

MediaTheme and Lightbox gain the module boundary (+20 and +25 B).

The whole branch (#14300 and this) against its main base 8c5743e (pnpm size:pages --base 8c5743ea3c8729620fd28585e8e6e1e3ee74d973 --head d85741ff --page toast=Toast, gzip): docs, form and menu +0; table −3; Toast −33 (with #14300's +48, a Toast page saves about 33 B when both ship).

  • New MediaThemeSurface case in MediaTheme.dom.test.tsx: for dark, light and off, the surface renders exactly the markup MediaTheme renders.
  • Existing MediaTheme, Toast, Lightbox and theme tests pass unchanged.

Scope

Components: theme (MediaTheme, MediaThemeSurface), Toast

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Overlap checked: #13179, #14300 (stacked on #14300, which supersedes #13179; this adds only the fixed-mode surface)

Testing

  • vitest run theme, Toast, Lightbox and hooks/useAutoMediaMode: green (2,390 tests).
  • check:knowledge: aligned.

Merge order with #14307: that PR adds an internal StyleX marker to MediaTheme's element for inline code. Whichever of the two lands second puts mediaSurfaceMarker on MediaThemeSurface's element, so Toast's card carries it too.

@vercel

vercel Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Dec 4, 2026 8:38am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Dec 4, 2026
@astracat-bot

astracat-bot Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Dec 4, 2026, 12:21 PM UTC

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Dec 4, 2026
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · f636c9a

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
lab/CommentThread 377.5 kB (+83 B) · 2.4 kB CSS (0) — — · — · —
lab/Comments 384.5 kB (+64 B) · 2.5 kB CSS (0) — — · — · —
Markdown 202.5 kB (+15 B) · 23.9 kB CSS (0) — — · — · —

✓ passed · ✗ needs a fix · Δ changed, for review in the shots below · ↻ needs re-verify · — did not run

132 more components
Component Size LoC Visual · A11y · RTL
lab/ListInput 102.9 kB (+15 B) · 1.3 kB CSS (0) — — · — · —
charts/Chart 261.5 kB (+10 B) · 529 B CSS (0) — — · — · —
AppShell 95.6 kB (+3 B) · 15.2 kB CSS (0) — — · — · —
TopNavHeading 93.3 kB (+3 B) · 12.7 kB CSS (0) — — · — · —
SideNavHeading 94.2 kB (+2 B) · 12.8 kB CSS (0) — — · — · —
BreadcrumbItem 108.1 kB (+1 B) · 14.3 kB CSS (0) — — · — · —
Timestamp 28.8 kB (+1 B) · 11.6 kB CSS (0) — — · — · —
AlertDialog 138.5 kB (0) · 16.5 kB CSS (0) — — · — · —
Banner 73.3 kB (0) · 11.9 kB CSS (0) — — · — · —
BaseTypeahead 88.7 kB (0) · 12.4 kB CSS (0) — — · — · —
Button 71.2 kB (0) · 11.3 kB CSS (0) — — · — · —
ButtonGroup 45.3 kB (0) · 3.8 kB CSS (0) — — · — · —
Calendar 82.4 kB (0) · 12.0 kB CSS (0) — — · — · —
Carousel 83.1 kB (0) · 12.4 kB CSS (0) — — · — · —
ChatComposer 95.7 kB (0) · 14.0 kB CSS (0) — — · — · —
ChatComposerInput 92.8 kB (0) · 12.8 kB CSS (0) — — · — · —
ChatComposerTokenElement 92.8 kB (0) · 12.8 kB CSS (0) — — · — · —
ChatDictationButton 71.8 kB (0) · 11.4 kB CSS (0) — — · — · —
ChatLayout 95.0 kB (0) · 11.9 kB CSS (0) — — · — · —
ChatLayoutScrollButton 71.7 kB (0) · 11.5 kB CSS (0) — — · — · —
ChatMessageList 29.5 kB (0) · 7.9 kB CSS (0) — — · — · —
ChatMessageMetadata 21.0 kB (0) · 4.2 kB CSS (0) — — · — · —
ChatSendButton 71.6 kB (0) · 11.3 kB CSS (0) — — · — · —
ChatToolCalls 34.0 kB (0) · 9.3 kB CSS (0) — — · — · —
CheckboxInput 74.2 kB (0) · 11.1 kB CSS (0) — — · — · —
CheckboxList 69.3 kB (0) · 8.5 kB CSS (0) — — · — · —
CheckboxListItem 85.9 kB (0) · 13.1 kB CSS (0) — — · — · —
CheckIndicator 9.0 kB (0) · 681 B CSS (0) — — · — · —
Citation 21.4 kB (0) · 4.6 kB CSS (0) — — · — · —
CodeBlock 87.6 kB (0) · 13.1 kB CSS (0) — — · — · —
CommandPalette 88.1 kB (0) · 14.0 kB CSS (0) — — · — · —
CommandPaletteInput 35.1 kB (0) · 8.4 kB CSS (0) — — · — · —
ComplexSelector 88.6 kB (0) · 13.7 kB CSS (0) — — · — · —
ContextMenu 111.5 kB (0) · 20.0 kB CSS (0) — — · — · —
ContextMenuItem 42.4 kB (0) · 7.4 kB CSS (0) — — · — · —
DateInput 215.0 kB (0) · 19.5 kB CSS (0) — — · — · —
DateRangeInput 101.9 kB (0) · 14.6 kB CSS (0) — — · — · —
DateTimeInput 239.0 kB (0) · 21.3 kB CSS (0) — — · — · —
DialogHeader 74.5 kB (0) · 13.0 kB CSS (0) — — · — · —
DrawerHeader 74.6 kB (0) · 14.5 kB CSS (0) — — · — · —
DropdownMenu 138.8 kB (0) · 20.2 kB CSS (0) — — · — · —
DropdownMenuCheckboxItem 30.6 kB (0) · 7.8 kB CSS (0) — — · — · —
DropdownMenuItem 29.7 kB (0) · 7.2 kB CSS (0) — — · — · —
DropdownMenuRadioItem 30.6 kB (0) · 7.8 kB CSS (0) — — · — · —
DropdownMenuSubMenu 84.1 kB (0) · 11.6 kB CSS (0) — — · — · —
Field 64.0 kB (0) · 8.0 kB CSS (0) — — · — · —
FieldLabel 59.5 kB (0) · 6.5 kB CSS (0) — — · — · —
FieldStatus 10.9 kB (0) · 3.7 kB CSS (0) — — · — · —
FileInput 81.7 kB (0) · 13.2 kB CSS (0) — — · — · —
Icon 8.8 kB (0) · 681 B CSS (0) — — · — · —
IconButton 71.2 kB (0) · 11.3 kB CSS (0) — — · — · —
InfoTip 53.9 kB (0) · 6.1 kB CSS (0) — — · — · —
InputGroup 66.2 kB (0) · 9.5 kB CSS (0) — — · — · —
Link 61.3 kB (0) · 7.8 kB CSS (0) — — · — · —
ListItem 85.1 kB (0) · 13.1 kB CSS (0) — — · — · —
MobileNav 84.0 kB (0) · 12.0 kB CSS (0) — — · — · —
MobileNavToggle 73.4 kB (0) · 12.0 kB CSS (0) — — · — · —
MoreMenu 139.0 kB (0) · 20.2 kB CSS (0) — — · — · —
MultiSelector 110.9 kB (0) · 19.5 kB CSS (0) — — · — · —
NavHeadingMenuItem 20.3 kB (0) · 7.1 kB CSS (0) — — · — · —
NumberInput 110.5 kB (0) · 13.5 kB CSS (0) — — · — · —
Pagination 156.1 kB (0) · 20.6 kB CSS (0) — — · — · —
Popover 110.5 kB (0) · 15.9 kB CSS (0) — — · — · —
PowerSearch 328.0 kB (0) · 27.9 kB CSS (0) — — · — · —
ProgressBar 12.5 kB (0) · 7.1 kB CSS (0) — — · — · —
RadioList 65.5 kB (0) · 8.0 kB CSS (0) — — · — · —
RadioListItem 82.0 kB (0) · 11.7 kB CSS (0) — — · — · —
SegmentedControl 105.9 kB (0) · 7.8 kB CSS (0) — — · — · —
Selector 122.8 kB (0) · 20.2 kB CSS (0) — — · — · —
SelectorOption 25.9 kB (0) · 6.9 kB CSS (0) — — · — · —
SideNav 120.1 kB (0) · 12.8 kB CSS (0) — — · — · —
SideNavCollapseButton 72.2 kB (0) · 11.4 kB CSS (0) — — · — · —
SideNavItem 87.5 kB (0) · 12.6 kB CSS (0) — — · — · —
Slider 120.0 kB (0) · 9.7 kB CSS (0) — — · — · —
Step 32.7 kB (0) · 5.8 kB CSS (0) — — · — · —
Stepper 72.9 kB (0) · 11.5 kB CSS (0) — — · — · —
Switch 114.7 kB (0) · 11.0 kB CSS (0) — — · — · —
Table 127.3 kB (0) · 21.6 kB CSS (0) — — · — · —
TableCell 112.6 kB (0) · 20.7 kB CSS (0) — — · — · —
TableHeaderCell 112.5 kB (0) · 20.4 kB CSS (0) — — · — · —
TableSelectionToolbar 81.8 kB (0) · 14.9 kB CSS (0) — — · — · —
TabList 49.4 kB (0) · 7.0 kB CSS (0) — — · — · —
TabMenu 89.5 kB (0) · 12.7 kB CSS (0) — — · — · —
TextArea 98.0 kB (0) · 10.6 kB CSS (0) — — · — · —
TextInput 105.2 kB (0) · 13.2 kB CSS (0) — — · — · —
Thumbnail 75.9 kB (0) · 12.9 kB CSS (0) — — · — · —
TimeInput 187.2 kB (0) · 18.3 kB CSS (0) — — · — · —
ToggleButton 71.9 kB (0) · 11.4 kB CSS (0) — — · — · —
ToggleButtonGroup 42.5 kB (0) · 3.8 kB CSS (0) — — · — · —
Token 31.7 kB (0) · 5.1 kB CSS (0) — — · — · —
Tokenizer 119.1 kB (0) · 22.5 kB CSS (0) — — · — · —
TopNav 75.2 kB (0) · 12.4 kB CSS (0) — — · — · —
TopNavMegaMenu 86.4 kB (0) · 13.4 kB CSS (0) — — · — · —
TopNavMenu 92.5 kB (0) · 12.7 kB CSS (0) — — · — · —
TreeList 48.3 kB (0) · 6.1 kB CSS (0) — — · — · —
Typeahead 100.4 kB (0) · 14.9 kB CSS (0) — — · — · —
lab/AudioPlayer 242.1 kB (0) · 1.8 kB CSS (0) — — · — · —
lab/ChatEmojiPicker 134.2 kB (0) · 773 B CSS (0) — — · — · —
lab/ChatReactionBar 135.7 kB (0) · 1.1 kB CSS (0) — — · — · —
lab/CommentComposer 193.1 kB (0) · 1.9 kB CSS (0) — — · — · —
lab/CommentPin 64.0 kB (0) · 1.2 kB CSS (0) — — · — · —
lab/DiffViewer 100.5 kB (0) · 2.3 kB CSS (0) — — · — · —
lab/EmojiPicker 125.2 kB (0) · 751 B CSS (0) — — · — · —
lab/MediaCaptionsButton 231.6 kB (0) · 1.5 kB CSS (0) — — · — · —
lab/MediaFullscreenButton 231.6 kB (0) · 1.5 kB CSS (0) — — · — · —
lab/MediaPlaybackRate 231.6 kB (0) · 1.5 kB CSS (0) — — · — · —
lab/MediaPlayButton 231.6 kB (0) · 1.5 kB CSS (0) — — · — · —
lab/MediaSeekButton 231.6 kB (0) · 1.5 kB CSS (0) — — · — · —
lab/MediaTime 231.6 kB (0) · 1.5 kB CSS (0) — — · — · —
lab/MediaTimeSlider 231.6 kB (0) · 1.5 kB CSS (0) — — · — · —
lab/MediaVolume 231.6 kB (0) · 1.5 kB CSS (0) — — · — · —
lab/NavigationScreen 87.2 kB (0) · 1.5 kB CSS (0) — — · — · —
lab/NavigationStack 87.2 kB (0) · 1.5 kB CSS (0) — — · — · —
lab/PageControl 79.6 kB (0) · 716 B CSS (0) — — · — · —
lab/Schedule 123.1 kB (0) · 3.9 kB CSS (0) — — · — · —
lab/SelectableCardGroup 74.5 kB (0) · 162 B CSS (0) — — · — · —
lab/TabBar 85.1 kB (0) · 1.8 kB CSS (0) — — · — · —
lab/TabBarItem 3.9 kB (0) · 1.8 kB CSS (0) — — · — · —
lab/TabBarMoreList 98.9 kB (0) · 1.8 kB CSS (0) — — · — · —
lab/Tour 112.7 kB (0) · 1.0 kB CSS (0) — — · — · —
lab/TransferList 134.8 kB (0) · 1.4 kB CSS (0) — — · — · —
lab/TransferListSelector 147.6 kB (0) · 1.6 kB CSS (0) — — · — · —
richtext/RichTextEditor 315.1 kB (0) · 2.7 kB CSS (0) — — · — · —
richtext/RichTextEditorToolbar 299.6 kB (0) · 454 B CSS (0) — — · — · —
richtext/RichTextView 291.7 kB (0) · 2.4 kB CSS (0) — — · — · —
Collapsible 30.2 kB (−1 B) · 4.7 kB CSS (0) — — · — · —
Spinner 26.0 kB (−3 B) · 7.0 kB CSS (0) — — · — · —
Toast · Storybook 111.2 kB (−55 B) · 11.7 kB CSS (0) 1,864 (0) — · — · —
lab/VideoPlayer 237.5 kB (−2.5 kB) · 2.1 kB CSS (0) — — · — · —
Overlay 16.3 kB (−8.9 kB) · 4.3 kB CSS (0) — — · — · —
Lightbox 146.5 kB (−9.4 kB) · 12.5 kB CSS (0) — — · — · —
lab/DialogHeroHeader 86.6 kB (−9.4 kB) · 372 B CSS (0) — — · — · —

Package size: @astryxdesign/core 8.18 MB packed (+1.4 kB); no new dependencies.

Wide change (shared styles: packages/core/src/theme/MediaDarkPage.tsx, packages/core/src/theme/MediaTheme.tsx, packages/core/src/theme/MediaThemeSurface.tsx, 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

@cixzhang

cixzhang commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 3eadc91

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Dec 4, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested. The size win holds up and the new internal module is now approved by an engineering owner at this head, but Core does not typecheck and the records, changeset and description need a few corrections. These fixes touch spec records, so the next head needs a fresh /approve-spec <full head SHA> from an engineering owner, which you can post as one.

Blocking:

  • Core does not build: useThemeIdentity returns getRegisteredTheme's DefinedTheme | null where it declares DefinedTheme | undefined, so Core's typecheck fails with TS2322 at useTheme.ts:562 (reproduced locally); ending line 556 with ?? undefined, as useThemeDefinition does, fixes it.
  • Theme-application ownership not amended: architecture:theme-application still says MediaTheme.tsx owns local light/dark surface context while MediaThemeSurface.tsx now applies it and Toast uses it directly, so amend that Owning code line (and list the new file in applies_to).
  • Tooltip is not a user of the new module: the record bullet (MediaTheme.spec.md:72-75), the file header (MediaThemeSurface.tsx:11-12) and the description say it is used by MediaTheme, Toast and Tooltip, but only MediaTheme and Toast import it.
  • Toast's side is not always measured: the changeset and the description say Toast renders the surface with the side it measured, but before measurement it uses the side component:Toast FR13 picks from the theme, so say it uses the side it resolves for its card.

Also:

  • Reference-page deltas missing: add the docs, form, menu and table first-load deltas for the whole branch, which INV10 asks for when a shared module grows.
  • Missing Stack line: add Stack: #14300 → #14302 to both pull request bodies so each one is reviewed on its own increment.
  • Stale MediaTheme header: MediaTheme.tsx:11-13 still lists Toast as a user of MediaTheme.
  • Toast saving overstated across the branch: with #14300's +48 B, a Toast page saves about 42 B rather than about 80 B if both changesets ship together.
Claims and files checked

Review mode: same-head; reason: none

Changed rules (0): none since the last review.

Claims:

  • Title, a component that knows its side applies it without the backdrop measurement: verified (Toast.tsx:46 imports only the surface).
  • MediaTheme's measurement import makes fixed-side users pay for colour parsing, contrast maths and the side picker: verified on the base (MediaTheme.tsx imported the measurement hook).
  • Adding MediaTheme to a Button page costs about 2.6 KB gzip: reported.
  • A component that knows its side pays only for the scope: verified (the surface imports only styles, naming and MediaDarkPage).
  • Stacked on #14300 and merges after it: verified (#14300's head is an ancestor); no Stack line.
  • MediaTheme's API and behaviour are unchanged for fixed sides and auto: verified (equivalence test and existing MediaTheme tests run here; no API rows).
  • Toast's card takes the side it measures, as before: false before measurement.
  • The surface renders the marker, dark-page side and text colour, measures nothing and is not exported: verified (MediaThemeSurface.tsx, theme barrel, package exports).
  • MediaTheme measures only for auto and renders the surface: verified (MediaTheme.tsx:88-93).
  • Toast renders the surface with the side it already measures: false before measurement.
  • The Owns bullet names the module as used by MediaTheme, Toast and Tooltip: false for Tooltip.
  • Size table, how it was built, and the +20 B / +25 B boundary cost: reported.
  • New equivalence test for dark, light and off: verified (runs and passes here).
  • Existing MediaTheme, Toast, Lightbox and theme tests pass unchanged: verified (run here).
  • No public API, behaviour, visual or policy change: verified for API and behaviour (no API rows; identical markup); the record change is owner-approved.
  • Product changes discovered were removed or split: reported.
  • No internal context in public text: verified (scan of added lines, title, body, branch and commit messages).
  • Overlap with #13179 and #14300: verified (#14300 is open and carried here).
  • Tests green, 2,390: verified (54 files, 2,390 tests run here).
  • Knowledge check aligned: verified (run here).
  • Surface changeset, a Toast page about 80 B smaller: reported (relative to #14300's head).
  • Surface changeset, MediaTheme applies its side through an internal surface and behaves as before: verified.
  • Surface changeset, Toast renders the surface with the side it measured: false before measurement.
  • Cache-key changeset, MediaTheme and Lightbox pages that do not call useTheme about 9.5 KB smaller: reported.
  • Cache-key changeset, the measurement keys on theme and colour mode and no longer resolves tokens: verified (useAutoMediaMode.ts:143-181).
  • Cache-key changeset, it measures again on the same changes as before: verified (useTheme memoizes tokens on the same theme and mode; the reprobe test covers a theme change, a mode change, an unchanged render and a root data-theme change).

Files:

  • .changeset/media-theme-static-surface.md: measured-side wording; Toast saving across the branch.
  • .changeset/use-auto-media-mode-theme-key.md: clear.
  • docs/specs/components/theme/MediaTheme.spec.md: Tooltip.
  • packages/core/src/Toast/Toast.tsx: clear.
  • packages/core/src/hooks/useAutoMediaMode.reprobe.test.tsx: clear.
  • packages/core/src/hooks/useAutoMediaMode.ts: clear.
  • packages/core/src/theme/MediaTheme.dom.test.tsx: clear.
  • packages/core/src/theme/MediaTheme.tsx: stale header.
  • packages/core/src/theme/MediaThemeSurface.tsx: Tooltip in the header; its ownership is not reflected in architecture:theme-application.
  • packages/core/src/theme/useTheme.ts: TS2322.

Automated review (maintainer link)

Comment thread packages/core/src/theme/useTheme.ts Resolved
…'s saving under a Theme provider

Co-authored-by: JasonOA888 <JasonOA888@users.noreply.github.com>
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Dec 4, 2026
@cixzhang

cixzhang commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec d85741f

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Dec 4, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested. Core now builds and typechecks in a local run, an engineering owner approved the new internal surface at this head, and last round's Tooltip, release-note and ownership wording is fixed. Two statements still disagree with the code.

  • Theme-compilation INV21 still names MediaTheme as Toast's writer: INV21 in docs/architecture/theme-compilation.md says Toast's dark-page attribute is one "which MediaTheme writes beside its own side". Toast now renders MediaThemeSurface, which writes it (MediaThemeSurface.tsx:53). Change it to "which MediaThemeSurface writes", then record a fresh /approve-spec for that head.
  • Toast's side is not always measured: the description's Intended invariant still says "Toast's card takes the side it measures, as before". Toast.tsx:493 uses the side component:Toast FR13 picks from the theme until the card is measured, so reword the sentence as the Change list already does.
  • Stack line does not hold (non-blocking): #12410, named as the top, does not yet contain this branch or #14300's.
  • Miss: Comments still name MediaTheme as Toast's writer (non-blocking): MediaDarkPage.tsx:8-11, :26, :37, privateAttributes/mediaDarkPage.ts:7-11 and Toast.tsx:213 still say MediaTheme does what MediaThemeSurface now does.
Claims and files checked

Review mode: full; reason: spec-record

  • Claim (title): a component that knows its side applies it without MediaTheme's measurement. Verified: the surface imports no measurement code, and Toast renders it.
  • Claim: the Stack line orders #14300, this pull request, then #12410. Does not hold: #12410 contains neither branch (non-blocking).
  • Claim: on the base, MediaTheme loads its measurement even for a fixed side. Verified: the base MediaTheme imports it statically.
  • Claim: MediaTheme costs a Button page about 2.6 KB gzip. Reported.
  • Claim: after the split, a side-aware component pays only for the scope. Verified from the surface's imports.
  • Claim: this branch is stacked on #14300 and merges after it. Verified: #14300's head is in this branch.
  • Claim: MediaTheme's API and behaviour are unchanged for fixed and auto modes. Verified: no API rows, the markup moved verbatim, and the MediaTheme tests pass locally.
  • Claim: Toast's card takes the side it measures, as before. False: Toast uses the theme-picked side until the card is measured.
  • Claim: the surface renders the marker, dark-page side and text colour, measures nothing, and is not exported. Verified.
  • Claim: MediaTheme resolves its side, measures only for auto, and renders the surface. Verified (MediaTheme.tsx:89-95).
  • Claim: Toast renders the surface with the side it resolves for its card. Verified (Toast.tsx:493, :540).
  • Claim: the MediaTheme and theme-application records name the module. Verified; the theme-compilation record's INV21 is not amended (finding).
  • Claim: the page-size table and the module-boundary costs of +20 and +25 B. Reported.
  • Claim: whole-branch reference pages and the Toast page. Reported, and reproduced locally within a few bytes: docs +0, form +0, menu +5, table +4, Toast −42 B.
  • Claim: the new test compares the surface's markup with MediaTheme's for dark, light and off. Verified: it passes locally.
  • Claim: the existing MediaTheme, Toast, Lightbox and theme tests pass unchanged. Verified: no existing test was edited, and 2,429 tests pass locally.
  • Claim: scope is theme and Toast, with no public API, behaviour, visual or policy change. Verified.
  • Claim: this pull request adds only the fixed-mode surface over #14300. Verified for its own commits.
  • Claim: tests are green (2,390). Reported; 2,429 pass locally over a slightly wider set.
  • Claim: the knowledge check is aligned. Verified locally.
  • Claim (release note): MediaTheme applies its side through a surface that measures nothing, Toast renders it with the side it resolves, and MediaTheme behaves as before. Verified.
  • Claim (release note): a Toast page loads about 80 B less than with MediaTheme. Reported.
  • Claim (release note): measuring pages with no other useTheme call save about 9.5 KB with no provider and 2.6 to 3.3 KB under one. Reported; the no-provider figure is reproduced locally (MediaTheme −9,573, Lightbox −9,679, Overlay −9,113 B).
  • Claim (release note): the measurement re-measures from the theme and colour mode, no longer resolves the token set, and re-measures on the same changes as before. Verified (useAutoMediaMode.ts:145, useTheme.ts:596-599; the re-probe test passes locally).
  • File .changeset/media-theme-static-surface.md: clear.
  • File .changeset/use-auto-media-mode-theme-key.md: clear.
  • File docs/architecture/theme-application.md: clear.
  • File docs/specs/components/theme/MediaTheme.spec.md: clear.
  • File packages/core/src/Toast/Toast.tsx: non-blocking (stale docblock at line 213).
  • File packages/core/src/hooks/useAutoMediaMode.reprobe.test.tsx: clear.
  • File packages/core/src/hooks/useAutoMediaMode.ts: clear.
  • File packages/core/src/theme/MediaTheme.dom.test.tsx: clear.
  • File packages/core/src/theme/MediaTheme.tsx: clear.
  • File packages/core/src/theme/MediaThemeSurface.tsx: finding (theme-compilation INV21 still names MediaTheme as its writer for Toast).
  • File packages/core/src/theme/useTheme.ts: clear.

Automated review (maintainer link)

Comment thread packages/core/src/Toast/Toast.tsx Resolved
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Dec 4, 2026
@cixzhang

cixzhang commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec f636c9a

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Dec 4, 2026

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. CI passes at this head, an engineering owner approved the record edits that name MediaThemeSurface for this head, and the theme, Toast, Lightbox and Overlay tests pass in a local run.

  • Stack line does not hold (non-blocking): #14311's description writes this in place of its own number and #12410's adds a clause naming #14307, so the four descriptions do not share one identical Stack line and these pull requests are not reviewed as one stack; give #14311 and #12410 exactly this line, with #14307 in it if #12410 builds on it.
Claims and files checked

Review mode: same-head; reason: none

  • changed rules (0): none
  • Claim (title): a component that knows its side applies it without MediaTheme's measurement. Verified: the surface imports no measurement code (MediaThemeSurface.tsx:16-20), and Toast renders it (Toast.tsx:46, :540).
  • Claim: the Stack line orders #14300, this pull request, #14311, then #12410. Does not hold: #14311 and #12410 carry different Stack lines, although each branch contains the one before it (non-blocking).
  • Claim: on the base, MediaTheme loads its measurement even for a fixed side. Verified: the base imports the measurement hook statically.
  • Claim: MediaTheme costs a Button page about 2.6 KB gzip. Reported.
  • Claim: after the split, a component that knows its side pays only for the scope. Verified from the surface's imports.
  • Claim: this branch is stacked on #14300 and merges after it. Verified: #14300's head is in this branch.
  • Claim: MediaTheme's API and behaviour are unchanged for fixed and auto modes. Verified: CI's API report lists no rows, the markup moved verbatim, and the MediaTheme tests pass in a local run.
  • Claim: Toast's card takes the side it resolves, the theme's until it measures the card and then the measured side, as before. Verified (Toast.tsx:480-493, :540; the Toast tests pass locally and in CI).
  • Claim: the surface renders the marker, dark-page side and text colour for dark, light or off, measures nothing, and is not exported. Verified (MediaThemeSurface.tsx:44-58; the theme barrel does not export it).
  • Claim: MediaTheme resolves its side, measures only for auto, and renders the surface. Verified (MediaTheme.tsx:89-95).
  • Claim: Toast renders the surface with the side it resolves, in place of MediaTheme with that fixed side. Verified (Toast.tsx:540).
  • Claim: the MediaTheme and theme-application records name the module, its two users and that it is internal. Verified (MediaTheme.spec.md:72-75, theme-application.md:16, :196).
  • Claim: the page-size table and the module-boundary costs of +20 and +25 B. Reported.
  • Claim: whole-branch reference pages and the Toast page. Reported; CI's size analysis shows Button and Table unchanged and Toast at −55 B.
  • Claim: the new test compares the surface's markup with MediaTheme's for dark, light and off. Verified: it passes in a local run.
  • Claim: the existing MediaTheme, Toast, Lightbox and theme tests pass unchanged. Verified: no existing case was edited, 2,429 tests pass locally, and CI's test jobs pass.
  • Claim: scope is theme and Toast, with no public API, behaviour, visual or policy change. Verified.
  • Claim: product changes found during the work were removed or split. Reported.
  • Claim: public text carries no internal context. Verified: the title, description, branch, commit messages and added lines carry none.
  • Claim: stacked on #14300, which supersedes an older pull request; this adds only the fixed-mode surface. Verified for its own commits; the supersession is reported.
  • Claim: tests are green (2,390). Reported; 2,429 pass locally over a slightly wider set, and CI's test jobs pass.
  • Claim: the knowledge check is aligned. Verified in a local run.
  • Claim: whichever of this and #14307 lands second moves the inline-code marker onto the surface. Reported: a plan for a later merge.
  • Claim (release note): MediaTheme applies its side through a surface that measures nothing, Toast renders it with the side it resolves, and MediaTheme behaves as before. Verified.
  • Claim (release note): a Toast page loads about 80 B less than with MediaTheme. Reported.
  • Claim (release note): pages that measure their backdrop with no other useTheme call save about 9.5 KB with no provider and 2.6 to 3.3 KB under one. Reported; CI's size analysis shows Lightbox at −9,595 B and Overlay at −9,140 B.
  • Claim (release note): the measurement re-measures from the theme and colour mode, no longer resolves the token set, and re-measures on the same changes as before. Verified (useAutoMediaMode.ts:145, useTheme.ts:596-599; the re-probe test passes locally).
  • File .changeset/media-theme-static-surface.md: clear.
  • File .changeset/use-auto-media-mode-theme-key.md: clear.
  • File docs/architecture/theme-application.md: clear.
  • File docs/architecture/theme-compilation.md: clear.
  • File docs/specs/components/theme/MediaTheme.spec.md: clear.
  • File packages/core/src/Toast/Toast.tsx: clear.
  • File packages/core/src/hooks/useAutoMediaMode.reprobe.test.tsx: clear.
  • File packages/core/src/hooks/useAutoMediaMode.ts: clear.
  • File packages/core/src/privateAttributes/mediaDarkPage.ts: clear.
  • File packages/core/src/theme/MediaDarkPage.tsx: clear.
  • File packages/core/src/theme/MediaTheme.dom.test.tsx: clear.
  • File packages/core/src/theme/MediaTheme.tsx: clear.
  • File packages/core/src/theme/MediaThemeSurface.tsx: clear.
  • File packages/core/src/theme/useTheme.ts: clear.

Automated review (maintainer link)

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request is reviewed as part of its stack; see the review on #12410.

Automated review (maintainer link)

This branch was successfully deployed

1 active deployment
Preview — f636c9a8 Deployed Dec 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant