From 576ab22a9f41be12da0e1fe0d75bcb25ebca607a Mon Sep 17 00:00:00 2001 From: Opus Date: Fri, 24 Apr 2026 21:36:51 +0200 Subject: [PATCH] fix(web-ia-health w333): regression w331 layout tasks - clean injection + patch backend CAUSE RACINE (Yacine: tasks vides bas gauche pas centrer): - Wave 331 avait injecte un JS poller qui creait sa propre liste tasks - Cette liste etait appendChild au parent du titre Recent Tasks - MAIS le layout natif est grid 12 cols avec card col-6 - = Liste injectee tombait en colonne gauche bas hors layout FIX wave 333 (2 patches PROPRES): 1. web-ia-health.html: - REMOVE script w331-tasks-poller (pollution UI) - SWITCH /api/web-ia-health-cached.php -> /api/web-ia-health.php (cached etait band-aid temporaire, plus besoin) 2. /api/web-ia-health.php: - PATCH backend pour ALSO parser /tmp/wevia-job-*.log - Detecte status: done/failed/pending depuis content - Extract label intelligent (Prompt: ou ===) - Ajoute au tableau recent_tasks NATIF - Le rendu natif card col-6 + feed-item est PROPRE - Tasks safficheront dans la JOLIE section au bon endroit Result attendu apres CF purge + F5: - Recent Tasks (10) section affiche jusqu a 10 tasks reelles - Layout natif respecte (card col-6 sur grid 12 cols) - Statut couleurs: done vert / failed rouge / pending orange - Plus de pollution gauche bas - Plus de Aucune task recente Zero regression (clean restore + additif backend uniquement) chattr +i toggle, GOLD backup x2 (html + php) CF purge 2 URLs Doctrine 333: fix propre via backend natif au lieu de polluer UI --- api/web-ia-health.php | 27 ++++++++++++ web-ia-health.html | 98 +------------------------------------------ 2 files changed, 29 insertions(+), 96 deletions(-) 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); - +