diff --git a/internal/web/server_test.go b/internal/web/server_test.go index 07186722..ba171c05 100644 --- a/internal/web/server_test.go +++ b/internal/web/server_test.go @@ -1751,6 +1751,17 @@ func TestHandlerIndexServesHTML(t *testing.T) { !strings.Contains(markup, `displayRepos = [openRepo];`) { t.Fatalf("expected index html chat to render closable prompted repository tabs, icon-only repos tab, and isolate active repository chat") } + syncChatOpenRepoKeyIndex := strings.Index(markup, `function syncChatOpenRepoKey(pageRepos, selectedTab, restoreFocusKey)`) + selectedChatTabIndex := -1 + focusedChatRepoIndex := -1 + if syncChatOpenRepoKeyIndex >= 0 { + syncChatOpenRepoKeyMarkup := markup[syncChatOpenRepoKeyIndex:] + selectedChatTabIndex = strings.Index(syncChatOpenRepoKeyMarkup, `if (selectedTab?.key) {`) + focusedChatRepoIndex = strings.Index(syncChatOpenRepoKeyMarkup, `if (restoreFocusKey && visibleKeys.includes(restoreFocusKey)) {`) + } + if syncChatOpenRepoKeyIndex < 0 || selectedChatTabIndex < 0 || focusedChatRepoIndex < 0 || selectedChatTabIndex > focusedChatRepoIndex { + t.Fatalf("expected selected chat repository tab to control the open repo before restoring textarea focus") + } if !strings.Contains(markup, `if (viewingRepoChat) { chatStatus.textContent = "";`) { t.Fatalf("expected active repository chat to clear repository count status") diff --git a/internal/web/static/index.html b/internal/web/static/index.html index cdaf7844..8e1bc447 100644 --- a/internal/web/static/index.html +++ b/internal/web/static/index.html @@ -6843,6 +6843,10 @@