Skip to content

fix: preserve reverted drafts after save errors - #44

Merged
jerelvelarde merged 1 commit into
CopilotKit:mainfrom
Bortlesboat:fix/preserve-drafts-after-save-errors
Oct 5, 2026
Merged

jerelvelarde merged 1 commit into
CopilotKit:mainfrom
Bortlesboat:fix/preserve-drafts-after-save-errors

Conversation

@Bortlesboat

Copy link
Copy Markdown
Contributor

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 to Temporary, revert to Original while the save is pending, then lose the response: the next poll currently replaces the draft with Temporary and 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.

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 NathanTarbert left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 jerelvelarde left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jerelvelarde
jerelvelarde merged commit ddb70ef into CopilotKit:main Oct 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants