// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates // SPDX-License-Identifier: MIT import { PauseCircleOutlined, SoundOutlined } from "@ant-design/icons"; import { useCallback, useRef, useState } from "react"; import { Button } from "~/components/ui/button"; import { Tooltip, TooltipTrigger, TooltipContent, } from "~/components/ui/tooltip"; import { useMessage } from "~/core/store"; import { cn } from "~/lib/utils"; import { LoadingAnimation } from "./loading-animation"; import { Markdown } from "./markdown"; export function ResearchReportBlock({ className, messageId, }: { className?: string; messageId: string; }) { const message = useMessage(messageId); const contentRef = useRef(null); const [isTTS, setIsTTS] = useState(false); const handleTTS = useCallback(() => { if (contentRef.current) { if (isTTS) { window.speechSynthesis.cancel(); setIsTTS(false); } else { const text = contentRef.current.textContent; if (text) { const utterance = new SpeechSynthesisUtterance(text); setIsTTS(true); window.speechSynthesis.speak(utterance); } } } }, [isTTS]); return (
{message?.content && !message.isStreaming && (

{isTTS ? "Pause" : "Listen to the report"}

)}
{message?.content} {message?.isStreaming && }
); }