09f26ed9a7dcc52b03b4d3e5b2f97c5177cd9334
max
  Mon Sep 21 06:00:40 2026 -0700
Drop the ${hgsid} trackDb variable; add session ids to links in the browser instead

A description page's links can carry the session id without the page itself holding
one.  addHgsidToLinks() in utils.js walks the rendered page and appends hgsid to every
<a href> that stays on this host and points into the same cgi-bin directory: a relative
CGI link gets one, a static .html, a link to another host, a mailto and a plain #anchor
do not, and a link that already names a session is left alone.  hgc and hgTrackUi call
it through a new jsAddHgsidToLinks(), and hgTracks.js calls it on the track description
popup once the ajax content is in.  A link written with a literal $hgsid is rewritten
rather than skipped, so the description pages already deployed in the GenArk hubs work
again.

hVarSubst no longer knows about hgsid: it is out of the trackDb variable list, so
hVarSubstTrackDbHtml is a hub-only pass again and needs no cart, and hVarSubstWithCart
and webIncludeHelpFileSubst, which existed only to resolve it, are gone.  The variable
is taken out of the trackDb README and out of the twenty-odd description pages that
used it.

refs #38380

diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c
index d45e5586048..d117c9271d6 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -3771,34 +3771,33 @@
 {
 trackDbPrintOrigAssembly(tdb, database);
 }
 
 static char *getHtmlFromSelfOrParent(struct trackDb *tdb, char *liftDb)
 /* Get html from self or from parent if not in self. */
 {
 for (;tdb != NULL; tdb = tdb->parent)
     {
     if (sameString(trackHubSkipHubName(tdb->track), "quickLiftChain"))
         tdb->html = hFileContentsOrWarning(hHelpFile(trackHubSkipHubName(tdb->track)));
     if (liftDb && isEmpty(tdb->html))
         tdb->html = getTrackHtml(liftDb, tdb->table);
     if (tdb->html != NULL && tdb->html[0] != 0)
         {
-        // resolve $hgsid, which hgTrackDb had no cart to resolve, and for a hub the rest of
-        // its description page variables: a hub page never went through hgTrackDb at all.
-        // tdb is the track the html belongs to, so $parentTrack means its container.
-        hVarSubstTrackDbHtml(cart, tdb, database);
+        // a hub's description page never went through hgTrackDb, so resolve its variables
+        // here.  tdb is the track the html belongs to, so $parentTrack means its container.
+        hVarSubstTrackDbHtml(tdb, database);
         return tdb->html;
         }
     }
 return NULL;
 }
 
 void printTrackHtml(struct trackDb *tdb)
 /* If there's some html associated with track print it out. Also print
  * last update time for data table and make a link
  * to the TB table schema page for this table. */
 {
 // safety net: a few detail pages never print a position, so flush the iframe here
 printPendingIframe();
 if (!isCustomTrack(tdb->track) && !isMyVariantsType(tdb->type))
     {
@@ -3814,30 +3813,31 @@
 char *html = getHtmlFromSelfOrParent(tdb, liftDb);
 if (html != NULL && html[0] != 0)
     {
     htmlHorizontalLine();
 
     // Add pennantIcon
     printPennantIconNote(tdb);
 
     // Wrap description html in div with limited width, so when the page is very wide
     // due to long details, the user doesn't have to scroll right to read the description.
     puts("<div class='readableWidth'>");
     puts(html);
     puts("</div>");
     }
 hPrintf("<BR>\n");
+jsAddHgsidToLinks();
 }
 
 static struct chain *quickLiftChainInRange(struct trackDb *tdb, int id)
 /* Load one chain out of the assembly the track came from and map it onto the reference.
  * Every chain in the window is loaded and then matched on id, rather than asking for the
  * one id:  the chain's sequence name in the other assembly is not known here, and the
  * by-id loaders abort when the id is not in the range they were given. */
 {
 char *liftDb = trackDbSetting(tdb, "quickLiftDb");
 char *table = NULL;
 quickLiftResolveTable(tdb, trackHubSkipHubName(tdb->table), &table, &liftDb);
 char *quickLiftFile = trackDbSetting(tdb, "quickLiftUrl");
 
 char *chainFile = NULL, *linkFile = NULL;
 if (startsWith("big", tdb->type))