Skip to content

perf(core): Toast's swipe claim and Popover's surface motion come with the touch runtime - #11463

Draft
cixzhang wants to merge 13 commits into
perf/defer-touch-runtimefrom
perf/defer-touch-toast-popover
Draft

cixzhang wants to merge 13 commits into
perf/defer-touch-runtimefrom
perf/defer-touch-toast-popover

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Primary intent

Performance, stacked on #11450: Toast and Popover stop importing the touch runtime (the gesture host and the animator) statically. They take it from the shared loader that #11450 adds, so a page that imports Toast or Popover no longer carries the runtime in its first load; the runtime loads after first paint. On the measured app this is all of the embed view's remaining first-load touch code. It is not a bug fix or a feature: no behavior changes after the load, and there's no API change.

User or maintainer impact

  • People loading a page with a Toast viewport or a Popover download less JavaScript before first paint. Measured on a consumer app's production build with this PR and perf(core): SegmentedControl, Switch and BottomSheet load the touch animator after first paint #11450 together: 25 KB fewer bytes on first load and the composer ready 129 ms sooner at 2 Mbit (below).
  • Before the runtime loads (first paint, then idle, at most 2 s):
    • a toast tracks no swipe (it still dismisses by its button, its timer and keys);
    • a popover under a finger presents as under a fine pointer, without growing out of its trigger.
      A swipe or a press already in flight when the load lands finishes that way; the next one takes the touch path.

Problem and solution fit

  • Toast: useToastGesture drew the swipe from React's events, but claimed a finger's touch with the gesture host's one-way pan, which is a static import of gestures/useGestureRecognizer and GestureHost. That pan is now the runtime part ToastSwipeClaim. It renders nothing and mounts after the load, as a sibling that follows the card, so the card's node is attached when the claim attaches to it. The hook starts no swipe until the claim exists.
  • Popover: usePopoverSurfaceMotion created its touch presentation with createPopoverSurfaceMotion, a static import of the animator. It now takes the factory from the runtime at open time, and treats an open before the load as a fine-pointer one.

Authority

architecture:react-component-runtime INV13 and spec:AST-080 DEC-5, as amended in #11450. INV13's gap line drops Toast and Popover.

Change and evidence

  • Toast/useToastGesture.ts, Toast/Toast.tsx, Popover/usePopoverSurfaceMotion.ts, utils/touchRuntimeModules.tsx (ToastSwipeClaim, createPopoverSurfaceMotion), plus the INV13 gap line.
  • With this change, no static path from the Toast or Popover entries reaches motion/animator or gestures/GestureHost.

Static first-load graph (module counts only)

Structural evidence, not a size claim; the size numbers above and below come from real bundlers. The modules each page reaches through static imports, from this PR's head against #11450's head (its base):

Page Modules (base → head) Import depth (base → head)
docs 250 → 250 10 → 10
form 235 → 235 9 → 9
menu 299 → 299 8 → 8
table 644 → 637 (−7: Popover surface motion and the layer exit copy) 12 → 12
one Toast 230 → 211 (−19) 11 → 11
one Popover 223 → 204 (−19) 9 → 9

Measured effect on a consumer app

Measured on a consumer app's production build (its own bundler, not an estimate), n=10 interleaved runs. The measured build is this PR's head, which includes #11450, so the effect belongs to the pair.

Measure 2 Mbit 20 Mbit
Composer ready, home route −129 ms (10/10 runs lower) −18 ms, not significant (p 0.34)
Composer ready, session route −114 ms (10/10 runs lower) —
First Contentful Paint −44 ms −12 ms (9/10)
Largest Contentful Paint −124 ms —
First-load requests −3 −3
Bytes served on first load −25 KB −25 KB

At 20 Mbit there is no slowdown, despite three more chunk levels. The measured build also dropped one unrelated entry from the app's own configuration.

Scope

Components: Toast, Popover, utils/touchRuntimeModules

  • This PR has one primary intent.
  • Independently removable deltas were removed or split (the other static importers are later PRs in the stack).
  • Public text and artifacts contain no internal Meta context.

Testing

Red first, each failing on #11450's head:

  • utils/touchRuntime.boundary.test.ts: the Toast and Popover entries reach no touch module statically.
  • ToastViewport.test.tsx: "tracks no swipe before the touch runtime loads" (a pen swipe past the threshold neither moves nor dismisses the toast).
  • usePopoverSurfaceMotion.test.tsx: "before the touch runtime loads, presents a coarse open as a fine-pointer one".

