"use client"; import * as React from "react"; import { Activity, MoreHorizontal, Pencil, RefreshCw, Trash2, CheckCircle2, XCircle, CircleDashed, Zap, Lock, Globe } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Tooltip } from "@/components/ui/tooltip"; import { ActionSheet } from "@/components/ui/sheet"; import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator } from "@/components/ui/dropdown-menu"; import { ProviderIcon } from "@/components/brand/provider-icon"; import { useIsMobile } from "@/lib/client/hooks"; import { formatRelative, formatMs, formatNumber, cn } from "@/lib/utils"; import type { PublicEndpoint } from "@/lib/client/types"; const STATUS: Record = { valid: { label: "Reachable", variant: "success", icon: }, invalid: { label: "Unreachable", variant: "danger", icon: }, error: { label: "Error", variant: "danger", icon: }, unverified: { label: "Not tested", variant: "warning", icon: }, }; function hostOf(url: string): string { try { const u = new URL(url); return `${u.host}${u.pathname.replace(/\/$/, "")}`; } catch { return url; } } export function EndpointRow({ endpoint, testing, syncing, onTest, onSync, onEdit, onRemove }: { endpoint: PublicEndpoint; testing: boolean; syncing: boolean; onTest: () => void; onSync: () => void; onEdit: () => void; onRemove: () => void }) { const ui = STATUS[endpoint.status] ?? STATUS.unverified; const isMobile = useIsMobile(); const [more, setMore] = React.useState(false); const total = endpoint.modelsAvailable ?? endpoint.discoveredModels.length + endpoint.manualModels.length; const items = [ { key: "edit", label: "Edit endpoint", icon: , onSelect: onEdit }, { key: "sync", label: "Refresh model list", icon: , onSelect: onSync, disabled: !endpoint.modelsPath || syncing }, "separator" as const, { key: "remove", label: "Remove endpoint", icon: , onSelect: onRemove, destructive: true }, ]; return (
  • {endpoint.name}

    {ui.icon} {ui.label} {endpoint.isPrivate ? ( local ) : ( {endpoint.baseUrl.startsWith("https") ? "https" : "http"} )}

    {hostOf(endpoint.baseUrl)}

    Models
    {formatNumber(total)} {endpoint.manualModels.length ? · {endpoint.manualModels.length} manual : null}
    Latency
    {endpoint.lastLatencyMs !== null ? ( <> {formatMs(endpoint.lastLatencyMs)} ) : ( "—" )}
    Last tested
    {formatRelative(endpoint.lastValidatedAt)}
    Auth
    {endpoint.hasKey ? endpoint.keyHint : endpoint.headerNames.length ? `${endpoint.headerNames.length} header${endpoint.headerNames.length === 1 ? "" : "s"}` : "none"}
    {endpoint.lastValidationError ? (
    Last error
    {endpoint.lastValidationError}
    ) : null}
    {endpoint.discoveredModels.length ? (
      {endpoint.discoveredModels.slice(0, isMobile ? 4 : 8).map((m) => (
    • {m.id}
    • ))} {endpoint.discoveredModels.length > (isMobile ? 4 : 8) ?
    • +{endpoint.discoveredModels.length - (isMobile ? 4 : 8)} more
    • : null}
    ) : null}
    Edit endpoint Refresh model list Remove endpoint
    {isMobile ? : null}
  • ); }