If a user disabled the 'remember open tabs' option, Sidewise should ideally still remember information about those open tabs, and if Chrome restores open tabs upon browser launch or later, Sidewise should resurrect those open tabs with their original tree position and other data as accurately as possible.
One possible approach is to load the saved tree into memory but don't actually display its contents in the sidebar immediately; keep it around as a "phantom tree" and should we detect the need to do page reassociations either on browser launch or afterwards, secondarily look into this phantom tree for a matching remembered page element. If such an element is found, transfer it to the "real" tree and restore its position as accurately as possible, using known parent/child/before-sibling/after-sibling elements from its entry in the phantom tree to determine the best insertion point into the real tree.
In particular, to support this we would need to allow for inserting a row from the phantom tree into the real tree as a parent of some existing (already transferred) nodes. This would allow us to properly rebuild a branch of the tree if child rows get restored prior to their parent rows.
Once implemented, the 'remember open tabs' option actually becomes 'show open tabs from previous sessions in Last Session windows', since prior open-tab data will always get retained and the option will only control whether we actually show those open tabs as hibernated-restorable tabs within Last Session windows upon browser relaunch.
If a user disabled the 'remember open tabs' option, Sidewise should ideally still remember information about those open tabs, and if Chrome restores open tabs upon browser launch or later, Sidewise should resurrect those open tabs with their original tree position and other data as accurately as possible.
One possible approach is to load the saved tree into memory but don't actually display its contents in the sidebar immediately; keep it around as a "phantom tree" and should we detect the need to do page reassociations either on browser launch or afterwards, secondarily look into this phantom tree for a matching remembered page element. If such an element is found, transfer it to the "real" tree and restore its position as accurately as possible, using known parent/child/before-sibling/after-sibling elements from its entry in the phantom tree to determine the best insertion point into the real tree.
In particular, to support this we would need to allow for inserting a row from the phantom tree into the real tree as a parent of some existing (already transferred) nodes. This would allow us to properly rebuild a branch of the tree if child rows get restored prior to their parent rows.
Once implemented, the 'remember open tabs' option actually becomes 'show open tabs from previous sessions in Last Session windows', since prior open-tab data will always get retained and the option will only control whether we actually show those open tabs as hibernated-restorable tabs within Last Session windows upon browser relaunch.