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

ThreadRelationshipIcon.tsx

50 lines1.6 KB

1import type { ProviderDriverKind, ServerProvider } from "@t3tools/contracts";
2import { BotIcon, type LucideIcon } from "lucide-react";
3import { cn } from "../../lib/utils";
4import { ProviderInstanceIcon } from "./ProviderInstanceIcon";
5​
6/** Shared by lineage and timeline links, including the provider glyph and status badge. */
7export function ThreadRelationshipIcon({
8 driver,
9 provider,
10 status,
11 fallbackIcon: FallbackIcon = BotIcon,
12}: {
13 driver?: ProviderDriverKind | undefined;
14 provider?: ServerProvider | undefined;
15 status: string | null;
16 fallbackIcon?: LucideIcon;
17}) {
18 const iconClassName = "size-4 shrink-0 text-muted-foreground";
19 return (
20 <span className="relative inline-flex shrink-0 items-center justify-center">
21 {driver ? (
22 <ProviderInstanceIcon
23 driverKind={driver}
24 displayName={provider?.displayName ?? driver}
25 acpRegistryIconUrl={provider?.iconUrl}
26 iconClassName={iconClassName}
27 className="z-auto"
28 />
29 ) : (
30 <FallbackIcon className={iconClassName} />
31 )}
32 <span
33 className={cn(
34 "absolute -bottom-1 -right-1 size-2 rounded-full border-2 border-card",
35 status === "running" ||
36 status === "in_progress" ||
37 status === "pending" ||
38 status === "waiting"
39 ? "bg-info"
40 : status === "failed" || status === "error"
41 ? "bg-destructive"
42 : status === "completed"
43 ? "bg-success"
44 : "bg-muted-foreground/45",
45 )}
46 aria-hidden="true"
47 />
48 </span>
49 );