diff --git a/web/app/components/workflow/header/checklist.tsx b/web/app/components/workflow/header/checklist.tsx index 4c3d3c6a81..e43ab2f5b2 100644 --- a/web/app/components/workflow/header/checklist.tsx +++ b/web/app/components/workflow/header/checklist.tsx @@ -78,7 +78,7 @@ const WorkflowChecklist = () => { placement='bottom-end' offset={{ mainAxis: 12, - crossAxis: -4, + crossAxis: 4, }} open={open} onOpenChange={setOpen} @@ -174,7 +174,7 @@ const WorkflowChecklist = () => { } { !needWarningNodes.length && ( -
+
{t('workflow.panel.checklistResolved')}
diff --git a/web/app/components/workflow/header/run-and-history.tsx b/web/app/components/workflow/header/run-and-history.tsx index 8cc44cc07e..43143013ee 100644 --- a/web/app/components/workflow/header/run-and-history.tsx +++ b/web/app/components/workflow/header/run-and-history.tsx @@ -16,14 +16,12 @@ import { BlockEnum, WorkflowRunningStatus, } from '../types' +import ViewHistory from './view-history' import { Play, StopCircle, } from '@/app/components/base/icons/src/vender/line/mediaAndDevices' -import { ClockPlay } from '@/app/components/base/icons/src/vender/line/time' -import TooltipPlus from '@/app/components/base/tooltip-plus' import { Loading02 } from '@/app/components/base/icons/src/vender/line/general' -import { useStore as useAppStore } from '@/app/components/app/store' import { useFeaturesStore } from '@/app/components/base/features/hooks' const RunMode = memo(() => { @@ -160,11 +158,7 @@ const PreviewMode = memo(() => { PreviewMode.displayName = 'PreviewMode' const RunAndHistory: FC = () => { - const { t } = useTranslation() - const { setCurrentLogItem, setShowMessageLogModal } = useAppStore() - const workflowStore = useWorkflowStore() const isChatMode = useIsChatMode() - const showRunHistory = useStore(state => state.showRunHistory) return (
@@ -175,23 +169,7 @@ const RunAndHistory: FC = () => { isChatMode && }
- -
{ - workflowStore.setState({ showRunHistory: !showRunHistory }) - setCurrentLogItem() - setShowMessageLogModal(false) - }} - > - -
-
+
) } diff --git a/web/app/components/workflow/header/view-history.tsx b/web/app/components/workflow/header/view-history.tsx new file mode 100644 index 0000000000..7ffc224147 --- /dev/null +++ b/web/app/components/workflow/header/view-history.tsx @@ -0,0 +1,174 @@ +import { + memo, + useState, +} from 'react' +import cn from 'classnames' +import useSWR from 'swr' +import { useTranslation } from 'react-i18next' +import { + useIsChatMode, + useWorkflow, + useWorkflowRun, +} from '../hooks' +import { WorkflowRunningStatus } from '../types' +import { + PortalToFollowElem, + PortalToFollowElemContent, + PortalToFollowElemTrigger, +} from '@/app/components/base/portal-to-follow-elem' +import TooltipPlus from '@/app/components/base/tooltip-plus' +import { useStore as useAppStore } from '@/app/components/app/store' +import { + ClockPlay, + ClockPlaySlim, +} from '@/app/components/base/icons/src/vender/line/time' +import { CheckCircle, XClose } from '@/app/components/base/icons/src/vender/line/general' +import { AlertCircle, AlertTriangle } from '@/app/components/base/icons/src/vender/line/alertsAndFeedback' +import { + fetcChatRunHistory, + fetchWorkflowRunHistory, +} from '@/service/workflow' +import Loading from '@/app/components/base/loading' +import { + useStore, + useWorkflowStore, +} from '@/app/components/workflow/store' + +const ViewHistory = () => { + const { t } = useTranslation() + const isChatMode = useIsChatMode() + const [open, setOpen] = useState(false) + const { formatTimeFromNow } = useWorkflow() + const workflowStore = useWorkflowStore() + const { appDetail, setCurrentLogItem, setShowMessageLogModal } = useAppStore() + const historyWorkflowData = useStore(s => s.historyWorkflowData) + const { handleBackupDraft } = useWorkflowRun() + const { data: runList, isLoading: runListLoading } = useSWR((appDetail && !isChatMode) ? `/apps/${appDetail.id}/workflow-runs` : null, fetchWorkflowRunHistory) + const { data: chatList, isLoading: chatListLoading } = useSWR((appDetail && isChatMode) ? `/apps/${appDetail.id}/advanced-chat/workflow-runs` : null, fetcChatRunHistory) + + const data = isChatMode ? chatList : runList + const isLoading = isChatMode ? chatListLoading : runListLoading + + return ( + ( + + setOpen(v => !v)}> + +
{ + setCurrentLogItem() + setShowMessageLogModal(false) + }} + > + +
+
+
+ +
+
+
{t('workflow.common.runHistory')}
+
{ + setCurrentLogItem() + setShowMessageLogModal(false) + setOpen(false) + }} + > + +
+
+ { + isLoading && ( +
+ +
+ ) + } +
+ { + !data?.data.length && ( +
+ +
+ {t('workflow.common.notRunning')} +
+
+ ) + } + { + data?.data.map(item => ( +
{ + workflowStore.setState({ + historyWorkflowData: item, + }) + handleBackupDraft() + setOpen(false) + }} + > + { + !isChatMode && item.status === WorkflowRunningStatus.Stopped && ( + + ) + } + { + !isChatMode && item.status === WorkflowRunningStatus.Failed && ( + + ) + } + { + !isChatMode && item.status === WorkflowRunningStatus.Succeeded && ( + + ) + } +
+
+ {`Test ${isChatMode ? 'Chat' : 'Run'}#${item.sequence_number}`} +
+
+ {item.created_by_account.name} · {formatTimeFromNow((item.finished_at || item.created_at) * 1000)} +
+
+
+ )) + } +
+
+
+
+ ) + ) +} + +export default memo(ViewHistory) diff --git a/web/app/components/workflow/panel/chat-record/index.tsx b/web/app/components/workflow/panel/chat-record/index.tsx index 1ee0c6d6e9..22a2bb82da 100644 --- a/web/app/components/workflow/panel/chat-record/index.tsx +++ b/web/app/components/workflow/panel/chat-record/index.tsx @@ -78,21 +78,23 @@ const ChatRecord = () => { background: 'linear-gradient(156deg, rgba(242, 244, 247, 0.80) 0%, rgba(242, 244, 247, 0.00) 99.43%), var(--white, #FFF)', }} > -
+
{`TEST CHAT#${historyWorkflowData?.sequence_number}`}
- } - noChatInput - allToolIcons={{}} - showPromptLog - /> +
+ } + noChatInput + allToolIcons={{}} + showPromptLog + /> +
) } diff --git a/web/app/components/workflow/panel/index.tsx b/web/app/components/workflow/panel/index.tsx index 88426a3a0b..b5d35d94eb 100644 --- a/web/app/components/workflow/panel/index.tsx +++ b/web/app/components/workflow/panel/index.tsx @@ -9,7 +9,6 @@ import { Panel as NodePanel } from '../nodes' import { useStore } from '../store' import { useIsChatMode } from '../hooks' import DebugAndPreview from './debug-and-preview' -import RunHistory from './run-history' import Record from './record' import InputsPanel from './inputs-panel' import WorkflowPreview from './workflow-preview' @@ -21,7 +20,6 @@ const Panel: FC = () => { const nodes = useNodes() const isChatMode = useIsChatMode() const selectedNode = nodes.find(node => node.data.selected) - const showRunHistory = useStore(state => state.showRunHistory) const showInputsPanel = useStore(s => s.showInputsPanel) const workflowRunningData = useStore(s => s.workflowRunningData) const historyWorkflowData = useStore(s => s.historyWorkflowData) @@ -88,11 +86,6 @@ const Panel: FC = () => { ) } - { - showRunHistory && ( - - ) - }
) } diff --git a/web/app/components/workflow/panel/record.tsx b/web/app/components/workflow/panel/record.tsx index bfebbb8137..dc000e6f93 100644 --- a/web/app/components/workflow/panel/record.tsx +++ b/web/app/components/workflow/panel/record.tsx @@ -1,17 +1,12 @@ import { memo } from 'react' -import { useIsChatMode } from '../hooks' import Run from '../run' import { useStore } from '../store' const Record = () => { - const isChatMode = useIsChatMode() const historyWorkflowData = useStore(s => s.historyWorkflowData) return ( -
+
{`Test Run#${historyWorkflowData?.sequence_number}`}
diff --git a/web/app/components/workflow/panel/run-history.tsx b/web/app/components/workflow/panel/run-history.tsx deleted file mode 100644 index e6224e726d..0000000000 --- a/web/app/components/workflow/panel/run-history.tsx +++ /dev/null @@ -1,130 +0,0 @@ -import { memo } from 'react' -import cn from 'classnames' -import { useTranslation } from 'react-i18next' -import useSWR from 'swr' -import { WorkflowRunningStatus } from '../types' -import { - useIsChatMode, - useWorkflow, - useWorkflowRun, -} from '../hooks' -import { CheckCircle, XClose } from '@/app/components/base/icons/src/vender/line/general' -import { AlertCircle, AlertTriangle } from '@/app/components/base/icons/src/vender/line/alertsAndFeedback' -import { - useStore, - useWorkflowStore, -} from '@/app/components/workflow/store' -import { useStore as useAppStore } from '@/app/components/app/store' -import { fetcChatRunHistory, fetchWorkflowRunHistory } from '@/service/workflow' -import Loading from '@/app/components/base/loading' -import { ClockPlaySlim } from '@/app/components/base/icons/src/vender/line/time' - -const RunHistory = () => { - const { t } = useTranslation() - const isChatMode = useIsChatMode() - const { appDetail, setCurrentLogItem, setShowMessageLogModal } = useAppStore() - const { formatTimeFromNow } = useWorkflow() - const { handleBackupDraft } = useWorkflowRun() - const workflowStore = useWorkflowStore() - const historyWorkflowData = useStore(s => s.historyWorkflowData) - const { data: runList, isLoading: runListLoading } = useSWR((appDetail && !isChatMode) ? `/apps/${appDetail.id}/workflow-runs` : null, fetchWorkflowRunHistory) - - const { data: chatList, isLoading: chatListLoading } = useSWR((appDetail && isChatMode) ? `/apps/${appDetail.id}/advanced-chat/workflow-runs` : null, fetcChatRunHistory) - - const data = isChatMode ? chatList : runList - const isLoading = isChatMode ? chatListLoading : runListLoading - - if (!appDetail) - return null - - return ( -
-
- {t('workflow.common.runHistory')} -
{ - workflowStore.setState({ - showRunHistory: false, - }) - setCurrentLogItem() - setShowMessageLogModal(false) - }} - > - -
-
- { - isLoading && ( -
- -
- ) - } -
- { - !data?.data.length && ( -
-
-
- -
-
- {t('workflow.common.notRunning')} -
-
-
- ) - } - { - data?.data.map(item => ( -
{ - workflowStore.setState({ - historyWorkflowData: item, - }) - handleBackupDraft() - }} - > - { - !isChatMode && item.status === WorkflowRunningStatus.Stopped && ( - - ) - } - { - !isChatMode && item.status === WorkflowRunningStatus.Failed && ( - - ) - } - { - !isChatMode && item.status === WorkflowRunningStatus.Succeeded && ( - - ) - } -
-
- {`Test ${isChatMode ? 'Chat' : 'Run'}#${item.sequence_number}`} -
-
- {item.created_by_account.name} · {formatTimeFromNow((item.finished_at || item.created_at) * 1000)} -
-
-
- )) - } -
-
- ) -} - -export default memo(RunHistory)