Also:

  • The Toast and Popover suites that drive touch motion load the runtime in beforeAll.
  • packages/core/src/Toast, packages/core/src/Popover and utils/touchRuntime*: 303 passed.
  • Core typecheck and check:knowledge pass.

Writing rubric results

  • R1 present tense: pass; only INV13's gap line changes.
  • R2–R7: none in the record.

Owner and land path

Owner: the Astryx fix loop, lane 3. Lands after #8690 merges, in stack order (#11450, #11463, #11466, #11476, #11478, #11508, #11518, #11525, #11530, #11536, #11540, #11544), each after Specs, CodeBunny at its head and green CI; the drain merges.

…h the touch runtime

Toast no longer imports the gesture host statically: its one-way pan that claims a finger's touch is a runtime part mounted after the load, and until then no swipe starts. Popover's touch presentation creates its surface motion from the runtime; until it loads a popover presents as under a fine pointer. INV13's gap line drops Toast and Popover. With these, no static path from Toast or Popover reaches the animator or the gesture host.
@vercel

vercel Bot commented Nov 13, 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 14, 2026 8:08pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 13, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 039f33c

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 13, 2026
@astracat-bot

astracat-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟡 Reviewed (for maintainers only) Nov 14, 2026, 8:26 PM UTC

@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: moving Toast's swipe claim and Popover's touch motion onto the shared touch runtime works as described, and the record change has an engineering owner's approval at this head, but two things need fixing first.

  • ToastSwipeClaim keeps shouldReceive and its claim in refs through per-site Effects (packages/core/src/utils/touchRuntimeModules.tsx lines 99-103 and 126-129); use useCommittedRef(shouldReceive) (or drop the ref, since that callback is stable) and pass claimRef so the part calls useCommittedRefInto(claimRef, claim).
  • The Toast record's FR4 and the Popover record's FR9 still say a swipe toward the edge dismisses and a finger-opened popover grows, with no word about the window before the touch runtime loads; add one sentence to each that names that window under INV13 (for Toast, also under its swipe-only custom-content gap).

Also worth a look: the stack's Changeset names only SegmentedControl, Switch and BottomSheet, and the header of Popover/PopoverTouch.ts still says Popover imports the touch modules statically.

Claims and files checked
  • Claim: Toast and Popover no longer import the touch runtime statically. Verified: the boundary test's new Toast and Popover cases fail on the base and pass here.
  • Claim: a page with a toast or a popover no longer carries the runtime in its first load. Verified for both components' import graphs; page bytes not measured.
  • Claim: on the measured app this is all of the embed view's remaining first-load touch code, about 32 KB gzip. Not verifiable from this pull request.
  • Claim: no behavior changes after the load. Verified: 303 tests pass, and in a real browser the loaded popover grows and a swipe dismisses the toast exactly as on the base.
  • Claim: no API change. Verified: the built API surfaces of Core and the themes are identical.
  • Claim: before the load a toast tracks no swipe and still dismisses by its button, timer and keys. Verified by the new test and a browser finger swipe; the button and timer paths are unchanged.
  • Claim: before the load a finger-opened popover presents as under a fine pointer. Verified by the new test and in a browser, which plays the layer's own entrance.
  • Claim: the window is first paint, then idle, at most 2 s. Verified as when the load starts; the chunk download comes on top.
  • Claim: a gesture already in flight when the load lands finishes on its old path. Verified in code: the swipe start and the presentation are decided at press and open.
  • Claim: the pan is a runtime part that renders nothing and mounts after the card. Verified in Toast.tsx and touchRuntimeModules.tsx.
  • Claim: Popover takes the motion factory from the runtime at open. Verified in usePopoverSurfaceMotion.ts.
  • Claim: INV13's gap line drops Toast and Popover. Verified.
  • Claim: the three new tests fail on the base. Verified.
  • Claim: suites that drive touch motion load the runtime first. Verified.
  • Claim: 303 tests pass, and the core typecheck and knowledge check pass. Verified.
  • Claim: public text carries no internal context. Verified.
  • File docs/architecture/react-component-runtime.md: clear.
  • File packages/core/src/Popover/Popover.test.tsx: clear.
  • File packages/core/src/Popover/usePopoverSurfaceMotion.test.tsx: clear.
  • File packages/core/src/Popover/usePopoverSurfaceMotion.ts: non-blocking comment suggestion.
  • File packages/core/src/Toast/Toast.tsx: clear.
  • File packages/core/src/Toast/ToastViewport.test.tsx: clear.
  • File packages/core/src/Toast/useToastGesture.ts: finding (the claim is handed over through an Effect).
  • File packages/core/src/utils/touchRuntime.boundary.test.ts: clear.
  • File packages/core/src/utils/touchRuntimeModules.tsx: finding (two per-site ref Effects).

