Commit e5cf4ea6 authored by JzoNg's avatar JzoNg

fix result panel

parent 768ca2d3
import { memo } from 'react' import { memo } from 'react'
import cn from 'classnames'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import useSWR from 'swr' import useSWR from 'swr'
...@@ -6,7 +7,7 @@ import { WorkflowRunningStatus } from '../types' ...@@ -6,7 +7,7 @@ import { WorkflowRunningStatus } from '../types'
import { XClose } from '@/app/components/base/icons/src/vender/line/general' import { XClose } from '@/app/components/base/icons/src/vender/line/general'
import { AlertCircle } from '@/app/components/base/icons/src/vender/line/alertsAndFeedback' import { AlertCircle } from '@/app/components/base/icons/src/vender/line/alertsAndFeedback'
import { CheckCircle } from '@/app/components/base/icons/src/vender/solid/general' import { CheckCircle } from '@/app/components/base/icons/src/vender/solid/general'
import { useStore } from '@/app/components/workflow/store' import { useStore as useRunHistoryStore } from '@/app/components/workflow/store'
import { useStore as useAppStore } from '@/app/components/app/store' import { useStore as useAppStore } from '@/app/components/app/store'
import { fetchWorkflowRunHistory } from '@/service/workflow' import { fetchWorkflowRunHistory } from '@/service/workflow'
import Loading from '@/app/components/base/loading' import Loading from '@/app/components/base/loading'
...@@ -14,6 +15,7 @@ import Loading from '@/app/components/base/loading' ...@@ -14,6 +15,7 @@ import Loading from '@/app/components/base/loading'
const RunHistory = () => { const RunHistory = () => {
const { t } = useTranslation() const { t } = useTranslation()
const appDetail = useAppStore(state => state.appDetail) const appDetail = useAppStore(state => state.appDetail)
const workflowRunId = useRunHistoryStore(state => state.workflowRunId)
const { data, isLoading } = useSWR(appDetail ? `/apps/${appDetail.id}/workflow-runs` : null, fetchWorkflowRunHistory) const { data, isLoading } = useSWR(appDetail ? `/apps/${appDetail.id}/workflow-runs` : null, fetchWorkflowRunHistory)
if (!appDetail) if (!appDetail)
...@@ -25,7 +27,7 @@ const RunHistory = () => { ...@@ -25,7 +27,7 @@ const RunHistory = () => {
{t('workflow.common.runHistory')} {t('workflow.common.runHistory')}
<div <div
className='flex items-center justify-center w-6 h-6 cursor-pointer' className='flex items-center justify-center w-6 h-6 cursor-pointer'
onClick={() => useStore.setState({ showRunHistory: false })} onClick={() => useRunHistoryStore.setState({ showRunHistory: false })}
> >
<XClose className='w-4 h-4 text-gray-500' /> <XClose className='w-4 h-4 text-gray-500' />
</div> </div>
...@@ -42,8 +44,11 @@ const RunHistory = () => { ...@@ -42,8 +44,11 @@ const RunHistory = () => {
data?.data.map(item => ( data?.data.map(item => (
<div <div
key={item.id} key={item.id}
className='flex mb-0.5 px-2 py-[7px] rounded-lg hover:bg-primary-50 cursor-pointer' className={cn(
onClick={() => useStore.setState({ workflowRunId: item.id })} 'flex mb-0.5 px-2 py-[7px] rounded-lg hover:bg-primary-50 cursor-pointer',
item.id === workflowRunId && 'bg-primary-50',
)}
onClick={() => useRunHistoryStore.setState({ workflowRunId: item.id, runningStatus: item.status as WorkflowRunningStatus })}
> >
{ {
appDetail?.mode === 'workflow' && item.status === WorkflowRunningStatus.Failed && ( appDetail?.mode === 'workflow' && item.status === WorkflowRunningStatus.Failed && (
...@@ -56,7 +61,12 @@ const RunHistory = () => { ...@@ -56,7 +61,12 @@ const RunHistory = () => {
) )
} }
<div> <div>
<div className='flex items-center text-[13px] font-medium text-primary-600 leading-[18px]'> <div
className={cn(
'flex items-center text-[13px] font-medium leading-[18px]',
item.id === workflowRunId && 'text-primary-600',
)}
>
Test Run#{item.sequence_number} Test Run#{item.sequence_number}
</div> </div>
<div className='flex items-center text-xs text-gray-500 leading-[18px]'> <div className='flex items-center text-xs text-gray-500 leading-[18px]'>
......
...@@ -11,6 +11,7 @@ type Props = { ...@@ -11,6 +11,7 @@ type Props = {
time?: number time?: number
tokens?: number tokens?: number
steps?: number steps?: number
showSteps?: boolean
} }
const MetaData: FC<Props> = ({ const MetaData: FC<Props> = ({
...@@ -20,6 +21,7 @@ const MetaData: FC<Props> = ({ ...@@ -20,6 +21,7 @@ const MetaData: FC<Props> = ({
time, time,
tokens, tokens,
steps = 1, steps = 1,
showSteps = true,
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
...@@ -73,7 +75,7 @@ const MetaData: FC<Props> = ({ ...@@ -73,7 +75,7 @@ const MetaData: FC<Props> = ({
<div className='my-[5px] w-[72px] h-2 rounded-sm bg-[rgba(0,0,0,0.05)]'/> <div className='my-[5px] w-[72px] h-2 rounded-sm bg-[rgba(0,0,0,0.05)]'/>
)} )}
{status !== 'running' && ( {status !== 'running' && (
<span>{`${time}s`}</span> <span>{`${time?.toFixed(3)}s`}</span>
)} )}
</div> </div>
</div> </div>
...@@ -88,7 +90,7 @@ const MetaData: FC<Props> = ({ ...@@ -88,7 +90,7 @@ const MetaData: FC<Props> = ({
)} )}
</div> </div>
</div> </div>
{steps > 0 && ( {showSteps && (
<div className='flex'> <div className='flex'>
<div className='shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-xs leading-[18px] truncate'>{t('runLog.meta.steps')}</div> <div className='shrink-0 w-[104px] px-2 py-[5px] text-gray-500 text-xs leading-[18px] truncate'>{t('runLog.meta.steps')}</div>
<div className='grow px-2 py-[5px] text-gray-900 text-xs leading-[18px]'> <div className='grow px-2 py-[5px] text-gray-900 text-xs leading-[18px]'>
......
...@@ -17,6 +17,7 @@ type ResultPanelProps = { ...@@ -17,6 +17,7 @@ type ResultPanelProps = {
created_by: string created_by: string
finished_at?: number finished_at?: number
steps: number steps: number
showSteps?: boolean
} }
const ResultPanel: FC<ResultPanelProps> = ({ const ResultPanel: FC<ResultPanelProps> = ({
...@@ -30,6 +31,7 @@ const ResultPanel: FC<ResultPanelProps> = ({ ...@@ -30,6 +31,7 @@ const ResultPanel: FC<ResultPanelProps> = ({
created_at, created_at,
created_by, created_by,
steps, steps,
showSteps,
}) => { }) => {
return ( return (
<div className='bg-white py-2'> <div className='bg-white py-2'>
...@@ -46,7 +48,7 @@ const ResultPanel: FC<ResultPanelProps> = ({ ...@@ -46,7 +48,7 @@ const ResultPanel: FC<ResultPanelProps> = ({
readOnly readOnly
title={<div>INPUT</div>} title={<div>INPUT</div>}
language={CodeLanguage.json} language={CodeLanguage.json}
value={inputs || ''} value={JSON.stringify(inputs)}
onChange={() => {}} onChange={() => {}}
/> />
{process_data && ( {process_data && (
...@@ -54,7 +56,7 @@ const ResultPanel: FC<ResultPanelProps> = ({ ...@@ -54,7 +56,7 @@ const ResultPanel: FC<ResultPanelProps> = ({
readOnly readOnly
title={<div>PROCESS DATA</div>} title={<div>PROCESS DATA</div>}
language={CodeLanguage.json} language={CodeLanguage.json}
value={process_data} value={JSON.stringify(process_data)}
onChange={() => {}} onChange={() => {}}
/> />
)} )}
...@@ -63,7 +65,7 @@ const ResultPanel: FC<ResultPanelProps> = ({ ...@@ -63,7 +65,7 @@ const ResultPanel: FC<ResultPanelProps> = ({
readOnly readOnly
title={<div>OUTPUT</div>} title={<div>OUTPUT</div>}
language={CodeLanguage.json} language={CodeLanguage.json}
value={outputs} value={JSON.stringify(outputs)}
onChange={() => {}} onChange={() => {}}
/> />
)} )}
...@@ -79,6 +81,7 @@ const ResultPanel: FC<ResultPanelProps> = ({ ...@@ -79,6 +81,7 @@ const ResultPanel: FC<ResultPanelProps> = ({
time={elapsed_time} time={elapsed_time}
tokens={total_tokens} tokens={total_tokens}
steps={steps} steps={steps}
showSteps={showSteps}
/> />
</div> </div>
</div> </div>
......
...@@ -30,7 +30,7 @@ const StatusPanel: FC<ResultProps> = ({ ...@@ -30,7 +30,7 @@ const StatusPanel: FC<ResultProps> = ({
)} )}
> >
<div className='flex'> <div className='flex'>
<div className='mr-24'> <div className='flex-[33%] max-w-[120px]'>
<div className='text-xs leading-[18px] font-medium text-gray-400'>{t('runLog.resultPanel.status')}</div> <div className='text-xs leading-[18px] font-medium text-gray-400'>{t('runLog.resultPanel.status')}</div>
<div <div
className={cn( className={cn(
...@@ -64,18 +64,18 @@ const StatusPanel: FC<ResultProps> = ({ ...@@ -64,18 +64,18 @@ const StatusPanel: FC<ResultProps> = ({
)} )}
</div> </div>
</div> </div>
<div className='mr-24'> <div className='flex-[33%] max-w-[152px]'>
<div className='text-xs leading-[18px] font-medium text-gray-400'>{t('runLog.resultPanel.time')}</div> <div className='text-xs leading-[18px] font-medium text-gray-400'>{t('runLog.resultPanel.time')}</div>
<div className='flex items-center gap-1 h-[18px] text-gray-700 text-xs leading-3 font-semibold'> <div className='flex items-center gap-1 h-[18px] text-gray-700 text-xs leading-3 font-semibold'>
{status === 'running' && ( {status === 'running' && (
<div className='w-16 h-2 rounded-sm bg-[rgba(0,0,0,0.05)]'/> <div className='w-16 h-2 rounded-sm bg-[rgba(0,0,0,0.05)]'/>
)} )}
{status !== 'running' && ( {status !== 'running' && (
<span>{`${time}s`}</span> <span>{`${time?.toFixed(3)}s`}</span>
)} )}
</div> </div>
</div> </div>
<div className='mr-24'> <div className='flex-[33%]'>
<div className='text-xs leading-[18px] font-medium text-gray-400'>{t('runLog.resultPanel.tokens')}</div> <div className='text-xs leading-[18px] font-medium text-gray-400'>{t('runLog.resultPanel.tokens')}</div>
<div className='flex items-center gap-1 h-[18px] text-gray-700 text-xs leading-3 font-semibold'> <div className='flex items-center gap-1 h-[18px] text-gray-700 text-xs leading-3 font-semibold'>
{status === 'running' && ( {status === 'running' && (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment