import Divider from "@/src/components/twui/layout/Divider"; import Stack from "@/src/components/twui/layout/Stack"; import React from "react"; import MarkdownEditorPreviewComponent from "@/src/components/twui/mdx/markdown/MarkdownEditorPreviewComponent"; import { ChatCompletionMessageParam } from "openai/resources/index"; type Props = { streamRes: string; setStreamRes: React.Dispatch>; history: ChatCompletionMessageParam[]; }; export default function AIPromptPreview({ setStreamRes, streamRes, history, }: Props) { const responseContentRef = React.useRef(null); const isContentInterrupted = React.useRef(false); React.useEffect(() => { if (isContentInterrupted.current) return; if (responseContentRef.current) { responseContentRef.current.scrollTop = responseContentRef.current.scrollHeight; } }, [streamRes]); if (!streamRes?.match(/./)) return null; return ( { isContentInterrupted.current = true; }, onMouseLeave: () => { isContentInterrupted.current = false; }, }} /> ); }