import type { ReactNode } from "react"; import type { PoolOverview, PoolSubscriptionState } from "@peppa/core"; import { Badge } from "@/components/ui/badge"; const hhmm = (d: Date) => d.toLocaleTimeString("ru-RU", { hour: "2-digit", minute: "2-digit", timeZone: process.env.PEPPA_TZ || undefined }); const KIND: Record = { claude: "Claude", codex: "ChatGPT", opencode: "OpenCode" }; function tone(s: PoolSubscriptionState): "ok" | "warn" | "danger" | "muted" | "primary" { if (s.status === "auth_error") return "danger"; if (s.status === "pending") return "muted"; if (s.limitedUntil) return "warn"; return s.activeSessions ? "primary" : "ok"; } /** * PEP-107: the subscriptions of a pool as people see them — which one is at work, which is * free, when a limit resets, how full the usage window is; `action` adds a button per row. */ export function PoolSubscriptions({ o, action }: { o: PoolOverview; action?: (s: PoolSubscriptionState) => ReactNode }) { if (!o.subscriptions.length) return

В пуле нет подписок.

; return ( ); } /** One line under the list: is there a spare, does anyone wait. */ export function PoolSummary({ o }: { o: PoolOverview }) { const parts: string[] = []; if (o.usableCount === 0) parts.push("рабочих подписок нет — агенты ждут сброса"); else if (o.usableCount === 1) parts.push("запасной подписки нет: на лимите агенты встанут до сброса"); else parts.push(`рабочих подписок: ${o.usableCount} — на лимите агент переедет на свободную`); if (o.waiting) parts.push(`ждут сброса: ${o.waiting}`); return

{parts.join(" · ")}

; }