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