From 829835310699bdd2dfe16bdde6f0e6ebdd66fd15 Mon Sep 17 00:00:00 2001 From: Myron Blair Date: Thu, 11 Jun 2026 18:21:44 +0000 Subject: [PATCH] Fix Vision Protocol: rename shadowed ts var, load agents dynamically const ts = ts() in loadVision caused TDZ ReferenceError crashing gallery. visionRunScreenshot now fetches online agents from agents_list API when no screenshots exist yet (previously showed No agents online falsely). Co-Authored-By: Claude Sonnet 4.6 --- public_html/admin/index.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/public_html/admin/index.php b/public_html/admin/index.php index 6da58d0..d8f225f 100644 --- a/public_html/admin/index.php +++ b/public_html/admin/index.php @@ -2922,7 +2922,7 @@ async function loadVision() { } gallery.innerHTML = shots.map(s => { - const ts = ts(s.created_at); + const shotTs = ts(s.created_at); const has = s.file_size > 0; const meth = (s.method || 'unknown').toUpperCase(); const dim = s.width && s.height ? `${s.width}×${s.height}` : ''; @@ -2939,7 +2939,7 @@ async function loadVision() { ◈ ${dim ? dim + ' · ' : ''}${Math.round((s.file_size||0)/1024)}KB IMAGE ` : '
TEXT SNAPSHOT ONLY
'} ${analysis ? `
${esc(analysis)}${s.vision_analysis?.length>180?'…':''}
` : ''} -
${ts}
+
${shotTs}
`; }).join(''); @@ -2965,8 +2965,11 @@ async function visionViewScreenshot(id) { } async function visionRunScreenshot() { - // Pick agent from dropdown or prompt - const agents = _visionAgents; + let agents = _visionAgents.length ? _visionAgents : null; + if (!agents) { + const all = await api('agents_list'); + agents = (Array.isArray(all) ? all : []).filter(a => a.status === 'online').map(a => a.hostname).filter(Boolean); + } if (!agents.length) { toast('No agents online — check AGENTS tab', 'err'); return; }