index.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import type { FC } from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import { File02 } from '@/app/components/base/icons/src/vender/line/files'
  4. import type { IChatItem } from '@/app/components/base/chat/chat/type'
  5. import { useStore as useAppStore } from '@/app/components/app/store'
  6. type LogProps = {
  7. logItem: IChatItem
  8. }
  9. const Log: FC<LogProps> = ({
  10. logItem,
  11. }) => {
  12. const { t } = useTranslation()
  13. const setCurrentLogItem = useAppStore(s => s.setCurrentLogItem)
  14. const setShowPromptLogModal = useAppStore(s => s.setShowPromptLogModal)
  15. const setShowAgentLogModal = useAppStore(s => s.setShowAgentLogModal)
  16. const setShowMessageLogModal = useAppStore(s => s.setShowMessageLogModal)
  17. const { workflow_run_id: runID, agent_thoughts } = logItem
  18. const isAgent = agent_thoughts && agent_thoughts.length > 0
  19. return (
  20. <div
  21. className='shrink-0 p-1 flex items-center justify-center rounded-[6px] font-medium text-gray-500 hover:bg-gray-50 cursor-pointer hover:text-gray-700'
  22. onClick={(e) => {
  23. e.stopPropagation()
  24. e.nativeEvent.stopImmediatePropagation()
  25. setCurrentLogItem(logItem)
  26. if (runID)
  27. setShowMessageLogModal(true)
  28. else if (isAgent)
  29. setShowAgentLogModal(true)
  30. else
  31. setShowPromptLogModal(true)
  32. }}
  33. >
  34. <File02 className='mr-1 w-4 h-4' />
  35. <div className='text-xs leading-4'>{runID ? t('appLog.viewLog') : isAgent ? t('appLog.agentLog') : t('appLog.promptLog')}</div>
  36. </div>
  37. )
  38. }
  39. export default Log