fix(workflow): fix var-selector not update when edges change (#8259)

Co-authored-by: Chen(MAC) <chenchen404@outlook.com>
This commit is contained in:
Pika
2024-09-13 11:03:39 +08:00
committed by GitHub
parent 49cee773c5
commit a9c1f1a041
2 changed files with 13 additions and 21 deletions

View File

@@ -4,12 +4,13 @@ import {
useWorkflow,
useWorkflowVariables,
} from '@/app/components/workflow/hooks'
import type { ValueSelector, Var } from '@/app/components/workflow/types'
import type { Node, ValueSelector, Var } from '@/app/components/workflow/types'
type Params = {
onlyLeafNodeVar?: boolean
hideEnv?: boolean
hideChatVar?: boolean
filterVar: (payload: Var, selector: ValueSelector) => boolean
passedInAvailableNodes?: Node[]
}
const useAvailableVarList = (nodeId: string, {
@@ -17,6 +18,7 @@ const useAvailableVarList = (nodeId: string, {
filterVar,
hideEnv,
hideChatVar,
passedInAvailableNodes,
}: Params = {
onlyLeafNodeVar: false,
filterVar: () => true,
@@ -25,7 +27,7 @@ const useAvailableVarList = (nodeId: string, {
const { getNodeAvailableVars } = useWorkflowVariables()
const isChatMode = useIsChatMode()
const availableNodes = onlyLeafNodeVar ? getTreeLeafNodes(nodeId) : getBeforeNodesInSameBranch(nodeId)
const availableNodes = passedInAvailableNodes || (onlyLeafNodeVar ? getTreeLeafNodes(nodeId) : getBeforeNodesInSameBranch(nodeId))
const {
parentNode: iterationNode,