Skip to content

feat(lab): useRefreshControl, the refresh control's behavior on the gesture system - #8171

Draft
vjeux wants to merge 1884 commits into
meta:mainfrom
vjeux:uikit/c28-refresh-hook
Draft

vjeux wants to merge 1884 commits into
meta:mainfrom
vjeux:uikit/c28-refresh-hook

Conversation

@vjeux

@vjeux vjeux commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #8170 and #8098 (the page's scroll-style owner). Carries #8562 (Core's internal entries) as a dependency; if the entries land differently, this follows her decision. Review only this PR's change: vjeux/astryx@94298d4...e6f4e63

Why

RefreshControl needs a pull that reads a finger at a scroll's top without taking it from native scrolling, so a scroll that runs out turns into the pull, as on iOS.

What led to it

Part of the touch-presentations program (spec:AST-094). #8170 adds the pull's mapping and state machine; this adds the hook that reads the finger and drives the motion; RefreshControl (#8175) renders it.

Options and tradeoffs

  • Take the finger when the pull starts: simpler, but a scroll running into the top would have to change hands, and pushing back wouldn't scroll natively.
  • Watch the finger: the pull starts at the top under a finger moving down, and pushing back scrolls natively (DEC-7, FR14). The cost: the pull moves the content on the main thread, the one exception to compositor-only motion.
  • An armed native slot for short releases: short releases would return in two stages.

Why this choice

Watching keeps native scrolling in charge, as UIKit does. Settle, end and spin run on the compositor. Near the top the scroll owner's overscroll-behavior-y is none, so the browser draws no rubber band of its own; the scroll listener lives only while the pull can run, and a scroll lock stands the pull down. Under Reduce Motion the settle and the end cross-fade and the trigger turn is skipped. No haptic: UIKit has none. Callers see nothing new; core's internal entries gain six named re-exports.

How to check it

The hook's unit tests drive real touch sequences through the gesture system:

  1. A pull at the top past the trigger calls onRefresh, and a promise keeps it refreshing until it settles.
  2. A controlled isRefreshing drives the state from the first render.
  3. A scroll lock taken mid-pull cancels it: the content settles back and nothing starts.
  4. The same pull works on an Android phone.

Browser, iOS and Android proofs come with the component (#8175).

Evidence

Stack (merge in this order): #8360 gesture foundation (carries #8076) → #8086 refresh values → #8170 pull and state machine → this PR → #8175 RefreshControl. It also needs #8098 (useScrollLock v2, on #8360).

@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 Error Error Oct 29, 2026 8:49pm 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) Nov 1, 2026, 3:41 AM UTC

@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

Component Size

Component Import before Import after Delta CSS before CSS after Delta
core/AlertDialog 56.9KB 58.8KB +1.9KB 12.4KB 12.4KB 0B
core/AppShell 57.9KB 58.6KB +780B 11.6KB 11.6KB 0B
core/AvatarGroupOverflow 39.9KB 40.2KB +320B 6.4KB 6.4KB 0B
core/Banner 47.8KB 48.1KB +305B 9.9KB 9.9KB 0B
core/BaseTypeahead 54.3KB 54.6KB +264B 9.9KB 9.9KB 0B
core/BottomSheet 34.0KB 35.6KB +1.6KB 7.9KB 7.9KB 0B
core/BottomSheetSwitcher 14.8KB 16.5KB +1.7KB 3.3KB 3.3KB 0B
core/BreadcrumbItem 66.4KB 66.7KB +316B 11.0KB 11.0KB 0B
core/Button 43.3KB 43.6KB +287B 9.2KB 9.2KB 0B
core/Calendar 54.9KB 55.2KB +306B 10.0KB 10.0KB 0B
core/Carousel 50.2KB 50.5KB +340B 10.2KB 10.2KB 0B
core/ChatComposer 60.6KB 60.9KB +286B 10.8KB 10.8KB 0B
core/ChatComposerInput 55.7KB 56.0KB +279B 10.1KB 10.1KB 0B
core/ChatComposerTokenElement 55.7KB 56.0KB +279B 10.1KB 10.1KB 0B
core/ChatDictationButton 46.5KB 46.8KB +281B 9.5KB 9.5KB 0B
core/ChatLayout 48.8KB 49.1KB +289B 9.9KB 9.9KB 0B
core/ChatLayoutScrollButton 46.4KB 46.7KB +271B 9.6KB 9.6KB 0B
core/ChatSendButton 45.8KB 46.1KB +280B 9.2KB 9.2KB 0B
core/CheckboxInput 49.9KB 50.2KB +283B 9.3KB 9.3KB 0B
core/CheckboxListItem 54.0KB 54.3KB +253B 10.5KB 10.5KB 0B
core/ClickableCard 12.8KB 13.1KB +289B 6.9KB 6.9KB 0B
core/CodeBlock 60.5KB 60.8KB +292B 10.7KB 10.7KB 0B
core/Collapsible 11.7KB 12.0KB +291B 4.2KB 4.2KB 0B
core/CommandPalette 50.9KB 52.7KB +1.8KB 11.8KB 11.8KB 0B
core/CommandPaletteItem 8.4KB 8.7KB +280B 3.5KB 3.5KB 0B
core/ComplexSelector 55.8KB 56.1KB +330B 10.6KB 10.6KB 0B
core/ContextMenu 77.7KB 79.5KB +1.8KB 14.6KB 14.6KB 0B
core/ContextMenuItem 16.6KB 16.8KB +290B 5.2KB 5.2KB 0B
core/DateInput 99.9KB 101.7KB +1.8KB 14.8KB 14.8KB 0B
core/DateRangeInput 69.4KB 71.2KB +1.8KB 11.2KB 11.2KB 0B
core/DateTimeInput 110.1KB 111.9KB +1.8KB 15.2KB 15.2KB 0B
core/Dialog 16.2KB 17.9KB +1.7KB 7.1KB 7.1KB 0B
core/DialogHeader 48.8KB 49.1KB +294B 9.8KB 9.8KB 0B
core/Drawer 31.6KB 33.3KB +1.6KB 8.0KB 8.0KB 0B
core/DrawerHeader 48.9KB 49.2KB +265B 11.2KB 11.2KB 0B
core/DropdownMenu 72.7KB 73.0KB +301B 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.4KB +285B 9.5KB 9.5KB 0B
core/FileInput 54.1KB 54.4KB +269B 10.3KB 10.3KB 0B
core/IconButton 43.3KB 43.6KB +287B 9.2KB 9.2KB 0B
core/Item 11.4KB 11.6KB +273B 4.7KB 4.7KB 0B
core/LayerProvider 63.3KB 63.6KB +302B 10.1KB 10.1KB 0B
core/Lightbox 51.2KB 53.0KB +1.8KB 9.8KB 9.8KB 0B
core/Link 43.5KB 43.8KB +303B 7.6KB 7.6KB 0B
core/ListItem 53.5KB 53.7KB +274B 10.5KB 10.5KB 0B
core/Markdown 144.5KB 146.2KB +1.7KB 17.4KB 17.4KB 0B
core/MobileNav 51.0KB 51.8KB +802B 10.1KB 10.1KB 0B
core/MobileNavToggle 46.2KB 46.5KB +275B 9.4KB 9.4KB 0B
core/MoreMenu 72.9KB 73.2KB +297B 14.7KB 14.7KB 0B
core/MultiSelector 76.2KB 77.9KB +1.8KB 14.6KB 14.6KB 0B
core/NumberInput 55.7KB 56.0KB +282B 10.7KB 10.7KB 0B
core/Outline 28.6KB 28.9KB +306B 4.0KB 4.0KB 0B
core/Pagination 87.7KB 89.4KB +1.7KB 15.3KB 15.3KB 0B
core/Popover 49.8KB 50.1KB +260B 12.1KB 12.1KB 0B
core/PowerSearch 155.1KB 156.9KB +1.8KB 18.6KB 18.6KB 0B
core/RadioListItem 52.1KB 52.4KB +294B 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 80.9KB +1.7KB 15.0KB 15.0KB 0B
core/SelectorOption 14.5KB 14.8KB +251B 5.1KB 5.1KB 0B
core/SideNav 58.0KB 58.8KB +815B 10.6KB 10.6KB 0B
core/SideNavCollapseButton 46.6KB 46.9KB +258B 9.5KB 9.5KB 0B
core/SideNavHeading 54.7KB 55.0KB +264B 10.1KB 10.1KB 0B
core/SideNavItem 54.5KB 54.8KB +280B 10.1KB 10.1KB 0B
core/Step 32.4KB 32.7KB +296B 5.3KB 5.3KB 0B
core/Stepper 47.4KB 47.7KB +281B 9.6KB 9.6KB 0B
core/Switch 48.4KB 48.7KB +298B 9.3KB 9.3KB 0B
core/Tab 9.7KB 10.0KB +294B 4.1KB 4.1KB 0B
core/TabMenu 51.6KB 51.9KB +291B 10.0KB 10.0KB 0B
core/Table 84.0KB 85.7KB +1.7KB 15.1KB 15.1KB 0B
core/TableCell 78.8KB 80.5KB +1.7KB 14.8KB 14.8KB 0B
core/TableHeaderCell 78.6KB 80.3KB +1.7KB 14.8KB 14.8KB 0B
core/TableSelectionToolbar 52.4KB 52.6KB +291B 11.2KB 11.2KB 0B
core/TextInput 53.5KB 53.8KB +288B 10.5KB 10.5KB 0B
core/Thumbnail 50.7KB 50.9KB +290B 11.0KB 11.0KB 0B
core/TimeInput 86.8KB 88.7KB +1.9KB 13.8KB 13.8KB 0B
core/Timestamp 27.5KB 27.5KB +16B 9.5KB 9.5KB 0B
core/Toast 59.8KB 60.1KB +273B 9.7KB 9.7KB 0B
core/ToggleButton 44.1KB 44.4KB +257B 9.3KB 9.3KB 0B
core/Token 29.6KB 29.9KB +305B 4.5KB 4.5KB 0B
core/Tokenizer 64.8KB 65.1KB +322B 11.7KB 11.7KB 0B
core/TopNav 51.9KB 52.6KB +802B 10.4KB 10.4KB 0B
core/TopNavHeading 54.2KB 54.4KB +244B 9.9KB 9.9KB 0B
core/TopNavItem 9.0KB 9.3KB +283B 3.8KB 3.8KB 0B
core/TopNavMegaMenu 54.2KB 54.5KB +283B 10.8KB 10.8KB 0B
core/TopNavMegaMenuItem 9.1KB 9.4KB +281B 4.1KB 4.1KB 0B
core/TopNavMenu 53.6KB 53.9KB +274B 10.1KB 10.1KB 0B
core/TreeList 32.5KB 32.8KB +290B 4.7KB 4.7KB 0B
core/Typeahead 61.5KB 61.7KB +283B 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.

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
@astryxdesign/lab 4.6KB 1.9KB 1.9KB 0B
Package stylesheet Gzip before Gzip after Delta
@astryxdesign/core 34.6KB 34.6KB 0B
@astryxdesign/lab 11.1KB 11.1KB 0B

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 739,916
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 is on hold for an owner decision on the draft spec spec:AST-094, which is the only authority this change cites. Its FR19 and FR20 also forbid the refresh pull's non-claiming, browser-shared pan as written. An engineering owner can approve the record, with FR19/FR20 amended for the refresh pull, by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner. Independently of that decision:

  • Merge after #8045, #8062, #8074, #8076, #8086, #8098 and #8170 and rebase, since against main this pull request carries about 28,000 lines, of which only 1,323 are its own commit.
  • Make the controlled isRefreshing the single source (useRefreshControl.ts:722-729), because today a pull-triggered refresh stays on while the prop reads false.
  • Apply overscroll-behavior-y: none only while the scroll owner overflows (AST-025 FR14), and read the scroll-lock state with useSyncExternalStore instead of an Effect (:444-447).

