Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ProviderHealthBanner.tsx

38 lines1.2 KB

1import { type ServerProviderStatus } from "@t3tools/contracts";
2import { memo } from "react";
3import { Alert, AlertDescription, AlertTitle } from "../ui/alert";
4import { CircleAlertIcon } from "lucide-react";
5​
6export const ProviderHealthBanner = memo(function ProviderHealthBanner({
7 status,
8}: {
9 status: ServerProviderStatus | null;
10}) {
11 if (!status || status.status === "ready") {
12 return null;
13 }
14​
15 const providerLabel =
16 status.provider === "codex"
17 ? "Codex"
18 : status.provider === "claudeAgent"
19 ? "Claude"
20 : status.provider;
21 const defaultMessage =
22 status.status === "error"
23 ? `${providerLabel} provider is unavailable.`
24 : `${providerLabel} provider has limited availability.`;
25 const title = providerLabel === "Codex" ? "Codex provider status" : `${providerLabel} status`;
26​
27 return (
28 <div className="pt-3 mx-auto max-w-3xl">
29 <Alert variant={status.status === "error" ? "error" : "warning"}>
30 <CircleAlertIcon />
31 <AlertTitle>{title}</AlertTitle>
32 <AlertDescription className="line-clamp-3" title={status.message ?? defaultMessage}>
33 {status.message ?? defaultMessage}
34 </AlertDescription>
35 </Alert>
36 </div>
37 );
38});