/** * Trouve-KA — flux temps réel du bot (footer) * Author: Simon-Pierre Boucher * Contact: contact@spboucher.ai */ "use client"; import { useEffect, useState } from "react"; type LiveEvent = { at: string; url: string; domain: string; outcome: string; }; /** * Affiche en temps réel le site que TrouveKABot est en train de scraper. * Poll /api/live toutes les 4 s; se cache silencieusement si l'API est injoignable. */ export function LiveCrawl() { const [event, setEvent] = useState(null); useEffect(() => { let active = true; const tick = async () => { try { const res = await fetch("/api/live", { cache: "no-store" }); if (!res.ok) return; const data = (await res.json()) as { event: LiveEvent | null }; if (active && data.event) setEvent(data.event); } catch { // API injoignable : on garde le dernier événement affiché } }; tick(); const id = setInterval(tick, 4000); return () => { active = false; clearInterval(id); }; }, []); if (!event) return null; const shortUrl = event.url.replace(/^https?:\/\/(www\.)?/, "").slice(0, 80); return (

); }