feat: enhance component picker and workflow variable block functionality

This commit is contained in:
zhsama
2026-01-08 18:17:09 +08:00
parent 872fd98eda
commit 8b0bc6937d
3 changed files with 28 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import type {
import {
memo,
useCallback,
useEffect,
useMemo,
useState,
} from 'react'
@ -78,6 +79,11 @@ const MixedVariableTextInput = ({
const [selectedAgent, setSelectedAgent] = useState<{ id: string, title: string } | null>(null)
useEffect(() => {
if (!detectedAgentFromValue && selectedAgent)
setSelectedAgent(null)
}, [detectedAgentFromValue, selectedAgent])
const agentNodes = useMemo(() => {
return availableNodes
.filter(node => node.data.type === BlockEnum.Agent)
@ -89,13 +95,7 @@ const MixedVariableTextInput = ({
const handleAgentSelect = useCallback((agent: { id: string, title: string }) => {
setSelectedAgent(agent)
if (onChange) {
const agentVar = `{{#${agent.id}.text#}}`
const newValue = value ? `${agentVar}${value}` : agentVar
onChange(newValue)
setControlPromptEditorRerenderKey(Date.now())
}
}, [onChange, value, setControlPromptEditorRerenderKey])
}, [])
const handleAgentRemove = useCallback(() => {
const agentNodeId = detectedAgentFromValue?.nodeId || selectedAgent?.id