feat: last run frontend (#21369)

The frontend of feat: Persist Variables for Enhanced Debugging Workflow (#20699).

Co-authored-by: jZonG <jzongcode@gmail.com>
This commit is contained in:
Joel
2025-06-24 09:10:30 +08:00
committed by GitHub
parent 10b738a296
commit 1a1bfd4048
122 changed files with 5888 additions and 2061 deletions

View File

@@ -10,6 +10,7 @@ import {
useNodesReadOnly,
useWorkflow,
} from '@/app/components/workflow/hooks'
import useInspectVarsCrud from '../../hooks/use-inspect-vars-crud'
const useConfig = (id: string, payload: StartNodeType) => {
const { nodesReadOnly: readOnly } = useNodesReadOnly()
@@ -18,6 +19,13 @@ const useConfig = (id: string, payload: StartNodeType) => {
const { inputs, setInputs } = useNodeCrud<StartNodeType>(id, payload)
const {
deleteNodeInspectorVars,
renameInspectVarName,
nodesWithInspectVars,
deleteInspectVar,
} = useInspectVarsCrud()
const [isShowAddVarModal, {
setTrue: showAddVarModal,
setFalse: hideAddVarModal,
@@ -31,6 +39,12 @@ const useConfig = (id: string, payload: StartNodeType) => {
const [removedIndex, setRemoveIndex] = useState(0)
const handleVarListChange = useCallback((newList: InputVar[], moreInfo?: { index: number; payload: MoreInfo }) => {
if (moreInfo?.payload?.type === ChangeType.remove) {
const varId = nodesWithInspectVars.find(node => node.nodeId === id)?.vars.find((varItem) => {
return varItem.name === moreInfo?.payload?.payload?.beforeKey
})?.id
if(varId)
deleteInspectVar(id, varId)
if (isVarUsedInNodes([id, moreInfo?.payload?.payload?.beforeKey || ''])) {
showRemoveVarConfirm()
setRemovedVar([id, moreInfo?.payload?.payload?.beforeKey || ''])
@@ -46,8 +60,12 @@ const useConfig = (id: string, payload: StartNodeType) => {
if (moreInfo?.payload?.type === ChangeType.changeVarName) {
const changedVar = newList[moreInfo.index]
handleOutVarRenameChange(id, [id, inputs.variables[moreInfo.index].variable], [id, changedVar.variable])
renameInspectVarName(id, inputs.variables[moreInfo.index].variable, changedVar.variable)
}
}, [handleOutVarRenameChange, id, inputs, isVarUsedInNodes, setInputs, showRemoveVarConfirm])
else if(moreInfo?.payload?.type !== ChangeType.remove) { // edit var type
deleteNodeInspectorVars(id)
}
}, [deleteInspectVar, deleteNodeInspectorVars, handleOutVarRenameChange, id, inputs, isVarUsedInNodes, nodesWithInspectVars, renameInspectVarName, setInputs, showRemoveVarConfirm])
const removeVarInNode = useCallback(() => {
const newInputs = produce(inputs, (draft) => {