import React from "react"; import { Button } from "@/src/components/ui/button"; import { HoverCard, HoverCardContent, HoverCardTrigger, } from "@/src/components/ui/hover-card"; import { StatusBadge } from "@/src/components/layouts/status-badge"; import { PRODUCTION_LABEL, LATEST_PROMPT_LABEL } from "@langfuse/shared"; import { cn } from "@/src/utils/tailwind"; interface TruncatedLabelsProps { labels: string[]; maxVisibleLabels?: number; className?: string; badgeClassName?: string; showSimpleBadges?: boolean; } export function TruncatedLabels({ labels, maxVisibleLabels = 5, className, badgeClassName, showSimpleBadges = false, }: TruncatedLabelsProps) { // Enhanced sorting: prioritize latest and production labels const sortedLabels = [...labels].sort((a, b) => { // Production label comes first if (a === PRODUCTION_LABEL) return -1; if (b === PRODUCTION_LABEL) return 1; // Latest label comes second if (a === LATEST_PROMPT_LABEL) return -1; if (b === LATEST_PROMPT_LABEL) return 1; // Then alphabetically return a.localeCompare(b); }); // Split labels into visible and hidden const visibleLabels = sortedLabels.slice(0, maxVisibleLabels); const hiddenLabels = sortedLabels.slice(maxVisibleLabels); const hasHiddenLabels = hiddenLabels.length > 0; if (sortedLabels.length === 0) { return null; } return (
{visibleLabels.map((label) => showSimpleBadges ? (
{label}
) : ( ), )} {hasHiddenLabels && (

All Labels

{sortedLabels.map((label) => showSimpleBadges ? (
{label}
) : ( ), )}
)}
); }