From 8e436d0da297aa652f778c7205ac630c861115c4 Mon Sep 17 00:00:00 2001 From: "Junaid Y. Sheikh" Date: Thu, 16 Jul 2026 04:40:26 +0500 Subject: [PATCH] fix(ui): preserve server-reported live agent count (#71) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Settings agent card's render() set window.__t3mpLiveAgents from CLIENT-side pings only (Object.keys(pingStatus).filter(ok)). Agents connected server-side — via autoReconnect (ping:false) or a status?check=1 re-ping — are live on the server even though this client never pinged them, so every re-render reset the count to 0. Since upstream's t3mpHasBackend() is now `llmAvailable || live > 0`, that clobber made the War Room show "No LLM backbone — connect an agent before hunting" on localhost even with a genuinely-live local agent (repro: 3 agents connected, hermes lastPing.ok on the server, yet hasBackend=false after any detect/render). Fix: live = max(client-pinged-ok, server-reported-live), reading the server's own agent state (window.__t3mpServerAgents, refreshed via status?check=1). The summary and the global now both reflect reality and re-renders no longer break the gate. Verified: hasBackend stays true across detect/connect re-renders. Co-authored-by: Claude Opus 4.8 --- docs/index.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/index.html b/docs/index.html index 8b33885..38ebca1 100755 --- a/docs/index.html +++ b/docs/index.html @@ -24817,7 +24817,14 @@ Be specific and actionable. Format as structured JSON.`; list.innerHTML = agents.map(function(a){ return rowHtml(a); }).join(''); const ready = agents.filter(function(a){return a.ready;}).length; const installed = agents.filter(function(a){return a.installed;}).length; - const live = Object.keys(pingStatus).filter(function(k){return pingStatus[k].ok;}).length; + // Live = client-side successful pings OR agents the SERVER already reports live. Agents connected + // server-side (autoReconnect, or a status?check=1 re-ping) are live even though THIS client never + // pinged them; counting only client pings here clobbered window.__t3mpLiveAgents back to 0 on every + // re-render, which broke the War Room backbone gate (t3mpHasBackend) for a genuinely-usable agent. + const clientLive = Object.keys(pingStatus).filter(function(k){return pingStatus[k].ok;}).length; + const serverLive = Array.isArray(window.__t3mpServerAgents) + ? window.__t3mpServerAgents.filter(function(a){ return a.lastPing && a.lastPing.ok; }).length : 0; + const live = Math.max(clientLive, serverLive); const sum = document.getElementById('localAgentsSummary'); if (sum) sum.innerHTML = connectedIds.length+' active'+(live?' · '+live+' live':'')+' · '+ready+' ready · '+installed+'/'+agents.length+' installed'; // expose live/connected counts separately. A plain connect is just a registration; only a