fix(stage-ui): skip optimistic updates before apply#1304
fix(stage-ui): skip optimistic updates before apply#1304Garfield550 merged 2 commits intomoeru-ai:mainfrom
Conversation
Avoid leaving phantom optimistic state behind when a mutation is intentionally skipped by checking the guard before applying the optimistic update. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Summary of ChangesHello, 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 refactors the Highlights
Changelog
Activity
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 addresses a bug where optimistic updates could result in a phantom UI state if the action was skipped. The fix correctly moves the skipActionIf guard before the apply call, ensuring that no optimistic state is set when an action is skipped. A new regression test has been added to verify this behavior, confirming that apply() and action() are not called when skipActionIf returns true. The changes are well-contained and effectively resolve the issue.
|
No place uses the useOptimisticMutation hook, but LGTM |
Summary
skipActionIf()guard ahead ofapply()so skipped optimistic mutations do not leave phantom UI state behindpackages/stage-ui/src/composables/use-optimistic.test.tsthat proves skipped mutations do not callapply()oraction()Validation
pnpm -F @proj-airi/stage-ui exec vitest run src/composables/use-optimistic.test.tspnpm -F @proj-airi/stage-ui typecheckmoeru-lint --fixon the staged files successfully during commitNotes
pnpm lint:fixattempt still reports unrelated pre-existing lint issues elsewhere in the monorepo, but the touched composable files passed the staged-file lint hook and the targeted test/typecheck flow