import { useState } from "react"; import { Badge } from "@/components/ui/badge"; import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "@/components/ui/collapsible"; import { ChatVoicePlayer } from "./ChatVoicePlayer"; import { ChatMarkdownMessage } from "./ChatMarkdownMessage"; interface ChatVoiceBadgeProps { content: string; messageType: string; // "voice_input" | "voice_full" autoPlayVoice?: boolean; } export function ChatVoiceBadge({ content, messageType, autoPlayVoice = false, }: ChatVoiceBadgeProps) { const [open, setOpen] = useState(false); const spokenMatch = content.match(/SPOKEN:\s*([\s\S]*?)(?=\nDETAILED:|$)/); const spokenText = spokenMatch?.[1]?.trim() ?? content; const detailedMatch = content.match(/DETAILED:\s*([\s\S]*)/); return (
Voice

{spokenText}

{messageType === "voice_full" && ( <> {detailedMatch && ( {open ? "Hide full response" : "Show full response"} )} )}
); }