'use client' import type { FC } from 'react' import { useTranslation } from 'react-i18next' import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor' import { CodeLanguage } from '@/app/components/workflow/nodes/code/types' import StatusPanel from '@/app/components/workflow/run/status' import useTimestamp from '@/hooks/use-timestamp' type ResultPanelProps = Readonly<{ status: string elapsed_time?: number total_tokens?: number error?: string inputs?: any outputs?: any created_by?: string created_at: string agentMode?: string tools?: string[] iterations?: number }> const ResultPanel: FC = ({ elapsed_time, total_tokens, error, inputs, outputs, created_by, created_at, agentMode, tools, iterations, }) => { const { t } = useTranslation() const { formatTime } = useTimestamp() return (
INPUT
} language={CodeLanguage.json} value={inputs} isJSONStringifyBeauty /> OUTPUT
} language={CodeLanguage.json} value={outputs} isJSONStringifyBeauty />
{t(($) => $['meta.title'], { ns: 'runLog' })}
{t(($) => $['meta.status'], { ns: 'runLog' })}
SUCCESS
{t(($) => $['meta.executor'], { ns: 'runLog' })}
{created_by || 'N/A'}
{t(($) => $['meta.startTime'], { ns: 'runLog' })}
{formatTime( Date.parse(created_at) / 1000, t(($) => $.dateTimeFormat, { ns: 'appLog' }) as string, )}
{t(($) => $['meta.time'], { ns: 'runLog' })}
{`${elapsed_time?.toFixed(3)}s`}
{t(($) => $['meta.tokens'], { ns: 'runLog' })}
{`${total_tokens || 0} Tokens`}
{t(($) => $['agentLogDetail.agentMode'], { ns: 'appLog' })}
{agentMode === 'function_call' ? t(($) => $['agent.agentModeType.functionCall'], { ns: 'appDebug' }) : t(($) => $['agent.agentModeType.ReACT'], { ns: 'appDebug' })}
{t(($) => $['agentLogDetail.toolUsed'], { ns: 'appLog' })}
{tools?.length ? tools?.join(', ') : 'Null'}
{t(($) => $['agentLogDetail.iterations'], { ns: 'appLog' })}
{iterations}
) } export default ResultPanel