import { IconFileCode, IconSparkles, IconWorld, IconX, } from "@tabler/icons-react" import type { ReactNode } from "react" import { useTranslation } from "react-i18next" import ReactMarkdown from "react-markdown" import rehypeHighlight from "rehype-highlight" import rehypeRaw from "rehype-raw" import rehypeSanitize from "rehype-sanitize" import remarkGfm from "remark-gfm" import type { SkillDetailResponse, SkillSupportItem } from "@/api/skills" import { MarkdownCodeBlock, MessageCodeBlock, } from "@/components/chat/message-code-block" import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, } from "@/components/ui/sheet" import { Skeleton } from "@/components/ui/skeleton" import { cn } from "@/lib/utils" import { OriginBadge } from "./origin-badge" import { getOriginLabel, getSkillOriginKind } from "./origin-utils" import type { SkillDetailView } from "./types" const DETAIL_VIEWS = [ "preview", "raw", "meta", ] as const satisfies SkillDetailView[] interface DetailSheetProps { open: boolean selectedSkill: SkillSupportItem | null selectedSkillDetail?: SkillDetailResponse isLoading: boolean error: unknown detailView: SkillDetailView onDetailViewChange: (view: SkillDetailView) => void onOpenChange: (open: boolean) => void } export function DetailSheet({ open, selectedSkill, selectedSkillDetail, isLoading, error, detailView, onDetailViewChange, onOpenChange, }: DetailSheetProps) { const { t } = useTranslation() const activeSkillDetail = selectedSkillDetail ?? selectedSkill const activeSkillOrigin = activeSkillDetail ? getSkillOriginKind(activeSkillDetail) : null const detailLineCount = selectedSkillDetail ? selectedSkillDetail.content.split("\n").length : 0 const detailCharacterCount = selectedSkillDetail?.content.length ?? 0 return (
{activeSkillDetail?.origin_kind === "builtin" ? ( ) : activeSkillDetail?.registry_name ? ( ) : ( )}
{activeSkillDetail?.name || t("pages.agent.skills.viewer_title")} {activeSkillDetail?.description || t("pages.agent.skills.viewer_description")}
{isLoading ? (
) : error ? (
{t("pages.agent.skills.load_detail_error")}
) : selectedSkillDetail ? (
{activeSkillOrigin === "third_party" ? (
{selectedSkillDetail.registry_name ? ( ) : null} {selectedSkillDetail.installed_version ? ( ) : null} {selectedSkillDetail.registry_url ? ( {selectedSkillDetail.registry_url} } mono /> ) : null}
) : null}
{DETAIL_VIEWS.map((view) => ( ))}
{detailView === "preview" ? (
{selectedSkillDetail.content}
) : null} {detailView === "raw" ? ( ) : null} {detailView === "meta" ? (
) : null}
) : null}
) } function MetadataItem({ label, value, mono = false, }: { label: string value: ReactNode mono?: boolean }) { return (
{label}
{value}
) }