d7dd4f55e28699bb783563b8bece5bf23f392995
chmalee
  Wed May 13 11:07:57 2026 -0700
Adds hg.conf myVariantsDataDir for writing ctfiles outside trash/, per-db short/long label rename on hgTrackUi, and a shared removal helper so the hgTrackUi remove button, hgTracks trash icon, and hgCustom checkbox all function the same, refs #33808

diff --git src/hg/lib/customTrack.c src/hg/lib/customTrack.c
index 480e38744f2..0aac5925f5c 100644
--- src/hg/lib/customTrack.c
+++ src/hg/lib/customTrack.c
@@ -3,30 +3,31 @@
 
 /* Copyright (C) 2014 The Regents of the University of California 
  * See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */
 
 #include "common.h"
 #include "hash.h"
 #include "obscure.h"
 #include "memalloc.h"
 #include "portable.h"
 #include "errAbort.h"
 #include "errCatch.h"
 #include "linefile.h"
 #include "sqlList.h"
 #include "jksql.h"
 #include "customTrack.h"
+#include "myVariants.h"
 #include "ctgPos.h"
 #include "psl.h"
 #include "gff.h"
 #include "genePred.h"
 #include "net.h"
 #include "hdb.h"
 #include "hui.h"
 #include "cheapcgi.h"
 #include "wiggle.h"
 #include "hgConfig.h"
 #include "customFactory.h"
 #include "trashDir.h"
 #include "jsHelper.h"
 #include "botDelay.h"
 #include "wikiLink.h"
@@ -955,37 +956,47 @@
     if (cartVarExists(cart, CT_DO_REMOVE_VAR))
         selectedTable = cartOptionalString(cart, CT_SELECTED_TABLE_VAR);
     else
         selectedTable = cartOptionalString(cart, CT_UPDATED_TABLE_VAR);
     if (selectedTable)
         {
         for (ct = ctList; ct != NULL; ct = nextCt)
             {
             nextCt = ct->next;
             if (sameString(selectedTable, ct->tdb->track))
                 {
                 if (cartVarExists(cart, CT_DO_REMOVE_VAR))
                     {
                     /* remove a track if requested, e.g. by hgTrackUi */
                     removedCt = TRUE;
+                    /* myVariants tracks need type-specific cleanup so the
+                     * SQL-backed entry doesn't reappear next page load.
+                     * When the helper handled the cart cleanup itself we
+                     * skip the wide cartRemovePrefix below so other-
+                     * assembly per-db labels survive. */
+                    boolean handledByMyVariants =
+                        myVariantsHandleCtRemoval(ct, cart, genomeDb);
                     slRemoveEl(&ctList, ct);
+                    if (!handledByMyVariants)
+                        {
                         /* remove visibility variable */
                         cartRemove(cart, selectedTable);
                         /* remove configuration variables */
                         char buf[128];
                         safef(buf, sizeof buf, "%s.", selectedTable);
                         cartRemovePrefix(cart, buf);
+                        }
                     cartRemove(cart, CT_DO_REMOVE_VAR);
                     }
                 else
                     {
                     if (html && differentString(html, ct->tdb->html))
                         {
                         ct->tdb->html = html;
                         changedCt = TRUE;
                         }
                     }
                 break;
                 }
             }
         }
     cartRemove(cart, CT_DO_REMOVE_VAR);