refactor: Phase 1 — split xstateUtilsV5.ts into focused modules#1345
Open
refactor: Phase 1 — split xstateUtilsV5.ts into focused modules#1345
Conversation
Split the 2,001-line God Object into 4 focused modules: - xstateTypes.ts (14 lines) — PersistedXStateData, PreApprovalUpdateData - xstateEffects.ts (781 lines) — handleStateTransitions, sendCanceledEmail - xstatePersistence.ts (569 lines) — snapshot save/restore/migration, machine selection, status mapping - xstateTransitions.ts (667 lines) — executeXStateTransition, getAvailableXStateTransitions xstateUtilsV5.ts becomes a 1-line barrel re-export so external callers are unaffected. No runtime behavior changes. All 83 test files (1,318 tests) pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
664efa4 to
1bcb34c
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Phase 1 refactor of the XState “god object” (xstateUtilsV5.ts) into smaller, responsibility-focused modules while keeping external callers stable via a barrel re-export.
Changes:
- Replaced
xstateUtilsV5.tsimplementation with a barrel export to preserve the existing import path/API. - Introduced focused modules for types, persistence, effects, and transition APIs.
- Updated the XState refactoring plan document to reflect revised goals and the phased approach.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| booking-app/lib/stateMachines/xstateUtilsV5.ts | Converts the former monolith into a barrel re-export to preserve compatibility. |
| booking-app/lib/stateMachines/xstateTypes.ts | Extracts shared type definitions used across the refactored modules. |
| booking-app/lib/stateMachines/xstatePersistence.ts | Hosts Firestore snapshot creation/restoration and related helpers. |
| booking-app/lib/stateMachines/xstateEffects.ts | Hosts transition side effects and state-change handling logic. |
| booking-app/lib/stateMachines/xstateTransitions.ts | Hosts the public transition API and wires persistence/effects together. |
| booking-app/docs/xstate-refactoring-plan.md | Updates the refactoring plan narrative and Phase 3 framing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary of Changes
Phase 1 of the XState refactoring plan (see
docs/xstate-refactoring-plan.md).Splits the 2,001-line
xstateUtilsV5.tsGod Object into 4 focused modules:xstateTypes.tsxstateEffects.tsxstatePersistence.tsxstateTransitions.tsxstateUtilsV5.tsAlso updates
docs/xstate-refactoring-plan.mdwith goals and risk assessment.What this does NOT change
Checklist
Screenshots / Video
N/A — no UI changes.