import React, { useEffect, useRef } from "react"; import { Card, CardContent } from "@/components/ui/card"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Bot, Phone, MessageSquare, Wrench } from "lucide-react"; import { Item } from "@/components/types"; type TranscriptProps = { items: Item[]; }; const Transcript: React.FC = ({ items }) => { const scrollRef = useRef(null); useEffect(() => { scrollRef.current?.scrollIntoView({ behavior: "smooth" }); }, [items]); // Show messages, function calls, and function call outputs in the transcript const transcriptItems = items.filter( (it) => it.type === "message" || it.type === "function_call" || it.type === "function_call_output" ); return ( {transcriptItems.length === 0 && (

No messages yet

Start a call to see the transcript

)}
{transcriptItems.map((msg, i) => { const isUser = msg.role === "user"; const isTool = msg.role === "tool"; // Default to assistant if not user or tool const Icon = isUser ? Phone : isTool ? Wrench : Bot; // Combine all text parts into a single string for display const displayText = msg.content ? msg.content.map((c) => c.text).join("") : ""; return (
{isUser ? "Caller" : isTool ? "Tool Response" : "Assistant"} {msg.timestamp}

{displayText}

); })}
); }; export default Transcript;