Automated review (maintainer link)

Comment on lines +99 to +103
const shouldReceiveRef = useRef(shouldReceive);
// Syncs the pan's touch filter with the toast's newest one.
useIsomorphicLayoutEffect(() => {
shouldReceiveRef.current = shouldReceive;
});

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 Effect only copies shouldReceive into a ref, which the repository's pre-review item j flags. Use const shouldReceiveRef = useCommittedRef(shouldReceive); from ../hooks/useCommittedRef, or drop the ref: shouldReceive is a useCallback with no dependencies in useToastGesture.ts.

Comment on lines +126 to +129
useIsomorphicLayoutEffect(() => {
onClaim(claim);
return () => onClaim(null);
}, [claim, onClaim]);

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 Effect's only job is to write claim into useToastGesture's claimRef through onClaim. Pass claimRef in the props and call useCommittedRefInto(claimRef, claim) instead, so the hand-over goes through the shared hook.

Comment on lines +82 to +85
// The touch presentation's motion comes with the shared touch runtime,
// which loads after first paint. Until then a popover presents as under a
// fine pointer.
useTouchRuntime();

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 (comment style): the call's result is unused, and the comment does not say why the call is here, so it reads as dead code. Suggested: // This call schedules the page's one load of the touch runtime. Until it loads, a popover presents as under a fine pointer.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 4693441

@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: Toast's swipe claim and Popover's touch motion now come from the shared touch runtime as described, and the record change has an engineering owner's approval at this head, but three things need fixing first.

  • ToastSwipeClaim keeps shouldReceive and its claim in refs through per-site Effects (packages/core/src/utils/touchRuntimeModules.tsx lines 96-100 and 123-126); use useCommittedRef(shouldReceive) (or drop that ref, since the callback is stable) and pass claimRef so the part calls useCommittedRefInto(claimRef, claim), as SegmentedMotion in the same file does.
  • The Toast record's FR4 and the Popover record's FR9 still say a swipe toward the edge dismisses and a finger-opened popover grows, with no word about the window before the touch runtime loads; add one sentence to each that names that window, as the base branch does for SegmentedControl FR9 and FR13 (for Toast, also under its swipe-only custom-content gap).
  • Miss: on a page whose only touch component is a toast, nothing schedules the runtime until the first toast mounts (packages/core/src/Toast/useToastGesture.ts line 141), so the load starts with that toast instead of after first paint and that toast cannot be swiped; schedule the load from the page-level host, for example one useTouchRuntime() call in ToastViewport.

Also worth a look: the stack's changeset names only SegmentedControl, Switch and BottomSheet, and the header of Popover/PopoverTouch.ts still says Popover imports the touch modules statically.

