Closed okdistribute closed 2 years ago
Yes, we definitely need to improve this. See also issues #4 and #374 for previous discussions of the same problem. If you want to have a go at fixing this, I can help you get started.
Thanks for the test case. I think I've fixed the bug on #446 — can you give it a try?
This test fails after I save and then re-load the document. If you remove lines 1445 and 1446, the tests pass. If you port this test to preview.4, the test passes. So this seems to be a bug somewhere between preview.4 and preview.5. I did a git bisect and found that hash 325f9e8f7d4a16ed7a168494161cecf47185aea9 is the first bad commit.
This is a hack for supporting branching and merging from unrelated documents that were created within the same app. It is not directly supported by the Automerge API, which is probably how the bug snuck through. I think it's important to make this hack more automatic in the Automerge API. If I get some time to think about it I can say more or make a suggestion about how the API should work. Without this, there is no way to get reliable behavior for merging two branched documents that don't start with a single author.
EDIT: On further investigation, I found that
changeIndexByHash
does not contain actor0000
in the re-hydrated version of the document. https://github.com/automerge/automerge/blob/main/backend/new.js#L1523