There was a race condition where we could leave the tab active index pointing to the wrong pane. That meant that the tab information computed by the gui layer would see no panes marked as active, and thus would end up with no active tab. This commit fixes that by clamping the active index to the number of panes. refs: https://github.com/wez/wezterm/issues/2304