994528edb7d89068f371fef6d8a5fc72566f7334
lrnassar
  Fri Sep 4 13:35:16 2026 -0700
Adding an opt-in "Keep only last search" checkbox to the new BLAT search form. refs #36292

Behind a new hg.conf setting, blatOnlyLatestCheckbox (default off, documented in ex.hg.conf).
When checked, each new BLAT search removes the user's earlier BLAT result tracks in hgc's
buildBigPsl (cart variable blatOnlyLatest, remembered per browser in localStorage); unchecked
keeps the current accumulate behavior, so site defaults are unchanged. Deletion requires both
the hg.conf setting and the cart variable, so a stale cart cannot delete tracks where the
feature is off. Independent of, and coexists with, the blatOldTracks hg.conf setting.

diff --git src/hg/hgBlat/hgBlat.c src/hg/hgBlat/hgBlat.c
index ec5c178f7f3..4b4d345c698 100644
--- src/hg/hgBlat/hgBlat.c
+++ src/hg/hgBlat/hgBlat.c
@@ -2773,30 +2773,37 @@
 /* Sort and output have no dropdown on this page - hgBlat.js submits them as hidden fields, so the
  * request is unchanged.  They are pinned to the defaults rather than read from the cart: with no
  * control to change them, a stale cart value (say output=psl left over from the classic form) would
  * otherwise be stuck for the rest of the session with no way for the user to get back. */
 jsonWriteString(jw, "sort", pslSortList[0]);      /* "query,score" */
 jsonWriteString(jw, "output", outputList[0]);     /* "hyperlink" */
 jsonWriteBoolean(jw, "allResults", allResults);
 jsonWriteBoolean(jw, "autoRearr", autoRearr);
 jsonWriteBoolean(jw, "allGenomes", allGenomes);
 /* "Keep results" only means something on a machine configured to clear earlier BLAT result tracks.
  * With blatOldTracks at its "keep" default, or at "hide", there is nothing to opt out of, so the
  * checkbox is not shown at all.  hgc.c (buildBigPsl) is what acts on blatKeepResults. */
 jsonWriteBoolean(jw, "showKeepResults",
                  sameString(cfgOptionDefault("blatOldTracks", "keep"), "delete"));
 jsonWriteBoolean(jw, "keepResults", cartUsualBoolean(cart, "blatKeepResults", FALSE));
+/* "Keep only last search" checkbox (RM #38086): the inverse framing - results accumulate by
+ * default (the current public behavior) and checking the box opts into removing earlier BLAT
+ * result tracks on each new search.  Gated by its own hg.conf setting, independent of
+ * blatOldTracks above; hgc.c (buildBigPsl) is what acts on blatOnlyLatest. */
+jsonWriteBoolean(jw, "showOnlyLatest",
+    sameString(cfgOptionDefault("blatOnlyLatestCheckbox", "off"), "on"));
+jsonWriteBoolean(jw, "onlyLatest", cartUsualBoolean(cart, "blatOnlyLatest", FALSE));
 /* The example is fetched on demand rather than inlined: it is a real 2.5 kb sequence, which would
  * otherwise be embedded in every page load of the form just to serve the few users who click
  * "Load example".  The sequence is a window over two PTP4A3 exons that is also carried by an alt
  * haplotype and a fix patch of chr8, so the results table shows the alt/fix rows and their
  * explanatory icons rather than a single boring hit. */
 jsonWriteString(jw, "exampleUrl", "../goldenPath/help/blatExample.fa");
 jsonWriteString(jw, "exampleLabel", "Load example - human PTP4A3 gene");
 /* Same "similar tools" links the classic page offered, so the sidebar isn't a set of dead links.
  * These carry $DB$ rather than a baked-in db: picking a genome no longer reloads the page, so
  * blatFormSetDb() re-expands them against the newly chosen assembly.
  *
  * Deliberately NOT gated on hgPcrOk() the way the classic form was.  That test can only be made for
  * the assembly the page happened to load with, so on a page where the genome can be changed without
  * a round trip it goes stale immediately: loading on an assembly without a PCR server would hide
  * these links for the rest of the session, even after switching to hg38.  hgPcr reports an