@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.