diff --git a/web/app/components/workflow/hooks.ts b/web/app/components/workflow/hooks.ts index 5d3fe70233..60d3631a70 100644 --- a/web/app/components/workflow/hooks.ts +++ b/web/app/components/workflow/hooks.ts @@ -876,9 +876,10 @@ export const useWorkflowRun = () => { body: params, }, { - onWorkflowStarted: ({ task_id, workflow_run_id }) => { + onWorkflowStarted: ({ task_id, workflow_run_id, sequence_number }) => { useStore.setState({ runningStatus: WorkflowRunningStatus.Running }) useStore.setState({ taskId: task_id }) + useStore.setState({ currentSequenceNumber: sequence_number }) useStore.setState({ workflowRunId: workflow_run_id }) const newNodes = produce(getNodes(), (draft) => { draft.forEach((node) => { diff --git a/web/app/components/workflow/panel/record.tsx b/web/app/components/workflow/panel/record.tsx index 2891dd5890..1a5deb4707 100644 --- a/web/app/components/workflow/panel/record.tsx +++ b/web/app/components/workflow/panel/record.tsx @@ -4,14 +4,17 @@ import { useStore } from '../store' import { XClose } from '@/app/components/base/icons/src/vender/line/general' const Record = () => { - const { workflowRunId, setWorkflowRunId } = useStore() + const { currentSequenceNumber, setCurrentSequenceNumber, workflowRunId, setWorkflowRunId } = useStore() return (
- Test Run#5 + {`Test Run#${currentSequenceNumber}`}
setWorkflowRunId('')} + onClick={() => { + setWorkflowRunId('') + setCurrentSequenceNumber(0) + }} >
diff --git a/web/app/components/workflow/panel/run-history.tsx b/web/app/components/workflow/panel/run-history.tsx index fedd720028..7428a32867 100644 --- a/web/app/components/workflow/panel/run-history.tsx +++ b/web/app/components/workflow/panel/run-history.tsx @@ -48,7 +48,11 @@ const RunHistory = () => { '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 })} + onClick={() => useRunHistoryStore.setState({ + currentSequenceNumber: item.sequence_number, + workflowRunId: item.id, + runningStatus: item.status as WorkflowRunningStatus, + })} > { appDetail?.mode === 'workflow' && item.status === WorkflowRunningStatus.Failed && ( diff --git a/web/app/components/workflow/run/node.tsx b/web/app/components/workflow/run/node.tsx index 2090002007..1666d7000a 100644 --- a/web/app/components/workflow/run/node.tsx +++ b/web/app/components/workflow/run/node.tsx @@ -21,7 +21,7 @@ const NodePanel: FC = ({ nodeInfo, collapsed, collapseHandle }) => { const getTime = (time: number) => { if (time < 1) - return `${time * 1000} ms` + return `${(time * 1000).toFixed(3)} ms` if (time > 60) return `${parseInt(Math.round(time / 60).toString())} m ${(time % 60).toFixed(3)} s` } @@ -53,7 +53,7 @@ const NodePanel: FC = ({ nodeInfo, collapsed, collapseHandle }) => { />
{nodeInfo.title}
-
{`${getTime(nodeInfo.elapsed_time)} · ${getTokenCount(nodeInfo.execution_metadata.total_tokens)} tokens`}
+
{`${getTime(nodeInfo.elapsed_time)} · ${getTokenCount(nodeInfo.execution_metadata?.total_tokens || 0)} tokens`}
{nodeInfo.status === 'succeeded' && ( )} @@ -73,34 +73,45 @@ const NodePanel: FC = ({ nodeInfo, collapsed, collapseHandle }) => { {!collapsed && (
- {/* ###TODO### no data */} {nodeInfo.status === 'stopped' && ( -
{t('workflow.tracing.stopBy', { user: 'Evan' })}
+
{t('workflow.tracing.stopBy', { user: nodeInfo.created_by ? nodeInfo.created_by.name : 'N/A' })}
)} {nodeInfo.status === 'failed' && (
{nodeInfo.error}
)}
- {/* ###TODO### value */} INPUT
} language={CodeLanguage.json} - value={''} - onChange={() => {}} - /> -
-
- {/* ###TODO### value */} - OUTPUT
} - language={CodeLanguage.json} - value={''} + value={JSON.stringify(nodeInfo.inputs)} onChange={() => {}} />
+ {/* ###TODO### conditions by type */} + {nodeInfo.process_data && ( +
+ PROCESS DATA
} + language={CodeLanguage.json} + value={JSON.stringify(nodeInfo.process_data)} + onChange={() => {}} + /> +
+ )} + {nodeInfo.outputs && ( +
+ OUTPUT
} + language={CodeLanguage.json} + value={JSON.stringify(nodeInfo.outputs)} + onChange={() => {}} + /> + + )} )} diff --git a/web/app/components/workflow/run/result-panel.tsx b/web/app/components/workflow/run/result-panel.tsx index 8e055637ea..c57758efb5 100644 --- a/web/app/components/workflow/run/result-panel.tsx +++ b/web/app/components/workflow/run/result-panel.tsx @@ -51,6 +51,7 @@ const ResultPanel: FC = ({ value={JSON.stringify(inputs)} onChange={() => {}} /> + {/* ###TODO### */} {process_data && ( = ({ runID }) => { url: `/apps/${appID}/workflow-runs/${runID}/node-executions`, }) const collapseState = nodeList.map(node => node.status === 'succeeded') - setList(nodeList) + setList(nodeList.reverse()) setCollapseState(collapseState) setLoading(false) } diff --git a/web/app/components/workflow/store.ts b/web/app/components/workflow/store.ts index 3214466656..2d8af249d8 100644 --- a/web/app/components/workflow/store.ts +++ b/web/app/components/workflow/store.ts @@ -14,6 +14,7 @@ import type { WorkflowRunningStatus } from './types' type State = { mode: Mode taskId: string + currentSequenceNumber: number workflowRunId: string showRunHistory: boolean showFeaturesPanel: boolean @@ -32,6 +33,7 @@ type State = { type Action = { setMode: (mode: Mode) => void setTaskId: (taskId: string) => void + setCurrentSequenceNumber: (currentSequenceNumber: number) => void setWorkflowRunId: (workflowRunId: string) => void setShowRunHistory: (showRunHistory: boolean) => void setShowFeaturesPanel: (showFeaturesPanel: boolean) => void @@ -51,6 +53,8 @@ export const useStore = create(set => ({ mode: Mode.Editing, taskId: '', setTaskId: taskId => set(() => ({ taskId })), + currentSequenceNumber: 0, + setCurrentSequenceNumber: currentSequenceNumber => set(() => ({ currentSequenceNumber })), workflowRunId: '', setWorkflowRunId: workflowRunId => set(() => ({ workflowRunId })), setMode: mode => set(() => ({ mode })), diff --git a/web/types/workflow.ts b/web/types/workflow.ts index 2ae683e55f..c67d819b4e 100644 --- a/web/types/workflow.ts +++ b/web/types/workflow.ts @@ -50,6 +50,7 @@ export type NodeTracingListResponse = { export type WorkflowStartedResponse = { task_id: string workflow_run_id: string + sequence_number: number event: string data: { id: string