← Lessons

quiz vs the machine

Gold1490

System Design

Version History and Undo

Tracking how a shared document evolved and undoing only your own edits.

6 min read · core · beat Gold to climb

Two related features

Version history lets users browse and restore past states, while undo reverses recent edits. Both rely on keeping the stream of operations rather than only the final text.

Snapshots plus log

Storing every keystroke forever is wasteful, so systems keep periodic snapshots of full state plus the operation log since the last snapshot. Restoring a version replays the log up to a chosen point on top of the nearest snapshot.

The collaborative undo twist

In a shared document, pressing undo should reverse your own last edit, not a coworker's. This needs selective undo: the system inverts a specific operation and transforms that inverse against everything that happened after it.

Per user undo stacks make this feel natural, since each person controls only their own history.

Key idea

Version history and collaborative undo store snapshots plus an operation log so users can restore states and selectively reverse their own edits.

Check yourself

Answer to earn rating on the learn ladder.

1. Why combine snapshots with an operation log?

2. What does collaborative undo need that single user undo does not?

3. How is a chosen version reconstructed?