refactor(ai)!: replace boolean loading states with RequestStatus type#2068
Open
victorcg88 wants to merge 1 commit intomainfrom
Open
refactor(ai)!: replace boolean loading states with RequestStatus type#2068victorcg88 wants to merge 1 commit intomainfrom
victorcg88 wants to merge 1 commit intomainfrom
Conversation
BREAKING CHANGE: The AI module now uses RequestStatus type instead of boolean loading states. Users should: * Update from `suggestionsLoading: boolean` to `suggestionsStatus: RequestStatus`. * Update from `setSuggestionsSearchLoading: boolean` to `setSuggestionsSearchStatus: RequestStatus`. * Adjust computed properties accordingly.
dd0e8a3 to
3355101
Compare
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.
Motivation and context
This PR migrates the AI module from using boolean loading states to a more robust
RequestStatustype for tracking the loading state of AI suggestions and suggestions search. This change aligns the AI module with the pattern used across other X modules and provides more granular state information.The previous implementation used separate boolean flags (
suggestionsLoadingandsuggestionsSearchLoading) which only indicated whether a request was in progress. The newRequestStatustype provides four distinct states:initial: No request has been made yetloading: A request is in progresssuccess: The request completed successfullyerror: The request failedThis enhanced state tracking allows for better UI feedback and more precise conditional logic in components.
Type of change
How has this been tested?
Tests have been updated to verify the new
RequestStatusimplementation:ai-overviewcomponentinitial,loading,success,error)Tests performed according to testing guidelines.
Migration guide
Breaking changes
The AI module's store state and mutations have been updated to use
RequestStatusinstead of boolean loading states. This is a breaking change for any code that directly accesses these properties.What changed
RequestStatus)suggestionsLoading: booleansuggestionsStatus: 'success' | 'loading' | 'error' | 'initial'suggestionsSearchLoading: booleansuggestionsSearchStatus: 'success' | 'loading' | 'error' | 'initial'Migration steps
1. Store state access
Before:
After:
2. Store mutations
Before:
After:
3. Component props
If you're using the AI components directly and checking loading states:
Before:
After:
4. Compatibility layer (optional)
If you need to maintain backward compatibility during migration, you can add computed properties:
Affected components
AiOverview: Now usessuggestionsStatusinstead ofsuggestionsLoadingfetchAndSaveAiSuggestions,fetchAndSaveAiSuggestionsSearch)Unaffected (no migration needed)
@empathyco/x-componentsexports (no component props changed)Checklist: