Skip to content

test(interaction-harness): openStory returns once Storybook has finished the story's render - #8913

Draft
vjeux wants to merge 1647 commits into
meta:mainfrom
vjeux:harness/open-story-finished-render
Draft

vjeux wants to merge 1647 commits into
meta:mainfrom
vjeux:harness/open-story-finished-render

Conversation

@vjeux

@vjeux vjeux commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Review only this PR's change: vjeux/astryx@045f666...fbd8034

Stacked on #8360, whose story.ts and Storybook self-test it changes.

Why

openStory returned at the story's first render, while Storybook was still finishing it: it waits out the story's animations (phase completing), runs afterEach, and only then reports the story finished (STORY_FINISHED, phase finished), about 150 ms later. Its decorators' effects, a listener on the document among them, landed inside a proof's first measurement window, so a proof measuring from openStory's return measured Storybook too.

What led to it

The change lived on the web-input drivers helper line, which no longer carries it, and it applies only to the foundation re-fold's story.ts.

Options and tradeoffs

  • Wait a fixed time after the first render: a guess that load breaks.
  • Wait for Storybook's own phase finished for this story (this pull request).

Why this choice

openStory also waits until __STORYBOOK_PREVIEW__.currentRender is this story at phase finished. The self-test records every listener added to the document or the window from before Storybook loads, and checks that openStory returns at phase finished with none landing after it, read two frames and a task later rather than after a fixed wait.

How to check it

With a built Storybook, pnpm test:interaction internal/interaction-harness/src/storybook.interaction.browser.spec.ts --grep "openStory returns once" passes in both engines.

Evidence

vjeux and others added 30 commits October 26, 2026 14:11
A watcher already adds nothing to the derived touch-action, and
manageStyle is per element, so attaching one with manageStyle: false
beside a claiming recognizer switched off that recognizer's touch-action
(spec:AST-094 FR18). The README now says a watcher adds nothing instead.

Co-authored-by: Christopher Chedeau <vjeuxx@gmail.com>
…l, straight or diagonal, and not before

spec:AST-094 FR20's verification names a finger moved 9 px and 10 px
straight, and (7, 7) and (8, 8) diagonally: a scroll above the touch takes
it only once the finger has travelled 10 px from where it landed. The host
already measures that distance; these cases pin the boundary.
…g running

Landing a waiting Reduce Motion move on the node just detached rebuilt
every channel the landing touched there, so an axis still moving (a coast
on y while x waited in a dip) was baked onto the detached node again and
promoted it, leaving an animation, timers and will-change behind. After the
landing, the unmount now cancels what runs, clears the retire timers and
demotes, before the target goes back to none. The test fails on the
previous head.
The README's busy-main-thread paragraph and busyWindowProof's JSDoc said an
undelivered frame is never a miss; when fewer than minJudgedFrames frames
were delivered in the judged part, its span counts every frame. One clause
in each says so.
…ose finds it

The unmount kept the node of the first attach(null) in the task, so after
attach(null), attach(next), attach(null) it landed a waiting Reduce Motion
move on the node already replaced, and next stayed at its dip's opacity.
A dispose right after attach(null) landed on no element, leaving the
detached node at opacity 0. The latest detached node is now kept while its
unmount is pending; the unmount and dispose both land there. Two tests
fail on the previous head.
…that Effect

The isEnabled sync's silence covered recognizer listeners but not
usePressTracker: a press-tracked control inside an element whose double tap a
rerender turns off heard touchUpInside (and its un-highlight) from that
layout Effect (react-component-runtime INV2). Silencing it would leave the
control highlighted, so the tracker's callbacks that arrive during a sync
run in a microtask just after it, in order: the press still ends and
un-highlights, outside the Effect.

Tests, failing before (the events arrived inside the Effect): a press
waiting on an ancestor double tap, alone and with a single tap waiting on
it, reports nothing from the Effect that turns the double tap off, then
touchUpInside and the un-highlight just after.

Co-authored-by: Christopher Chedeau <vjeuxx@gmail.com>
…ile it ran

