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/lib/cart.c src/hg/lib/cart.c
index 66874e63ad2..624ae97804a 100644
--- src/hg/lib/cart.c
+++ src/hg/lib/cart.c
@@ -1395,30 +1395,40 @@
     {
     char buffer[1024];
     safef(buffer, sizeof buffer, "hgHubConnect.hub.%s", id);
     cartRemove(cart, buffer);
 
     safef(buffer, sizeof buffer, "quickLift.%s", id);
     cartRemovePrefix(cart, buffer);
 
     // now we need to remove any custom tracks that are on this hub
     safef(buffer, sizeof buffer, "ctfile_hub_%s", id);
     cartRemovePrefix(cart, buffer);
 
     // remove any visibilities in the cart
     safef(buffer, sizeof buffer, "hub_%s", id);
     cartRemovePrefix(cart, buffer);
+
+    // if the current db belongs to this hub, reset to a valid default
+    char *db = cartOptionalString(cart, "db");
+    safef(buffer, sizeof buffer, "hub_%s_", id);
+    if (db != NULL && startsWith(buffer, db))
+        {
+        cartSetString(cart, "db", hDefaultDb());
+        cartRemove(cart, "org");
+        cartRemove(cart, "genome");
+        }
     }
 
 cartRemove(cart, "hubId");
 cartRemove(cart, hgHubDoDisconnect);
 }
 
 static void hideIfNotInCart(struct cart *cart, char *track)
 /* If this track is not mentioned in the cart, set it to hide */
 {
 if (cartOptionalString(cart, track) == NULL)
     cartSetString(cart, track, "hide");
 }
 
 void cartHideDefaultTracks(struct cart *cart)
 /* Hide all the tracks who have default visibilities in trackDb