[Automated review]

Comment on lines +722 to +729
useEffect(() => {
if (isRefreshingProp === undefined) {
return;
}
dispatch(
isRefreshingProp ? {type: 'begin', source: 'program'} : {type: 'end'},
);
}, [dispatch, isRefreshingProp]);

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 is the only path from a controlled isRefreshing into the hook, and it runs only when the prop changes. After a pull triggers with the prop still false, the hook stays refreshing (spinner, aria-busy, 60 px inset) until the prop goes true and then false. An app that never commits true for that refresh cannot end it. The first render with isRefreshing set to true also returns false and is repaired after commit (react-component-runtime INV1/INV3, and its "not casually mirrored into a second source of truth" rule).

When controlled, return the prop, and after a trigger end the refresh on the next commit unless the prop became true.

Comment on lines +444 to +447
useEffect(() => {
setIsLocked(isScrollLockActive());
return subscribeScrollLock(setIsLocked);
}, []);

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 sets state from an external store with no comment naming the system, and it starts from isLocked: false even when a lock already holds. For that first commit, the edge Effect above claims overscroll-behavior-y on the scroll owner.

const isLocked = useSyncExternalStore(subscribeScrollLock, isScrollLockActive, () => false);

Comment on lines +380 to +411
const applyEdge = useCallback(() => {
const current = owner.current;
const near =
isPullEnabledRef.current &&
scrollTopOf(current) < Math.max(heightOf(current), REFRESH_HEIGHT);
const state = edge.current;
if (!near || state.element !== current) {
releaseEdge();
}
if (!near) {
return;
}
if (current == null) {
if (edge.current.releaseRoot == null) {
edge.current = {
element: null,
saved: null,
releaseRoot: claimRootScrollStyle({overscrollBehaviorY: 'none'}),
};
}
return;
}
if (current.style.overscrollBehaviorY !== 'none') {
// First claim, or the owner's own render replaced the value.
edge.current = {
element: current,
saved: current.style.overscrollBehaviorY,
releaseRoot: null,
};
current.style.overscrollBehaviorY = 'none';
}
}, [releaseEdge]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

near never checks whether the owner overflows. A short or empty list in an overflow-y: auto container gets overscroll-behavior-y: none for the whole time the hook is mounted on a touch screen. AST-025 FR14 (current) allows containment "only on axes that currently overflow" to avoid exactly that dead scroll zone. Gate the claim on scrollHeight > clientHeight.

@vjeux vjeux Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Kept on purpose. This is the refresh pull's own containment, not ScrollableArea's, and it follows UIKit: a UIScrollView with a UIRefreshControl always bounces vertically (alwaysBounceVertical), so a list shorter than its scroll view still pulls and refreshes. That is one of this stack's interaction proofs ("a list shorter than the screen still pulls and refreshes").

Without the claim, a pull on a scroll owner that doesn't overflow chains to the page: the page rubber-bands under the pull, and on iOS Safari the page's own reload can fire. The claim is held only near the top, only while a control is mounted and the pull is enabled (iOS only), and it is dropped while a scroll lock holds the page.

If AST-025 FR14 should govern the refresh pull too, that needs an owner decision on the spec, and pulls on short lists would stop working.

@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 for an engineering-owner decision on the draft spec spec:AST-094, the only authority this change cites: as written, its FR4/DEC-1 keep touch physics out of themes and its FR19/FR20 require a recognizer to claim its touches, while this hook plays theme-retunable motion and never claims. An engineering owner can approve the record with those claims amended by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner. Independently of that decision:

  • Merge after #8045, #8062, #8074, #8076, #8086, #8098, #8170, #8257 and #8258 and rebase, since against main this pull request carries 31,776 authored lines, of which 1,461 are its own commit.
  • Make the controlled isRefreshing the single source (useRefreshControl.ts:748-755), because today a pull-triggered refresh stays on while the prop reads false.
  • Apply overscroll-behavior-y: none only while the scroll owner overflows (AST-025 FR14), read the scroll-lock state with useSyncExternalStore, and document the three new experimental exports with stability: 'experimental' (AST-017 FR21).

[Automated review]

Comment on lines +748 to +755
useEffect(() => {
if (isRefreshingProp === undefined) {
return;
}
dispatch(
isRefreshingProp ? {type: 'begin', source: 'program'} : {type: 'end'},
);
}, [dispatch, isRefreshingProp]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When controlled, this Effect is the only path from isRefreshing into the hook, and it runs only when the prop changes. After a pull triggers, or refresh() runs, with the prop at false, the hook stays refreshing (spinner, aria-busy, 60 px inset) until the prop goes true and then false across two commits, so an app that never commits true for that refresh cannot end it; mounting with true also renders false first (react-component-runtime INV1/INV3 and its controlled-state rule). When controlled, return the prop, and end a triggered refresh on the next commit unless the prop became true.

Comment on lines +400 to +402
const near =
isPullEnabledRef.current &&
scrollTopOf(current) < Math.max(heightOf(current), REFRESH_HEIGHT);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

near never checks whether the owner overflows, so a short or empty list in an overflow-y: auto container keeps overscroll-behavior-y: none for as long as the hook is mounted. AST-025 FR14 (current) allows containment only on axes that currently overflow; gate the claim on scrollHeight > clientHeight.

@vjeux vjeux Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Kept on purpose. This is the refresh pull's own containment, not ScrollableArea's, and it follows UIKit: a UIScrollView with a UIRefreshControl always bounces vertically (alwaysBounceVertical), so a list shorter than its scroll view still pulls and refreshes. That is one of this stack's interaction proofs ("a list shorter than the screen still pulls and refreshes").

Without the claim, a pull on a scroll owner that doesn't overflow chains to the page: the page rubber-bands under the pull, and on iOS Safari the page's own reload can fire. The claim is held only near the top, only while a control is mounted and the pull is enabled (iOS only), and it is dropped while a scroll lock holds the page.

If AST-025 FR14 should govern the refresh pull too, that needs an owner decision on the spec, and pulls on short lists would stop working.

Comment on lines +483 to +486
useEffect(() => {
setIsLocked(isScrollLockActive());
return subscribeScrollLock(setIsLocked);
}, []);

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 sets state from an external store without naming it, and starts from isLocked: false even when a lock already holds, so on a client mount under a lock the edge Effect above claims the top edge for one commit. Reading it during render avoids both:

const isLocked = useSyncExternalStore(subscribeScrollLock, isScrollLockActive, () => false);

@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 for an engineering-owner decision on the draft spec spec:AST-094, the only authority this change cites: as written, its FR4/DEC-1 keep touch motion out of themes and its FR19/FR20 require a recognizer to claim its touches, while this hook plays theme-retunable motion and never claims. An engineering owner can approve the record with those claims amended by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner. Independently of that decision:

  • Merge after the nine stacked predecessors and rebase, since against main this pull request carries 31,908 authored lines, of which 1,593 are its own commit; before #8062 lands, its 744 px compact edge needs to follow the theme's md point under the current spec:AST-012 FR9, and #8257's platform condition sits outside FR2.
  • Make the controlled isRefreshing the single source (useRefreshControl.ts:846-853), and start the end slide from end() rather than an Effect that misses a refresh beginning and ending in one render (:679-691).
  • Apply overscroll-behavior-y: none only while the scroll owner overflows (AST-025 FR14), read the scroll-lock state with useSyncExternalStore, and document the three new experimental exports with stability: 'experimental' (AST-017 FR21).

[Automated review]

Comment on lines +679 to +691
useEffect(() => {
if (isRefreshing || pendingEnd.current == null) {
return;
}
endFrame.current = requestAnimationFrame(() => {
endFrame.current = requestAnimationFrame(() => {
endFrame.current = null;
const play = pendingEnd.current;
pendingEnd.current = null;
play?.();
});
});
}, [isRefreshing]);

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 is the only thing that starts the slide end() parks in pendingEnd (:634), and it runs only when isRefreshing changes. When a refresh begins and ends in one render (refresh() from a timer, a network callback or an Effect, with an onRefresh that returns no pending promise, on a scroll owner whose content does not fill it), isRefreshing never changes, so the 60 px inset and the spinner stay on while the hook reports isRefreshing: false. react-component-runtime INV2 keeps work in the handler that can do it: end() can schedule the two frames itself, or this Effect can key on a per-end counter:

const [endCount, setEndCount] = useState(0);
// in end(): pendingEnd.current = ...; setEndCount(count => count + 1);
useEffect(() => {
  // the same two frames
}, [endCount]);

Comment on lines +75 to +79
export const COMPACT_QUERY = '(width < 744px), (height < 500px)';

/** Both: presentations such as a sheet in place of a popover. */
export const COMPACT_TOUCH_QUERY =
'(width < 744px) and (pointer: coarse), (height < 500px) and (pointer: coarse)';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Current AST-012 FR9 makes a screen compact “while its viewport width is below the effective md point (FR1) or its viewport height is below 500”, and says every resolver that chooses a presentation by screen size, this touch resolver and Selector's adaptive presentation included, uses that one definition and “none keeps size numbers of its own” (public-component-api INV17 repeats it). These queries keep their own 744 px edge, so a coarse-pointer screen 744 to 767 px wide and at least 500 px tall, such as an iPad mini in portrait, gets the popover where FR9 gives the sheet, and a theme that moves md is ignored. Derive the width edge from the theme's effective md point, and update the ContextMenu and MoreMenu docs and the touch-presentation Changeset to match.

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

Current AST-012 FR2 closes the when vocabulary to width, height, pointer, contrast and motion, and says “Future environment fields require explicit additions to this closed vocabulary.” platform would be a released defineTheme input that the record does not admit; it needs an owner's FR2 amendment first, or it should leave this stack.

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

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.

  • Reduced motion: every reducedMotion: 'keep' is gone, and the animator resolves it (design:reduced-motion). The release settle passes touchRelease, the end and the spinner's exit take the animator's cross-fade, and the trigger turn asks animator.reducedMotion().
  • Touch listeners: the pull's touches come only through the gesture host (RefreshPullRecognizer on useGestureRecognizer; fix(gestures): pointer-read fingers get the blur refusal and the pinch rule of the Touch Events path #8309 keeps the host's listener passive for it). The listeners at line 502 are the scroll owner's scroll and resize listeners. They move into the one touch module, refreshTouchController.ts, and attach only while the pull is enabled (INV5).
  • The touch gate moves to the resolver's touch presentation (useTouchPresentation), Android included, and the scroll lock is read from useScrollLock's store (fix(useScrollLock): keep the page where it is while an overlay is open #8098) during render.

@vjeux
vjeux force-pushed the uikit/c28-refresh-hook branch from 489c802 to 25043e1 Compare October 24, 2026 23:45
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Oct 24, 2026
@vjeux

vjeux commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

Done in 25043e1 (#8175 at 8bfbe7c). No reducedMotion: 'keep' is left: the animator resolves reduced motion. The gate is useTouchPresentation, and the scroll lock is read from useScrollLock's store. Everything a finger drives lives in refreshTouchController.ts. Its scroll listener is held only while the pull can run, and there is no resize listener. The scroll listener stays for now because the host's touch listeners are passive, so a claim made at touch-down could land after the browser has started its own overscroll for that gesture. It goes once the host can claim the edge at touch-down.

@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 for an engineering-owner decision on the draft spec spec:AST-094, the only authority this change cites, and on the current spec:AST-025 FR14: as written, AST-094's FR4/DEC-1 keep touch motion out of themes and its FR19/FR20 require a recognizer to claim its touches, and FR14 allows overscroll containment only on axes that overflow, while this hook plays theme-retunable motion, never claims, and keeps overscroll containment on scroll owners that do not overflow. An engineering owner can approve the records with those claims amended by commenting /approve-spec <full head SHA> once the amended records are on the head, and the author may do so as an engineering owner. Independently of that decision:

  • Merge after the eleven stacked predecessors and rebase, since against main this pull request carries 33,399 authored lines, of which 1,998 are its own commit; #8257's platform theme condition also sits outside spec:AST-012 FR2.
  • Play the end slide on every end rather than only when isRefreshing changes (refreshTouchController.ts:683-695), so a refresh() that settles in its own task cannot leave the inset and the spinner on.
  • Document the three new experimental exports with stability: 'experimental' (AST-017 FR21), and name the external system in the Effects at useRefreshControl.ts:211-231.

[Automated review]

Comment on lines +683 to +695
useEffect(() => {
if (isRefreshing || pendingEnd.current == null) {
return;
}
endFrame.current = requestAnimationFrame(() => {
endFrame.current = requestAnimationFrame(() => {
endFrame.current = null;
const play = pendingEnd.current;
pendingEnd.current = null;
play?.();
});
});
}, [isRefreshing]);

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 is still the only thing that plays the slide end() parks at line 625, and it runs only when the hook's isRefreshing state changes across a commit. When refresh() runs outside a React event (a timer, a network callback, an Effect) with an onRefresh that settles in a microtask, the begin and the end land in one batch and the state never changes, so on a scroll owner that cannot scroll the inset away the content keeps its 60 px inset and the spinner keeps turning while isRefreshing reads false. end() can schedule its two frames itself, or this Effect can key on a per-end counter that end() bumps; a test that calls refresh() from a timer with a synchronous onRefresh would pin it.

Comment on lines +211 to +231
useEffect(() => {
if (isRefreshingProp === undefined) {
return;
}
dispatch(
isRefreshingProp ? {type: 'begin', source: 'program'} : {type: 'end'},
);
}, [dispatch, isRefreshingProp]);

// A refresh the hook started (a pull or `refresh()`) under a controlled
// `isRefreshing`: the parent took it if the prop is now true, otherwise it
// ends (a parent that keeps false, or sets true then false in one handler).
useEffect(() => {
if (!awaitingProp.current) {
return;
}
awaitingProp.current = false;
if (isRefreshingProp === false) {
dispatch({type: 'end'});
}
}, [controlledCheck, dispatch, isRefreshingProp]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Both Effects call dispatch, which sets isRefreshing and drives the touch layer's inset and slide and the announcement, but neither comment names the external system it synchronizes, which react-component-runtime INV3 asks of a new Effect. A sentence on each naming the touch layer and the announcer would meet it.

Comment on lines +93 to +98
export {
claimRootScrollStyle,
isScrollLockActive,
subscribeScrollLock,
} from '../hooks/rootScrollStyles';
export type {RootScrollStyle} from '../hooks/rootScrollStyles';

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 three functions carry @experimental in their declarations, but no authored doc marks them, and AST-017 FR21 needs both before a surface sits outside the stable promise. A .doc.mjs with stability: 'experimental', as useTouchPresentation and useGestureRecognizer have, saying they may change or be removed in a patch release, would close it.

@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 for an engineering-owner decision on the draft spec spec:AST-094, the only record this change names as its specification, and on the current spec:AST-025 FR14: as written, AST-094's FR4/DEC-1 keep touch motion out of themes and its FR19/FR20 require a recognizer to claim its touches, and FR14 allows overscroll containment only on axes that overflow, while this hook plays theme-resolved motion, never claims, and contains overscroll on scroll owners that do not overflow. An engineering owner can approve the records with those claims amended by commenting /approve-spec <full head SHA> once the amended records are on the head, and the author may do so as an engineering owner. Independently of that decision:

  • Land the twelve stacked predecessors and rebase, since against main this pull request carries 35,075 authored lines and its own commit is 2,010.
  • Start the end slide from end() itself (refreshTouchController.ts:683-695), so a refresh() that begins and ends in one render cannot leave the inset and the spinner on.
  • Add real-browser evidence for the Safari, WebKit and Chromium behaviour the hook relies on (spec:AST-013 FR10), with iOS Safari for the reload and rubber-band claims.
  • Drop the platform theme condition or amend spec:AST-012 FR2 first, document the three new experimental exports with stability: 'experimental' (spec:AST-017 FR21), and name the external system in the Effects at useRefreshControl.ts:211-231.

[Automated review]

Comment on lines +683 to +695
useEffect(() => {
if (isRefreshing || pendingEnd.current == null) {
return;
}
endFrame.current = requestAnimationFrame(() => {
endFrame.current = requestAnimationFrame(() => {
endFrame.current = null;
const play = pendingEnd.current;
pendingEnd.current = null;
play?.();
});
});
}, [isRefreshing]);

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 is the only thing that plays the slide end() parks at line 625, and it runs only when the hook's isRefreshing state changes across a commit. An uncontrolled refresh() called outside a React event (a timer, a network callback, an Effect) with an onRefresh that settles within the same task sets isRefreshing to true and back to false before React renders, so this Effect never runs; on a container that cannot scroll the full 60 px, the content keeps its inset and the spinner keeps turning while isRefreshing reads false. Letting end() schedule its two frames itself, or keying this Effect on a counter that end() increments, fixes it; a test that calls refresh() from a timer with a synchronous onRefresh would pin it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 035eaca: end() now increments a counter that this Effect is keyed on, so a refresh that begins and ends before React renders still slides off its inset two frames after the end commits. New test: refresh() from a timer with an onRefresh that settles at once returns the content to 0.

Comment on lines +22 to +25
* that travel: one write per move, no React render. The scroll owner's
* `overscroll-behavior-y` is `none` while it is within one viewport of its
* top, so the browser draws no rubber band (and Safari's own page reload
* never fires) where the pull is drawn instead. Scrolling stays native.

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 states browser behaviour (no rubber band, Safari's reload kept away), as do lines 477-480, 620-624 and 731-737, but the hook's only evidence is jsdom. spec:AST-013 FR10 asks for real-browser evidence for paint and browser event timing, and for an iOS Safari check of a Safari claim: a Chromium and WebKit proof of the pull, settle and end on the interaction harness, plus an iOS Safari check, or narrower comments, would meet it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The real-browser evidence for these comments is in the component PR stacked on this one (#8175), since a pull needs the component's markup:

  • Its interaction spec runs in Chromium and in WebKit (Playwright's container). It covers the pull, the trigger, the settle and the end, and that on the page the document's top edge belongs to the pull (the root's overscroll-behavior-y). Under a mouse it stays the browser's.
  • Its iOS 26.2 simulator clips (Mobile Safari, HID touches) include a pull on the page with no reload.
  • Its Android clips (Chrome 124 emulator) include a page pull with no reload; it was checked by the page's performance.timeOrigin and navigation type.

This PR keeps the jsdom tests of the mechanism; the comments describe what those proofs show.

Comment on lines +211 to +231
useEffect(() => {
if (isRefreshingProp === undefined) {
return;
}
dispatch(
isRefreshingProp ? {type: 'begin', source: 'program'} : {type: 'end'},
);
}, [dispatch, isRefreshingProp]);

// A refresh the hook started (a pull or `refresh()`) under a controlled
// `isRefreshing`: the parent took it if the prop is now true, otherwise it
// ends (a parent that keeps false, or sets true then false in one handler).
useEffect(() => {
if (!awaitingProp.current) {
return;
}
awaitingProp.current = false;
if (isRefreshingProp === false) {
dispatch({type: 'end'});
}
}, [controlledCheck, dispatch, isRefreshingProp]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Both Effects call dispatch, which sets isRefreshing, drives the touch layer's inset and slide, and announces, but neither comment names the external system it synchronizes, which react-component-runtime INV3 asks of a new Effect. A sentence on each naming the touch layer and the announcer would meet it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 035eaca: each Effect now names what it syncs outside React, the touch layer (inset, spin, slide) and the announcer.

Comment on lines +93 to +98
export {
claimRootScrollStyle,
isScrollLockActive,
subscribeScrollLock,
} from '../hooks/rootScrollStyles';
export type {RootScrollStyle} from '../hooks/rootScrollStyles';

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 three functions and RootScrollStyle carry @experimental in their declarations, but no authored doc marks them, and spec:AST-017 FR21 needs both before a surface sits outside the stable promise. A .doc.mjs with stability: 'experimental', like useTouchPresentation.doc.mjs, saying they may change or be removed in a patch release, would close it.

Comment on lines +118 to +124
/**
* The platform's web engine: `ios` is iOS and iPadOS WebKit (every browser
* there), detected with `@supports (-webkit-touch-callout: none)`; `other`
* 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.

spec:AST-012 FR2 closes the when vocabulary to width, height, pointer, contrast and motion, and says "Future environment fields require explicit additions to this closed vocabulary." platform would be a released defineTheme input the record does not admit, so it needs an owner's FR2 amendment first, or it should leave this stack.

Comment thread packages/core/src/theme/defineTheme.ts Outdated
Comment on lines +259 to +262
* // A softer sheet and a slower reduced-motion fade:
* motion: {
* springs: { 'springs.sheetPresent': { duration: 0.6, bounce: 0.1 } },
* durations: { 'navigation.transitionMs': 300 },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

navigation.transitionMs is the navigation transition context's duration (motion/uikit/navigation.ts), not a Reduce Motion fade, and design:reduced-motion DR4 says theme values offer no way to keep a longer animation under reduced motion. Dropping "and a slower reduced-motion fade" keeps the example from promising what DR4 forbids.

vjeux added 26 commits October 28, 2026 17:39
…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.
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 29, 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 is on hold for an engineering-owner decision on four current spec claims this refresh pull departs from: spec:AST-094 FR36–FR38 (it starts a refresh while the finger is still down, keeps it when a release moves back and settles from zero velocity), AST-094 FR4 (its springs and durations play as table constants, not motion roles), AST-094 FR43 (it pulls only under a coarse pointer, while FR43 has gestures work for every pointer) and spec:AST-025 FR14 (overscroll-behavior-y: none near the top on scroll owners that do not overflow). An engineering owner settles this by amending those claims for the refresh pull, or by asking for the hook to conform, and records the decision by commenting /approve-spec <full head SHA> on the pull request; the author may do so as an engineering owner. Whatever that decision, these changes are needed:

  • Land the stacked predecessors and rebase, since against main the branch carries 32,705 authored lines and 2,141 of them are this pull request's own.
  • Show the inset and spinner when a controlled refresh is already running as a server-rendered page hydrates on a touch screen (useRefreshControl.ts:176-178, AST-094 FR13).
  • Share one document scroll listener across instances (refreshTouchController.ts:502-505, FR24) and stop reading layout once the pull has begun (:723-759, FR9).
  • Add real-browser evidence for the touch layer's named-browser workarounds or narrow them (spec:AST-013 FR10), assert the announcement's channel and update count (spec:AST-009 FR4), and name what the four remaining Effects synchronize (architecture:react-component-runtime INV3).

[Automated review]

Comment on lines +176 to +178
if (isTouchRef.current) {
touch.begin();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

On a server-rendered page whose controlled isRefreshing is already true, this begin runs after the hydrating commit, while useTouchPresentation still reports the pointer presentation, so touch.begin() is skipped; nothing runs it once the presentation turns to touch, so that refresh never shows its inset or spinner on a phone (AST-094 FR13). Running the touch layer's begin() when the pull becomes enabled while the model is refreshing with no inset, with a hydration test, would close it.

Comment on lines +502 to +505
document.addEventListener('scroll', onScroll, {
capture: true,
passive: 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 capture listener is per instance, so N enabled controls hold N document scroll listeners, and the test at useRefreshControl.test.tsx:617-646 pins that; AST-094 FR24's verification fails "a per-instance document or window listener". One module-level listener serving every mounted control would keep it at one.

Comment on lines +758 to +759
const scrolledBack =
scrollTopOf(owner.current) - geometry.scrollTop0 > 0.5;

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 reads scrollTop on every move after the pan began, as :723-724, :732, :742 and :750 read style and layout at began, while AST-094 FR9 allows "no layout read after the gesture begins". Resolving the owner and its height at touch-down (onTouchDown already calls resolveOwner()) and taking the offset from the passive scroll listener would remove them.

@vjeux
vjeux marked this pull request as draft October 29, 2026 22:32

This branch had an error being deployed

1 failed deployment
Preview — 338dc334 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