refactor(mosaic): model destructive reverification as nested statecharts - #9993
Closed
alexcarpenter wants to merge 1 commit into
Closed
alexcarpenter wants to merge 1 commit into
alexcarpenter wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 8036928 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueComment |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Concept PR stacked on #9864. It re-models delete-account reverification as two statecharts that talk to each other, instead of a model + controller +
useReverificationWithStatehook.Machine lib (
packages/mosaic/src/machine)value,matches(), and events that bubble to parents.#idand.childtargets.invoke. A state can invoke a child machine, which appears onsnapshot.children; itsonDonereceives the child's context.stateInguard.childActor(actor, machine)narrows a child to a known machine.Destructive (
destructive.machine.ts)closed→open.{confirming, running, failed, verifying.{challenge, retrying}}.session_reverification_required, the machine entersverifying, which invokes the reverification machine. Once that finishes, it retries the action.CLOSEis blocked while running or retrying. Closing during the challenge stops the child.Reverification (
reverification.machine.ts,reverification.actors.ts)starting→factor.{editing.{ready, preparing.{idle, queued}}, submitting, help}/methods.{list, preparing, help}/unavailable/finishing→verified(final).useReverificationActors(). The machine only names them.<Reverification actor={...} />just renders the child actor's snapshot.Impossible combinations such as "retrying while closed" or "submitting while preparing" are now unrepresentable, rather than guarded against with booleans.
Behavior differences from #9864:
unavailablestays on screen until the user dismisses it.Bundle cost: the machine lib grows from ~1.6 KB to ~2.8 KB min+gzip. For comparison, XState +
@xstate/reactis ~14.8 KB.Not intended to merge as-is. Next up: a typed actor registry and typed transition targets.
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change