Skip to content

refactor(core): a theme's reduced-motion mark, internal until 'always' ships - #9761

Merged
cixzhang merged 5 commits into
mainfrom
lane4/theme-always-mark
Nov 3, 2026
Merged

cixzhang merged 5 commits into
mainfrom
lane4/theme-always-mark

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Part of #8677 (its first part, split out). #8895 builds on it.

This adds internal plumbing for a theme's reducedMotion: 'always' (spec:AST-108 FR6) and changes no behavior: no public theme can set reducedMotion, and resolveKnobs still resolves every theme to 'system'. So no theme marks its root and nothing changes for anyone.

User impact

What changes

  • privateAttributes/reducedMotion.stylex.ts (new): owns data-astryx-reduced-motion.
    • Writers: reducedMotionMarkProps(isMarked) and setRootReducedMotionMark(root, isMarked).
    • Reader: themeReducesMotion(element) checks the element, an ancestor, or <html>.
  • Theme.tsx: when the theme's motion resolves reducedMotion to 'always':
    • it marks its wrapper with the attribute and --_astryx-reduced-motion: 1;
    • the root theme also marks <html> (useRootThemeSync's new flag), so portaled layers read the mark;
    • the server renders the mark, so hydration changes nothing.
  • Readers: motion/animator.ts, motion/reducedMotion.ts (reducedMotionFade) and motion/animatedLayout.ts count the mark as the Reduce Motion setting.
  • theme/motionKnobs.ts: the internal ThemeReducedMotion widens to 'system' | 'always'. resolveKnobs is unchanged.
  • theme/themeMotion.ts: adds REDUCED_MOTION_PROPERTY.
  • Changeset: [chore] Internal: patch.

No behavior change: every theme resolves to 'system', so the new branches never run in a shipped app.

Evidence

  • privateAttributes/reducedMotion.test.tsx:
    • the reader finds the mark on an ancestor and on <html>, and returns false without an element;
    • reducedMotionFade counts the mark as the setting: a fade on a coarse pointer, at once on a fine one.
  • motion/animator.test.ts: under the mark, with the setting off and a fine pointer, a move lands at once; without the mark, the same move springs.
  • theme/themeReducedMotionMark.test.tsx:
    • unmocked, every theme marks nothing;
    • with resolveMotionKnobs mocked to 'always', the wrapper and <html> carry the mark and the property, a nested theme marks only its own wrapper, the server renders the mark, and the mark leaves on unmount.
  • Other checks: the theme, motion and privateAttributes suites pass. pnpm review:pre reports no findings. check:knowledge, check:changesets and check:package-boundaries pass.

Credit

Built from @vjeux's commits on #8677 ("a theme with reducedMotion 'always' marks its root" and follow-ups), reshaped onto current main as internal plumbing with the attribute in its owner module. Co-authored-by trailer on the commit.

cixzhang and others added 3 commits November 3, 2026 07:23
…' ships

Plumbing for spec:AST-108 FR6, with no change for anyone today: no public
theme can set reducedMotion, and resolveKnobs still resolves every theme to
'system', so no theme marks its root.

- privateAttributes/reducedMotion.stylex.ts owns data-astryx-reduced-motion:
  reducedMotionMarkProps and setRootReducedMotionMark write it, and
  themeReducesMotion reads it on an element, an ancestor, or <html>.
- Theme marks its wrapper, and the root theme marks <html>, with the
  attribute and the --_astryx-reduced-motion custom property when the
  theme's motion resolves reducedMotion to 'always'. The server renders the
  mark.
- The animator, reducedMotionFade and the layout glide count the mark as the
  person's Reduce Motion setting.
- ThemeReducedMotion (internal) widens to 'system' | 'always'.

Tests cover the reader, the three readers' use of it, and the Theme mark
through a mocked resolveMotionKnobs.

Co-authored-by: Christopher Chedeau <[email protected]>
@vercel

vercel Bot commented Nov 3, 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 Nov 3, 2026 5:23pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 3, 2026
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 3, 2026
@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 8979875

@astracat-bot

astracat-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 3, 2026, 5:28 PM UTC

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 76c611b

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
DateTimeInput 161.0 kB (+51 B) · 17.1 kB CSS (0) — — · — · —
PowerSearch 192.3 kB (+49 B) · 21.6 kB CSS (0) — — · — · —
Slider 89.4 kB (+49 B) · 9.4 kB CSS (0) — — · — · —
9 more components
Component Size LoC Visual · A11y · RTL
lab/MobilePowerSearch 217.2 kB (+48 B) · 1.2 kB CSS (0) — — · — · —
Switch 87.7 kB (+47 B) · 10.6 kB CSS (0) — — · — · —
Collapsible 22.6 kB (+43 B) · 4.5 kB CSS (0) — — · — · —
SideNav 66.5 kB (+39 B) · 10.9 kB CSS (0) — — · — · —
TimeInput 91.0 kB (+38 B) · 14.3 kB CSS (0) — — · — · —
SegmentedControl 82.5 kB (+34 B) · 7.8 kB CSS (0) — — · — · —
DateInput 104.2 kB (+28 B) · 15.4 kB CSS (0) — — · — · —
TreeList 38.0 kB (+28 B) · 5.0 kB CSS (0) — — · — · —
AppShell 69.1 kB (+26 B) · 12.2 kB CSS (0) — — · — · —

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

API changes: none in this pull request

Committed API report behind this build: core 50 rows; run pnpm api:report.

Wide change (shared styles: packages/core/src/theme/Theme.tsx, packages/core/src/theme/motionKnobs.ts, packages/core/src/theme/themeMotion.ts, and 1 more): add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.

CI impact: +5.6 job-min per update · pool +6.9% · time to green +21.5 min · standard runners ⚠️
Before After Change
Job-minutes per PR update 80.6 86.2 +5.6
Runner pool, runner-minutes a day 29,972 32,054 +2,082 (+6.9%)
Average concurrent jobs 20.8 22.3 +1.4
Time to green (median → this run) 17.4 min 38.9 min +21.5 min
Runs a day 372 372 0

Changed jobs: pr-interaction-webkit changed: standard

Flags: time to green +21.5 min.

Assumptions: before is each job's average over the last 20 pull-request runs; after keeps that for unchanged jobs and uses this run's minutes for added or changed ones, weighted by how often each changed job ran in those runs; runs a day averages the seven whole days before today; time to green compares this run with the median of those runs that ran the same jobs.


Generated by PR Enrichment workflow | View full report

@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.

No blocking issues found. The reduced-motion mark lands as internal plumbing for reducedMotion: 'always'. Every theme still resolves to 'system', so nothing changes for anyone today.

Non-blocking suggestions:

  • Add a test for the layout glide's mark check in packages/core/src/motion/animatedLayout.ts. Disabling that check leaves every suite green. layoutMotionFor(area) under a marked ancestor, with Reduce Motion off and a fine pointer, should return {kind: 'instant'}.
  • Two changed comments could be clearer. The animator's Reduced Motion comment says it reads "nothing else" and then adds the theme mark, and the themeReducesMotion JSDoc does not parse. Suggested rewrites are inline.

[Automated review]

Comment on lines 974 to +976
// Reduced Motion reads the person's settings and nothing else: no option
// overrides them (design:reduced-motion DR4).
const prefersReducedMotion = defaultPrefersReducedMotion;
// overrides them (design:reduced-motion DR4). A theme that reduces motion
// for everyone counts as the setting.

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.

Non-blocking: this comment now contradicts itself. It says Reduced Motion reads the person's settings "and nothing else", then adds the theme mark. A shorter version that keeps only the constraint:

// No option overrides the person's Reduce Motion setting. A theme that
// reduces motion for everyone counts as that setting.

Comment on lines +38 to +39
* Whether the theme `element` is in reduces motion for everyone: its root,
* or `<html>` for the root theme, carries the mark.

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.

Non-blocking: "Whether the theme element is in reduces motion for everyone" does not parse. Suggested wording:

/**
 * Whether the theme that holds `element` reduces motion for everyone. Its
 * root, or `<html>` for the root theme, carries the mark.
 */

if (matches(area, '(prefers-reduced-motion: reduce)')) {
if (
matches(area, '(prefers-reduced-motion: reduce)') ||
themeReducesMotion(area)

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.

Non-blocking: no test covers this branch. If you disable it, the motion, private-attribute and Theme mark suites still pass. A small case next to the existing Reduce Motion tests in animatedLayout.test.ts would pin it: put area under an element that carries the mark, keep Reduce Motion off with a fine pointer, and expect layoutMotionFor(area) to return {kind: 'instant'}.

@cixzhang
cixzhang marked this pull request as ready for review November 3, 2026 15:43
…le that calls no StyleX

The animator reads the reduced-motion mark through its owner module, which
the private-attribute rule names .stylex.ts. The module imports nothing, and
the check that the graph reaches no @stylexjs import still holds it to that.

@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.

No blocking issues found. The reduced-motion mark lands as internal plumbing for reducedMotion: 'always', and the plain-Node foundation test fix keeps its StyleX import check. Every theme still resolves to 'system', so nothing changes for anyone today.

Non-blocking suggestions that still apply:

  • Add a test for the layout glide's mark check in packages/core/src/motion/animatedLayout.ts: under a marked ancestor, with Reduce Motion off and a fine pointer, layoutMotionFor(area) should return {kind: 'instant'}.
  • Two changed comments could be clearer: the animator's Reduced Motion comment says it reads "nothing else" and then adds the theme mark, and the themeReducesMotion JSDoc does not parse.

[Automated review]

@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.

No blocking issues found. The reduced-motion mark lands as internal plumbing for reducedMotion: 'always', and the CI scope and plain-Node test updates follow the animator's new import of the owner module. Every theme still resolves to 'system', so nothing changes for anyone today.

Non-blocking suggestions:

  • Before 'always' ships, add a test for the layout glide's mark check in packages/core/src/motion/animatedLayout.ts: under a marked ancestor, with Reduce Motion off and a fine pointer, layoutMotionFor(area) should return {kind: 'instant'}.
  • Three changed comments could be tighter: the animator's Reduced Motion comment says it reads "nothing else" and then adds the theme mark, the themeReducesMotion JSDoc does not parse, and the comment above the check in reducedMotionFade restates the condition below it.

[Automated review]

} = {},
): ReducedMotionFade | null {
if (!defaultPrefersReducedMotion()) {
// A theme that reduces motion for everyone counts as the setting.

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.

Non-blocking: this comment restates the condition on the next line, which already reads as "the setting or the theme mark". Consider dropping it; the animator's comment already states the rule.

@cixzhang
cixzhang merged commit 2c925f7 into main Nov 3, 2026
94 of 97 checks passed
@github-actions
github-actions Bot deleted the lane4/theme-always-mark branch November 4, 2026 06:04
cixzhang added a commit that referenced this pull request Nov 12, 2026
The old base (#9761) landed squashed, so this resolves as main plus this
branch's own changes. main's later Reduce Motion work updates the
pending lists: ClickableCard, SelectableCard, Spinner's rotor, Thumbnail,
the press module and useMobileKeyboard are listed; Lightbox, Spinner,
AppShell and MobileNav come off (main removed their arms or reads).
cixzhang added a commit that referenced this pull request Nov 20, 2026
…eaches the hooks that hold no element

Main now carries the mark's private-attribute module, the root and wrapper
marks, and the animator's read of them (#9761), so this re-port keeps only
what main lacks: Theme passes 'always' down through ThemeReducesMotionContext
(beside Theme's other contexts in useTheme.ts; a nested theme keeps an
ancestor's), and motion/reducedMotion.ts gains reducesMotion(element) and its
hook form useReducesMotion, which the chat scroll and streaming text now
read. The swipe release already reads the mark through reducedMotionFade.
The other script readers follow in a stacked change.

Co-authored-by: Christopher Chedeau <[email protected]>
cixzhang added a commit that referenced this pull request Nov 22, 2026
…at hold no element; the chat scroll and streaming text read it (#9763)

* refactor(core): a theme's reduced-motion mark, internal until 'always' ships

Plumbing for spec:AST-108 FR6, with no change for anyone today: no public
theme can set reducedMotion, and resolveKnobs still resolves every theme to
'system', so no theme marks its root.

- privateAttributes/reducedMotion.stylex.ts owns data-astryx-reduced-motion:
  reducedMotionMarkProps and setRootReducedMotionMark write it, and
  themeReducesMotion reads it on an element, an ancestor, or <html>.
- Theme marks its wrapper, and the root theme marks <html>, with the
  attribute and the --_astryx-reduced-motion custom property when the
  theme's motion resolves reducedMotion to 'always'. The server renders the
  mark.
- The animator, reducedMotionFade and the layout glide count the mark as the
  person's Reduce Motion setting.
- ThemeReducedMotion (internal) widens to 'system' | 'always'.

Tests cover the reader, the three readers' use of it, and the Theme mark
through a mocked resolveMotionKnobs.

Co-authored-by: Christopher Chedeau <[email protected]>

* chore: a changeset for the internal reduced-motion mark; keep unrelated formatting out

* docs(Theme): say why no theme marks its root, in the present tense

* refactor(core): the reduced-motion mark carries a marker of its own, and the chat scroll, streaming text and swipe settle read it

Internal, like the mark it builds on: no theme can set reducedMotion
'always' yet, so nothing changes for anyone.

- theme/reducedMotion.markers.stylex.ts defines reducedMotionScope. Theme
  puts it on the marked wrapper, and the root theme writes its class on
  <html> beside the mark, so a Reduce Motion style keyed on
  stylex.when.ancestor('[data-astryx-reduced-motion]', reducedMotionScope)
  reaches portaled layers.
- motion/reducedMotion.ts adds reducesMotion(element): the person's setting
  or the mark. hooks/useReducesMotion.ts is its hook form, for a hook that
  holds no element: the setting, followed live, or the theme tree through
  ThemeReducesMotionContext, where a nested theme never removes an
  ancestor's 'always'.
- useChatStreamScroll, useStreamingText and ItemSwipeLayer read them.
- motion/reducedMotion.test.ts guards the rest with lists that only shrink:
  every Reduce Motion arm needs its twin on the mark, and every script read
  of the setting needs the mark. A read through a constant that holds the
  query counts.
- Tests reach 'always' through a themeMotion mock
  (theme/reducedMotionAlways.testing.ts).

Co-authored-by: Christopher Chedeau <[email protected]>

* test: the motion foundation may read a private attribute's owner module that calls no StyleX

The animator reads the reduced-motion mark through its owner module, which
the private-attribute rule names .stylex.ts. The module imports nothing, and
the check that the graph reaches no @stylexjs import still holds it to that.

* ci: the WebKit interaction proofs cover the reduced-motion mark's owner module, which the animator reads

* Merge lane4/theme-always-mark into lane4/r8895-mark

* Merge main into lane4/r8895-mark

The old base (#9761) landed squashed, so this resolves as main plus this
branch's own changes. main's later Reduce Motion work updates the
pending lists: ClickableCard, SelectableCard, Spinner's rotor, Thumbnail,
the press module and useMobileKeyboard are listed; Lightbox, Spinner,
AppShell and MobileNav come off (main removed their arms or reads).

* refactor(core): re-port onto main: a theme's reducedMotion 'always' reaches the hooks that hold no element

Main now carries the mark's private-attribute module, the root and wrapper
marks, and the animator's read of them (#9761), so this re-port keeps only
what main lacks: Theme passes 'always' down through ThemeReducesMotionContext
(beside Theme's other contexts in useTheme.ts; a nested theme keeps an
ancestor's), and motion/reducedMotion.ts gains reducesMotion(element) and its
hook form useReducesMotion, which the chat scroll and streaming text now
read. The swipe release already reads the mark through reducedMotionFade.
The other script readers follow in a stacked change.

Co-authored-by: Christopher Chedeau <[email protected]>

* refactor(core): the reduced-motion context lives beside the mark, so the motion foundation loads in plain Node

scripts/motion-node-load.test.mjs requires the motion foundation to reach no
theme module and no StyleX module. motion/reducedMotion.ts now reads
ThemeReducesMotionContext from privateAttributes/reducedMotion.stylex.ts, the
mark's owner module, which calls no StyleX, instead of theme/useTheme.ts.
reducedMotion.ts holds a hook, so it starts with 'use client'.

* refactor(core): the script readers' rule lives in the mark's owner module, which loads no animator

motion/reducedMotion.ts imports the animator, so a reader on every page
(press feedback, streaming text) would load it at first load. reducesMotion
and useReducesMotion now live in privateAttributes/reducedMotion.stylex.ts
beside the mark and its context; that module loads no animator, theme or
StyleX module. reducedMotionFade calls the same reducesMotion. spec:AST-108
FR6 gains the sentence that script readers decide through that module.
First-load gzip against main: docs +72 B, form +56 B, menu -42 B, table
+11 B, a Markdown page +122 B.

* refactor(core): the animator decides Reduce Motion through the same reducesMotion

The animator kept its own copy of the rule (the setting, or the mark on the
target). It now calls reducesMotion(target) from the mark's owner module,
and defaultPrefersReducedMotion delegates to reducesMotion(), so one rule
remains. The changeset's list of readers that follow names Resizable.

* Merge branch 'main' into lane4/r8895-mark

* Merge main into lane4/r8895-mark
cixzhang added a commit that referenced this pull request Nov 22, 2026
…me's reducedMotion 'always' (#13138)

* refactor(core): a theme's reduced-motion mark, internal until 'always' ships

Plumbing for spec:AST-108 FR6, with no change for anyone today: no public
theme can set reducedMotion, and resolveKnobs still resolves every theme to
'system', so no theme marks its root.

- privateAttributes/reducedMotion.stylex.ts owns data-astryx-reduced-motion:
  reducedMotionMarkProps and setRootReducedMotionMark write it, and
  themeReducesMotion reads it on an element, an ancestor, or <html>.
- Theme marks its wrapper, and the root theme marks <html>, with the
  attribute and the --_astryx-reduced-motion custom property when the
  theme's motion resolves reducedMotion to 'always'. The server renders the
  mark.
- The animator, reducedMotionFade and the layout glide count the mark as the
  person's Reduce Motion setting.
- ThemeReducedMotion (internal) widens to 'system' | 'always'.

Tests cover the reader, the three readers' use of it, and the Theme mark
through a mocked resolveMotionKnobs.

Co-authored-by: Christopher Chedeau <[email protected]>

* chore: a changeset for the internal reduced-motion mark; keep unrelated formatting out

* docs(Theme): say why no theme marks its root, in the present tense

* refactor(core): the reduced-motion mark carries a marker of its own, and the chat scroll, streaming text and swipe settle read it

Internal, like the mark it builds on: no theme can set reducedMotion
'always' yet, so nothing changes for anyone.

- theme/reducedMotion.markers.stylex.ts defines reducedMotionScope. Theme
  puts it on the marked wrapper, and the root theme writes its class on
  <html> beside the mark, so a Reduce Motion style keyed on
  stylex.when.ancestor('[data-astryx-reduced-motion]', reducedMotionScope)
  reaches portaled layers.
- motion/reducedMotion.ts adds reducesMotion(element): the person's setting
  or the mark. hooks/useReducesMotion.ts is its hook form, for a hook that
  holds no element: the setting, followed live, or the theme tree through
  ThemeReducesMotionContext, where a nested theme never removes an
  ancestor's 'always'.
- useChatStreamScroll, useStreamingText and ItemSwipeLayer read them.
- motion/reducedMotion.test.ts guards the rest with lists that only shrink:
  every Reduce Motion arm needs its twin on the mark, and every script read
  of the setting needs the mark. A read through a constant that holds the
  query counts.
- Tests reach 'always' through a themeMotion mock
  (theme/reducedMotionAlways.testing.ts).

Co-authored-by: Christopher Chedeau <[email protected]>

* test: the motion foundation may read a private attribute's owner module that calls no StyleX

The animator reads the reduced-motion mark through its owner module, which
the private-attribute rule names .stylex.ts. The module imports nothing, and
the check that the graph reaches no @stylexjs import still holds it to that.

* ci: the WebKit interaction proofs cover the reduced-motion mark's owner module, which the animator reads

* Merge lane4/theme-always-mark into lane4/r8895-mark

* Merge main into lane4/r8895-mark

The old base (#9761) landed squashed, so this resolves as main plus this
branch's own changes. main's later Reduce Motion work updates the
pending lists: ClickableCard, SelectableCard, Spinner's rotor, Thumbnail,
the press module and useMobileKeyboard are listed; Lightbox, Spinner,
AppShell and MobileNav come off (main removed their arms or reads).

* refactor(core): re-port onto main: a theme's reducedMotion 'always' reaches the hooks that hold no element

Main now carries the mark's private-attribute module, the root and wrapper
marks, and the animator's read of them (#9761), so this re-port keeps only
what main lacks: Theme passes 'always' down through ThemeReducesMotionContext
(beside Theme's other contexts in useTheme.ts; a nested theme keeps an
ancestor's), and motion/reducedMotion.ts gains reducesMotion(element) and its
hook form useReducesMotion, which the chat scroll and streaming text now
read. The swipe release already reads the mark through reducedMotionFade.
The other script readers follow in a stacked change.

Co-authored-by: Christopher Chedeau <[email protected]>

* refactor(core): the remaining Reduce Motion script readers read a theme's 'always'

Carousel's button and index scrolls, BottomSheet's alignment, cross-fade,
haptic and scroll settle, MobileNav's and AppShell's close hold, the mobile
keyboard's scroll and press feedback's release now decide through
motion/reducedMotion.ts (reducesMotion or useReducesMotion), which counts a
theme's reducedMotion: 'always' mark beside the person's setting.
Resizable's close slide, a DOM-free entry, ORs the setting with the mark
through the mark's owner module, as animatedLayout does. A guard test
keeps any new script read of the setting on the same rule (spec:AST-108
FR6). Stacked on the change that adds useReducesMotion.

Co-authored-by: Christopher Chedeau <[email protected]>

* refactor(core): the reduced-motion context lives beside the mark, so the motion foundation loads in plain Node

scripts/motion-node-load.test.mjs requires the motion foundation to reach no
theme module and no StyleX module. motion/reducedMotion.ts now reads
ThemeReducesMotionContext from privateAttributes/reducedMotion.stylex.ts, the
mark's owner module, which calls no StyleX, instead of theme/useTheme.ts.
reducedMotion.ts holds a hook, so it starts with 'use client'.

* Merge branch 'lane4/r8895-mark' into l0/reduced-motion-script-readers

* refactor(core): the script readers' rule lives in the mark's owner module, which loads no animator

motion/reducedMotion.ts imports the animator, so a reader on every page
(press feedback, streaming text) would load it at first load. reducesMotion
and useReducesMotion now live in privateAttributes/reducedMotion.stylex.ts
beside the mark and its context; that module loads no animator, theme or
StyleX module. reducedMotionFade calls the same reducesMotion. spec:AST-108
FR6 gains the sentence that script readers decide through that module.
First-load gzip against main: docs +72 B, form +56 B, menu -42 B, table
+11 B, a Markdown page +122 B.

* refactor(core): the remaining readers decide through the mark's owner module; a tighter guard; BottomSheet and Resizable tests

Every reader in this change now imports reducesMotion or useReducesMotion
from privateAttributes/reducedMotion.stylex.ts (merged from the base), which
loads no animator, so press feedback and Carousel no longer pull the
animator into first-load JavaScript. Resizable calls reducesMotion too, so
its inline copies go. The guard now counts each listed file's spellings of
the setting's query and fails any call of the animator's setting-only read
outside the motion foundation. BottomSheet (a coarse pointer's fade, no
alignment travel) and Resizable (no spring-back past the maximum) gain tests
under a theme's 'always' with the setting off. snap-paging's pager-only list
no longer holds the owner module, which every reader loads. spec:AST-108's
verification table names the guard. First-load gzip against main for the
stack: docs +74 B, form +24 B, menu +64 B, table +108 B.

* test(core): the reduced-motion guard matches the setting's query in any quote style and the exported query constants

The guard counted only a single-quoted query, so a template-literal read
or a read through REDUCED_MOTION_FADE_QUERY, REDUCED_MOTION_INSTANT_QUERY
or REDUCED_MOTION_COARSE_QUERY passed it. It now matches the query in any
quote style and fails any use of those constants outside the file that owns
each. The animator's entry leaves the allow-list (it reads through
reducesMotion now). AST-108's verification row and the changeset say so.

* refactor(core): the animator decides Reduce Motion through the same reducesMotion

The animator kept its own copy of the rule (the setting, or the mark on the
target). It now calls reducesMotion(target) from the mark's owner module,
and defaultPrefersReducedMotion delegates to reducesMotion(), so one rule
remains. The changeset's list of readers that follow names Resizable.

* test(core): the reduced-motion guard matches the setting's query inside a longer quoted query

A reader that spells '(pointer: fine) and (prefers-reduced-motion: reduce)'
passed the guard, which matched only a quote directly before the setting's
query. It now matches the setting's query anywhere inside a quoted string.

* Merge branch 'main' into lane4/r8895-mark

* Merge main into lane4/r8895-mark

* Merge #9763's head (main merge) into l0/reduced-motion-script-readers

* fix(core): one reduced-motion rule for the glide and the Dialog entrance

After the main merge: main's Dialog reads the setting's query itself, which
the readers guard refuses. It now asks reducesMotion(dialog), and watches
the setting through the owner module's new watchReduceMotionSetting only
while it is open under the setting (a theme's mark does not end).
reducesMotion reads the element's own window, so the layout glide calls it
instead of its own copy of the rule. The defaultPrefersReducedMotion
comment says it is the setting alone. Folds in #9763's review notes.

* test(motion): the readers guard allows the layout glide no spelling

The glide calls reducesMotion(area), so its allowance is unused; without
it, moving the glide back to the setting alone fails the guard. Comments
say a theme's mark is not watched, instead of that it does not change.

* Merge branch 'main' into l0/reduced-motion-script-readers

main holds #9763's squash, whose files equal its b312f7b head; the
owner module keeps this branch's version.

* fix(Dialog): the entrance stays still if the theme reduces motion when the setting ends

The setting watcher asks the theme's mark again before it replays the
travelling entrance.

* refactor(BottomSheet): the coarse cross-fade reads the owner module's rule once

Folds in review notes. useReducesMotion already includes the setting, so
the panel's cross-fade is reduced motion on a coarse pointer, and the
setting-only query goes; the readers guard drops BottomSheetPanel's
allowance and constant. The Dialog comment says the entrance replays only
when no theme's mark holds.

* test(motion): the readers guard catches reducesMotion with no element

A reducesMotion() call with no element reads the setting alone; only the
animator's setting-only read may make it.

* test(Dialog): pin the entrance's two theme-mark branches

Folds in review notes: under a theme's reduced-motion mark the dialog
reads no opener, and with the setting on too it watches no setting. The
Carousel's local is named for what it holds (setting or mark).

* test(Dialog): pin the re-check before a replayed entrance

When the setting ends after a theme's mark appeared, the entrance stays
still. The case fails without the re-check.

* test(Resizable): the 'always' spring-back case reads only frames after the lift

In WebKit a frame can run between the start of the recording and the
lift's dispatch; that frame still shows the edge past the limit. Each
recorded frame now says whether the page had heard the pointer's lift,
and the case checks only those.

* Merge branch 'main' into l0/reduced-motion-script-readers
cixzhang added a commit that referenced this pull request Nov 25, 2026
…rom the setting or a theme (#13512)

* refactor(core): a theme's reduced-motion mark, internal until 'always' ships

Plumbing for spec:AST-108 FR6, with no change for anyone today: no public
theme can set reducedMotion, and resolveKnobs still resolves every theme to
'system', so no theme marks its root.

- privateAttributes/reducedMotion.stylex.ts owns data-astryx-reduced-motion:
  reducedMotionMarkProps and setRootReducedMotionMark write it, and
  themeReducesMotion reads it on an element, an ancestor, or <html>.
- Theme marks its wrapper, and the root theme marks <html>, with the
  attribute and the --_astryx-reduced-motion custom property when the
  theme's motion resolves reducedMotion to 'always'. The server renders the
  mark.
- The animator, reducedMotionFade and the layout glide count the mark as the
  person's Reduce Motion setting.
- ThemeReducedMotion (internal) widens to 'system' | 'always'.

Tests cover the reader, the three readers' use of it, and the Theme mark
through a mocked resolveMotionKnobs.

Co-authored-by: Christopher Chedeau <[email protected]>

* chore: a changeset for the internal reduced-motion mark; keep unrelated formatting out

* docs(Theme): say why no theme marks its root, in the present tense

* refactor(core): the reduced-motion mark carries a marker of its own, and the chat scroll, streaming text and swipe settle read it

Internal, like the mark it builds on: no theme can set reducedMotion
'always' yet, so nothing changes for anyone.

- theme/reducedMotion.markers.stylex.ts defines reducedMotionScope. Theme
  puts it on the marked wrapper, and the root theme writes its class on
  <html> beside the mark, so a Reduce Motion style keyed on
  stylex.when.ancestor('[data-astryx-reduced-motion]', reducedMotionScope)
  reaches portaled layers.
- motion/reducedMotion.ts adds reducesMotion(element): the person's setting
  or the mark. hooks/useReducesMotion.ts is its hook form, for a hook that
  holds no element: the setting, followed live, or the theme tree through
  ThemeReducesMotionContext, where a nested theme never removes an
  ancestor's 'always'.
- useChatStreamScroll, useStreamingText and ItemSwipeLayer read them.
- motion/reducedMotion.test.ts guards the rest with lists that only shrink:
  every Reduce Motion arm needs its twin on the mark, and every script read
  of the setting needs the mark. A read through a constant that holds the
  query counts.
- Tests reach 'always' through a themeMotion mock
  (theme/reducedMotionAlways.testing.ts).

Co-authored-by: Christopher Chedeau <[email protected]>

* test: the motion foundation may read a private attribute's owner module that calls no StyleX

The animator reads the reduced-motion mark through its owner module, which
the private-attribute rule names .stylex.ts. The module imports nothing, and
the check that the graph reaches no @stylexjs import still holds it to that.

* ci: the WebKit interaction proofs cover the reduced-motion mark's owner module, which the animator reads

* Merge lane4/theme-always-mark into lane4/r8895-mark

* Merge main into lane4/r8895-mark

The old base (#9761) landed squashed, so this resolves as main plus this
branch's own changes. main's later Reduce Motion work updates the
pending lists: ClickableCard, SelectableCard, Spinner's rotor, Thumbnail,
the press module and useMobileKeyboard are listed; Lightbox, Spinner,
AppShell and MobileNav come off (main removed their arms or reads).

* refactor(core): re-port onto main: a theme's reducedMotion 'always' reaches the hooks that hold no element

Main now carries the mark's private-attribute module, the root and wrapper
marks, and the animator's read of them (#9761), so this re-port keeps only
what main lacks: Theme passes 'always' down through ThemeReducesMotionContext
(beside Theme's other contexts in useTheme.ts; a nested theme keeps an
ancestor's), and motion/reducedMotion.ts gains reducesMotion(element) and its
hook form useReducesMotion, which the chat scroll and streaming text now
read. The swipe release already reads the mark through reducedMotionFade.
The other script readers follow in a stacked change.

Co-authored-by: Christopher Chedeau <[email protected]>

* refactor(core): the remaining Reduce Motion script readers read a theme's 'always'

Carousel's button and index scrolls, BottomSheet's alignment, cross-fade,
haptic and scroll settle, MobileNav's and AppShell's close hold, the mobile
keyboard's scroll and press feedback's release now decide through
motion/reducedMotion.ts (reducesMotion or useReducesMotion), which counts a
theme's reducedMotion: 'always' mark beside the person's setting.
Resizable's close slide, a DOM-free entry, ORs the setting with the mark
through the mark's owner module, as animatedLayout does. A guard test
keeps any new script read of the setting on the same rule (spec:AST-108
FR6). Stacked on the change that adds useReducesMotion.

Co-authored-by: Christopher Chedeau <[email protected]>

* refactor(core): the reduced-motion context lives beside the mark, so the motion foundation loads in plain Node

scripts/motion-node-load.test.mjs requires the motion foundation to reach no
theme module and no StyleX module. motion/reducedMotion.ts now reads
ThemeReducesMotionContext from privateAttributes/reducedMotion.stylex.ts, the
mark's owner module, which calls no StyleX, instead of theme/useTheme.ts.
reducedMotion.ts holds a hook, so it starts with 'use client'.

* Merge branch 'lane4/r8895-mark' into l0/reduced-motion-script-readers

* refactor(core): the script readers' rule lives in the mark's owner module, which loads no animator

motion/reducedMotion.ts imports the animator, so a reader on every page
(press feedback, streaming text) would load it at first load. reducesMotion
and useReducesMotion now live in privateAttributes/reducedMotion.stylex.ts
beside the mark and its context; that module loads no animator, theme or
StyleX module. reducedMotionFade calls the same reducesMotion. spec:AST-108
FR6 gains the sentence that script readers decide through that module.
First-load gzip against main: docs +72 B, form +56 B, menu -42 B, table
+11 B, a Markdown page +122 B.

* refactor(core): the remaining readers decide through the mark's owner module; a tighter guard; BottomSheet and Resizable tests

Every reader in this change now imports reducesMotion or useReducesMotion
from privateAttributes/reducedMotion.stylex.ts (merged from the base), which
loads no animator, so press feedback and Carousel no longer pull the
animator into first-load JavaScript. Resizable calls reducesMotion too, so
its inline copies go. The guard now counts each listed file's spellings of
the setting's query and fails any call of the animator's setting-only read
outside the motion foundation. BottomSheet (a coarse pointer's fade, no
alignment travel) and Resizable (no spring-back past the maximum) gain tests
under a theme's 'always' with the setting off. snap-paging's pager-only list
no longer holds the owner module, which every reader loads. spec:AST-108's
verification table names the guard. First-load gzip against main for the
stack: docs +74 B, form +24 B, menu +64 B, table +108 B.

* test(core): the reduced-motion guard matches the setting's query in any quote style and the exported query constants

The guard counted only a single-quoted query, so a template-literal read
or a read through REDUCED_MOTION_FADE_QUERY, REDUCED_MOTION_INSTANT_QUERY
or REDUCED_MOTION_COARSE_QUERY passed it. It now matches the query in any
quote style and fails any use of those constants outside the file that owns
each. The animator's entry leaves the allow-list (it reads through
reducesMotion now). AST-108's verification row and the changeset say so.

* refactor(core): the animator decides Reduce Motion through the same reducesMotion

The animator kept its own copy of the rule (the setting, or the mark on the
target). It now calls reducesMotion(target) from the mark's owner module,
and defaultPrefersReducedMotion delegates to reducesMotion(), so one rule
remains. The changeset's list of readers that follow names Resizable.

* test(core): the reduced-motion guard matches the setting's query inside a longer quoted query

A reader that spells '(pointer: fine) and (prefers-reduced-motion: reduce)'
passed the guard, which matched only a quote directly before the setting's
query. It now matches the setting's query anywhere inside a quoted string.

* Merge branch 'main' into lane4/r8895-mark

* fix(core): transform transitions land at once under reduced motion, from the setting or a theme

One shared helper, privateAttributes/transformMotion.stylex.ts, gives a
transform's duration a factor that reads the --_astryx-reduced-motion
property Theme writes where it writes the reduced-motion mark, and the
media key for the person's setting. 30 transform transitions build their
durations from it: chevrons that turned even under the setting now land
at once, and the sites that only followed the media query now follow a
theme that reduces motion for everyone too. Colour and opacity keep their
durations. A Chromium spec sweeps eight stories under no reduction, the
setting, a nested marked theme and a marked root.

* fix(core): the reduced-motion transform factor lives in motion/reducedMotion.stylex.ts

CodeBunny review: fold the helper into the existing CSS-side module of the
Reduced Motion policy (reducedMotionTransform: factor, settle) instead of
a new module; spell the setting's media key literally at each site; the
resize handle's pill changes every property at once under the setting
(DR3), and the mark matches. Stepper's per-connector timing reads
useReducesMotion in script instead of a calc, so its timing tests keep
their values. Tests that pin a duration string are updated, and the
changeset says no theme can set reducedMotion 'always' yet.

* fix(BottomSheet): under a theme that reduces motion, the sheet lands on the next frame

PR Review's motion check: with the 0.01s settle, the sheet's entrance
from its @starting-style offset showed one frame between. The sheet's own
wait resolves a zero duration, so it takes the factor alone (0s under
the mark), as the setting's arm already lands in one frame.

* test(TreeList): with a mouse under reduced motion, the chevron lands at once

The test asserted a chevron turn under Reduce Motion that no record
grants; design:reduced-motion DR1 and DR3 govern (a rotation is
movement, and with a fine pointer it completes at once). Ruled by the
Specification session. The group's at-once assertion stays.

* Merge main into lane4/r8895-mark

* Merge #9763's head (main merge) into l0/reduced-motion-script-readers

* Merge l0/reduced-motion-script-readers (on #9763's main merge) into l0/reduced-motion-transform-transitions

Conflicts: MultiSelector imports (both kept); OverlayScrim, where main
added clip-path to the transition: each fade duration and the clip's hide
delay read the reduced-motion factor, so the mark matches the setting.

* Merge l0/reduced-motion-script-readers into l0/reduced-motion-transform-transitions

* fix(core): one reduced-motion rule for the glide and the Dialog entrance

After the main merge: main's Dialog reads the setting's query itself, which
the readers guard refuses. It now asks reducesMotion(dialog), and watches
the setting through the owner module's new watchReduceMotionSetting only
while it is open under the setting (a theme's mark does not end).
reducesMotion reads the element's own window, so the layout glide calls it
instead of its own copy of the rule. The defaultPrefersReducedMotion
comment says it is the setting alone. Folds in #9763's review notes.

* fix(Dialog, Overlay): a reduced-motion theme shows the dialog and lifts the scrim clip at once

The Dialog's entrance keyframes take the reduced-motion factor on their
duration, so under a theme's 'always' the dialog appears at once (DR3),
as under the setting. The scrim's hover clip delay takes it too, so the
reveal settles in one frame.

* test(motion): the readers guard allows the layout glide no spelling

The glide calls reducesMotion(area), so its allowance is unused; without
it, moving the glide back to the setting alone fails the guard. Comments
say a theme's mark is not watched, instead of that it does not change.

* Merge l0/reduced-motion-script-readers into l0/reduced-motion-transform-transitions

* Merge branch 'main' into l0/reduced-motion-script-readers

main holds #9763's squash, whose files equal its b312f7b head; the
owner module keeps this branch's version.

* fix(Dialog): the entrance stays still if the theme reduces motion when the setting ends

The setting watcher asks the theme's mark again before it replays the
travelling entrance.

* Merge l0/reduced-motion-script-readers (on main) into l0/reduced-motion-transform-transitions

* Merge l0/reduced-motion-script-readers into l0/reduced-motion-transform-transitions

* refactor(BottomSheet): the coarse cross-fade reads the owner module's rule once

Folds in review notes. useReducesMotion already includes the setting, so
the panel's cross-fade is reduced motion on a coarse pointer, and the
setting-only query goes; the readers guard drops BottomSheetPanel's
allowance and constant. The Dialog comment says the entrance replays only
when no theme's mark holds.

* docs(BottomSheet): shorten the reduced-motion settle comment

* test(motion): the readers guard catches reducesMotion with no element

A reducesMotion() call with no element reads the setting alone; only the
animator's setting-only read may make it.

* Merge l0/reduced-motion-script-readers into l0/reduced-motion-transform-transitions

* test(Dialog): pin the entrance's two theme-mark branches

Folds in review notes: under a theme's reduced-motion mark the dialog
reads no opener, and with the setting on too it watches no setting. The
Carousel's local is named for what it holds (setting or mark).

* Merge l0/reduced-motion-script-readers into l0/reduced-motion-transform-transitions

* test(Dialog): pin the re-check before a replayed entrance

When the setting ends after a theme's mark appeared, the entrance stays
still. The case fails without the re-check.

* Merge l0/reduced-motion-script-readers into l0/reduced-motion-transform-transitions

* test(Resizable): the 'always' spring-back case reads only frames after the lift

In WebKit a frame can run between the start of the recording and the
lift's dispatch; that frame still shows the edge past the limit. Each
recorded frame now says whether the page had heard the pointer's lift,
and the case checks only those.

* Merge l0/reduced-motion-script-readers into l0/reduced-motion-transform-transitions

* Merge branch 'main' into l0/reduced-motion-script-readers

* Merge l0/reduced-motion-script-readers into l0/reduced-motion-transform-transitions

* Merge branch 'main' into l0/reduced-motion-transform-transitions

* Merge branch 'main' into l0/reduced-motion-transform-transitions

* Merge branch 'main' into l0/reduced-motion-transform-transitions

* Merge branch 'main' into l0/reduced-motion-transform-transitions

This branch was successfully deployed

1 active deployment
Preview — 76c611ba Deployed Nov 3, 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