← back to Answer Cockpit
TK-11793: scan budget 150s + stale-while-revalidate scan (fleet scanner is ~90s at 59 sessions); honest stale flag when the last scan is old or was the fallback
6b98c039ad3994ff1c0689dbdbe9658d2843fac3 · 2026-09-16 09:19:53 -0700 · Steve Abrams
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Files touched
Diff
commit 6b98c039ad3994ff1c0689dbdbe9658d2843fac3
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Wed Sep 16 09:19:53 2026 -0700
TK-11793: scan budget 150s + stale-while-revalidate scan (fleet scanner is ~90s at 59 sessions); honest stale flag when the last scan is old or was the fallback
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---
lib/queue.js | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/lib/queue.js b/lib/queue.js
index 0982b12..eac370b 100644
--- a/lib/queue.js
+++ b/lib/queue.js
@@ -20,8 +20,13 @@ const ticketlane = require('./ticketlane');
const HOME = process.env.HOME || require('os').homedir();
const TS_PY = path.join(HOME, 'Projects/terminal-status/terminal_status.py');
const ALL_SH = path.join(HOME, '.claude/skills/allcolordots/allcolordots.sh');
-const CACHE_MS = 4000;
-const SCAN_TIMEOUT_MS = 45000;
+// 2026-09-16: at 59 live sessions the dot scanner takes ~90s (iTerm2 itself at 150% CPU), so a
+// 45s budget made it fail → allcolordots fallback → stale → WARN. Budget it for reality and let
+// the last good scan serve requests while a fresh one runs in the background (never a fake PASS:
+// stale:true is still surfaced when the LAST scan was the fallback or older than STALE_AFTER_MS).
+const CACHE_MS = 15000;
+const SCAN_TIMEOUT_MS = 150000;
+const STALE_AFTER_MS = 5 * 60 * 1000;
// copied from terminal_status.py:48-63
const COLORS = {
@@ -88,6 +93,12 @@ async function rawScan() {
async function scan() {
if (cached && Date.now() - cached.ts < CACHE_MS) return cached.result;
+ // Stale-while-revalidate for the SCAN too: if a scan is running and we have a previous one,
+ // serve it (flagged stale when it is genuinely old) instead of waiting ~90s.
+ if (inflight && cached) {
+ const age = Date.now() - cached.ts;
+ return { ...cached.result, stale: !!cached.result.stale || age > STALE_AFTER_MS, scanAgeMs: age, refreshing: true };
+ }
if (inflight) return inflight;
inflight = rawScan().then((res) => {
cached = { ts: Date.now(), result: res };
← 191e46b TK-11793: pane watcher only while a viewer is polling, 60s i
·
back to Answer Cockpit
·
TK-11793: true stale-while-revalidate for the scan — expired 493f3d8 →