@shida I finally have a repeatable repro! It’s a fun little edge case that I backed into from thinking about the protocol (thanks for going into the details there, it wouldn’t have been possible without that!).
Have Dynalist open in two tabs, A and B. Open dev console in tab A.
- Create item “Foo” in A with child item “Bar” and collapse “Foo”. Make sure it syncs to B.
- In the “network” tab of dev console on A change from “Online” to “Offline”.
- In A, zoom into the “Foo” item and delete “Bar”. The item is now no longer collapsed in A since it has no children.
- In B, zoom into the “Foo” item and add a new item “Baz”. It should remain collapsed and now have two children.
- Change A back to “Online” and sync changes (e.g.
Tab A should now be in an inconsistent state where it’s uncollapsed with child “Baz”, as opposed to B and and other clients which will have “Baz” and be collapsed. No matter how many times you sync or perform new changes tab A will remain in this inconsistent state.
The root cause is that an offline tab can move into an uncollapsed state while other clients (and thus the server) never become uncollapsed. This means there are no
collapse_changes to sync down to the uncollapsed client since from the perspective of the server the item never became uncollapsed (all other clients always had at least one child).
When I’ve experienced this problem I don’t think it was exactly like this repro, but it likely has the same root cause, so if the fix is fundamental enough it should hopefully resolve it (as opposed to just patching this one edge case). I still need to figure out what the exact case is when I’ve hit this in the past…
One robust solution is to always provide syncing clients the collapse state of new items’ parents, which should hopefully resolve this issue.
EDIT: Thinking about this a bit more, it’s likely that when I’ve experienced this I’ve quickly deleted the last item in a collapsed child and then put my computer to sleep before the collapsed change is synced, but after the item deletion synced (was able to repro locally that that can occur). I think even switching tabs is sometimes sufficient to prevent the collapsed state syncing from occurring.