diff --git a/web/app/components/workflow/nodes/_base/components/variable/var-full-path-panel.tsx b/web/app/components/workflow/nodes/_base/components/variable/var-full-path-panel.tsx index 67179feef0..8742fae526 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/var-full-path-panel.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/var-full-path-panel.tsx @@ -28,7 +28,7 @@ const VarFullPathPanel: FC = ({ additionalProperties: false, } let current = schema - for (let i = 0; i < path.length; i++) { + for (let i = 1; i < path.length; i++) { const isLast = i === path.length - 1 const name = path[i] current.properties[name] = { @@ -49,7 +49,7 @@ const VarFullPathPanel: FC = ({ diff --git a/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx b/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx index c7ef4598f7..b776983803 100644 --- a/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx +++ b/web/app/components/workflow/nodes/_base/components/variable/var-reference-picker.tsx @@ -6,6 +6,7 @@ import { RiArrowDownSLine, RiCloseLine, RiErrorWarningFill, + RiMoreLine, } from '@remixicon/react' import produce from 'immer' import { useStoreApi } from 'reactflow' @@ -37,6 +38,8 @@ import AddButton from '@/app/components/base/button/add-button' import Badge from '@/app/components/base/badge' import Tooltip from '@/app/components/base/tooltip' import { isExceptionVariable } from '@/app/components/workflow/utils' +import VarFullPathPanel from './var-full-path-panel' +import { Type } from '../../../llm/types' const TRIGGER_DEFAULT_WIDTH = 227 @@ -156,16 +159,15 @@ const VarReferencePicker: FC = ({ return getNodeInfoById(availableNodes, outputVarNodeId)?.data }, [value, hasValue, isConstant, isIterationVar, iterationNode, availableNodes, outputVarNodeId, startNode]) - const varName = useMemo(() => { - if (hasValue) { - const isSystem = isSystemVar(value as ValueSelector) - let varName = '' - if (Array.isArray(value)) - varName = value.length >= 3 ? (value as ValueSelector).slice(-2).join('.') : value[value.length - 1] + const isShowAPart = (value as ValueSelector).length > 2 - return `${isSystem ? 'sys.' : ''}${varName}` - } - return '' + const varName = useMemo(() => { + if (!hasValue) + return '' + + const isSystem = isSystemVar(value as ValueSelector) + const varName = Array.isArray(value) ? value[(value as ValueSelector).length - 1] : '' + return `${isSystem ? 'sys.' : ''}${varName}` }, [hasValue, value]) const varKindTypes = [ @@ -253,6 +255,22 @@ const VarReferencePicker: FC = ({ const WrapElem = isSupportConstantValue ? 'div' : PortalToFollowElemTrigger const VarPickerWrap = !isSupportConstantValue ? 'div' : PortalToFollowElemTrigger + + const tooltipPopup = useMemo(() => { + if (isValidVar && isShowAPart) { + return ( + ) + } + if (!isValidVar && hasValue) + return t('workflow.errorMsg.invalidVariable') + + return null + }, [isValidVar, isShowAPart, hasValue, t, outputVarNode?.title, outputVarNode?.type, value]) return (
= ({ className='grow h-full' >
- +
{hasValue ? ( @@ -336,6 +354,12 @@ const VarReferencePicker: FC = ({
)} + {isShowAPart && ( +
+ + +
+ )}
{!hasValue && } {isEnv && }