Claims and files checked
  • Claim: Toast and Popover no longer import the touch runtime statically. Verified: the boundary test's new Toast and Popover cases fail on the base and pass here.
  • Claim: they take it from the base branch's shared loader. Verified: useTouchRuntime and getTouchRuntime in both hooks.
  • Claim: a page with a toast or a popover no longer carries the runtime in its first load. Verified for both import graphs; page bytes not measured.
  • Claim: on the measured app this is all of the remaining first-load touch code, about 32 KB gzip. Not verified here: the measurement comes from the base pull request.
  • Claim: no behavior change after the load and no API change. Verified: the suites pass with the runtime loaded, and the API surface generator lists no change.
  • Claim: before the load a toast tracks no swipe but still dismisses by its button, timer and keys. Verified: useToastGesture.ts line 182 and the new test.
  • Claim: before the load a finger-opened popover presents as under a fine pointer. Verified: the new test.
  • Claim: a swipe or press in flight when the load lands finishes that way. Verified by reading: the claim part attaches only when it mounts, and Popover decides at open.
  • Claim: the claim part renders nothing and follows the card, so the card is attached first. Verified: Toast.tsx fragment order.
  • Claim: the hook starts no swipe until the claim exists; Popover takes the factory at open. Verified.
  • Claim: the governing records are the runtime architecture record's touch-module invariant and the stylesheet spec's decision as the base branch amends them, and the gap line drops Toast and Popover. Verified.
  • Claim: the three new tests fail on the base pull request's head. Verified: all fail there and pass here.
  • Claim: the touch-driving suites load the runtime before their cases. Verified.
  • Claim: 303 tests pass. At this head 304 pass; the merged base adds one.
  • Claim: core typecheck and the knowledge check pass; the record stays in the present tense. Verified.
  • Claim: no internal context in public text. Verified.
  • docs/architecture/react-component-runtime.md: clear.
  • packages/core/src/Popover/Popover.test.tsx: clear.
  • packages/core/src/Popover/usePopoverSurfaceMotion.test.tsx: clear.
  • packages/core/src/Popover/usePopoverSurfaceMotion.ts: non-blocking comment suggestion.
  • packages/core/src/Toast/Toast.tsx: clear.
  • packages/core/src/Toast/ToastViewport.test.tsx: clear.
  • packages/core/src/Toast/useToastGesture.ts: the claim hand-over and the load scheduling findings.
  • packages/core/src/utils/touchRuntime.boundary.test.ts: clear.
  • packages/core/src/utils/touchRuntimeModules.tsx: the per-site ref Effects finding.

Automated review (maintainer link)

}, [claim, direction]);
// draws the swipe. The pan comes with the shared touch runtime, which
// loads after first paint; until then no swipe starts.
const touchRuntime = useTouchRuntime();

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.

