mirror of
https://github.com/langgenius/dify.git
synced 2026-02-24 18:05:11 +00:00
fix(workflow): lock chatflow start node from type change
This commit is contained in:
@@ -102,6 +102,7 @@ describe('workflow-app/useAvailableNodesMetaData', () => {
|
||||
expect(nodeTypes).toContain(BlockEnum.TriggerPlugin)
|
||||
expect(nodeTypes).not.toContain(BlockEnum.Answer)
|
||||
expect(startNode?.metaData.isUndeletable).toBe(false)
|
||||
expect(startNode?.metaData.isTypeFixed).toBe(false)
|
||||
})
|
||||
|
||||
it('should include chatflow-only nodes when chat mode is enabled', () => {
|
||||
@@ -117,6 +118,7 @@ describe('workflow-app/useAvailableNodesMetaData', () => {
|
||||
expect(nodeTypes).not.toContain(BlockEnum.TriggerSchedule)
|
||||
expect(nodeTypes).not.toContain(BlockEnum.TriggerPlugin)
|
||||
expect(startNode?.metaData.isUndeletable).toBe(true)
|
||||
expect(startNode?.metaData.isTypeFixed).toBe(true)
|
||||
})
|
||||
|
||||
it('should hide sandbox-only nodes and keep agent when sandbox is disabled', () => {
|
||||
|
||||
@@ -57,6 +57,7 @@ export const useAvailableNodesMetaData = () => {
|
||||
metaData: {
|
||||
...StartDefault.metaData,
|
||||
isUndeletable: isChatMode, // start node is undeletable in chat mode, @use-nodes-interactions: handleNodeDelete function
|
||||
isTypeFixed: isChatMode, // start node (user input) is immutable in chatflow mode
|
||||
},
|
||||
}), [isChatMode])
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ import { checkMakeGroupAvailability } from './use-make-group'
|
||||
import { useNodesMetaData } from './use-nodes-meta-data'
|
||||
import { useNodesSyncDraft } from './use-nodes-sync-draft'
|
||||
import {
|
||||
useIsChatMode,
|
||||
useNodesReadOnly,
|
||||
useWorkflow,
|
||||
useWorkflowReadOnly,
|
||||
@@ -326,6 +327,7 @@ export const useNodesInteractions = () => {
|
||||
const { store: workflowHistoryStore } = useWorkflowHistoryStore()
|
||||
const { handleSyncWorkflowDraft } = useNodesSyncDraft()
|
||||
const { getAfterNodesInSameBranch } = useWorkflow()
|
||||
const isChatMode = useIsChatMode()
|
||||
const { getNodesReadOnly } = useNodesReadOnly()
|
||||
const { getWorkflowReadOnly } = useWorkflowReadOnly()
|
||||
const { handleSetHelpline } = useHelpline()
|
||||
@@ -1963,7 +1965,14 @@ export const useNodesInteractions = () => {
|
||||
return
|
||||
|
||||
const { nodes, setNodes, edges, setEdges } = collaborativeWorkflow.getState()
|
||||
const currentNode = nodes.find(node => node.id === currentNodeId)!
|
||||
const currentNode = nodes.find(node => node.id === currentNodeId)
|
||||
if (!currentNode)
|
||||
return
|
||||
|
||||
// In chatflow mode, the Start (user input) node is immutable.
|
||||
if (isChatMode && currentNode.data.type === BlockEnum.Start)
|
||||
return
|
||||
|
||||
const connectedEdges = getConnectedEdges([currentNode], edges)
|
||||
const nodesWithSameType = nodes.filter(
|
||||
node => node.data.type === nodeType,
|
||||
@@ -2051,6 +2060,7 @@ export const useNodesInteractions = () => {
|
||||
})
|
||||
},
|
||||
[
|
||||
isChatMode,
|
||||
getNodesReadOnly,
|
||||
collaborativeWorkflow,
|
||||
handleSyncWorkflowDraft,
|
||||
|
||||
Reference in New Issue
Block a user