0df5f6317fd6e0033a31aaf56b928f574823075c
chmalee
  Wed Jun 3 11:06:54 2026 -0700
Recommended track sets now can load from a file in htdocs/data/recTrackSets/db/sessionName. The settings are overlayed onto the current cart and no reload of the page is required anymore, refs #37281

diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c
index dda58090698..c861e4c7ebc 100644
--- src/hg/hgTracks/hgTracks.c
+++ src/hg/hgTracks/hgTracks.c
@@ -7531,48 +7531,60 @@
     {
     // store session name and user
     char *otherUserName = cartOptionalString(cart, hgsOtherUserName);
     char *otherUserSessionName = rtsLoad;
 
     // Hide all tracks except custom tracks
     struct hash *excludeHash = newHash(2);
     hashStore(excludeHash, "user");
     changeTrackVisExclude(groupList, NULL, tvHide, excludeHash);
 
     // delete any ordering we have
     char wildCard[32];
     safef(wildCard,sizeof(wildCard),"*_%s",IMG_ORDER_VAR);
     cartRemoveLike(cart, wildCard);
 
-    // now we have to restart to load the session since that happens at cart initialization
-    
+    if (loadRecTrackSetFromFile(cart, rtsLoad))
+        {
+        // Settings from the htdocs file are now overlaid on the cart.  The visibility
+        // loop below and the draw path read them, so no redirect is needed.  Record
+        // which set is loaded so hasRecTrackSet() and change detection still work, and
+        // drop the one-shot action variable so it does not persist in the cart.
+        cartSetString(cart, hgsOtherUserSessionName, rtsLoad);
+        cartRemove(cart, "rtsLoad");
+        }
+    else
+        {
+        // No htdocs file for this set: fall back to loading the session from hgcentral.
+        // That happens at cart initialization, so we have to restart to load it.
         char newUrl[4096];
         safef(newUrl, sizeof newUrl,
             "./hgTracks?"
             hgsOtherUserSessionName "=%s"
             "&" hgsOtherUserName "=%s"
             "&" hgsMergeCart "=on"
             "&" hgsDoOtherUser "=submit"
             "&hgsid=%s"
             , otherUserSessionName, otherUserName,cartSessionId(cart));
 
         cartCheckout(&cart);   // make sure cart records all our changes above
 
         // output the redirect and exit
         printf("<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=%s\">", newUrl);
         exit(0);
         }
+    }
 
 boolean hideTracks = cgiOptionalString( "hideTracks") != NULL;
 if (hideTracks)
     changeTrackVis(groupList, NULL, tvHide);    // set all top-level tracks to hide
 
 /* Get visibility values if any from ui. */
 struct hash *superTrackHash = newHash(5);  // cache whether supertrack is hiding tracks or not
 char buffer[4096];
 
 // Check to see if we have a versioned default gene track and let the knownGene 
 // cart variable determine its visibility
 char *defaultGeneTrack = NULL;
 char *knownDb = hdbDefaultKnownDb(database);
 if (differentString(knownDb, database))
     defaultGeneTrack = hdbGetMasterGeneTrack(knownDb);