Earde

Preserving unsent editor changes across reconnects

by u/tolwiz[MOD][ADMIN]5 hr ago2 comments
Promoted conversation
Promoted from #general
2026-08-05 · 8 messages · 3 participants
NightOwlDev2026-08-05 11:44view in chat
Has anyone found a safe way to preserve unsent editor changes when Northstar reconnects? Right now a reconnect replaces the local draft with the last server snapshot.
tolwiz2026-08-05 11:44view in chat
Does the overwrite happen as soon as the connection is restored, or only after Northstar receives the first server snapshot?
NightOwlDev2026-08-05 11:46view in chat
Only after the first server snapshot arrives. The local draft survives the reconnect itself, but the snapshot handler replaces the editor state without checking for unsent changes.
ansuzgardraiwoseed2026-08-05 11:46view in chat
We should keep the last synchronized document and the local draft as separate states. After reconnecting, Northstar could apply the new server snapshot as the base and then replay the pending local edits on top of it.
tolwiz2026-08-05 11:46view in chat
That should work if we store unsent changes as operations rather than another complete snapshot. Reconnect would update the base document first, then reapply the local operation log.
NightOwlDev2026-08-05 11:46view in chat
What happens if one of those operations targets a block that another collaborator deleted while the client was disconnected? That is where we currently lose the draft.
ansuzgardraiwo2026-08-05 11:46view in chat
If an operation cannot be replayed cleanly, we should preserve its content in a recovery draft and show a conflict instead of discarding it. The user can then copy or reapply the text manually.
tolwiz2026-08-05 11:47view in chat
Agreed. The reconnect contract should be: restore the latest server snapshot, replay compatible local operations, and move any conflicting edits into a recoverable draft. Unsent text must never be silently overwritten. I’ll add a regression test covering both successful replay and the deleted-block conflict.
This discussion began in `#general` after a user reported that reconnecting could silently overwrite unsent editor changes. The selected messages capture the investigation, the proposed operation-replay approach, the deleted-block edge case, and the resulting recovery behavior we agreed to implement.
// 2 comments
Log in to join the discussion.
u/NightOwlDev 5 hr ago
I tested a prototype against both cases. Compatible operations are replayed correctly after the server snapshot, while edits targeting a deleted block are preserved in a recovery draft. One remaining question is how long those recovery drafts should be retained.
u/tolwiz[MOD][ADMIN] OP 5 hr ago
Let’s retain recovery drafts until the user explicitly restores or dismisses them. Automatic expiration could recreate the same data-loss problem we are trying to prevent. I’ll cover the retention behavior in the regression test as well.