All writing
5 min readEngineeringDesign

Page history without a version-control degree

An editor that autosaves every second could keep a version every second. That list would be unusable. What Nex keeps instead, and why it records what a save replaced.

Page history is one of those features that is easy to ship and hard to ship usefully. The naive version is a snapshot per save. Because the editor autosaves on a debounce, that is a row roughly every second you are typing — a list too long to read, too expensive to keep, and made entirely of versions nobody wants.

A version is a session, not a save

Nex opens a version when you come back to a page after a break. The first save after a quiet period records what the page said before that session started; everything you type for the next while belongs to it.

That matches how people actually think about their own edits. Nobody wants the twelve states their paragraph passed through while they were writing it. They want “what did this page say before I sat down this morning”, and they want it after realising that the version from this morning was better.

It records the state a save replaced

This is the part that sounds backwards and is the whole idea. When you save, Nex snapshots the old content, not the new.

Recording the new content gives you a list of states you already have — the most recent one is on the page in front of you. Recording the state it replaced captures the only thing that is otherwise gone. Every entry in the history is a thing you can no longer see anywhere else, which is the definition of what a history is for.

Restoring is itself undoable

Before a restore overwrites anything, the current state is snapshotted too. So restoring an old version can be undone by restoring the version the restore created.

A restore that destroys what it replaced is a worse trap than the edit it was meant to fix, because people press it while they are already panicking. The feature has to be safe to try when you are not sure.

It shows you the version before you take it

The history dialog is two columns: versions on the left, the one you picked on the right. A list of timestamps with no preview asks you to restore something in order to find out what it was, which is exactly backwards.

The preview is plain text rather than the editor. Mounting a second editor to look at an old version means loading every node view — a whiteboard included — for something nobody is going to edit. Text is enough to answer “is this the one”, which is the only question being asked at that moment.

The title travels with the body

Restoring a version restores what the page was called at the time. A version is a record of what the page was, and restoring half of that leaves a document whose name describes an edit that is no longer there.

History is capped per page, and pruned oldest-first past the cap. Nobody reads past the first screenful, and an unbounded history is a storage bill in exchange for a list that gets less useful the longer it grows.