From fa41668cc29252b8122c9f690a610c874a9ed933 Mon Sep 17 00:00:00 2001 From: Joel Date: Mon, 26 May 2025 17:13:05 +0800 Subject: [PATCH] fix: specail panel not show --- .../components/before-run-form/index.tsx | 104 +++++++----------- .../components/before-run-form/panel-wrap.tsx | 41 +++++++ .../_base/components/workflow-panel/index.tsx | 29 ++++- .../workflow-panel/last-run/use-last-run.ts | 5 + .../nodes/loop/use-single-run-form-params.ts | 5 +- web/app/components/workflow/types.ts | 2 +- 6 files changed, 118 insertions(+), 68 deletions(-) create mode 100644 web/app/components/workflow/nodes/_base/components/before-run-form/panel-wrap.tsx diff --git a/web/app/components/workflow/nodes/_base/components/before-run-form/index.tsx b/web/app/components/workflow/nodes/_base/components/before-run-form/index.tsx index 85b93dd69d..f316308931 100644 --- a/web/app/components/workflow/nodes/_base/components/before-run-form/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/before-run-form/index.tsx @@ -3,7 +3,6 @@ import type { FC } from 'react' import React, { useEffect } from 'react' import { useTranslation } from 'react-i18next' import { - RiCloseLine, RiLoader2Line, } from '@remixicon/react' import type { Props as FormProps } from './form' @@ -20,8 +19,7 @@ import { getProcessedFiles } from '@/app/components/base/file-uploader/utils' import type { BlockEnum } from '@/app/components/workflow/types' import type { Emoji } from '@/app/components/tools/types' import type { SpecialResultPanelProps } from '@/app/components/workflow/run/special-result-panel' -import SpecialResultPanel from '@/app/components/workflow/run/special-result-panel' -// import { useWhyDidYouUpdate } from 'ahooks' +import PanelWrap from './panel-wrap' const i18nPrefix = 'workflow.singleRun' export type BeforeRunFormProps = { @@ -66,18 +64,14 @@ function formatValue(value: string | any, type: InputVarType) { } const BeforeRunForm: FC = ({ nodeName, - nodeType, - toolIcon, onHide, onRun, onStop, runningStatus, result, forms, - showSpecialResultPanel, filteredExistVarForms, existVarValuesInForms, - ...restResultPanelParams }) => { const { t } = useTranslation() @@ -160,67 +154,47 @@ const BeforeRunForm: FC = ({ return null return ( -
-
-
-
- {t(`${i18nPrefix}.testRun`)} {nodeName} -
-
{ - onHide() - }}> - -
-
- { - showSpecialResultPanel && ( -
- + +
+
+ {filteredExistVarForms.map((form, index) => ( +
+
+ {index < forms.length - 1 && }
- ) - } - { - !showSpecialResultPanel && ( -
-
- {filteredExistVarForms.map((form, index) => ( -
- - {index < forms.length - 1 && } -
- ))} -
-
- {isRunning && ( -
- -
- )} - -
- {isRunning && ( - - )} - {isFinished && ( - <> - {result} - - )} + ))} +
+
+ {isRunning && ( +
+
- ) - } + )} + +
+ {isRunning && ( + + )} + {isFinished && ( + <> + {result} + + )}
-
+
) } export default React.memo(BeforeRunForm) diff --git a/web/app/components/workflow/nodes/_base/components/before-run-form/panel-wrap.tsx b/web/app/components/workflow/nodes/_base/components/before-run-form/panel-wrap.tsx new file mode 100644 index 0000000000..7312adf6c6 --- /dev/null +++ b/web/app/components/workflow/nodes/_base/components/before-run-form/panel-wrap.tsx @@ -0,0 +1,41 @@ +'use client' +import type { FC } from 'react' +import React from 'react' +import { useTranslation } from 'react-i18next' +import { + RiCloseLine, +} from '@remixicon/react' + +const i18nPrefix = 'workflow.singleRun' + +export type Props = { + nodeName: string + onHide: () => void + children: React.ReactNode +} + +const PanelWrap: FC = ({ + nodeName, + onHide, + children, +}) => { + const { t } = useTranslation() + return ( +
+
+
+
+ {t(`${i18nPrefix}.testRun`)} {nodeName} +
+
{ + onHide() + }}> + +
+
+ {children} +
+
+ ) +} +export default React.memo(PanelWrap) diff --git a/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx b/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx index d4217a1f45..c8ec2c4795 100644 --- a/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx @@ -54,6 +54,8 @@ import BeforeRunForm from '../before-run-form' import { debounce } from 'lodash-es' import { NODES_EXTRA_DATA } from '@/app/components/workflow/constants' import { useLogs } from '@/app/components/workflow/run/hooks' +import PanelWrap from '../before-run-form/panel-wrap' +import SpecialResultPanel from '@/app/components/workflow/run/special-result-panel' type BasePanelProps = { children: ReactNode @@ -173,7 +175,32 @@ const BasePanel: FC = ({ return {} })() - if (isShowSingleRun || logParams.showSpecialResultPanel) { + if(logParams.showSpecialResultPanel) { + return ( +
+
+ +
+ +
+
+
+
+ ) + } + + if (isShowSingleRun) { return (
({ if(!selector || selector.length === 0) return const [nodeId, varName] = selector.slice(0, 2) + if(nodeId === id) { // inner vars like loop vars + values[variable] = true + return + } const inspectVarValue = hasSetInspectVar(nodeId, varName, systemVars, conversationVars) // also detect system var , env and conversation var if (inspectVarValue) values[variable] = true @@ -204,6 +208,7 @@ const useLastRun = ({ const getFilteredExistVarForms = (forms: FormProps[]) => { if (!forms || forms.length === 0) return [] + const existVarValuesInForms = getExistVarValuesInForms(forms) const res = forms.map((form, i) => { diff --git a/web/app/components/workflow/nodes/loop/use-single-run-form-params.ts b/web/app/components/workflow/nodes/loop/use-single-run-form-params.ts index dd3914848c..d7bbf9fa74 100644 --- a/web/app/components/workflow/nodes/loop/use-single-run-form-params.ts +++ b/web/app/components/workflow/nodes/loop/use-single-run-form-params.ts @@ -7,6 +7,7 @@ import type { CaseItem, Condition, LoopNodeType } from './types' import { ValueType } from '@/app/components/workflow/types' type Params = { + id: string payload: LoopNodeType runInputData: Record runResult: NodeTracing @@ -16,6 +17,7 @@ type Params = { } const useSingleRunFormParams = ({ + id, payload, runInputData, runResult, @@ -138,7 +140,8 @@ const useSingleRunFormParams = ({ if(loopVariable.value_type === ValueType.variable) vars.push(loopVariable.value) }) - return vars + const hasFilterLoopVars = vars.filter(item => item[0] !== id) + return hasFilterLoopVars } return { diff --git a/web/app/components/workflow/types.ts b/web/app/components/workflow/types.ts index cb19d16fcc..d4bd38685a 100644 --- a/web/app/components/workflow/types.ts +++ b/web/app/components/workflow/types.ts @@ -200,7 +200,7 @@ export type InputVar = { options?: string[] value_selector?: ValueSelector getVarValueFromDependent?: boolean - hide: boolean + hide?: boolean } & Partial export type ModelConfig = {