|  | @@ -5,9 +5,10 @@ import { useTranslation } from 'react-i18next'
 | 
	
		
			
				|  |  |  import {
 | 
	
		
			
				|  |  |    RiArrowDownSLine,
 | 
	
		
			
				|  |  |    RiCloseLine,
 | 
	
		
			
				|  |  | +  RiErrorWarningFill,
 | 
	
		
			
				|  |  |  } from '@remixicon/react'
 | 
	
		
			
				|  |  |  import produce from 'immer'
 | 
	
		
			
				|  |  | -import { useStoreApi } from 'reactflow'
 | 
	
		
			
				|  |  | +import { useEdges, useStoreApi } from 'reactflow'
 | 
	
		
			
				|  |  |  import useAvailableVarList from '../../hooks/use-available-var-list'
 | 
	
		
			
				|  |  |  import VarReferencePopup from './var-reference-popup'
 | 
	
		
			
				|  |  |  import { getNodeInfoById, isConversationVar, isENV, isSystemVar } from './utils'
 | 
	
	
		
			
				|  | @@ -33,6 +34,8 @@ import { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/typ
 | 
	
		
			
				|  |  |  import TypeSelector from '@/app/components/workflow/nodes/_base/components/selector'
 | 
	
		
			
				|  |  |  import AddButton from '@/app/components/base/button/add-button'
 | 
	
		
			
				|  |  |  import Badge from '@/app/components/base/badge'
 | 
	
		
			
				|  |  | +import Tooltip from '@/app/components/base/tooltip'
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  const TRIGGER_DEFAULT_WIDTH = 227
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  type Props = {
 | 
	
	
		
			
				|  | @@ -77,6 +80,7 @@ const VarReferencePicker: FC<Props> = ({
 | 
	
		
			
				|  |  |    const {
 | 
	
		
			
				|  |  |      getNodes,
 | 
	
		
			
				|  |  |    } = store.getState()
 | 
	
		
			
				|  |  | +  const edges = useEdges()
 | 
	
		
			
				|  |  |    const isChatMode = useIsChatMode()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    const { getCurrentVariableType } = useWorkflowVariables()
 | 
	
	
		
			
				|  | @@ -206,8 +210,16 @@ const VarReferencePicker: FC<Props> = ({
 | 
	
		
			
				|  |  |      isConstant: !!isConstant,
 | 
	
		
			
				|  |  |    })
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  const isEnv = isENV(value as ValueSelector)
 | 
	
		
			
				|  |  | -  const isChatVar = isConversationVar(value as ValueSelector)
 | 
	
		
			
				|  |  | +  const { isEnv, isChatVar, isValidVar } = useMemo(() => {
 | 
	
		
			
				|  |  | +    const isEnv = isENV(value as ValueSelector)
 | 
	
		
			
				|  |  | +    const isChatVar = isConversationVar(value as ValueSelector)
 | 
	
		
			
				|  |  | +    const isValidVar = Boolean(outputVarNode) || isEnv || isChatVar
 | 
	
		
			
				|  |  | +    return {
 | 
	
		
			
				|  |  | +      isEnv,
 | 
	
		
			
				|  |  | +      isChatVar,
 | 
	
		
			
				|  |  | +      isValidVar,
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }, [value, edges, outputVarNode])
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    // 8(left/right-padding) + 14(icon) + 4 + 14 + 2 = 42 + 17 buff
 | 
	
		
			
				|  |  |    const availableWidth = triggerWidth - 56
 | 
	
	
		
			
				|  | @@ -285,39 +297,44 @@ const VarReferencePicker: FC<Props> = ({
 | 
	
		
			
				|  |  |                      className='grow h-full'
 | 
	
		
			
				|  |  |                    >
 | 
	
		
			
				|  |  |                      <div ref={isSupportConstantValue ? triggerRef : null} className={cn('h-full', isSupportConstantValue && 'flex items-center pl-1 py-1 rounded-lg bg-gray-100')}>
 | 
	
		
			
				|  |  | -                      <div className={cn('h-full items-center px-1.5 rounded-[5px]', hasValue ? 'bg-white inline-flex' : 'flex')}>
 | 
	
		
			
				|  |  | -                        {hasValue
 | 
	
		
			
				|  |  | -                          ? (
 | 
	
		
			
				|  |  | -                            <>
 | 
	
		
			
				|  |  | -                              {isShowNodeName && !isEnv && !isChatVar && (
 | 
	
		
			
				|  |  | -                                <div className='flex items-center'>
 | 
	
		
			
				|  |  | -                                  <div className='p-[1px]'>
 | 
	
		
			
				|  |  | -                                    <VarBlockIcon
 | 
	
		
			
				|  |  | -                                      className='!text-gray-900'
 | 
	
		
			
				|  |  | -                                      type={outputVarNode?.type || BlockEnum.Start}
 | 
	
		
			
				|  |  | -                                    />
 | 
	
		
			
				|  |  | +                      <Tooltip popupContent={!isValidVar && hasValue && t('workflow.errorMsg.invalidVariable')}>
 | 
	
		
			
				|  |  | +                        <div className={cn('h-full items-center px-1.5 rounded-[5px] ', hasValue ? 'bg-white inline-flex' : 'flex',
 | 
	
		
			
				|  |  | +                          !isValidVar && hasValue && 'border border-red-400 !bg-[#FEF3F2]',
 | 
	
		
			
				|  |  | +                        )}>
 | 
	
		
			
				|  |  | +                          {hasValue
 | 
	
		
			
				|  |  | +                            ? (
 | 
	
		
			
				|  |  | +                              <>
 | 
	
		
			
				|  |  | +                                {isShowNodeName && !isEnv && !isChatVar && (
 | 
	
		
			
				|  |  | +                                  <div className='flex items-center'>
 | 
	
		
			
				|  |  | +                                    <div className='px-[1px] h-3'>
 | 
	
		
			
				|  |  | +                                      {outputVarNode?.type && <VarBlockIcon
 | 
	
		
			
				|  |  | +                                        className='!text-gray-900'
 | 
	
		
			
				|  |  | +                                        type={outputVarNode.type}
 | 
	
		
			
				|  |  | +                                      />}
 | 
	
		
			
				|  |  | +                                    </div>
 | 
	
		
			
				|  |  | +                                    <div className='mx-0.5 text-xs font-medium text-gray-700 truncate' title={outputVarNode?.title} style={{
 | 
	
		
			
				|  |  | +                                      maxWidth: maxNodeNameWidth,
 | 
	
		
			
				|  |  | +                                    }}>{outputVarNode?.title}</div>
 | 
	
		
			
				|  |  | +                                    <Line3 className='mr-0.5'></Line3>
 | 
	
		
			
				|  |  |                                    </div>
 | 
	
		
			
				|  |  | -                                  <div className='mx-0.5 text-xs font-medium text-gray-700 truncate' title={outputVarNode?.title} style={{
 | 
	
		
			
				|  |  | -                                    maxWidth: maxNodeNameWidth,
 | 
	
		
			
				|  |  | -                                  }}>{outputVarNode?.title}</div>
 | 
	
		
			
				|  |  | -                                  <Line3 className='mr-0.5'></Line3>
 | 
	
		
			
				|  |  | +                                )}
 | 
	
		
			
				|  |  | +                                <div className='flex items-center text-primary-600'>
 | 
	
		
			
				|  |  | +                                  {!hasValue && <Variable02 className='w-3.5 h-3.5' />}
 | 
	
		
			
				|  |  | +                                  {isEnv && <Env className='w-3.5 h-3.5 text-util-colors-violet-violet-600' />}
 | 
	
		
			
				|  |  | +                                  {isChatVar && <BubbleX className='w-3.5 h-3.5 text-util-colors-teal-teal-700' />}
 | 
	
		
			
				|  |  | +                                  <div className={cn('ml-0.5 text-xs font-medium truncate', (isEnv || isChatVar) && '!text-text-secondary')} title={varName} style={{
 | 
	
		
			
				|  |  | +                                    maxWidth: maxVarNameWidth,
 | 
	
		
			
				|  |  | +                                  }}>{varName}</div>
 | 
	
		
			
				|  |  |                                  </div>
 | 
	
		
			
				|  |  | -                              )}
 | 
	
		
			
				|  |  | -                              <div className='flex items-center text-primary-600'>
 | 
	
		
			
				|  |  | -                                {!hasValue && <Variable02 className='w-3.5 h-3.5' />}
 | 
	
		
			
				|  |  | -                                {isEnv && <Env className='w-3.5 h-3.5 text-util-colors-violet-violet-600' />}
 | 
	
		
			
				|  |  | -                                {isChatVar && <BubbleX className='w-3.5 h-3.5 text-util-colors-teal-teal-700' />}
 | 
	
		
			
				|  |  | -                                <div className={cn('ml-0.5 text-xs font-medium truncate', (isEnv || isChatVar) && '!text-text-secondary')} title={varName} style={{
 | 
	
		
			
				|  |  | -                                  maxWidth: maxVarNameWidth,
 | 
	
		
			
				|  |  | -                                }}>{varName}</div>
 | 
	
		
			
				|  |  | -                              </div>
 | 
	
		
			
				|  |  | -                              <div className='ml-0.5 text-xs font-normal text-gray-500 capitalize truncate' title={type} style={{
 | 
	
		
			
				|  |  | -                                maxWidth: maxTypeWidth,
 | 
	
		
			
				|  |  | -                              }}>{type}</div>
 | 
	
		
			
				|  |  | -                            </>
 | 
	
		
			
				|  |  | -                          )
 | 
	
		
			
				|  |  | -                          : <div className='text-[13px] font-normal text-gray-400'>{t('workflow.common.setVarValuePlaceholder')}</div>}
 | 
	
		
			
				|  |  | -                      </div>
 | 
	
		
			
				|  |  | +                                <div className='ml-0.5 text-xs font-normal text-gray-500 capitalize truncate' title={type} style={{
 | 
	
		
			
				|  |  | +                                  maxWidth: maxTypeWidth,
 | 
	
		
			
				|  |  | +                                }}>{type}</div>
 | 
	
		
			
				|  |  | +                                {!isValidVar && <RiErrorWarningFill className='ml-0.5 w-3 h-3 text-[#D92D20]' /> }
 | 
	
		
			
				|  |  | +                              </>
 | 
	
		
			
				|  |  | +                            )
 | 
	
		
			
				|  |  | +                            : <div className='text-[13px] font-normal text-gray-400'>{t('workflow.common.setVarValuePlaceholder')}</div>}
 | 
	
		
			
				|  |  | +                        </div>
 | 
	
		
			
				|  |  | +                      </Tooltip>
 | 
	
		
			
				|  |  |                      </div>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                    </VarPickerWrap>
 |