8fcdc8d74c55bc1ea951d03cfe374491b87285b4
chmalee
  Fri Feb 13 16:40:26 2026 -0800
When disconnecting an assembly hub on hgHubConnect, remove any of those assembly hub genomes from the recents list in localStorage. If the last connected db was one of those hubs, clear the db, org and genome cart variables and reset the db variable back to the default hg38, otherwise the first row of defaultDb is chosen as the current genome, refs #36535

diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c
index 9a2d0ff0e6f..2ebe53860ac 100644
--- src/hg/hgHubConnect/hgHubConnect.c
+++ src/hg/hgHubConnect/hgHubConnect.c
@@ -329,32 +329,33 @@
     safef(hubName, sizeof(hubName), "%s%u", hgHubConnectHubVarPrefix, hub->id);
     if (!cartUsualBoolean(cart, hubName, FALSE))
 	continue;
 
     if (count)
 	webPrintLinkTableNewRow();  // ends last row and starts a new one
     count++;
 
     puts("<tr>");
 
     ourCellStart();
     safef(id, sizeof id, "hubDisconnectButtonU%d", count);
     printf("<input name=\"hubDisconnectButton\" id='%s' "
 	"class=\"hubDisconnectButton\" type=\"button\" value=\"Disconnect\">\n", id);
     jsOnEventByIdF("click", id,
+	"removeRecentGenomesByHubUrl('%s');"
 	"document.disconnectHubForm.elements['hubId'].value='%d';"
-	"document.disconnectHubForm.submit(); return true;", hub->id);
+	"document.disconnectHubForm.submit(); return true;", javaScriptLiteralEncode(hub->hubUrl), hub->id);
     ourCellEnd();
 
     if (hub->trackHub != NULL)
 	{
 	ourPrintCellLink(hub->trackHub->shortLabel, hub->hubUrl);
 	}
     else
 	ourPrintCell("");
 
     boolean hubHasError = (!isEmpty(hub->errorMessage));
     if (hubHasError)
 	{
 	ourCellStart();
 	printf("<span class=\"hubError\">ERROR: %s </span>"
 	    "<a TARGET=_BLANK href=\"../goldenPath/help/hgTrackHubHelp.html#Debug\">Debug Help</a>\n", 
@@ -658,32 +659,33 @@
 int id = hubInfo->id;
 char jsId[256];
 struct slName *dbListNames = slNameListFromComma(hubInfo->dbList);
 printf("<tr>\n");
 if (id != 0)
     {
     ourCellStart();
     char hubName[32];
     safef(hubName, sizeof(hubName), "%s%u", hgHubConnectHubVarPrefix, id);
     if (cartUsualBoolean(cart, hubName, FALSE))
         {
         safef(jsId, sizeof jsId, "hubDisconnectButtonP%d", count);
         printf("<input name=\"hubDisconnectButton\" id='%s' "
             "class=\"hubDisconnectButton\" type=\"button\" value=\"Disconnect\">\n", jsId);
         jsOnEventByIdF("click", jsId,
+            "removeRecentGenomesByHubUrl('%s');"
             "document.disconnectHubForm.elements['hubId'].value= '%d';"
-            "document.disconnectHubForm.submit();return true;", id);
+            "document.disconnectHubForm.submit();return true;", javaScriptLiteralEncode(hubInfo->hubUrl), id);
         }
     else
         {
         // get first name off of list of supported databases
         char * name = dbListNames->name;
 
         // if the name isn't currently loaded, we assume it's a hub
         if (!hDbExists(name))
             {
             char buffer[512];
             safef(buffer, sizeof buffer, "hub_%d_%s",  id, name);
             name = cloneString(buffer);
             }
 
         safef(jsId, sizeof jsId, "hubConnectButton%d", count);