Description
We have a class of UX problems where out-of-order or incomplete changes are "applied" but without making any visible change to the document because their dependencies have not arrived. This is surprising to users.
Automerge is designed to accept changes in any order they arrive and queue those changes until their dependencies are all present. A user can call applyChanges()
repeatedly as changes come in from any source
We've seen this reported as a bug more than once now, particularly with Automerge.from
. If we look at this issue, we see a user reasonably expecting that calling getChanges()
on the output of Automerge.from
and then apply the result to another document doesn't work. Why? It's because Automerge.from()
makes an invisible change after Automerge.init()
which the user did not realize was happening and the subsequent Automerge.getChanges()
does not work as expected.
I'm not sure exactly what the solution is. Long term, it's probably something along the line of discouraging the use of manually calling getChanges()
to synchronize two documents, but that's a bit unsatisfying. I think shorter-term, I might consider changing the default behaviour of applyChanges()
to throw an error if the changes can't be applied and adding a second receiveChanges()
(or something) which more explicitly manages out-of-order changes but... this is a bit unconsidered.
(As an aside, this is somewhat related to but different from a problem that occurs when a user tries to merge documents created independently on two nodes with the same structure and is confused why changes from only one system are visible.)