fix: introduce a queue into update state machine#367
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| rollback: { | ||
| entry: "removeOptimisticAction", | ||
| always: { target: "idle", actions: "clear" }, | ||
| always: { target: "checkQueue", actions: "clear" }, |
There was a problem hiding this comment.
The rollback state clears the entire update queue (actions: "clear") if a single update fails, but it does not clean up the optimistic UI changes for the discarded queued items. The clearQueueOptimisticActions function was added to handle this cleanup, but it is never called, leading to a leaked UI state where the application shows updates that have been silently dropped.
Prompt for AI agents
Address the following comment on apps/web/src/components/calendar/flows/update-event/update-queue.ts at line 182:
<comment>The `rollback` state clears the entire update queue (`actions: "clear"`) if a single update fails, but it does not clean up the optimistic UI changes for the discarded queued items. The `clearQueueOptimisticActions` function was added to handle this cleanup, but it is never called, leading to a leaked UI state where the application shows updates that have been silently dropped.</comment>
<file context>
@@ -137,32 +153,44 @@ export function createUpdateQueueMachine({
rollback: {
entry: "removeOptimisticAction",
- always: { target: "idle", actions: "clear" },
+ always: { target: "checkQueue", actions: "clear" },
},
</file context>
Summary by cubic
Added a queue to the update-event state machine to serialize updates and capture START events fired during prompts or an in-flight mutation. This prevents dropped updates and race conditions during rapid edits.