Skip to content

feat(ui): migrate delete/leave-org sections to state machines#8948

Open
alexcarpenter wants to merge 2 commits into
feat/mosaic-machine-corefrom
feat/mosaic-machine-sections
Open

feat(ui): migrate delete/leave-org sections to state machines#8948
alexcarpenter wants to merge 2 commits into
feat/mosaic-machine-corefrom
feat/mosaic-machine-sections

Conversation

@alexcarpenter

Copy link
Copy Markdown
Member

Summary

Replaces useState boolean pairs in DeleteOrganization and LeaveOrganization with co-located machine definitions, demonstrating the simplest machine pattern.

Each section gets a *-machine.ts with three states and four events:

idle → confirming → deleting/leaving
          ↑              ↓
         OPEN         done/error → idle

Before: two useState booleans, event handlers with manual flag resets, impossible states representable (isDeleting && !open).

After: useMachine(machine, { context: { destroyFn } }) — impossible combinations unrepresentable by construction.

Stack

  1. feat/mosaic-machine-core — core library ✅
  2. This PR — section migrations
  3. feat/mosaic-machine-signin — sign-in flow machines + adoption guide

Test plan

  • turbo test --filter @clerk/ui passes
  • Delete/leave org dialogs open, confirm, submit, and cancel correctly

@changeset-bot

changeset-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 531fbbe

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

@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jun 22, 2026 6:52pm
swingset Ready Ready Preview, Comment Jun 22, 2026 6:52pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 9acb0d55-dbff-4481-bb9b-4a958ffedf69

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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Replaces the useState(open) + useState(isDeleting) pairs in
DeleteOrganization and LeaveOrganization with machine definitions.

Each section gets a co-located *-machine.ts that declares its three
states (idle → confirming → deleting/leaving) and the four events that
drive them (OPEN, CANCEL, CONFIRM, done/error). The .tsx files shrink
to a single useMachine call; impossible state combinations (open while
not confirming, deleting without confirming) become unrepresentable.
Adds optional error?: string | null to DestructiveProps so section
machines can surface async failure messages inside the confirm dialog.
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.

1 participant