Skip to content

feat(Toast): the swipe follows iOS notification banners under a finger - #8121

Draft
vjeux wants to merge 1658 commits into
meta:mainfrom
vjeux:uikit/c25-toast-swipe
Draft

vjeux wants to merge 1658 commits into
meta:mainfrom
vjeux:uikit/c25-toast-swipe

Conversation

@vjeux

@vjeux vjeux commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #8360 (and its predecessors) and #8047. Review only this PR's change: vjeux/astryx@78d7e64...296e1fa and the commits vjeux@9f8a9d4, vjeux@ac46115 and vjeux@2b59f30 (the other commits merge #8360, #8320, #8076 and #8047)

Primary intent

Under a finger (a coarse pointer, any touch device), Toast's swipe and exit follow the iOS notification banner; presentation picks today's toast or the banner everywhere.

User or maintainer impact

Each path: a test and a clip (Mobile Safari unless marked). Recorded on the iOS 26.2 simulator and the Android emulator.

Path Clip
Before (main): a 9 px jump after 8 px; fade 0.79, scale 0.989 main
Slow drags: the browser takes them at the pan's 10 pt start (FR17); Android takes flicks too (owner question) slow-drag
A 20 pt flick (the retract continues its speed), close, timeout (then Android's): slides out in 160 ms, unfaded flick close timeout a-close a-timeout
Chromium and WebKit (real touch, no page scroll): still 14 px, then 0.55×; released short, springs back; a second finger keeps it second-finger
Reduce Motion: close cross-fades, opacity only; a "toast" row closes after the fade rm-close
Pen, fine pointer (Chromium), slow start then a throw: before, springs back; now dismisses; after a 41 ms rest, springs back before after rest

presentation="toast" keeps today's swipe and fade everywhere, "notification" the banner; mouse unchanged (tested).

Problem and solution fit

Today's swipe is hand-tuned (first clip); the values are 60 fps iOS 26.2 banner recordings; axisRatio is a guess.

Authority

  • spec:AST-094 FR13, FR1, FR4 (the settle is springs.settle), FR7, FR17, FR24, FR25, FR37, FR38 (public-component-api INV16, spec:AST-017 DEC-23).
  • design:reduced-motion; AST-100's release filter (spec:AST-017 FR59).

Owner decisions (proposed): presentation, a public API addition, and the banner model (no fade or scale, pass-through while settling); Toast.spec.md records both.

Change

  • toastSwipe.ts: the math, tested on recordings.
  • useToastBannerSwipe.ts, the touch module: pan Toast.swipe, follow, settle, retract.
  • useToastGesture (fine pointer): the shared tracker at the lift.
  • presentation on Toast and ToastViewport; a banner row closes after its retract.
  • Toast.spec.md: the Presentation concept, the notification swipe (FR4) and retract (FR5), the changed default, and the bullets and gaps it closes.

Scope

  • This PR has one primary intent.
  • Independently removable deltas were removed or split.
  • Public text and artifacts contain no internal Meta context.

Size: +4,286 / −94 (tests 3,345). Toast's import (the CI's measurement): JS 63,513 → 93,254 B gzip; CSS 10,128 → 10,220 B gzip.

Testing

  • pnpm exec vitest run packages/core/src/Toast/ packages/core/src/motion/: 826 pass (29 files), with no unhandled error (vitest exits 0); the stack's top head (feat(Toast): every pointer swipes a toast, on the shared gesture host (spec:AST-094 FR43) #8678) passes the full core suite and the node project. jsdom: under a finger (a coarse-pointer stub), the banner suite, including the touch taken from the browser at the pan's 10 pt start and not at 9, a release moving back toward rest that springs back however far out the card is (spec:AST-094 FR37), the retract before a release's, the close button's, the timeout's and the app's dismissal, and a standalone Toast its owner keeps coming back to rest; an app's dismiss holds the row open until the retract ends; presentation="toast" keeps Toast's own swipe and fade under a finger, "notification" the notification banner with a fine pointer; a second finger anywhere keeps a moving swipe (FR10) and fails one that has not begun, so the page can pinch; with a fine pointer (each case checks the pointer is not coarse), Toast's own swipe and immediate close, and a flick read from the shared velocity tracker at the lift (a slow 47 px drag ending in a 2.3 px/ms throw dismisses; after a 41 ms rest it springs back, AST-100 FR2). Unit: the release rule cancels a release moving back (FR37); the retract starts at the card's release velocity, and a flick faster than its curve carries the card out sooner (FR38); the settle is springs.settle, Toast registers no motion role, a --motion-… variable changes nothing, and a bundle of the touch module carries no other spring row (INV6).
  • pnpm test:interaction ToastSwipe: Chromium 24/24; WebKit (the harness container script) 19 passed, 5 skips (3 Chromium-only; the 2 pen tests, which drive Chromium input). Real touch with a coarse pointer on both engines, no engine emulation and no native scroll; the retract is sampled against its curve after a resting release, a flick (starting at the flick's speed, FR38), the close button and the timeout; after the app's dismiss the row keeps its height while the card is on screen; with presentation="toast" under Reduce Motion the card fades out over several frames before its row closes (DR2; fails on the previous head). Under Reduce Motion the release, the close button and the app's dismiss animate opacity only and finish within 200 ms, and the entrance fades in place. With a fine pointer a mouse drag leaves the card alone, the card gets no layer, and the close button keeps Toast's fade; a real pen (Chromium) flicks on the speed at the lift and not after a 41 ms rest. The long-task check is Chromium's: the harness's log refuses to answer in WebKit, which has no Long Tasks API.
  • Mobile browsers: Mobile Safari (iOS 26.2 simulator, real HID strokes) for the slow drag and the flick; Chrome for Android (Android 15 emulator, Chromium 158, a real 60 Hz finger) for a slow drag and a flick, each logged frame by frame. The close and timeout clips come from earlier heads with the same retract code.
  • Root pnpm build, the Storybook build, pnpm typecheck, CI=true pnpm lint (0 errors; the one warning in Toast's files is main's) and pnpm check:knowledge: clean. A merge-tree with main (90da4a7) is clean (rc 0). The touch-module bundle test's "is absent from the root entry" red (scripts/touch-support-bundle.test.mjs, from main's refactor(core): one shared touch module that components import directly, reached by Lab through internal/touch #8465) is the one test(core): a touch component's import carries its gesture code, and nothing else does #8671 resolves.

Writing rubric results

R1 narration: the Presentation concept, FR4, FR5, the compatibility lines, and three current-state bullets state what the system does, in the present tense; none found.
R2 research: none in the record; the banner's measured values stay with their sources in motion/uikit/toast.ts, named by key.
R3 evidence: the FR4–FR5 verification row names test files, not changes; no basis cell changed.
R4 rejected alternatives: none.
R5 change references: none.
R6 open questions: none; the record keeps "None".

@vercel

vercel Bot commented Oct 24, 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 Oct 29, 2026 10:27pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Oct 30, 2026, 1:43 PM UTC

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

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approval waits on an engineering owner deciding the iOS-banner swipe model for Toast, which no current spec covers. That means the 14 px dead zone and 0.55x follow, dismissal at 15.7 px or 105 px/s, no fade while dragging, the 0.5 s spring-back that also runs under Reduce Motion, pass-through while settling, a second finger that no longer cancels the swipe (blocking pinch-zoom for that gesture), and whether draft AST-094 may narrow the current theme-tokens and interaction-modality records. An engineering owner records that decision by commenting /approve-spec 19dd8fd3117aaf92e2b5a65473cea3d8a26160ef, and the author, as an engineering owner, may do so. These fixes are needed either way:

  • Rebase onto the merged stack (#8052 through #8047) so this PR carries only its Toast commit instead of 24,617 authored lines.
  • Remove or complete the "Touch presentation" section of packages/core/src/gestures/README.md, which documents a utils/touchPresentation.ts module and test that do not exist.
  • Correct the stale references (sources.test.ts, uikit/switch.ts, uikit/contextMenu.ts, "decides at 8" and the changeset's "projected with its velocity") and update AST-057's description of useToastGesture.

[Automated review]

## Touch presentation

Whether a component presents itself the touch (UIKit) way is answered once,
in `../utils/touchPresentation.ts`:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This section documents ../utils/touchPresentation.ts (TOUCH_QUERY, COMPACT_QUERY, COMPACT_TOUCH_QUERY, useTouchPresentation(), readTouchPresentation(), useMotionPresentation()) and a test that enforces the query spelling, but none of them exists at this head. Drop the section until the resolver lands, or land the module and its test with it.

Comment thread packages/core/src/gestures/README.md Outdated
Comment on lines +221 to +222
scrolling therefore decides at 10 px or less (the toast's swipe decides at
8).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The toast's swipe begins at 5 px (toast.beginDistance in motion/uikit/toast.ts:43), not 8.

* Every leaf carries one or more `@source` (apple-docs | wwdc | webkit |
* measured | GUESS); webkit and GUESS values also carry the `@measure` task
* that will confirm or replace them (motion/README.md lists them all).
* sources.test.ts enforces both.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

sources.test.ts does not exist; the @source check lives in uikit/uikit.test.ts. scroll.ts:14 and timing.ts:14 say the same.

'@astryxdesign/core': patch
---

[fix] A Toast's swipe now follows iOS notification banners. The card stays still for the first 14 px of finger travel and then follows at 0.55 of the finger, with no jump. On release, the finger's travel projected with its velocity decides: a quick flick dismisses even when it barely moved the card, and a release short of dismissing springs the card back. A dismissed card leaves from where the finger left it and never moves back toward rest. The swipe no longer fades or shrinks the card. While the card springs back, touches pass through to the page.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This says "the finger's travel projected with its velocity decides", but isDismissRelease is two independent thresholds (15.7 px out, or 105 px/s) with no projection.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

Toast (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Entry File (ESM) 304B 304B 0B
Lines of Code 1382 1764 -
Complexity Very High Very High (165) -

Component Size

Component Import before Import after Delta CSS before CSS after Delta
core/AlertDialog 56.9KB 57.2KB +294B 12.4KB 12.4KB 0B
core/AppShell 57.9KB 58.1KB +242B 11.6KB 11.6KB 0B
core/AvatarGroupOverflow 39.9KB 40.2KB +303B 6.4KB 6.4KB 0B
core/Banner 47.8KB 48.1KB +289B 9.9KB 9.9KB 0B
core/BaseTypeahead 54.3KB 54.6KB +251B 9.9KB 9.9KB 0B
core/BreadcrumbItem 66.4KB 66.6KB +297B 11.0KB 11.0KB 0B
core/Button 43.3KB 43.5KB +273B 9.2KB 9.2KB 0B
core/Calendar 54.9KB 55.2KB +290B 10.0KB 10.0KB 0B
core/Carousel 50.2KB 50.5KB +316B 10.2KB 10.2KB 0B
core/ChatComposer 60.6KB 60.9KB +270B 10.8KB 10.8KB 0B
core/ChatComposerInput 55.7KB 56.0KB +264B 10.1KB 10.1KB 0B
core/ChatComposerTokenElement 55.7KB 56.0KB +264B 10.1KB 10.1KB 0B
core/ChatDictationButton 46.5KB 46.8KB +264B 9.5KB 9.5KB 0B
core/ChatLayout 48.8KB 49.1KB +273B 9.9KB 9.9KB 0B
core/ChatLayoutScrollButton 46.4KB 46.6KB +255B 9.6KB 9.6KB 0B
core/ChatSendButton 45.8KB 46.1KB +265B 9.2KB 9.2KB 0B
core/CheckboxInput 49.9KB 50.2KB +273B 9.3KB 9.3KB 0B
core/CheckboxListItem 54.0KB 54.3KB +244B 10.5KB 10.5KB 0B
core/ClickableCard 12.8KB 13.1KB +289B 6.9KB 6.9KB 0B
core/CodeBlock 60.5KB 60.8KB +278B 10.7KB 10.7KB 0B
core/Collapsible 11.7KB 12.0KB +291B 4.2KB 4.2KB 0B
core/CommandPalette 50.9KB 51.2KB +281B 11.8KB 11.8KB 0B
core/CommandPaletteItem 8.4KB 8.7KB +280B 3.5KB 3.5KB 0B
core/ComplexSelector 55.8KB 56.1KB +318B 10.6KB 10.6KB 0B
core/ContextMenu 77.7KB 78.0KB +275B 14.6KB 14.6KB 0B
core/ContextMenuItem 16.6KB 16.8KB +280B 5.2KB 5.2KB 0B
core/DateInput 99.9KB 100.1KB +243B 14.8KB 14.8KB 0B
core/DateRangeInput 69.4KB 69.6KB +266B 11.2KB 11.2KB 0B
core/DateTimeInput 110.1KB 110.3KB +248B 15.2KB 15.2KB 0B
core/DialogHeader 48.8KB 49.1KB +280B 9.8KB 9.8KB 0B
core/DrawerHeader 48.9KB 49.2KB +249B 11.2KB 11.2KB 0B
core/DropdownMenu 72.7KB 73.0KB +278B 14.7KB 14.7KB 0B
core/DropdownMenuCheckboxItem 16.1KB 16.4KB +284B 5.6KB 5.6KB 0B
core/DropdownMenuItem 15.4KB 15.7KB +287B 5.2KB 5.2KB 0B
core/DropdownMenuRadioItem 16.2KB 16.5KB +275B 5.6KB 5.6KB 0B
core/DropdownMenuSubMenu 58.1KB 58.3KB +270B 9.5KB 9.5KB 0B
core/FileInput 54.1KB 54.4KB +262B 10.3KB 10.3KB 0B
core/IconButton 43.3KB 43.6KB +273B 9.2KB 9.2KB 0B
core/Item 11.4KB 11.6KB +273B 4.7KB 4.7KB 0B
core/LayerProvider 63.3KB 90.8KB +27.5KB ⚠️ 10.1KB 10.2KB +140B
core/Lightbox 51.2KB 51.4KB +249B 9.8KB 9.8KB 0B
core/Link 43.5KB 43.8KB +288B 7.6KB 7.6KB 0B
core/ListItem 53.5KB 53.7KB +268B 10.5KB 10.5KB 0B
core/Markdown 144.5KB 144.7KB +247B 17.4KB 17.4KB 0B
core/MobileNav 51.0KB 51.3KB +264B 10.1KB 10.1KB 0B
core/MobileNavToggle 46.2KB 46.5KB +259B 9.4KB 9.4KB 0B
core/MoreMenu 72.9KB 73.2KB +278B 14.7KB 14.7KB 0B
core/MultiSelector 76.2KB 76.4KB +270B 14.6KB 14.6KB 0B
core/NumberInput 55.7KB 56.0KB +278B 10.7KB 10.7KB 0B
core/Outline 28.6KB 28.9KB +290B 4.0KB 4.0KB 0B
core/Pagination 87.7KB 88.0KB +263B 15.3KB 15.3KB 0B
core/Popover 49.8KB 50.1KB +238B 12.1KB 12.1KB 0B
core/PowerSearch 155.1KB 155.3KB +263B 18.6KB 18.6KB 0B
core/RadioListItem 52.1KB 52.4KB +286B 9.7KB 9.7KB 0B
core/SegmentedControlItem 8.6KB 8.9KB +285B 3.9KB 3.9KB 0B
core/SelectableCard 12.8KB 13.1KB +294B 7.1KB 7.1KB 0B
core/Selector 79.1KB 79.4KB +268B 15.0KB 15.0KB 0B
core/SelectorOption 14.5KB 14.8KB +251B 5.1KB 5.1KB 0B
core/SideNav 58.0KB 58.3KB +272B 10.6KB 10.6KB 0B
core/SideNavCollapseButton 46.6KB 46.9KB +242B 9.5KB 9.5KB 0B
core/SideNavHeading 54.7KB 55.0KB +248B 10.1KB 10.1KB 0B
core/SideNavItem 54.5KB 54.8KB +266B 10.1KB 10.1KB 0B
core/Step 32.4KB 32.7KB +279B 5.3KB 5.3KB 0B
core/Stepper 47.4KB 47.7KB +265B 9.6KB 9.6KB 0B
core/Switch 48.4KB 48.7KB +285B 9.3KB 9.3KB 0B
core/Tab 9.7KB 10.0KB +294B 4.1KB 4.1KB 0B
core/TabMenu 51.6KB 51.9KB +276B 10.0KB 10.0KB 0B
core/Table 84.0KB 84.2KB +253B 15.1KB 15.1KB 0B
core/TableCell 78.8KB 79.1KB +267B 14.8KB 14.8KB 0B
core/TableHeaderCell 78.6KB 78.8KB +272B 14.8KB 14.8KB 0B
core/TableSelectionToolbar 52.4KB 52.6KB +278B 11.2KB 11.2KB 0B
core/TextInput 53.5KB 53.8KB +281B 10.5KB 10.5KB 0B
core/Thumbnail 50.7KB 50.9KB +274B 11.0KB 11.0KB 0B
core/TimeInput 86.8KB 87.1KB +266B 13.8KB 13.8KB 0B
core/Timestamp 27.5KB 27.5KB -1B 9.5KB 9.5KB 0B
core/Toast 59.8KB 87.1KB +27.2KB ⚠️ 9.7KB 9.8KB +92B
core/ToggleButton 44.1KB 44.4KB +243B 9.3KB 9.3KB 0B
core/Token 29.6KB 29.9KB +289B 4.5KB 4.5KB 0B
core/Tokenizer 64.8KB 65.1KB +306B 11.7KB 11.7KB 0B
core/TopNav 51.9KB 52.1KB +277B 10.4KB 10.4KB 0B
core/TopNavHeading 54.2KB 54.4KB +231B 9.9KB 9.9KB 0B
core/TopNavItem 9.0KB 9.3KB +283B 3.8KB 3.8KB 0B
core/TopNavMegaMenu 54.2KB 54.4KB +268B 10.8KB 10.8KB 0B
core/TopNavMegaMenuItem 9.1KB 9.4KB +281B 4.1KB 4.1KB 0B
core/TopNavMenu 53.6KB 53.8KB +258B 10.1KB 10.1KB 0B
core/TreeList 32.5KB 32.8KB +274B 4.7KB 4.7KB 0B
core/Typeahead 61.5KB 61.7KB +268B 11.3KB 11.3KB 0B

Sizes are gzip. Import counts the JavaScript the import loads eagerly; CSS counts the package stylesheet rules referenced by the modules it can load from its own package, lazily loaded ones included.

⚠️ Touch-only size budget

These components grew past the touch-only budget (2 KB gzip JavaScript or 1 KB gzip CSS per component). If the growth runs only on a coarse pointer, load its JavaScript lazily so the import does not carry it, or justify the cost in the pull request description; CSS stays in the package stylesheet, so justify it.

Component JavaScript CSS
core/LayerProvider +27.5KB ⚠️ +140B
core/Toast +27.2KB ⚠️ +92B

Bundle Size Summary

Gzip figures measure each package's entry file, not the code an import pulls in.

Package Entry (ESM) Entry gzip before Entry gzip after Delta
@astryxdesign/core 4.9KB 1.2KB 1.2KB 0B
Package stylesheet Gzip before Gzip after Delta
@astryxdesign/core 34.6KB 34.6KB +87B

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

55 of 502 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 753,933
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,072
RichTextEditor Markdown parity: side by side probe dark 558,840
RichTextEditor Markdown parity: side by side probe light 540,756
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
AppShell With Mobile Nav probe light 217,010
AppShell With Mobile Nav probe dark 216,960
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
AppShell Playground neutral dark 65,198
AppShell Playground neutral light 63,788
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232

and 35 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approval waits on an engineering owner deciding the iOS-banner swipe model for Toast, which no current spec covers: the 14 px dead zone and 0.55x follow, dismissal at 15.7 px or 105 px/s, no fade while dragging, the 0.5 s spring-back that also runs under Reduce Motion, pass-through while settling, a second finger that no longer cancels the swipe (blocking pinch-zoom for that gesture), and whether draft AST-094 may amend the current theme-tokens, interaction-modality, user-states, buttons and AST-025 records. An engineering owner records that decision by commenting /approve-spec 33dbb831a6124c75f70c487a8513dc376bd0f3fc, and the author, as an engineering owner, may do so. These fixes are needed either way:

  • Rebase onto the merged stack (#8052 through #8047) so this PR carries only its Toast commit instead of 26,022 authored lines.
  • Remove or complete the "Touch presentation" section of packages/core/src/gestures/README.md, which documents a utils/touchPresentation.ts module and test that do not exist.
  • Correct the stale references ("decides at 8", sources.test.ts, uikit/switch.ts, uikit/contextMenu.ts and the changeset's "projected with its velocity") and update AST-057's description of useToastGesture.

[Automated review]

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approval waits on an engineering owner deciding the iOS-banner swipe model for Toast, which no current spec covers: the 14 px dead zone and 0.55x follow, dismissal at 15.7 px or 105 px/s, no fade while dragging, the 0.5 s spring-back that also runs under Reduce Motion, pass-through while settling, a second finger that no longer cancels a claimed swipe (blocking pinch-zoom for that gesture), and whether draft AST-094's requirements may become current. An engineering owner records that decision by commenting /approve-spec 4cf3606b4068909001bebf752e9188469dedfc21 on this pull request, and the author may do so if they are an engineering owner. These fixes are needed either way:

  • Rebase onto the merged stack (#8052 through #8047) so this PR carries only its Toast commit instead of 28,637 authored lines.
  • Take the theme motion roles and the platform adaptation condition out of this PR, or have architecture:theme-tokens INV1 and spec:AST-012 FR2 amended first, since draft AST-094 FR4 also says touch motion is not themable.
  • Return a standalone Toast to rest after a swipe dismissal, because today it stays where the finger left it when its owner keeps it mounted.
  • Remove or complete the gestures README's "Touch presentation" section, which documents a touchPresentation module that does not exist, and fix the stale references noted inline.

[Automated review]

isDismissRelease(session.offset, fingerVelocity)
) {
onSwipeExit?.();
dismiss();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

After a swipe dismissal the card keeps its last translate. Inside ToastViewport the exit plays from there, but a standalone Toast whose owner keeps it mounted after onDismiss stays where the finger left it: 25.3 px after a 60 px drag in the Narrow layout reference story. Base cleared the drag first for exactly this case. Return the card to rest when no onSwipeExit is given, and add a test on the standalone Toast.

* is everything else. Pair `ios` with `pointer: 'coarse'` for a touch
* profile, such as touch motion tuned per platform.
*/
platform?: 'ios' | 'other';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

platform is a new adaptation condition, but spec:AST-012 FR2 keeps the when vocabulary closed: "Future environment fields require explicit additions to this closed vocabulary." Drop it from this PR, or have that record amended first.

Comment thread packages/core/src/motion/roles.ts Outdated
`motion role "${id}" must be a dotted table path such as "sheet.present"`,
);
}
return `--motion-${id

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These --motion-<role> names come from table paths rather than tokens.stylex.ts, but architecture:theme-tokens INV1 says a core token name and its default originate there. Draft AST-094 FR4 and DEC-1 in this same PR also say touch motion is not themable.

## Touch presentation

Whether a component presents itself the touch (UIKit) way is answered once,
in `../utils/touchPresentation.ts`:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

../utils/touchPresentation.ts, the three queries, the three hooks and the test this section describes do not exist at this head. Drop the section until the resolver lands, or land the module and its test with it.

Comment thread packages/core/src/gestures/README.md Outdated
`touchmove` from 8 px keeps the page still for the whole gesture. Under
`pan-y` it scrolls only drags steeper than about 2:1 to 3:1, once the
vertical travel reaches about 10 px. A pan that competes with native
scrolling therefore decides at 10 px or less (the toast's swipe decides at

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The toast's swipe claims at 5 px (EARLY_CLAIM_DISTANCE) and begins at 10, as the Early claim paragraph above says, not at 8.

* Every leaf carries one or more `@source` (apple-docs | wwdc | webkit |
* measured | GUESS); webkit and GUESS values also carry the `@measure` task
* that will confirm or replace them (motion/README.md lists them all).
* sources.test.ts enforces both.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

sources.test.ts does not exist; the @source check is in uikit/uikit.test.ts. scroll.ts:14 and timing.ts:14 say the same.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approval waits on an engineering owner deciding whether Toast should adopt the iOS notification-banner swipe and retract exit proposed in draft AST-094: an engineering owner records that decision by commenting /approve-spec e32f22318deea384b1b53adadc7088efaa781e9d on this pull request, and the author may do so if they are an engineering owner. Whatever that decision, these changes are needed:

  • Under Reduce Motion, cross-fade the iOS spring-back and retract in 200 ms or less instead of keeping their travel, as the current reduced-motion design record requires.
  • Clear the dismissal latch so a directly rendered Toast that stays mounted does not end off-screen and unresponsive on iOS.
  • Load the touch-only gesture and motion code lazily or justify it (Toast's import grows by about 25 KB gzip), and derive the compact edge from the theme's md point instead of 744 px.
  • Land the predecessor pull requests first so this one carries only its own commit.

[Automated review]

) => boolean;
}

const RELEASE_OPTIONS = {reducedMotion: 'keep'} as const;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These options keep the spring-back (:206) and the 160 ms slide-out (:253) under Reduce Motion. The current reduced-motion design record (DR2, DR4) asks for an opacity-only cross-fade of 200 ms or less when a finger's release starts a transition, and says a component's own motion settings do not override it, so both calls need a short cross-fade instead of 'keep'.

if (isDismissingRef.current) {
return;
}
isDismissingRef.current = true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This latch, like retractingRef in useToastBannerSwipe.ts:255, is never cleared. A Toast rendered directly whose owner keeps it mounted ends at its retract target off-screen (844 px down in the Narrow layout reference story with the iOS idiom emulated), with its buttons still focusable, and later dismissals do nothing; clearing both and returning the card to rest when the toast is still mounted after onDismiss would fix it.

};
// A dismissal from outside (the viewport, an app's `dismiss()`) retracts
// the card too.
useIsomorphicLayoutEffect(() => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This layout effect starts the retract in reaction to isExiting, and the retract calls onRetract, which sets the viewport's isRetracting state. The react-component-runtime architecture (INV2, INV3) asks for that work in the handler that caused it, or an effect comment naming the external system it synchronizes.

export const TOUCH_QUERY = '(pointer: coarse)';

/** The viewport is compact: layout behaviours. */
export const COMPACT_QUERY = '(width < 744px), (height < 500px)';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

AST-012 FR9 (current) makes a screen compact while its width is below the theme's md point (768 by default) or its height is below 500, and says no resolver keeps size numbers of its own. With 744px, a coarse-pointer viewport 744 to 767 px wide keeps the popover where FR9 gives the sheet.

@cixzhang

Copy link
Copy Markdown
Contributor

Posted by Cindy's agent on her behalf.

Parts of this PR re-implement behavior that already exists, or is being specified, as a shared part of core. Converging keeps one implementation per behavior:

  • Touch gating. core/src/Toast/Toast.tsx:95 writes its own (pointer: coarse) check. This conflicts with AST-012 FR2 (touch is resolved once, through the closed adaptation vocabulary) and public-component-api INV16. Resolve through the shared touch resolver key so behavior matches the spec. If this behavior genuinely can't be expressed through the resolver, please raise it here as a spec question instead of shipping a separate check.
  • Reduced motion. core/src/Toast/useToastBannerSwipe.ts:101 handles reduced motion locally. Per design:reduced-motion (DR1–DR4), the animator is the one place that resolves it (touch cross-fades in 200 ms or less with no travel, a fine pointer changes at once), and core has no opt-out, so reducedMotion: 'keep' should be removed.
  • Commit or spring back on release. core/src/Toast/toastSwipe.ts:33 decides on its own whether a release finishes or springs back. A shared release rule is being specified (AST-057 FR5 covers row swipe today); avoid a component-specific threshold model.

This is about where the behavior lives, not about the PR's intent.

@vjeux

vjeux commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

Agreed: one implementation.

  • Touch gating: the swipe keys on the shared touch resolver (useTouchPresentation, a coarse primary pointer, the same on every touch device), and the banner swipe lives in Toast's one touch module, useToastBannerSwipe.ts; Toast.tsx keeps no pointer or touch-callout check of its own.
  • Reduced motion: reducedMotion: 'keep' is gone; the spring-back and the retract follow the animator's policy (a release passes touchRelease), and the entrance uses the shared reduced-motion queries and constants.
  • Commit or spring back on release: the release speed moves to the shared tracker (AST-100, spec(AST-100): one velocity tracker and one release filter for every gesture #8312); the dismiss offset and flick speed stay Toast's tuning in motion/uikit/toast.ts (AST-100 FR3).

@vjeux
vjeux force-pushed the uikit/c25-toast-swipe branch from e32f223 to a0dfe79 Compare October 25, 2026 00:16
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Oct 25, 2026
@vjeux vjeux changed the title feat(Toast): the swipe follows iOS notification banners feat(Toast): the swipe follows iOS notification banners under a finger Oct 25, 2026
vjeux added 25 commits October 28, 2026 11:33
…s, and the action-group tracker writes its own

The header and writePress called it the one writer of the press attribute,
but main's action-group tracker writes its groups' presses itself. They now
say what holds, as meta#8076's gestures README does.
…he press attribute

The release note said every press painter writes data-astryx-press
through one internal writer, but the action-group tracker
(hooks/actionGroupTracker.ts) writes its groups' presses itself, as the
gestures README and utils/pressFeedback.ts already say. The note now says
paintPress writes every press it tracks and the action-group tracker
writes its own.
…llowance under every primary pointer

The useMenuPress record's FR9 puts the trigger's held finger under
spec:AST-094 FR29 under every primary pointer (FR43), so a finger on a
touchscreen laptop may drift 13 pt before the open, as on a phone. The
trigger read (pointer: coarse) as its press started and took the long
press's 10 px where the pointer was fine. Three cases fail until it does
not: a 12 pt drift opens under a fine pointer too, a (12, 12) settle
opens there, and nothing reads a pointer query, the trigger's press
included.
…lowance under every primary pointer

The useMenuPress record's FR9 governs the trigger's held finger by
spec:AST-094 FR29 under every primary pointer (FR43). The trigger now
hands the long press FR29's 13 px drift allowance whatever the primary
pointer, so it no longer reads (pointer: coarse) as its press starts, and
the menus drop their coarsePointer import. ContextMenu keeps the long
press's own allowable movement. The changeset says the same.
Strict ESLint reported six unused bindings in files this pull request
carries: the host's HAPTIC_SWITCH_ATTRIBUTE import, two unused imports
in the pan's tests (scrollProbe, ScreenEdgePanGestureRecognizer), the
swipe test's drift, the presented-hit-testing test's gestures, and a
GestureHost test's before, which now asserts what it was read for: a
second finger's moves leave the pan where it was.
…eal angular speed

The release velocity of a rotation whose listener sets rotation = 0 on
each change, at 2 degrees every 16 ms, read 4.363 rad/s against the
2.182 rad/s of the same stream without a re-base: the test asserted only
more than 1.5. It now asserts the 2.18 rad/s (spec:AST-100 FR2), and
fails.
The rotation's velocity tracker samples the raw unwrapped angle, which
setting rotation does not move, so the setter's shift of the samples read
each re-base as extra turn and doubled the release velocity of a
listener that re-bases on every change. The setter no longer touches the
tracker.
…mates while it runs

The proof read the element's animations 230 ms in, after the dip had
ended, and asserted only that every animated key is opacity, which an
empty list passes: with the cross-fade removed from the plan (the move
still landing), the proof still passed. It now reads the keyframe keys
right after the call starts and asserts they include opacity and nothing
else; the same mutant fails it. Chromium and WebKit pass. (F1's in-flight
read from c648034.)
…roller, and its claimed moves are cancelled under pointer events

Two comparisons stop at the shadow boundary, each failing a case:
- once the host's listener on a recognizer's inner node has seen the
  finger, isFingerDownIn reads it as outside a light-DOM scroller around
  that root, so a scroll under it is not the finger's (FR20);
- under inputMode 'pointer-events', a claimed pan on a shadow host
  cancels none of its finger's moves over the inner content, since the
  finger's target is the inner node and its touches reach the host
  retargeted (FR19).
…the flat tree

isFingerDownIn and the pointer-events finger match compare with
containsAlongFlatTree, as the scroll watch already does: a finger on
content inside an open shadow root is down in the scroller around that
root, and its touches, retargeted to the shadow host, match its pointer
finger, so a claimed pan cancels its moves there (spec:AST-094 FR19,
FR20).
…achments asks, and only then

The host let the last attachment decide whether an element is an action
group (useGestureRecognizer always passes the option), and never
recomputed it at a detach: a plain attachment after the group's turned
the group off, and a group's attachment released left a recognizer that
never asked taking presses under a fine pointer. Fails until the host
counts the attachments that ask.
…ents asks

The host counts the attachments that pass actionGroup: true and keeps the
element a group while one remains, recomputed at each detach. An
attachment that passes false, as useGestureRecognizer does by default,
no longer turns a group off, and a group's last asking attachment taking
its leave ends the group.
… that content

The presented hit test takes the document's elementFromPoint, which
answers a shadow host for anything inside its open root, and compares
with Node.contains, which stops at the boundary: a recognizer on a
control inside a moving sheet's shadow root gets no finger, and the tap's
click goes to the host. Fails until the hit test descends into open roots
and compares along the flat tree.
Where a moving element is drawn away from its layout box, the host
hit-tests what is drawn under the finger with the document's
elementFromPoint, which answers a shadow host for anything inside its
open root. The hit test now descends through each open root's own
elementFromPoint and compares with the movers along the flat tree, so a
recognizer on a control inside a moving sheet's shadow root gets its
finger and the tap clicks that control.
…nt lets go

The host's touch-action rules sit in an adopted sheet or a style element
per document or shadow root, and were never removed, so a page whose
last recognizer detached kept them, against spec:AST-094 FR24 (nothing
touch-related remains after the last instance unmounts). Fails until a
root's rules go with its last marked element.
…th its last marked element

The touch-action writer records which elements it marked in each
document or shadow root, and when the last one is unmarked (its last
recognizer detached) it removes that root's adopted sheet or style
element, so nothing touch-related remains after the last instance
unmounts (spec:AST-094 FR24). A later mark writes the rules again; an
element marked in another root first lets go of the old one.
… the inline style it reads

- The motion registry, the host's engine gate and the README name the
  presented hit test as an engine workaround (spec:AST-013 FR6) with its
  review condition (re-measure on each iOS release; remove it once iOS
  WebKit hit-tests a compositor-moved element where it is drawn) and its
  regression fixture.
- While a curve runs the animator holds the value it starts from inline,
  so presentation.ts and the README no longer say the inline style holds
  the end.
…core/internal/touch

Core ships the internal entry @astryxdesign/core/internal/touch, which
re-exports the gesture primitives for Astryx's own packages, and the
Lab-import guard fails a Lab import of core outside core's exports
(architecture:react-component-runtime INV13). The README and the barrel's
header named internal workspace imports and said nothing here is
exported; they now name that entry.
…ill needs the element, and the listeners that cancel

The release note, the stream's header, the host's comment and the README
said the stream is one passive listener per event type and that a
document-capture stopPropagation no longer starves the recognizers. Such a
stop never hid a listener on the same node, and some subscriptions cancel.
They now say what changed: an app's window-capture stopPropagation, or a
document-capture stopImmediatePropagation registered before core, no
longer hides a touch; a recognizer that must claim still needs the touch to
reach its element; the gesture host's touchend, click and contextmenu
cancel while a claimer is attached and the page hold's touchmove while it
holds; and the stream stays ahead of an app's window-capture listener only
until a type's listener is re-added. The README's list of blocking
touchmove listeners gains the claimed touch's target and the document
while a claiming element moves.
…default it moves

The {stylexOptions} form of astryxStylex now passes StyleX
treeshakeCompensation: true unless the caller sets it. spec:AST-017 FR3
asks the release note to name the old and new default and the option
that restores the old one; it now does.
…er and for the two stops the input stream fixes

- A still finger with sub-pixel jitter over a scroll view keeps its tap
  and scrolls nothing (spec:AST-094 FR18–FR22).
- A tap is still recognized under an app's window-capture
  stopPropagation, and under a document-capture
  stopImmediatePropagation registered before core's: the recognizers hear
  touches on the window's capture phase.
Chromium and WebKit pass.
…s once

Where nothing that claims is attached, the host's touchend listener is
passive and cannot cancel the engine's own click after a retargeted tap
clicks what is drawn. The shared click guard swallows that late click
whatever is attached; this case pins it, as asked on meta#8293.
…esture host's subscriptions

The gesture host subscribes no click: the one cancelling click subscriber
is the click guard's, added at a window's first arm and kept. The release
note, the stream's header and the gestures README listed click with the
host's touchend and contextmenu; they now name the guard's own.
Toast.spec.md records what this branch ships: the `presentation` concept
(`adaptive` by default, `toast`, `notification`), the notification swipe
in FR4 and its retract in FR5, the released default it changes under a
finger, and the current-state bullets and gap text the notification
presentation closes (a release moving back springs back, the settle starts
at the release velocity, and reduced motion fades on a touch screen). The
toast presentation keeps its listed gaps: net travel, a theme-timed settle,
a second touch that cancels, and no projection.
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 29, 2026
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 29, 2026
@vjeux
vjeux marked this pull request as draft October 29, 2026 22:31

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approval is on hold until an engineering owner decides whether this head's rewrite of the current Toast record should stand: it makes the iOS notification banner Toast's default under a finger and adds presentation, while departing from spec:AST-094 FR36 (projected travel decides a release), FR6 (a finger can catch the card mid-flight) and FR4 (motion roles for the exit). An engineering owner records that decision by commenting /approve-spec 2b59f303464fe99168ff61de9ba8dc56a01f95b2 on this pull request, and the author may do so as an engineering owner; amending AST-094 on main settles it too. Whatever the decision, these changes are needed:

  • Land the predecessor pull requests, or rebase so this one carries only its Toast commits (31,897 authored lines today).
  • Add real-device recordings for the Mobile Safari and Chrome for Android claims, which AST-094's platform-support section requires.
  • Make the proposed FR4 state one release rule, pass touchRelease only for a touch release, name the three new Effects in useToastBannerSwipe.ts, and reword the three stale test comments.

[Automated review]

if (velocity < 0) {
return false;
}
return offset >= toast.dismissOffset || velocity >= toast.flickVelocity;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This two-threshold rule decides the release in place of spec:AST-094 FR36's projected travel against a commit point. It waits on the engineering owner's decision asked on this pull request; the proposed record's FR4 should then state this one rule, as an exception to FR36 if that is the decision.

const current = optionsRef.current;
if (
root == null ||
settlingRef.current != null ||

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Refusing touches while the card settles or retracts departs from spec:AST-094 FR6, "A finger MUST be able to catch any animation mid-flight at the value on screen"; this is part of the owner decision on hold.

/** The card's speed toward its edge at a dismissing release (px/s). */
const releaseVelocityRef = useRef(0);
const optionsRef = useRef(options);
useIsomorphicLayoutEffect(() => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This Effect, and the ones at lines 205 and 209, need a comment naming what they synchronize (architecture:react-component-runtime INV3), for example // Syncs the options ref with the newest render.

const handle = animator.animate(
{y: 0},
{spring: SETTLE_SPRING, velocity: {y: velocity * direction}},
{crossfadeAs: 'entrance', touchRelease: true},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Every release passes touchRelease: true, so with presentation="notification" a pen released where the primary pointer is fine cross-fades under Reduce Motion, where spec:AST-094 FR43 and design:reduced-motion DR3 change it at once. Passing touchRelease only for a touch pointer, here and for the retract (line 293), would conform.

| 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). Implementation gaps: the pause is one flag, so any pause condition ending resumes the timer while another still holds, and a toast raised while the window is already blurred starts its timer (Current-state impact). | 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. Implementation gap: a toast dismissed before it first renders, through its returned dismiss function in the handler that showed it, never reports `onHide` and lingers in a provider-hosted viewport; with no provider above the caller, a dismissal called before the fallback viewport mounts does nothing, so the toast shows and stays unless it auto-hides (Current-state impact). 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. In the notification presentation the card stays still for the first `toast.followFrom` px of travel and then follows at `toast.followRatio` of the finger, and a release dismisses when the card is `toast.dismissOffset` out or the finger lifts moving toward the edge at `toast.flickVelocity` or faster, the notification banner's measured values; in the toast presentation the card follows the finger 1:1. A short drag snaps back; horizontal intent or a gesture starting on an interactive descendant does not dismiss; a second touch before the swipe begins leaves the page its pinch, and one after it begins leaves it going (`spec:AST-094` FR10). Native page scrolling continues until touch intent matches the dismiss edge. In the default layout the visible dismiss button stays as a non-gesture alternative; custom content supplies its own. Implementation gaps: the toast presentation dismisses on net travel past a distance threshold or a flick, even after the finger moves back, and a second touch cancels its swipe; neither presentation projects travel; and only touch and pen drags are recognized, not a mouse (Current-state impact). | Current source and tests |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

FR4 now states two release rules: projected travel (the FR36 sentence) and, for the notification presentation, toast.dismissOffset or toast.flickVelocity, while the gaps say neither presentation projects travel. Once the owner rules, keep one rule, with the thresholds as a recorded exception to FR36 if that is the decision.

This branch was successfully deployed

1 active deployment
Preview — 2b59f303 Deployed Oct 29, 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.

2 participants