@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.
Ctrl-s
).
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.