diff --git a/api/web-ia-health.php b/api/web-ia-health.php index bc2dcf19e..80dc47280 100644 --- a/api/web-ia-health.php +++ b/api/web-ia-health.php @@ -59,7 +59,34 @@ usort($recent_tasks, fn($a,$b)=>$a["age_s"]-$b["age_s"]); $recent_tasks = array_slice($recent_tasks, 0, 10); $out["sections"]["tasks"] = $stats; $out["sections"]["tasks_timeline_24h"] = $buckets; +// === W333: ALSO add /tmp/wevia-job-*.log to recent_tasks === +$wevia_jobs = glob("/tmp/wevia-job-*.log"); +usort($wevia_jobs, fn($a,$b) => filemtime($b) - filemtime($a)); +$wevia_jobs = array_slice($wevia_jobs, 0, 10); +foreach ($wevia_jobs as $jf) { + $jname = basename($jf, ".log"); + $jmtime = filemtime($jf); + $jcontent = @file_get_contents($jf); + $jstatus = "done"; + if (strpos($jcontent, "ERROR") !== false || strpos($jcontent, "FAIL") !== false || strpos($jcontent, "Permission denied") !== false) $jstatus = "failed"; + elseif (strpos($jcontent, "elapsed=") === false && strpos($jcontent, "DONE") === false) $jstatus = "pending"; + $jlabel = "wevia-gen"; + if (preg_match("/Prompt:\s*(.+)/", $jcontent, $m)) $jlabel = "wevia: " . substr(trim($m[1]), 0, 40); + elseif (preg_match("/===\s*(.+?)\s*===/", $jcontent, $m)) $jlabel = trim($m[1]); + $recent_tasks[] = [ + "id" => $jname, + "status" => $jstatus, + "label" => $jlabel, + "cmd" => substr($jcontent, 0, 60), + "age_s" => $now - $jmtime, + "created" => date("c", $jmtime) + ]; +} +usort($recent_tasks, fn($a,$b)=>$a["age_s"]-$b["age_s"]); +$recent_tasks = array_slice($recent_tasks, 0, 10); $out["sections"]["tasks_recent"] = $recent_tasks; +// === END W333 === + // === SECTION 3: CDP LOCAL === $cdp = []; diff --git a/web-ia-health.html b/web-ia-health.html index 323f881de..449bef479 100644 --- a/web-ia-health.html +++ b/web-ia-health.html @@ -141,7 +141,7 @@ function toast(msg, err){ async function load(){ GRID.classList.add("loading"); try{ - const r = await fetch("/api/web-ia-health-cached.php?_="+Date.now(),{cache:"no-store"}); + const r = await fetch("/api/web-ia-health.php?_="+Date.now(),{cache:"no-store"}); const d = await r.json(); render(d); }catch(e){ @@ -463,100 +463,6 @@ function doAsk(){ load(); setInterval(load, 30000); - +