"use client" /** * agent-strip.tsx — Live state of Tiger + sub-agents * * Replaces the old "Agent Model" card on the home page. Now you see ALL 5 * agents at once with status, last activity, and file count. * * DATA SOURCE: /api/tiger/agents — already exists, returns: * { ok: true, agents: [{ id, name, emoji, role, fileCount, lastActivity }] } */ import * as React from "react" import useSWR from "swr" import { cn } from "@/lib/utils" interface Agent { id: string name: string emoji: string role: string fileCount: number lastActivity: number } interface AgentsResponse { ok: boolean agents: Agent[] } const fetcher = (url: string) => fetch(url).then((r) => r.json()) function relativeTime(ts: number): string { if (!ts) return "—" const diff = Date.now() - ts const m = Math.floor(diff / 60_000) if (m < 1) return "now" if (m < 60) return `${m}m` const h = Math.floor(m / 60) if (h < 24) return `${h}h` const d = Math.floor(h / 24) return `${d}d` } function statusOf(ts: number): "active" | "recent" | "idle" { if (!ts) return "idle" const diff = Date.now() - ts if (diff < 5 * 60_000) return "active" if (diff < 60 * 60_000) return "recent" return "idle" } const STATUS_DOT: Record<"active" | "recent" | "idle", string> = { active: "bg-green-500 animate-pulse", recent: "bg-amber-500", idle: "bg-zinc-500", } export function AgentStrip() { const { data, error, isLoading } = useSWR( "/api/tiger/agents", fetcher, { refreshInterval: 30_000 } ) if (isLoading) { return (
Agents
{Array.from({ length: 5 }).map((_, i) => (
))}
) } if (error || !data?.ok) { return (
Agents
Could not load agents. Bridge unreachable?
) } const agents = data.agents ?? [] return (
Agents View all →
{agents.map((agent) => { const status = statusOf(agent.lastActivity) return (
{agent.emoji} {agent.name}
{agent.role}
last: {relativeTime(agent.lastActivity)} {agent.fileCount} files
) })}
) } function SectionLabel({ children }: { children: React.ReactNode }) { return ( {children} ) }