Skip to content

fix(mosaic): resume machine actors after stop instead of resetting them - #10477

Merged
alexcarpenter merged 2 commits into
mainfrom
carp/mosaic-testing-improvements
Oct 28, 2026
Merged

alexcarpenter merged 2 commits into
mainfrom
carp/mosaic-testing-improvements

Conversation

@alexcarpenter

Copy link
Copy Markdown
Member

Description

Brings over the machine fix from #10341, without its React 19.2 Vitest project.

Machine actors now resume after stop() / start() instead of resetting to the initial state:

  • A start() after stop() resumes in the current state. Entry actions and invokes are not run again. The first start() is unchanged.
  • after timers are paused on stop and re-armed on start.
  • Invoke results and events that arrive while stopped are applied in arrival order on start.
  • An actor created with a snapshot keeps it across a restart. Before, StrictMode's stop/start sent useMachine(machine, { snapshot }) back to the initial state.
  • useMachine fires onDone once per actor. Before, a machine that starts in a final state called it twice under StrictMode.
  • useMachine subscribes with useSyncExternalStore before its start effect, so a flow shown again inside React 19.2 <Activity> renders the resumed snapshot. This one is not covered by a test here, since the repo runs React 18.3.

Also makes a few tests independent of how many times React renders or runs effects:

  • use-transition: the requestAnimationFrame mock keys callbacks by a stable id, so cancelling a frame from an earlier batch no longer leaves a hole in the queue.
  • use-layout-animation: asserts one live animator while mounted and every animator disposed once, instead of counting dispose calls.
  • useSelector render tests: assert no re-render after an unrelated change and a re-render after a related one, instead of exact render counts.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Ports the machine fix from #10341 without its React 19.2 test project, and
makes a few tests independent of render and effect counts.
@vercel

vercel Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Oct 28, 2026 12:16am UTC
swingset Ready Ready Preview Oct 28, 2026 12:16am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2de79e4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 4699f37 and 2de79e4.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between debfc72 and 4699f37.

Files selected for processing: 9
  • .changeset/mosaic-machine-resume.md
  • packages/mosaic/src/machine/__tests__/machine.test.ts
  • packages/mosaic/src/machine/__tests__/use-machine.test.tsx
  • packages/mosaic/src/machine/__tests__/wizard-migration.test.tsx
  • packages/mosaic/src/machine/create-actor.ts
  • packages/mosaic/src/machine/types.ts
  • packages/mosaic/src/machine/use-machine.ts
  • packages/mosaic/src/primitives/hooks/__tests__/use-layout-animation.test.tsx
  • packages/mosaic/src/primitives/hooks/__tests__/use-transition.test.ts
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Walkthrough

Actors now resume their initialized state after stopping. They retain paused timer delays and apply queued events and invoke settlements on restart. useMachine subscribes to snapshots earlier and calls onDone at most once. Tests cover actor restart behavior, hook rendering and completion, and animation cleanup. A Changeset file with empty frontmatter was added.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: ephem

Merge Risk: Minimal · previous review 4699f

No identified issue blocks merging after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surv… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title names the main change: machine actors now resume after stop() and start() instead of being reset to their initial state. It also follows the conventional commit prefix and scope. The title m…
Description check Passed The description states that the PR ports the machine fix from #10341 without its React 19.2 Vitest project. It lists the behavior changes: resume after stop/start, paused and re-armed after timers, qu…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: machine actors now resume after stop() and start() instead of being reset to their initial state. It also follows the conventional commit prefix and scope. The title matches the PR objectives and the create-actor.ts and types.ts changes.

Full details: Description check

Explanation

The description states that the PR ports the machine fix from #10341 without its React 19.2 Vitest project. It lists the behavior changes: resume after stop/start, paused and re-armed after timers, queued invoke results and events, snapshot retention, and a single onDone call in useMachine. It also covers the test changes in use-transition, use-layout-animation, and the useSelector render tests. Each of these matches the file summaries.

Full details: Docstring Coverage

Explanation

Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 12 functions across 8 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Linked repositories: Some configured repositories could not be included in this review. Cross-repository analysis may be incomplete. Please check linked-repository access and settings.

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@10477

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@10477

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@10477

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@10477

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@10477

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@10477

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@10477

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@10477

@clerk/expo-biometrics

npm i https://pkg.pr.new/@clerk/expo-biometrics@10477

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@10477

@clerk/expo-native-components

npm i https://pkg.pr.new/@clerk/expo-native-components@10477

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@10477

@clerk/express

npm i https://pkg.pr.new/@clerk/express@10477

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@10477

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@10477

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@10477

@clerk/mosaic

npm i https://pkg.pr.new/@clerk/mosaic@10477

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@10477

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@10477

@clerk/react

npm i https://pkg.pr.new/@clerk/react@10477

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@10477

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@10477

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@10477

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@10477

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@10477

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@10477

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@10477

commit: 2de79e4

@alexcarpenter
alexcarpenter merged commit e785d99 into main Oct 28, 2026
90 of 92 checks passed
@alexcarpenter
alexcarpenter deleted the carp/mosaic-testing-improvements branch October 28, 2026 00:34

This branch was successfully deployed

2 active deployments
Preview – swingset — 2de79e47 Deployed Oct 28, 2026 by vercel[bot]
Preview – clerk-js-sandbox — 2de79e47 Deployed Oct 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants