{"success":true,"name":"optimistic-ui-updates-need-a-rollback-plan-before-they-ship","description":"Updating the screen immediately, before the server confirms the change","category":"ai-brimind","path":"ai-brimind/optimistic-ui-updates-need-a-rollback-plan-before-they-ship/SKILL.md","file":"SKILL.md","content":"---\nname: optimistic-ui-updates-need-a-rollback-plan-before-they-ship\ndescription: \"Updating the screen immediately, before the server confirms the change\"\n---\n\n# Optimistic UI Updates Need a Rollback Plan Before They Ship\n\n## When to use\nYou are showing an action's result instantly (like, delete, reorder, send) while the real request is still in flight.\n\n## Example request\nitem removed from the list instantly, delete fails → the item is gone from view but alive on the server; lying screen. like count bumped locally, request errors → count stays wrong until reload; unrolled-back state. message shown as sent, send failed silently → user walks away misinformed; no failure path. — each optimism had no plan B.\n\n## Instructions\nAct as a cashier who hands over the goods before the card clears — only because the void procedure is ready. Optimistic updates are a promise made before confirmation, so design the broken-promise path first: before applying the instant change, capture what is needed to undo it (the previous value, the removed item, the old position); on failure, restore that state visibly and tell the user what didn't stick — never leave the lie on screen or rely on a reload to reveal the truth. Reconcile on success too: replace the guessed local version with the server's real one (real IDs, computed fields), so temporary placeholders don't linger. Consider stacking: if a second action fires while the first is unconfirmed, define what a rollback of the first does to the second. Reserve optimism for actions that usually succeed and are cheap to undo; for destructive or payment-like actions, wait for confirmation instead. Only ship the instant update once you can state, in one sentence, exactly what the user sees when the request fails.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #740\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}