Compare commits

..

No commits in common. "4036139901e6cde3515d411b81342a18d9869a64" and "1f22dd01898167f3ae8ab374b3a40a2948894c12" have entirely different histories.

View file

@ -1537,17 +1537,10 @@ async function refreshAiPanel() {
let status; let status;
let runs; let runs;
let detail = null; let detail = null;
let details = {};
try { try {
[status, runs] = await Promise.all([getJson('/api/ai/status'), getJson('/api/ai/runs')]); [status, runs] = await Promise.all([getJson('/api/ai/status'), getJson('/api/ai/runs')]);
const focus = runs.find((r) => r.status === 'running') || runs[0]; const focus = runs.find((r) => r.status === 'running') || runs[0];
if (focus) detail = await getJson(`/api/ai/runs/${focus.id}`); if (focus) detail = await getJson(`/api/ai/runs/${focus.id}`);
if (detail) details[detail.id] = detail;
// Runs that failed something need their detail too, or the list of failures
// has nothing to draw: without this only the newest run ever gets one.
for (const r of runs.slice(0, 5)) {
if (r.failed > 0 && !details[r.id]) details[r.id] = await getJson(`/api/ai/runs/${r.id}`);
}
} catch { } catch {
aiPoll = setTimeout(refreshAiPanel, 5000); aiPoll = setTimeout(refreshAiPanel, 5000);
return; return;
@ -1555,7 +1548,7 @@ async function refreshAiPanel() {
if (selectedScope !== 'ai' || !document.getElementById('aiRuns')) return; if (selectedScope !== 'ai' || !document.getElementById('aiRuns')) return;
const running = runs.some((r) => r.status === 'running'); const running = runs.some((r) => r.status === 'running');
const changed = aiState.expectChange || (aiState.runs || []).some((r) => r.status === 'running'); const changed = aiState.expectChange || (aiState.runs || []).some((r) => r.status === 'running');
aiState = { ...aiState, status, runs, detail, details }; aiState = { ...aiState, status, runs, detail };
renderAiLive(); renderAiLive();
if (changed && !running) { if (changed && !running) {
aiState.expectChange = false; aiState.expectChange = false;
@ -1568,7 +1561,7 @@ async function refreshAiPanel() {
} }
function renderAiLive() { function renderAiLive() {
const { status, runs = [], detail, details = {} } = aiState; const { status, runs = [], detail } = aiState;
if (!status || !document.getElementById('aiRuns')) return; if (!status || !document.getElementById('aiRuns')) return;
const c = status.config; const c = status.config;
document.getElementById('aiSetup').innerHTML = status.problem document.getElementById('aiSetup').innerHTML = status.problem
@ -1585,7 +1578,7 @@ function renderAiLive() {
start.disabled = Boolean(status.problem) || running; start.disabled = Boolean(status.problem) || running;
start.title = running ? 'A run is going: wait for it, or stop it' : ''; start.title = running ? 'A run is going: wait for it, or stop it' : '';
document.getElementById('aiRuns').innerHTML = runs.length document.getElementById('aiRuns').innerHTML = runs.length
? runs.slice(0, 5).map((r) => runHtml(r, details[r.id] || (detail && detail.id === r.id ? detail : null))).join('') ? runs.slice(0, 5).map((r) => runHtml(r, detail && detail.id === r.id ? detail : null)).join('')
: '<p class="form-hint">No runs yet.</p>'; : '<p class="form-hint">No runs yet.</p>';
const s = status.search; const s = status.search;
document.getElementById('aiSearch').textContent = s.error document.getElementById('aiSearch').textContent = s.error