There is a bit of an "action at a distance" problem with how session manager's state as it is perceived by various components. A specific example is the tabs tray interaction with the toolbar. If one tab is currently opened (one session is present in the manager), closing that tab will leave session manager with no sessions.
However, toolbar component assumes presence of a current session - so if you were to open a url, it'll crash as it hits a null
current session.
At first glance, this seems like a problem at an interface level between the session manager and its consumers. There are two methods to get a session, one of which will throw if set of sessions is empty. So the implicit contract is "you decide if I may be empty". Inevitably this leads to problems like the one I described above, where two parts of the system make different assumptions.
One way to address this would be to enforce a behaviour at the manager level - i.e. a "must have a default session" type of a session manager, which would be responsible for enforcing that behaviour. ISTM that we'd need this anyway for something like the "new tab" panel, but more generally it should help avoid having components step on each other's toes.
This kind of pattern likely generalizes well to other types of "in-between" components as well.
┆Issue is synchronized with this Jira Task