"use client"; import { Bot, Clock } from "lucide-react"; import { useQuery } from "@tanstack/react-query"; import { getLatestBotReport, type BotReportRead } from "@/lib/api/bot"; import { DashboardSection } from "./DashboardSection"; function timeAgo(iso: string): string { const diff = Math.floor((Date.now() - new Date(iso).getTime()) / 1000); if (diff < 60) return `${diff}s ago`; if (diff < 3600) return `${Math.floor(diff / 60)}m ago`; if (diff < 86400) return `${Math.floor(diff / 3600)}h ago`; return `${Math.floor(diff / 86400)}d ago`; } function StatusBadge({ status }: { status: string | null }) { if (!status) return null; const styles: Record = { busy: "bg-[color:rgba(251,191,36,0.15)] text-[color:var(--warning)]", idle: "bg-[color:rgba(52,211,153,0.15)] text-[color:var(--success)]", error: "bg-[color:rgba(248,113,113,0.12)] text-[color:var(--danger)]", }; const style = styles[status.toLowerCase()] ?? "bg-[color:var(--surface-strong)] text-muted"; return ( {status} ); } function ReportContent({ report }: { report: BotReportRead }) { return (

{report.project ?? "—"}

{report.task && (

{report.task}

)}
{timeAgo(report.reported_at)}
); } function EmptyState() { return (
Ripley hasn't reported in yet.
); } export function BotStatusSection() { const { data: report } = useQuery({ queryKey: ["bot-report-latest"], queryFn: getLatestBotReport, refetchInterval: 30_000, }); return ( {report ? : } ); }