Miss: this per-toast call is the only thing that schedules the touch runtime on a page whose only touch component is a toast, and ToastViewport renders no ToastSurface until a toast is raised. So the load starts with the first toast (often a click's answer) instead of after first paint, and that toast cannot be swiped until the load lands. One useTouchRuntime() call in ToastViewport would schedule it with the page, as INV13 describes.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 4f68088

@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: this head adds the pre-load window to the runtime, Toast and Popover records with an engineering owner's approval, but the code is unchanged since the last review, so its two code fixes are still needed, and the Toast record needs one more sentence.

  • ToastSwipeClaim keeps shouldReceive and its claim in refs through per-site Effects (packages/core/src/utils/touchRuntimeModules.tsx:96-100 and :123-126), which the runtime record forbids; use useCommittedRef(shouldReceive) and pass claimRef so the part calls useCommittedRefInto(claimRef, claim).
  • Miss: on a page whose only touch component is a toast, nothing schedules the runtime load until the first toast mounts (packages/core/src/Toast/useToastGesture.ts:141), so in Chromium the chunk is requested 11 ms after the tap that raises the toast instead of after first paint; one useTouchRuntime() call in ToastViewport would schedule it with the page.
  • The Toast record's gap entry for custom content without a control (docs/specs/components/Toast/Toast.spec.md:102-105) still says such a toast can be dismissed by a swipe, but before the load it has no swipe, and an error one has no timer either, so the person cannot dismiss it; name the pre-load window there and add "in the default layout" to FR4's new sentence.

Two optional cleanups: PopoverTouch.ts's header still says Popover imports the touch modules statically, and the stack's changeset does not mention Toast or Popover.

Claims and files checked
  • Claim: Toast and Popover stop importing the touch runtime statically and take it from the shared loader. Verified: the boundary test's two new entries fail on the base and pass here.
  • Claim: a page with a toast viewport or a popover no longer carries the runtime in its first load. Verified for the static graph; the page-level saving is not re-measured here.
  • Claim: no behavior change after the load and no API change. Verified: Chromium frames after the load are identical on base and head, and the API generator finds no change.
  • Claim: before the load (first paint, then idle, at most 2 s) a toast tracks no swipe. Partly false: the swipe is refused (new test), but on a toast-only page the window starts at the first toast, not at first paint.
  • Claim: the toast still dismisses by its button, timer and keys. Verified for the default layout; not for custom content without a control.
  • Claim: a popover under a finger presents as under a fine pointer before the load. Verified: new test and usePopoverSurfaceMotion.ts:117-120.
  • Claim: a swipe or press in flight when the load lands finishes that way. Verified: beginGesture refuses without the claim (useToastGesture.ts:182), and Popover decides at open.
  • Claim: ToastSwipeClaim renders nothing and mounts after the load as a sibling that follows the card; the hook starts no swipe until it exists. Verified: Toast.tsx:458, touchRuntimeModules.tsx:89-128, useToastGesture.ts:182.
  • Claim: INV13's gap line drops Toast and Popover. Verified.
  • Claim: the three new tests fail first on the base. Verified.
  • Claim: the touch-driving suites load the runtime in beforeAll; the suites pass; core typecheck and the knowledge check pass. Verified (306 pass at this head).
  • File docs/architecture/react-component-runtime.md: clear.
  • File docs/specs/components/Popover/Popover.spec.md: clear.
  • File docs/specs/components/Toast/Toast.spec.md: finding (custom-content gap).
  • File packages/core/src/Popover/Popover.test.tsx: clear.
  • File packages/core/src/Popover/usePopoverSurfaceMotion.test.tsx: clear.
  • File packages/core/src/Popover/usePopoverSurfaceMotion.ts: clear (one optional comment suggestion).
  • File packages/core/src/Toast/Toast.tsx: clear.
  • File packages/core/src/Toast/ToastViewport.test.tsx: clear.
  • File packages/core/src/Toast/useToastGesture.ts: finding (load scheduled per toast).
  • File packages/core/src/utils/touchRuntime.boundary.test.ts: clear.
  • File packages/core/src/utils/touchRuntimeModules.tsx: finding (per-site ref Effects).

Automated review (maintainer link)

| FR1 | A card carries `toast` with `type` and shows `body` and, on its first line, `endContent` then a dismiss Button named by `@astryx.toast.dismiss`; long body text wraps below. `renderContent` replaces that layout, receives `body`, `endContent`, `type`, timing, and a `dismiss` function, and gets no injected dismiss control. | Current source and tests |
| FR2 | With auto-hide on (the default for `info`, off for `error`), the card dismisses with reason `auto` after `autoHideDuration` ms. The timer pauses while the pointer is over the card, focus is inside it, a touch or pen gesture is active, or the window is blurred, and resumes with the remaining time (at least 1 s). Each pause condition holds the timer on its own: one ending resumes it only when no other still holds, and focus moving between the card's own controls keeps it held. A toast raised while the window is already blurred starts with its timer held. | Current source and tests |
| FR3 | The dismiss button, a swipe, a `dismiss` call, or the returned dismiss function dismiss with reason `manual`; `onHide` fires at most once, when the toast is dismissed, even when dismissed twice during its exit or before it shows. A toast replaced through `uniqueID` is not dismissed and reports no `onHide`. | Current source and tests |
| FR4 | A drag toward the position's block edge, from any pointer (`spec:AST-094` FR43), decides once, at release, per `spec:AST-094` FR36–FR37: projected travel past the commit point dismisses, and a release moving back toward the start cancels. A short drag snaps back; horizontal intent, a second touch, or a gesture starting on an interactive descendant does not dismiss. Native page scrolling continues until touch intent matches the dismiss edge. On a touch screen, the touch's first move decides: toward the dismiss edge, the swipe owns the touch. In the default layout the visible dismiss button stays as a non-gesture alternative; custom content supplies its own. Implementation gaps: the shipped rule dismisses on net travel past a distance threshold or a fast flick timed by its own average speed, even after the finger moves back, and recognizes only touch and pen drags, not a mouse (Current-state impact). Until the shared touch runtime has loaded (`architecture:react-component-runtime` INV13), a toast does not swipe; its close button and timer still dismiss it. | Current source and tests |

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.

Before the load, a renderContent toast with no control has no close button, and an error one has no timer, so it cannot be dismissed at all. The gap entry "Custom content without a control has only the swipe" (line 102) still says it has the swipe. Suggested: add "in the default layout" to this sentence, and one sentence in that gap entry naming the pre-load window.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec b994b59

@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: moving Toast's swipe claim and Popover's touch motion onto the shared touch runtime works as described, and the owner-approved records cover the direction, but three fixes from the last review are still open at this head.

  • ToastSwipeClaim keeps shouldReceive and its claim in refs through per-site Effects (packages/core/src/utils/touchRuntimeModules.tsx:96-100 and :123-126), which the runtime record forbids; use useCommittedRef(shouldReceive) and pass claimRef so the part calls useCommittedRefInto(claimRef, claim).
  • Miss: on a page whose only touch component is a toast, nothing schedules the runtime load until the first toast mounts (packages/core/src/Toast/useToastGesture.ts:141), so in Chromium the chunk is requested 39 ms after the tap that raises the toast instead of after first paint; one useTouchRuntime() call in ToastViewport would schedule it with the page.
  • The Toast record's gap entry for custom content without a control (docs/specs/components/Toast/Toast.spec.md:102-105) still says such a toast can be dismissed by a swipe, but before the load it has no swipe, and an error one has no timer either, so the person cannot dismiss it; name the pre-load window there and add "in the default layout" to FR4's new sentence.

Two optional cleanups: PopoverTouch.ts's header still says Popover imports the touch modules statically, and the stack's changeset does not mention Toast or Popover.

Claims and files checked
  • Claim: Toast and Popover stop importing the touch runtime statically and take it from the shared loader. Verified: the boundary test's two new entries fail on the base and pass here.
  • Claim: a page with a toast viewport or a popover no longer carries the runtime in its first load. Verified for the static graph; the page-level saving is not re-measured here.
  • Claim: no behavior change after the load and no API change. Verified: Chromium frames after the load are identical on base and head, and the API surface comparison finds no change.
  • Claim: before the load (first paint, then idle, at most 2 s) a toast tracks no swipe. Partly false: the swipe is refused (new test, and a held-back Chromium swipe), but on a toast-only page the window starts at the first toast, not at first paint.
  • Claim: the toast still dismisses by its button, timer and keys. Verified for the default layout; not for custom content without a control.
  • Claim: a popover under a finger presents as under a fine pointer before the load. Verified: new test, usePopoverSurfaceMotion.ts:117-120, and a held-back Chromium tap (full size at 60 ms).
  • Claim: a swipe or press in flight when the load lands finishes that way. Verified: beginGesture refuses without the claim (useToastGesture.ts:182), and Popover decides at open (:117-120, closeStart).
  • Claim: ToastSwipeClaim renders nothing and mounts after the load as a sibling that follows the card; the hook starts no swipe until it exists. Verified: Toast.tsx:458, touchRuntimeModules.tsx:89-128, useToastGesture.ts:182.
  • Claim: INV13's gap line drops Toast and Popover. Verified.
  • Claim: the three new tests fail first on the base. Verified (with the boundary file's two entries, four cases fail on the base).
  • Claim: the touch-driving suites load the runtime in beforeAll; the suites pass; core typecheck and the knowledge check pass. Verified (306 pass).
  • File docs/architecture/react-component-runtime.md: clear.
  • File docs/specs/components/Popover/Popover.spec.md: clear.
  • File docs/specs/components/Toast/Toast.spec.md: finding (custom-content gap).
  • File packages/core/src/Popover/Popover.test.tsx: clear.
  • File packages/core/src/Popover/usePopoverSurfaceMotion.test.tsx: clear.
  • File packages/core/src/Popover/usePopoverSurfaceMotion.ts: clear (one optional comment suggestion).
  • File packages/core/src/Toast/Toast.tsx: clear.
  • File packages/core/src/Toast/ToastViewport.test.tsx: clear.
  • File packages/core/src/Toast/useToastGesture.ts: finding (load scheduled per toast).
  • File packages/core/src/utils/touchRuntime.boundary.test.ts: clear.
  • File packages/core/src/utils/touchRuntimeModules.tsx: finding (per-site ref Effects).

Automated review (maintainer link)

# Conflicts:
#	docs/architecture/react-component-runtime.md
#	docs/specs/components/Popover/Popover.spec.md
#	packages/core/src/Toast/Toast.tsx
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec a3f3413

@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 record text this change rests on is now approved by an engineering owner for this head, so what remains are five fixes in the code, the Toast record and the description.

  • utils/touchRuntimeModules.tsx:96-100 and :123-126 copy shouldReceive and the swipe claim into refs with per-site Effects, which INV3 rules out; use useCommittedRef and useCommittedRefInto, as SegmentedMotion in the same file already does.
  • Miss: on a page whose only touch component is a toast, nothing schedules the touch runtime until the first toast mounts (Toast/useToastGesture.ts:141), so the load starts with that toast instead of after first paint, against INV13's "nothing loads them on demand" and the description's "first paint, then idle, at most 2 s"; schedule it once from ToastViewport, or narrow those claims.
  • Toast FR4's new sentence and the "Custom content without a control has only the swipe" gap entry imply a control-free renderContent toast can still be dismissed before the load, but it has no button and, as an error, no timer; scope the sentence to the default layout and name the pre-load window in that gap entry.
  • Miss: the description says only INV13's gap line changes in the records, but INV13's pre-load sentence, Toast FR4 and Popover FR9 change too; list them with their rubric results.
  • Newly live check: Toast/useToastGesture.ts grows to 510 lines while timing its flick with its own average speed, so INV19 asks it to take the release decision from VelocityTracker or to record in component:Toast why no shared engine fits.

Smaller points: Popover FR9's row carries two stray cells and INV13 one unwrapped line from the base merge, Popover/PopoverTouch.ts's header and the stack's changeset still describe the old static import, and the description's test count is now 318.

Claims and files checked
  • Claim: Toast and Popover no longer import the touch runtime statically and take it from the shared loader. Verified: the two new boundary cases fail on the base and pass here.
  • Claim: no static path from either entry reaches the animator or the gesture host. Verified: the boundary test checks exactly those two modules.
  • Claim: these two are all of the embed view's remaining first-load touch code, about 32 KB gzip. Consistent with the base pull request's measurements; not re-measured here.
  • Claim: no behavior change after the load and no API change. Verified: the Toast, Popover and touch-runtime suites pass with the runtime loaded (318), and the built public surfaces of Core and the themes show no change.
  • Claim: before the load a toast tracks no swipe and still dismisses by its button, timer and keys. Verified for the default layout; false for control-free custom content (third finding).
  • Claim: before the load a popover under a finger presents as under a fine pointer. Verified by the new test, which fails on the base.
  • Claim: the window before the load is first paint, then idle, at most 2 s. False on a page whose only touch component is a toast (second finding).
  • Claim: a swipe or press already in flight at the load finishes the old way. Verified in code: no swipe starts while the claim is missing, and a popover decides at open.
  • Claim: the swipe claim renders nothing, mounts after the load as the card's next sibling, and no swipe starts until it exists. Verified in Toast.tsx and useToastGesture.ts.
  • Claim: Popover takes the motion factory from the runtime at open. Verified in usePopoverSurfaceMotion.ts.
  • Claim: INV13's gap line drops Toast and Popover. Verified.
  • Claim: only INV13's gap line changes in the records. False (fourth finding).
  • Claim: the three named tests fail on the base pull request's head. Verified: four cases fail there, 193 pass.
  • Claim: suites that drive touch motion load the runtime first, and the suites pass. Verified; the count is now 318, not 303.
  • Claim: core typecheck and the knowledge check pass. Verified.
  • Claim: public text has no internal context. Verified.
  • File docs/architecture/react-component-runtime.md: clear apart from one unwrapped line.
  • File docs/specs/components/Popover/Popover.spec.md: two stray cells in FR9's row.
  • File docs/specs/components/Toast/Toast.spec.md: third finding.
  • File packages/core/src/Popover/Popover.test.tsx: clear.
  • File packages/core/src/Popover/usePopoverSurfaceMotion.test.tsx: clear.
  • File packages/core/src/Popover/usePopoverSurfaceMotion.ts: clear; one comment suggestion.
  • File packages/core/src/Toast/Toast.tsx: clear.
  • File packages/core/src/Toast/ToastViewport.test.tsx: clear.
  • File packages/core/src/Toast/useToastGesture.ts: second and fifth findings.
  • File packages/core/src/utils/touchRuntime.boundary.test.ts: clear.
  • File packages/core/src/utils/touchRuntimeModules.tsx: first finding.

Automated review (maintainer link)

# Conflicts:
#	docs/specs/components/Toast/Toast.spec.md
# Conflicts:
#	docs/architecture/react-component-runtime.md
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec af42d11

@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. An engineering owner has now approved the proposed INV13, Toast FR4 and Popover FR9 text for this head, so the spec question is settled; the five fixes below still apply to this pull request's code, records and description.

  • utils/touchRuntimeModules.tsx:96-100 and :123-126 copy shouldReceive and the swipe claim into refs with per-site Effects, which INV3 rules out; use useCommittedRef and useCommittedRefInto, as SegmentedMotion in the same file already does.
  • Miss: on a page whose only touch component is a toast, nothing schedules the touch runtime until the first toast mounts (Toast/useToastGesture.ts:141), so the load starts with that toast instead of after first paint, against INV13's "nothing loads them on demand" and the description's "first paint, then idle, at most 2 s"; schedule it once from ToastViewport, or narrow those claims.
  • Toast FR4's new sentence and the "Custom content without a control has only the swipe" gap entry imply a control-free renderContent toast can still be dismissed before the load, but it has no button and, as an error, no timer, as FR1 and FR2 still say; scope the sentence to the default layout and name the pre-load window in that gap entry.
  • Miss: the description says only INV13's gap line changes in the records, but INV13's pre-load sentence, Toast FR4 and Popover FR9 change too; list them with their rubric results.
  • Newly live check: Toast/useToastGesture.ts grows to 510 lines while timing its flick with its own average speed, so INV19 asks it to take the release decision from VelocityTracker or to record in component:Toast why no shared engine fits.

Smaller points: Popover FR9's row carries two stray cells and INV13 two unwrapped lines, Popover/PopoverTouch.ts's header and the stack's changeset still describe the old static import, and the description's test count is now 324.

Claims and files checked

Review mode: same-head; reason: none

  • Claim: Toast and Popover no longer import the touch runtime statically and take it from the shared loader. Verified: the two new boundary cases fail on the base and pass here.
  • Claim: no static path from either entry reaches the animator or the gesture host. Verified: the boundary test walks the static imports to exactly those two modules.
  • Claim: these two are all of the embed view's remaining first-load touch code, about 32 KB gzip. Consistent with the base pull request's measurements; not re-measured here.
  • Claim: no behavior change after the load and no API change. Verified: the Toast, Popover and touch-runtime suites pass with the runtime loaded (324), a swipe after the load dismisses on both sides in Chromium with identical frames, and the built public surfaces of Core and the themes show no change.
  • Claim: before the load a toast tracks no swipe and still dismisses by its button, timer and keys. Verified for the default layout; false for control-free custom content (third finding).
  • Claim: before the load a popover under a finger presents as under a fine pointer. Verified by the new test, which fails on the base.
  • Claim: the window before the load is first paint, then idle, at most 2 s. False on a page whose only touch component is a toast (second finding).
  • Claim: a swipe or press already in flight at the load finishes the old way. Verified in code: no swipe starts while the claim is missing, and a popover decides at open.
  • Claim: the swipe claim renders nothing, mounts after the load as the card's next sibling, and no swipe starts until it exists. Verified in Toast.tsx and useToastGesture.ts.
  • Claim: Popover takes the motion factory from the runtime at open. Verified in usePopoverSurfaceMotion.ts.
  • Claim: INV13's gap line drops Toast and Popover. Verified; AlertDialog stays, correctly, since it still imports the animator.
  • Claim: only INV13's gap line changes in the records. False (fourth finding).
  • Claim: the three named tests fail on the base pull request's head. Verified: four cases fail there, 193 pass.
  • Claim: suites that drive touch motion load the runtime first, and the suites pass. Verified; the count is now 324, not 303.
  • Claim: core typecheck and the knowledge check pass. Verified.
  • Claim: one primary intent, with no separable extras. Verified: no tag-along.
  • Claim: public text has no internal context. Verified.
  • Changesets: the pull request adds none.
  • File docs/architecture/react-component-runtime.md: clear apart from two unwrapped lines.
  • File docs/specs/components/Popover/Popover.spec.md: two stray cells in FR9's row.
  • File docs/specs/components/Toast/Toast.spec.md: third finding.
  • File packages/core/src/Popover/Popover.test.tsx: clear.
  • File packages/core/src/Popover/usePopoverSurfaceMotion.test.tsx: clear.
  • File packages/core/src/Popover/usePopoverSurfaceMotion.ts: clear; one comment suggestion.
  • File packages/core/src/Toast/Toast.tsx: clear.
  • File packages/core/src/Toast/ToastViewport.test.tsx: clear.
  • File packages/core/src/Toast/useToastGesture.ts: second and fifth findings.
  • File packages/core/src/utils/touchRuntime.boundary.test.ts: clear.
  • File packages/core/src/utils/touchRuntimeModules.tsx: first finding.

Automated review (maintainer link)

This branch was successfully deployed

1 active deployment
Preview — af42d111 Deployed Nov 14, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant