[object Object]

← back to Desktop Dotbar

dotbar: keep-last-good so a slow/empty scan never flaps the live count to 0

f72f77bf1581fba4bb05fcc3ace827db426960b0 · 2026-09-16 08:38:13 -0700 · Steve Abrams

The allcolordots scan can take 60-90s on a loaded box with many sessions; a timed-out
or empty scan returns 0 rows and was overwriting the good snapshot with total:0 (the bar
flipped back to '0 live'). Now refresh() only replaces the snapshot on a real result (>0)
or the first run, and the execFile cap is 120s. The bar holds the last good count between
slow refreshes instead of zeroing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AuZ7T3ffxRGXj5rrwgbquD

Files touched

Diff

commit f72f77bf1581fba4bb05fcc3ace827db426960b0
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Wed Sep 16 08:38:13 2026 -0700

    dotbar: keep-last-good so a slow/empty scan never flaps the live count to 0
    
    The allcolordots scan can take 60-90s on a loaded box with many sessions; a timed-out
    or empty scan returns 0 rows and was overwriting the good snapshot with total:0 (the bar
    flipped back to '0 live'). Now refresh() only replaces the snapshot on a real result (>0)
    or the first run, and the execFile cap is 120s. The bar holds the last good count between
    slow refreshes instead of zeroing.
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01AuZ7T3ffxRGXj5rrwgbquD
---
 server.js | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/server.js b/server.js
index 67f9297..1018e47 100755
--- a/server.js
+++ b/server.js
@@ -42,9 +42,10 @@ function ticketOf(label) {
 }
 
 async function getDots() {
-  // allcolordots scans every terminal and takes ~9-10s on a busy fleet; the default 8s cap
-  // timed out every refresh -> empty output -> the bar showed "0 live". Give it 25s headroom.
-  const { stdout } = await run('bash', [ALLCOLORDOTS, '--json'], 25000);
+  // allcolordots scans every terminal; on a busy/loaded box (many sessions) it can take 60-90s.
+  // The default 8s cap timed out every refresh -> empty output -> the bar showed "0 live". Give a
+  // generous cap; keep-last-good (in refresh()) covers the interim so the bar never flaps to 0.
+  const { stdout } = await run('bash', [ALLCOLORDOTS, '--json'], 120000);
   let rows = [];
   try { rows = JSON.parse(stdout || '[]'); } catch { rows = []; }
   rows = rows.filter(r => r && r.live); // only live sessions count as "running"
@@ -109,7 +110,12 @@ let refreshing = false;
 async function refresh() {
   if (refreshing) return;
   refreshing = true;
-  try { snapshot = { ...(await getDots()), stale: false }; } catch (e) { /* keep last */ }
+  try {
+    const next = await getDots();
+    // KEEP-LAST-GOOD: a slow/timed-out/errored scan returns 0 rows; never let that zero out a
+    // known-good count (the "0 live" flap). Accept a real result, or the very first run.
+    if (next.total > 0 || snapshot.updated === 0) snapshot = { ...next, stale: false };
+  } catch (e) { /* keep last */ }
   finally { refreshing = false; }
 }
 

← ef1d433 dotbar: fix '0 live' (scan timeout) + resizable bar (drag/Ta  ·  back to Desktop Dotbar  ·  dotbar: drop bare-Tab global resize hotkeys; keep drag grip 0d25ad6 →