import { useState, useEffect, useCallback } from 'react' const API = import.meta.env.VITE_BRAIN_API ?? '' interface SearchResult { score: number title: string filepath: string excerpt: string } interface HealthData { status: string indexed: number uptime: number } interface ClaimData { sess_id: string type: string scope: string status: string opened_at: string closed_at: string | null } interface AgentData { id: string label: string tier: string status: string scope: string } interface DocData { name: string label: string group: string } function formatUptime(seconds: number): string { if (seconds < 60) return `${seconds}s` if (seconds < 3600) return `${Math.floor(seconds / 60)}min` if (seconds < 86400) return `${Math.floor(seconds / 3600)}h ${Math.floor((seconds % 3600) / 60)}min` return `${Math.floor(seconds / 86400)}j ${Math.floor((seconds % 86400) / 3600)}h` } function formatTimeAgo(dateStr: string): string { const diff = Date.now() - new Date(dateStr).getTime() const mins = Math.floor(diff / 60000) if (mins < 1) return "à l'instant" if (mins < 60) return `il y a ${mins}min` const hours = Math.floor(mins / 60) if (hours < 24) return `il y a ${hours}h` const days = Math.floor(hours / 24) return `il y a ${days}j` } function StatCard({ label, value, sub, color }: { label: string; value: string | number; sub?: string; color?: string }) { return (
{content}
)}
{health ? `brain-engine up — ${formatUptime(health.uptime)}` : 'connexion...'}