import type { FC } from 'react' import type { IChatItem } from '@/app/components/base/chat/chat/type' import { cn } from '@langgenius/dify-ui/cn' import { Dialog, DialogContent, DialogTitle } from '@langgenius/dify-ui/dialog' import { useClickAway } from 'ahooks' import { useRef } from 'react' import { useTranslation } from 'react-i18next' import { useStore } from '@/app/components/app/store' import Run from '@/app/components/workflow/run' type RunActiveTab = 'RESULT' | 'DETAIL' | 'TRACING' const isRunActiveTab = (tab: string): tab is RunActiveTab => tab === 'RESULT' || tab === 'DETAIL' || tab === 'TRACING' type MessageLogModalProps = { currentLogItem?: IChatItem defaultTab?: string width: number fixedWidth?: boolean onCancel: () => void } const MessageLogModal: FC = ({ currentLogItem, defaultTab = 'DETAIL', width, fixedWidth, onCancel, }) => { const { t } = useTranslation() const ref = useRef(null) const appDetail = useStore((state) => state.appDetail) useClickAway(() => { if (fixedWidth) onCancel() }, ref) if (!currentLogItem || !currentLogItem.workflow_run_id) return null const activeTab = isRunActiveTab(defaultTab) ? defaultTab : 'DETAIL' const modalContent = ( <> {t(($) => $['runDetail.title'], { ns: 'appLog' })} ) if (!fixedWidth) { return ( { if (!open) onCancel() }} > {modalContent} ) } return (

{t(($) => $['runDetail.title'], { ns: 'appLog' })}

) } export default MessageLogModal