fix: preserve reverted drafts after save errors - #44
jerelvelarde merged 1 commit into
Conversation
Keep a reverted draft when polling observes a save whose response was lost. The existing conflict flow lets the user decide whether to load the remote page. Cover the lost-response sequence and explicit load-latest recovery.
NathanTarbert
left a comment
There was a problem hiding this comment.
Thanks @Bortlesboat, this is a really clean fix. The steps in the description (Original, Temporary, revert, response lost) are exact, and the regression test follows them one for one. I also like that it checks only one save fires while in conflict and that "Load latest" recovers cleanly.
Routing this through the existing conflict flow rather than adding a new state feels right. It does mean that if a save never reached the server and someone else edits the page meanwhile, the user now sees a conflict banner where before the remote edit just loaded. The client can't tell that case apart from "saved but the response was lost", so asking the user seems like the right side to err on. Nothing gets overwritten, and it costs one click.
There's a nearby case this doesn't cover, and it doesn't need to. If the poll with the newer revision arrives while the save is still in flight, the editor stays in "error" rather than "conflict". The draft is still safe, because retrying gets a 409 and lands in conflict. It might be worth a follow-up someday so the conflict shows straight away.
Looks good to me.
jerelvelarde
left a comment
There was a problem hiding this comment.
Prevents silent draft loss when a save commits but its response is lost. Reusing the existing dirty/conflict handling fits the template and retains explicit user control over loading the latest revision. No new permissions, external requests, or security blockers found.
Validation on the reviewed head: 165 tests passed; typecheck, lint, formatting, and production build passed.
Preserve the user's reverted page draft when the server commits an autosave but its response is lost. In the page editor, start with
Original, edit toTemporary, revert toOriginalwhile the save is pending, then lose the response: the next poll currently replaces the draft withTemporaryand marks it saved. The draft now stays in the existing conflict flow until the user resolves it.The regression fails before the fix and passes afterward, including explicit “Load latest” recovery. On Node 24.14.0, all 165 tests, typecheck, lint, formatting and the production build pass; validation used the autosave controller and existing component tests, without an interactive browser walkthrough.