git-watchtower 1.9.9 → 1.9.11

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.
@@ -732,6 +732,7 @@ const { ansi, box, truncate, sparkline: uiSparkline, visibleLength, stripAnsi, p
732
732
 
733
733
  // Error detection utilities imported from src/utils/errors.js
734
734
  const { ErrorHandler, isAuthError, isMergeConflict, isNetworkError } = require('../src/utils/errors');
735
+ const { Mutex } = require('../src/utils/async');
735
736
 
736
737
  // Keyboard handling utilities imported from src/ui/keybindings.js
737
738
  const { filterBranches } = require('../src/ui/keybindings');
@@ -1606,8 +1607,12 @@ async function stashAndRetry() {
1606
1607
  // Polling
1607
1608
  // ============================================================================
1608
1609
 
1610
+ const pollMutex = new Mutex();
1611
+
1609
1612
  async function pollGitChanges() {
1610
- if (store.get('isPolling')) return;
1613
+ // Skip if a poll is already in progress (don't queue)
1614
+ if (pollMutex.isLocked()) return;
1615
+ await pollMutex.acquire();
1611
1616
  store.setState({ isPolling: true, pollingStatus: 'fetching' });
1612
1617
 
1613
1618
  // Casino mode: start slot reels spinning (no sound - too annoying)
@@ -1728,10 +1733,12 @@ async function pollGitChanges() {
1728
1733
  // Detect updates on other branches (for flash notification)
1729
1734
  const updatedBranches = [];
1730
1735
  const currentBranchName = store.get('currentBranch');
1736
+ const activeBranchNames = new Set();
1731
1737
  for (const branch of pollFilteredBranches) {
1732
1738
  // Clear previous cycle's flag so only freshly-updated branches are highlighted
1733
1739
  branch.justUpdated = false;
1734
1740
  if (branch.isDeleted) continue;
1741
+ activeBranchNames.add(branch.name);
1735
1742
  const prevCommit = previousBranchStates.get(branch.name);
1736
1743
  if (prevCommit && prevCommit !== branch.commit && branch.name !== currentBranchName) {
1737
1744
  updatedBranches.push(branch);
@@ -1740,6 +1747,14 @@ async function pollGitChanges() {
1740
1747
  previousBranchStates.set(branch.name, branch.commit);
1741
1748
  }
1742
1749
 
1750
+ // Remove stale entries from previousBranchStates for branches
1751
+ // that no longer exist in the current poll results
1752
+ for (const name of previousBranchStates.keys()) {
1753
+ if (!activeBranchNames.has(name)) {
1754
+ previousBranchStates.delete(name);
1755
+ }
1756
+ }
1757
+
1743
1758
  // Flash and sound for updates or new branches
1744
1759
  const casinoOn = store.get('casinoModeEnabled');
1745
1760
  const notifyBranches = [...updatedBranches, ...newBranchList];
@@ -1956,6 +1971,7 @@ async function pollGitChanges() {
1956
1971
  }
1957
1972
  } finally {
1958
1973
  store.setState({ isPolling: false });
1974
+ pollMutex.release();
1959
1975
  render();
1960
1976
  }
1961
1977
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-watchtower",
3
- "version": "1.9.9",
3
+ "version": "1.9.11",
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": {