"use client"; import { useAtomValue, useSetAtom } from "jotai"; import { Boxes, XIcon } from "lucide-react"; import { useMemo } from "react"; import { Button } from "@/components/ui/button"; import { Drawer, DrawerContent, DrawerHandle, DrawerTitle } from "@/components/ui/drawer"; import { useMediaQuery } from "@/hooks/use-media-query"; import type { ArtifactKind, ChatArtifact } from "../model/artifact"; import { artifactsPanelOpenAtom, chatArtifactsAtom, closeArtifactsPanelAtom, } from "../state/artifacts-panel.atom"; import { ArtifactRow } from "./artifact-row"; const GROUP_ORDER: { kind: ArtifactKind; label: string }[] = [ { kind: "report", label: "Reports" }, { kind: "resume", label: "Resumes" }, { kind: "podcast", label: "Podcasts" }, { kind: "video", label: "Presentations" }, { kind: "image", label: "Images" }, ]; function groupByKind(artifacts: ChatArtifact[]): { label: string; items: ChatArtifact[] }[] { return GROUP_ORDER.map(({ kind, label }) => ({ label, items: artifacts.filter((a) => a.kind === kind), })).filter((group) => group.items.length > 0); } function EmptyState() { return (

No artifacts yet

Reports, podcasts, presentations, and images you generate will appear here.

); } function ArtifactGroups({ artifacts }: { artifacts: ChatArtifact[] }) { const groups = useMemo(() => groupByKind(artifacts), [artifacts]); if (groups.length === 0) return ; return (
{groups.map((group) => (

{group.label}

{group.items.map((artifact) => ( ))}
))}
); } /** Inner content shared by the desktop right-panel tab and the mobile drawer. */ export function ArtifactsPanelContent({ onClose }: { onClose?: () => void }) { const artifacts = useAtomValue(chatArtifactsAtom); return ( <>

Artifacts

{onClose && ( )}
); } /** * Mobile artifacts drawer. Desktop renders inside the layout-level RightPanel * tab instead, so this no-ops on large screens. */ export function MobileArtifactsPanel() { const isOpen = useAtomValue(artifactsPanelOpenAtom); const close = useSetAtom(closeArtifactsPanelAtom); const isDesktop = useMediaQuery("(min-width: 1024px)"); if (isDesktop || !isOpen) return null; return ( { if (!open) close(); }} shouldScaleBackground={false} > Artifacts
); }