A page opened after startCompositorTrace and closed before stop() was still
credited: its frames are in the browser-wide record, and neither check saw
it. The record now watches for new pages from start to stop, in the page's
own context and through the browser's target discovery in every context,
and stop() throws if one opened. Negative controls: a page opened and
closed mid-record, and one in another context, both make stop() refuse;
alone, it records.
…rns to joins that dip

Under Reduce Motion a call that names an opacity while an earlier dip's
move still waits to land took the dip branch. So a call naming the opacity
the dip already returns to, with no travel of its own, opened a second dip
from where the first had got to: mid fade out the element faded out twice,
and in the dip's own task the browser got a second, identical fade. A swipe
row's release does exactly that: its move's layer plays the travel as a
dip, then its state layer lands opacity 1 on the same element in the same
task. Such a call now joins the waiting dip: the planner returns joins, the
fade goes on as it was, the call takes the landing over and settles when
the dip ends, and the call it replaces lands with it, each value keeping
the call whose move it is. A call that names travel, or another opacity,
plans as before. Four tests (the planner's, mid dip, in the dip's task,
and a release played then landed) fail on the previous code.
…aiting dip returns to joins that dip; the internal changesets stop counting their users) into the presented start
@eslint-react/naming-convention-ref-name: the test component added in
07b3383 held its refs as outer and inner, two lint errors that failed
CI's ESLint step. Renamed outerRef and innerRef; no other change.
Inside a trace, waitForAnimation and watch.started() read the element through
handles, which find no element rather than wait for one, so a wait on an
element the page removed rejected with "no animation started on the
element" instead of "the element is not in the document", unlike the
untraced path. At its deadline, a traced wait with no element now rejects
as missing. Traced twin of the missing-element self-test; it fails on the
previous code.

Co-authored-by: Christopher Chedeau <vjeuxx@gmail.com>
…med or not

The planner's comment on the cross-fade's length said it is not a theme
role and no theme lengthens it. Under spec:AST-094 DEC-11 no motion role is
themeable: the fade's length is no role at all, and nothing lengthens it.
vjeux added 20 commits October 29, 2026 10:03
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.
…hed the story's render

openStory returned once the story's first element attached, its fonts loaded and two frames passed, while Storybook was still finishing the render: it waits out the story's animations (phase completing), runs afterEach, and only then reports the story finished (STORY_FINISHED, phase finished), about 150 ms later. Its decorators' effects, a listener on the document among them, landed inside a proof's first measurement window. openStory now also waits for Storybook's current render of that story to reach phase finished.

The self-test records every listener added to the document or the window from before Storybook loads, and checks that openStory returns at phase finished with none landing after it, read two frames and a task later rather than after a fixed wait.

Red first, in both engines: on the previous story.ts the phase right after openStory is not finished, and the self-test fails; with the change it passes 3 of 3 in Chromium and WebKit. This came from the web-input drivers helper line, which no longer carries it.
@vercel

vercel Bot commented Oct 30, 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 30, 2026 1:06am UTC

Request Review

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

astracat-bot Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

AI review status for this pull request.

Review status Updated
🟡 Reviewed (for maintainers only) Oct 30, 2026, 1:28 AM UTC

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

Changes requested: against main, this pull request carries all of the still-open #8360 (171 files, about 27,300 authored lines), while its own change is the 92-line openStory wait in internal/interaction-harness/src/story.ts and its self-test. Please keep it in draft until #8360 lands, then rebase on main so the diff holds only that change; the wait itself matches Storybook 10.6.2's render phases. While rebasing, consider widening or rewording the self-test's late-listener check: two frames and a task is shorter than Storybook's post-render tail, so today the phase assertion is what catches a regression.

[Automated review]

Comment on lines +100 to +101
// Two frames and a task more: a listener a render still in flight adds
// lands by then; a finished one adds none.

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 window is two frames and a task after openStory returns, about 33 ms at 60 Hz. On the previous story.ts it closes roughly 70 ms after the story's first element attaches, before Storybook's 100 ms completing delay ends, so a listener added at afterEach lands after it and only the phase assertion fails there. Either widen the window past that tail or say here that the phase check is what catches the regression.

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Oct 31, 2026

This branch was successfully deployed

1 active deployment
Preview — fbd80349 Deployed Oct 30, 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