mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-17 21:25:57 +08:00
fix: detect if has set sys vars
This commit is contained in:
parent
6d31e268e9
commit
42fb0bba74
@ -95,7 +95,7 @@ const useInspectVarsCrud = () => {
|
||||
})
|
||||
setInspectVarValue(nodeId, varId, value)
|
||||
}
|
||||
}, [doEditInspectorVar, setInspectVarValue])
|
||||
}, [doEditInspectorVar, invalidateConversationVarValues, invalidateSysVarValues, setInspectVarValue])
|
||||
|
||||
const [currNodeId, setCurrNodeId] = useState<string | null>(null)
|
||||
const [currEditVarId, setCurrEditVarId] = useState<string | null>(null)
|
||||
@ -129,8 +129,6 @@ const useInspectVarsCrud = () => {
|
||||
setCurrEditVarId(varId)
|
||||
}
|
||||
|
||||
// console.log(conversationVars, systemVars)
|
||||
|
||||
return {
|
||||
conversationVars: conversationVars || [],
|
||||
systemVars: systemVars || [],
|
||||
|
@ -102,7 +102,7 @@ type Params<T> = OneStepRunParams<T>
|
||||
const useLastRun = <T>({
|
||||
...oneStepRunParams
|
||||
}: Params<T>) => {
|
||||
const { conversationVars } = useInspectVarsCrud()
|
||||
const { conversationVars, systemVars } = useInspectVarsCrud()
|
||||
const blockType = oneStepRunParams.data.type
|
||||
const { handleSyncWorkflowDraft } = useNodesSyncDraft()
|
||||
const {
|
||||
@ -180,7 +180,7 @@ const useLastRun = <T>({
|
||||
form.inputs.forEach(({ variable }) => {
|
||||
const selector = variable.slice(1, -1).split('.')
|
||||
const [nodeId, varName] = selector.slice(0, 2)
|
||||
const inspectVarValue = hasSetInspectVar(nodeId, varName, conversationVars) // also detect system var , env and conversation var
|
||||
const inspectVarValue = hasSetInspectVar(nodeId, varName, systemVars, conversationVars) // also detect system var , env and conversation var
|
||||
if (inspectVarValue)
|
||||
values[variable] = true
|
||||
})
|
||||
|
@ -1,7 +1,7 @@
|
||||
import type { StateCreator } from 'zustand'
|
||||
import produce from 'immer'
|
||||
import type { NodeWithVar, VarInInspect } from '@/types/workflow'
|
||||
import { BlockEnum, type ValueSelector } from '../../../types'
|
||||
import type { ValueSelector } from '../../../types'
|
||||
import type { Node } from '@/app/components/workflow/types'
|
||||
import { isConversationVar, isENV, isSystemVar } from '../../../nodes/_base/components/variable/utils'
|
||||
|
||||
@ -26,7 +26,7 @@ type InspectVarsActions = {
|
||||
renameInspectVarName: (nodeId: string, varId: string, selector: ValueSelector) => void
|
||||
deleteInspectVar: (nodeId: string, varId: string) => void
|
||||
getInspectVar: (nodeId: string, name: string) => any
|
||||
hasSetInspectVar: (nodeId: string, name: string, conversationVars: VarInInspect[]) => boolean
|
||||
hasSetInspectVar: (nodeId: string, name: string, sysVars: VarInInspect[], conversationVars: VarInInspect[]) => boolean
|
||||
isInspectVarEdited: (nodeId: string, name: string) => boolean
|
||||
}
|
||||
|
||||
@ -174,17 +174,13 @@ export const createInspectVarsSlice: StateCreator<InspectVarsSliceShape> = (set,
|
||||
})?.value
|
||||
return variable
|
||||
},
|
||||
hasSetInspectVar: (nodeId, name, conversationVars: VarInInspect[]) => {
|
||||
hasSetInspectVar: (nodeId, name, sysVars, conversationVars) => {
|
||||
const isEnv = isENV([nodeId])
|
||||
if (isEnv) // always have value
|
||||
return true
|
||||
const isSys = isSystemVar([nodeId])
|
||||
if (isSys) {
|
||||
const isStartNodeRun = get().nodesWithInspectVars.some((node) => {
|
||||
return node.nodeType === BlockEnum.Start
|
||||
})
|
||||
return isStartNodeRun
|
||||
}
|
||||
if (isSys)
|
||||
return sysVars.some(varItem => varItem.selector?.[1] === name)
|
||||
const isChatVar = isConversationVar([nodeId])
|
||||
if (isChatVar)
|
||||
return conversationVars.some(varItem => varItem.selector?.[1] === name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user