You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let selected='orchestrator',offset=0;const log=document.querySelector('#log');const esc=s=>String(s).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
14
+
function pick(id,label){selected=id;offset=0;log.textContent='';document.querySelector('#agent').textContent=label;pollLog()}function resetLog(){offset=0;log.textContent='';pollLog()}
15
+
async function pollState(){try{const s=await(await fetch('/api/state')).json();title.textContent=s.title;meta.textContent=`run ${s.run_id} · ${s.run_status}`;summary.innerHTML=Object.entries(s.counts).filter(x=>x[1]).map(x=>`<span>${esc(x[0])} ${x[1]}</span>`).join('');let h=`<button class="case" onclick="pick('orchestrator','Plan orchestrator')">Plan orchestrator<span class="badge ${s.orchestrator_status}">${s.orchestrator_status}</span></button>`;for(const c of s.cases)h+=`<button class="case" onclick="pick('case:${esc(c.id)}','${esc(c.id)}')">${esc(c.id)}<span class="badge ${c.status}">${c.status}</span><br><small>${esc(c.title)}</small></button>`;cases.innerHTML=h}catch(e){meta.textContent=e}}
16
+
async function pollLog(){try{const r=await(await fetch(`/api/log?agent=${encodeURIComponent(selected)}&offset=${offset}`)).json();if(r.reset){offset=0;log.textContent=''}if(r.text){log.textContent+=r.text;offset=r.next_offset;if(follow.checked)log.scrollTop=log.scrollHeight}}catch(e){}}
0 commit comments