From 21d901577c298d0edd41fd6d2172016921281b17 Mon Sep 17 00:00:00 2001 From: moltenhub-bot Date: Tue, 12 May 2026 22:01:15 -0700 Subject: [PATCH] chore: When switching through chats that are open, I can see the chat Co-authored-by: Molten Bot 000 <260473928+moltenbot000@users.noreply.github.com> --- internal/web/server_test.go | 11 +++++++++++ internal/web/static/index.html | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) 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 @@

Connect to Hub

const visibleKeys = pageRepos .map((repo) => chatRepoKey(chatRepoRunValue(repo))) .filter(Boolean); + if (selectedTab?.key) { + state.chatOpenRepoKey = selectedTab.key; + return; + } if (restoreFocusKey && visibleKeys.includes(restoreFocusKey)) { state.chatOpenRepoKey = restoreFocusKey; return; @@ -6850,10 +6854,6 @@

Connect to Hub

if (state.chatOpenRepoKey && visibleKeys.includes(state.chatOpenRepoKey)) { return; } - if (selectedTab?.key && visibleKeys.includes(selectedTab.key)) { - state.chatOpenRepoKey = selectedTab.key; - return; - } state.chatOpenRepoKey = visibleKeys[0] || ""; }