Files
dify/web/app/components/workflow/run/result-text.tsx
yyh 30b9295156 Merge remote-tracking branch 'origin/build/feat/hitl' into wip/hitl-merge-web-conflicts-20260206-175434
# Conflicts:
#	api/.env.example
#	api/core/app/apps/advanced_chat/app_generator.py
#	api/core/app/apps/advanced_chat/app_runner.py
#	api/core/app/apps/advanced_chat/generate_task_pipeline.py
#	api/core/app/apps/workflow/app_generator.py
#	api/core/app/apps/workflow/app_runner.py
#	api/core/app/entities/queue_entities.py
#	api/core/workflow/node_events/__init__.py
#	api/core/workflow/runtime/graph_runtime_state.py
#	api/fields/message_fields.py
#	api/services/workflow_service.py
#	web/app/components/app/app-publisher/index.tsx
#	web/app/components/base/chat/chat/answer/index.tsx
#	web/app/components/base/chat/chat/hooks.ts
#	web/app/components/base/chat/chat/type.ts
#	web/app/components/base/prompt-editor/index.tsx
#	web/app/components/rag-pipeline/hooks/use-available-nodes-meta-data.ts
#	web/app/components/share/text-generation/result/header.tsx
#	web/app/components/workflow-app/components/workflow-header/features-trigger.tsx
#	web/app/components/workflow-app/hooks/use-workflow-run.ts
#	web/app/components/workflow/hooks/use-checklist.ts
#	web/app/components/workflow/hooks/use-fetch-workflow-inspect-vars.ts
#	web/app/components/workflow/hooks/use-workflow.ts
#	web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx
#	web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx
#	web/app/components/workflow/nodes/_base/node.tsx
#	web/app/components/workflow/nodes/tool/components/mixed-variable-text-input/components/placeholder.tsx
#	web/app/components/workflow/panel/debug-and-preview/hooks.ts
#	web/app/components/workflow/panel/workflow-preview.tsx
#	web/app/components/workflow/store/workflow/workflow-slice.ts
#	web/eslint-suppressions.json
#	web/i18n/en-US/common.json
#	web/i18n/zh-Hans/common.json
#	web/i18n/zh-Hant/common.json
#	web/service/workflow.ts
2026-02-06 19:13:51 +08:00

93 lines
3.0 KiB
TypeScript

'use client'
import type { FC } from 'react'
import type { LLMGenerationItem } from '@/types/workflow'
import { useTranslation } from 'react-i18next'
import GenerationContent from '@/app/components/base/chat/chat/answer/generation-content'
import LoadingAnim from '@/app/components/base/chat/chat/loading-anim'
import { FileList } from '@/app/components/base/file-uploader'
import { ImageIndentLeft } from '@/app/components/base/icons/src/vender/line/editor'
import { Markdown } from '@/app/components/base/markdown'
import StatusContainer from '@/app/components/workflow/run/status-container'
type ResultTextProps = {
isRunning?: boolean
isPaused?: boolean
outputs?: any
llmGenerationItems?: LLMGenerationItem[]
error?: string
onClick?: () => void
allFiles?: any[]
}
const ResultText: FC<ResultTextProps> = ({
isRunning,
isPaused,
outputs,
llmGenerationItems,
error,
onClick,
allFiles,
}) => {
const { t } = useTranslation()
const generationContentRenderIsUsed = llmGenerationItems?.length && llmGenerationItems.some((item) => {
return item.type === 'tool' || item.type === 'thought'
})
return (
<div className="bg-background-section-burn">
{isRunning && !outputs && (
<div className="pl-[26px] pt-4">
<LoadingAnim type="text" />
</div>
)}
{!isRunning && error && (
<div className="px-4 py-2">
<StatusContainer status="failed">
{error}
</StatusContainer>
</div>
)}
{!isPaused && !isRunning && !outputs && !error && !allFiles?.length && (
<div className="mt-[120px] flex flex-col items-center px-4 py-2 text-[13px] leading-[18px] text-gray-500">
<ImageIndentLeft className="h-6 w-6 text-gray-400" />
<div className="mr-2">{t('resultEmpty.title', { ns: 'runLog' })}</div>
<div>
{t('resultEmpty.tipLeft', { ns: 'runLog' })}
<span onClick={onClick} className="cursor-pointer text-primary-600">{t('resultEmpty.link', { ns: 'runLog' })}</span>
{t('resultEmpty.tipRight', { ns: 'runLog' })}
</div>
</div>
)}
{(outputs || !!allFiles?.length) && (
<>
{outputs && !generationContentRenderIsUsed && (
<div className="px-4 py-2">
<Markdown content={outputs} />
</div>
)}
{
generationContentRenderIsUsed && (
<div className="px-2 py-1">
<GenerationContent llmGenerationItems={llmGenerationItems} />
</div>
)
}
{!!allFiles?.length && allFiles.map(item => (
<div key={item.varName} className="system-xs-regular flex flex-col gap-1 px-4 py-2">
<div className="py-1 text-text-tertiary">{item.varName}</div>
<FileList
files={item.list}
showDeleteAction={false}
showDownloadAction
canPreview
/>
</div>
))}
</>
)}
</div>
)
}
export default ResultText