{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "session-info",
  "title": "Session Info",
  "description": "Session metadata rows: transport type, copyable ids, RTVI client/server versions.",
  "dependencies": [
    "@pipecat-ai/client-js@^1.14.0",
    "@pipecat-ai/client-react@^1.9.0",
    "lucide-react@^1.41.0"
  ],
  "registryDependencies": [
    "button",
    "tooltip"
  ],
  "files": [
    {
      "path": "src/components/session-info.tsx",
      "content": "\"use client\";\n\nimport type { BotReadyData } from \"@pipecat-ai/client-js\";\nimport { RTVIEvent } from \"@pipecat-ai/client-js\";\nimport { usePipecatClient, useRTVIClientEvent } from \"@pipecat-ai/client-react\";\nimport { CopyCheckIcon, CopyIcon } from \"lucide-react\";\nimport { useState } from \"react\";\n\nimport { Button } from \"@/components/ui/button\";\nimport {\n  Tooltip,\n  TooltipContent,\n  TooltipTrigger,\n} from \"@/components/ui/tooltip\";\nimport { cn } from \"@/lib/utils\";\n\nfunction Blank() {\n  return <span className=\"text-muted-foreground/60\">—</span>;\n}\n\n/** Truncated text with a copy-to-clipboard button. */\nexport function CopyText({\n  text,\n  className,\n}: {\n  text: string;\n  className?: string;\n}) {\n  const [copied, setCopied] = useState(false);\n\n  const copyToClipboard = async () => {\n    try {\n      await navigator.clipboard.writeText(text);\n      setCopied(true);\n      setTimeout(() => setCopied(false), 2000);\n    } catch (err) {\n      console.error(\"Failed to copy text: \", err);\n    }\n  };\n\n  return (\n    <span\n      className={cn(\n        \"flex w-full items-center justify-end gap-1 overflow-hidden\",\n        className,\n      )}\n    >\n      <span className=\"min-w-0 truncate\">{text}</span>\n      <Tooltip>\n        <TooltipTrigger\n          render={\n            <Button\n              variant=\"ghost\"\n              size=\"icon-xs\"\n              className=\"text-muted-foreground flex-none\"\n              onClick={() => void copyToClipboard()}\n              aria-label=\"Copy to clipboard\"\n            >\n              {copied ? <CopyCheckIcon /> : <CopyIcon />}\n            </Button>\n          }\n        />\n        <TooltipContent>\n          {copied ? \"Copied!\" : \"Copy to clipboard\"}\n        </TooltipContent>\n      </Tooltip>\n    </span>\n  );\n}\n\nexport interface SessionInfoViewProps {\n  /** Human-readable transport name (e.g. \"Daily\", \"Small WebRTC\"). */\n  transportName?: string;\n  sessionId?: string;\n  participantId?: string;\n  /** RTVI client library version. */\n  clientVersion?: string;\n  /** RTVI server version, from the BotReady event. */\n  serverVersion?: string;\n  noTransportType?: boolean;\n  noSessionId?: boolean;\n  noParticipantId?: boolean;\n  noRTVIVersion?: boolean;\n  className?: string;\n}\n\n/** Session metadata rows: transport, ids (copyable), RTVI versions. */\nexport function SessionInfoView({\n  transportName,\n  sessionId,\n  participantId,\n  clientVersion,\n  serverVersion,\n  noTransportType = false,\n  noSessionId = false,\n  noParticipantId = false,\n  noRTVIVersion = false,\n  className,\n}: SessionInfoViewProps) {\n  const rows: Array<[string, React.ReactNode]> = [];\n  if (!noTransportType) {\n    rows.push([\"Transport\", transportName ?? \"Unknown\"]);\n  }\n  if (!noSessionId) {\n    rows.push([\n      \"Session ID\",\n      sessionId ? <CopyText text={sessionId} /> : <Blank />,\n    ]);\n  }\n  if (!noParticipantId) {\n    rows.push([\n      \"Participant ID\",\n      participantId ? <CopyText text={participantId} /> : <Blank />,\n    ]);\n  }\n  if (!noRTVIVersion) {\n    rows.push([\"RTVI Client\", clientVersion ? `v${clientVersion}` : <Blank />]);\n    rows.push([\"RTVI Server\", serverVersion ? `v${serverVersion}` : <Blank />]);\n  }\n\n  return (\n    <dl\n      data-slot=\"session-info\"\n      className={cn(\n        \"grid w-full grid-cols-[auto_minmax(0,1fr)] items-center gap-2 overflow-hidden text-sm\",\n        className,\n      )}\n    >\n      {rows.map(([label, value]) => (\n        <div\n          key={label}\n          className=\"col-span-2 grid grid-cols-subgrid items-center\"\n        >\n          <dt className=\"text-muted-foreground\">{label}</dt>\n          <dd className=\"min-w-0 truncate text-right font-mono text-xs\">\n            {value}\n          </dd>\n        </div>\n      ))}\n    </dl>\n  );\n}\n\nexport interface SessionInfoProps extends Omit<\n  SessionInfoViewProps,\n  \"transportName\" | \"clientVersion\" | \"serverVersion\"\n> {\n  sessionId?: string;\n  participantId?: string;\n}\n\n/** Requires PipecatClientProvider and TooltipProvider for the copy buttons. */\nexport function SessionInfo(props: SessionInfoProps) {\n  const client = usePipecatClient();\n  const [serverVersion, setServerVersion] = useState<string | undefined>(\n    undefined,\n  );\n\n  useRTVIClientEvent(RTVIEvent.Disconnected, () => {\n    setServerVersion(undefined);\n  });\n\n  useRTVIClientEvent(RTVIEvent.BotReady, (botData: BotReadyData) => {\n    setServerVersion(botData.version);\n  });\n\n  // Derive a friendly transport name from the transport implementation.\n  const transportServiceName = (\n    client?.transport as unknown as {\n      __proto__?: { constructor?: { SERVICE_NAME?: string } };\n    } | null\n  )?.__proto__?.constructor?.SERVICE_NAME;\n\n  let transportName = \"Unknown\";\n  if (client && \"dailyCallClient\" in client.transport) {\n    transportName = \"Daily\";\n  } else if (transportServiceName === \"small-webrtc-transport\") {\n    transportName = \"Small WebRTC\";\n  } else if (transportServiceName === \"moq-transport\") {\n    transportName = \"MoQ\";\n  } else if (transportServiceName) {\n    transportName = transportServiceName;\n  }\n\n  return (\n    <SessionInfoView\n      transportName={transportName}\n      clientVersion={client?.version}\n      serverVersion={serverVersion}\n      {...props}\n    />\n  );\n}\n",
      "type": "registry:component",
      "target": "components/pipecat/session-info.tsx"
    }
  ],
  "docs": "Render inside a PipecatClientProvider, with a TooltipProvider ancestor for the copy buttons.",
  "categories": [
    "voice"
  ],
  "type": "registry:component"
}