import { CircleCheck, CircleAlert, Loader2, Play, ChevronRight, } from "lucide-react"; import type { AdapterEnvironmentTestResult } from "@paperclipai/shared"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; export type TestState = "idle" | "running" | "pass" | "fail"; const copy = { idle: { title: "Test your agent", description: "Check that your runtime and model can respond.", action: "Run test", }, running: { title: "Testing connection", description: "Checking the runtime and waiting for a model response…", action: "Testing…", }, pass: { title: "Connection successful", description: "Your runtime checks passed. Review the details below.", action: "Test again", }, warn: { title: "Connection needs attention", description: "Review the test details before running your agent.", action: "Test again", }, fail: { title: "Couldn't connect", description: "Check your model and provider connection, then try again.", action: "Retry test", }, } as const; export function RuntimeTestCard({ state, result, error, onTest, disabled = false, }: { state: TestState | "warn"; result: AdapterEnvironmentTestResult | null; error?: string | null; onTest: () => void; disabled?: boolean; }) { const content = copy[state]; const Icon = state === "running" ? Loader2 : state === "pass" ? CircleCheck : state === "fail" || state === "warn" ? CircleAlert : Play; return (

{content.title}

{state === "fail" && error ? error : content.description}

{result && result.checks.length > 0 && (
)}
); }