08 · History and diffs with Automerge

Many types of apps—spreadsheets, writing tools, design tools—could benefit from version control features like history, branching, and diffing. But common databases (like PostgreSQL, IndexedDB, or Core Data) offer a model focused only on a current snapshot of the user’s data, with little or no knowlege of history.

On Patchwork, we’ve been able to prototype very rapidly because we’re building on top of Automerge, a JSON data storage and synchronization library developed here at Ink & Switch.

Automerge was designed to support local-first software and uses a CRDT sync algorithm to merge together edits made on different devices, without the need for a central authority server. This internal machinery is also a good fit for version control interfaces:

It isn’t an accident that Automerge is a good fit for this domain: part of the project vision has always been supporting better versioning tools for collaborative work. It’s noteworthy how much alignment there is between the tools needed to support concurrent offline editing and version control tools—both require tracking history and support for concurrent editing.

In addition to using Automerge’s capabilities for rapid prototyping, part of the goal of Patchwork is to motivate future improvements to Automerge. We’ve tried improvements like attributing changes to authors in diffs, which was instrumental to our Edit Groups prototype. Then we’re working with the Automerge team on upstream changes to more deeply support user-facing version control features.

Next entry: 09 · Version history as chat

Sign up to the Ink & Switch Dispatch

Occasional stories from Ink & Switch about our work, publications, talks, and the people at the lab. Browse the archive.