git-watchtower 2.3.18 → 2.3.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1881,18 +1881,24 @@ async function pollGitChanges() {
1881
1881
  // Skip if a poll is already in progress (don't queue)
1882
1882
  if (pollMutex.isLocked()) return;
1883
1883
  const pollToken = await pollMutex.acquire();
1884
- store.setState({ isPolling: true, pollingStatus: 'fetching' });
1885
1884
 
1886
- // Casino mode: start slot reels spinning (no sound - too annoying)
1887
- if (store.get('casinoModeEnabled')) {
1888
- casino.startSlotReels(render);
1889
- }
1885
+ // Everything past acquire() must be wrapped so the finally releases
1886
+ // the token. The previous shape kept the setState / casino.startSlotReels
1887
+ // / render() calls outside the try, so a throw from any of them (e.g. a
1888
+ // store middleware error, a casino interval-setup failure) leaked the
1889
+ // mutex permanently and stalled every subsequent poll cycle.
1890
+ try {
1891
+ store.setState({ isPolling: true, pollingStatus: 'fetching' });
1890
1892
 
1891
- render();
1893
+ // Casino mode: start slot reels spinning (no sound - too annoying)
1894
+ if (store.get('casinoModeEnabled')) {
1895
+ casino.startSlotReels(render);
1896
+ }
1892
1897
 
1893
- const fetchStartTime = Date.now();
1898
+ render();
1899
+
1900
+ const fetchStartTime = Date.now();
1894
1901
 
1895
- try {
1896
1902
  const newCurrentBranch = await getCurrentBranch();
1897
1903
  const prevCurrentBranch = store.get('currentBranch');
1898
1904
 
@@ -2004,12 +2010,10 @@ async function pollGitChanges() {
2004
2010
  const updatedBranches = [];
2005
2011
  const updatedBranchPrevCommits = new Map();
2006
2012
  const currentBranchName = store.get('currentBranch');
2007
- const activeBranchNames = new Set();
2008
2013
  for (const branch of pollFilteredBranches) {
2009
2014
  // Clear previous cycle's flag so only freshly-updated branches are highlighted
2010
2015
  branch.justUpdated = false;
2011
2016
  if (branch.isDeleted) continue;
2012
- activeBranchNames.add(branch.name);
2013
2017
  const prevCommit = previousBranchStates.get(branch.name);
2014
2018
  if (prevCommit && prevCommit !== branch.commit && branch.name !== currentBranchName) {
2015
2019
  updatedBranches.push(branch);
@@ -2019,17 +2023,13 @@ async function pollGitChanges() {
2019
2023
  previousBranchStates.set(branch.name, branch.commit);
2020
2024
  }
2021
2025
 
2022
- // Remove stale entries from caches for branches
2023
- // that no longer exist in the current poll results
2024
- const staleCaches = [previousBranchStates, prInfoCache, store.get('sparklineCache'), store.get('aheadBehindCache')];
2025
- for (const cache of staleCaches) {
2026
- if (!cache) continue;
2027
- for (const name of cache.keys()) {
2028
- if (!activeBranchNames.has(name)) {
2029
- cache.delete(name);
2030
- }
2031
- }
2032
- }
2026
+ // (No second prune pass here pruneStaleEntries above already prunes
2027
+ // these four caches against fetchedBranchNames with a 30 s deleted-
2028
+ // branch grace period. The previous extra loop pruned against the
2029
+ // active-only set instead, which excluded isDeleted entries and so
2030
+ // wiped a recently-deleted branch's sparkline / PR status / ahead-
2031
+ // behind data IMMEDIATELY contradicting the retention window the
2032
+ // first prune was specifically designed to provide.)
2033
2033
 
2034
2034
  // Flash and sound for updates or new branches
2035
2035
  const casinoOn = store.get('casinoModeEnabled');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-watchtower",
3
- "version": "2.3.18",
3
+ "version": "2.3.20",
4
4
  "description": "Terminal-based Git branch monitor with activity sparklines and optional dev server with live reload",
5
5
  "main": "bin/git-watchtower.js",
6
6
  "bin": {
package/src/ui/ansi.js CHANGED
@@ -296,8 +296,15 @@ const NON_SGR_CSI_RE = /\x1b\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x6c\x6e-\x7e]/g;
296
296
 
297
297
  // Match OSC sequences: ESC ] ... terminator (BEL or ESC \). These set
298
298
  // terminal title, hyperlinks, etc. — all undesirable in untrusted input.
299
+ // The trailing `|$` alternation also matches an UNTERMINATED OSC tail
300
+ // (`\x1b]0;evil-text` with no \x07 / \x1b\\ before EOF). Without it,
301
+ // the literal payload survived sanitisation as visible text — ESC_RE
302
+ // stripped the leading `\x1b]` since `]` is in the `\\-_` range, but
303
+ // "0;evil-text" remained. Per ECMA-48, an unterminated OSC at EOF is
304
+ // effectively an open control string, so dropping it entirely is the
305
+ // safe default.
299
306
  // eslint-disable-next-line no-control-regex
300
- const OSC_RE = /\x1b\][\s\S]*?(?:\x07|\x1b\\)/g;
307
+ const OSC_RE = /\x1b\][\s\S]*?(?:\x07|\x1b\\|$)/g;
301
308
 
302
309
  // Match other 2-byte ESC sequences (Fe codes 0x40-0x5F) excluding CSI ([)
303
310
  // and OSC (]) which are handled separately above.