94041c12e043016875ebd340568bda0ccaf122f6
lrnassar
  Wed Jul 8 13:53:22 2026 -0700
Add db= to cross-CGI hgTracks/hgTrackUi/hgc links to prevent wrong-assembly errors. refs #37840

Completes the incomplete work from #26892: links from the browser to a different
CGI omitted db=, so the target CGI fell back to the cart's db (often wrong),
producing "Can't find <track> in track database <db>" errors and broken shared
links. Adds the current-assembly db to link builders across hgTracks
(chromGraphTrack, expRatioTracks, config ruler and per-track configure links,
variation), hgVai, hgFileUi, hgGtexTrackSettings, hgBlat, hgGene, hgNear, the
barChart/GTEx faceted UI (facetedBar, barChartUi, gtexUi), and the hgTrackUi
group-configure link.

diff --git src/hg/hgc/facetedBar.c src/hg/hgc/facetedBar.c
index 9770a420b76..b9786d765f2 100644
--- src/hg/hgc/facetedBar.c
+++ src/hg/hgc/facetedBar.c
@@ -107,31 +107,31 @@
 
 facetedTableUpdateOnClick(facTab, cart);
 struct facetField **selectedFf = NULL;
 struct fieldedTable *selected = facetedTableSelect(facTab, cart, &selectedFf);
 
 /* Write html to make white background */
 hInsideStyleToWhite();
 
 /* Add a few extra status bits  and a way back home before facets and table display */
 printf("&nbsp;&nbsp;<B>Bars selected:</B> %d of %d", selected->rowCount, table->rowCount);
 printf("&nbsp;&nbsp;&nbsp;&nbsp;<b><a href=%s>Return to Genome Browser</href></a></b><p>\n", 
                      hgTracksPathAndSettings());
 
 /* Set up url that has enough context to get back to us.  */
 struct dyString *returnUrl = dyStringNew(0);
-dyStringPrintf(returnUrl, "../cgi-bin/hgc?g=%s", trackName);
+dyStringPrintf(returnUrl, "../cgi-bin/hgc?db=%s&g=%s", database, trackName);
 if (item != NULL)
     dyStringPrintf(returnUrl, "&i=%s", item);
 dyStringPrintf(returnUrl, "&%s", cartSidUrlString(cart));
 
 /* Working within a form we save context.  It'd be nice to work outside of form someday. */
 printf("<form action=\"../cgi-bin/hgc\" name=\"facetForm\" ");
 printf("method=\"GET\">\n");
 printf("<div style=\"background-color:white\">");
 cartSaveSession(cart);
 cgiContinueHiddenVar("g");
 cgiContinueHiddenVar("i");
 
 char *valFieldName = "val";
 
 boolean singleCell = !trackDbSettingOff(tdb, "singleCellColumnNames");