feat(stage-ui,server): use optimistic request for provider catalog#951
feat(stage-ui,server): use optimistic request for provider catalog#951nekomeowww merged 8 commits intomainfrom
Conversation
Summary of ChangesHello @luoling8192, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the user experience in the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
⏳ Approval required for deploying to Cloudflare Workers (Preview) for stage-web.
Hey, @nekomeowww, @sumimakito, @luoling8192, @LemonNekoGH, kindly take some time to review and approve this deployment when you are available. Thank you! 🙏 |
There was a problem hiding this comment.
Code Review
This pull request introduces a useOptimistic composable to provide a better user experience with optimistic UI updates, and refactors the provider catalog management to use it. This is a great improvement for perceived performance.
I've found a couple of high-severity issues:
- In the new
useOptimisticcomposable, there's a potential bug where the result of an asynchronous action can be lost if anonSuccesshandler isn't provided. - In the
provider-catalogstore, when adding a new provider, if the server returns a different ID than the temporary one created on the client, the temporary entry is not cleaned up, leading to data inconsistencies.
I've provided detailed comments and code suggestions to address these points. Besides these, the changes are well-implemented and the new tests for useOptimistic are comprehensive.
| * A wrapper for performing optimistic updates with automatic rollback. | ||
| * Integrates with useAsyncState for loading/error tracking. | ||
| */ | ||
| export function useOptimistic<T, R = T>(options: UseOptimisticOptions<T, R>) { |
There was a problem hiding this comment.
Pehaps... useMutateOptimistic? Or useOptimisticMutate?
There was a problem hiding this comment.
Could you explain why should we use mutate?
There was a problem hiding this comment.
There was a problem hiding this comment.
However, what inspired me is this React implementation, https://react.dev/reference/react/useOptimistic
There was a problem hiding this comment.
Then should we divide this into two composables?
Co-authored-by: Neko <neko@ayaka.moe>
…oeru-ai#951) --------- Co-authored-by: Neko <neko@ayaka.moe>
No description provided.