Fix: Unable to reconnect after deleting the connection between begin and parser #13868 (#13869)

### What problem does this PR solve?

Fix: Unable to reconnect after deleting the connection between begin and
parser #13868
### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu
2026-03-31 14:44:47 +08:00
committed by GitHub
parent db5ab7bbe8
commit 4f27090289
3 changed files with 21 additions and 5 deletions

View File

@@ -18,10 +18,20 @@ export function CommonHandle({
const { visible, hideModal, showModal } = useSetModalState();
const { canShowDropdown, setActiveDropdown, clearActiveDropdown } =
useDropdownManager();
const { hasChildNode } = useGraphStore((state) => state);
const { hasDownstreamNode, hasUpstreamNode } = useGraphStore(
(state) => state,
);
const isPipeline = useIsPipeline();
const isConnectable = !(isPipeline && hasChildNode(nodeId)); // Using useMemo will cause isConnectable to not be updated when the subsequent connection line is deleted
let isConnectable = true;
if (isPipeline) {
if (props.type === 'source') {
isConnectable = !hasDownstreamNode(nodeId);
} else if (props.type === 'target') {
isConnectable = !hasUpstreamNode(nodeId);
}
}
const value = useMemo(
() => ({

View File

@@ -692,6 +692,7 @@ export const RestrictedUpstreamMap = {
[Operator.Loop]: [Operator.Begin],
[Operator.LoopStart]: [Operator.Begin],
[Operator.ExitLoop]: [Operator.Begin],
[Operator.PDFGenerator]: [Operator.Begin],
};
export const NodeMap = {

View File

@@ -115,7 +115,8 @@ export type RFState = {
) => void; // Deleting a condition of a classification operator will delete the related edge
findAgentToolNodeById: (id: string | null) => string | undefined;
selectNodeIds: (nodeIds: string[]) => void;
hasChildNode: (nodeId: string) => boolean;
hasDownstreamNode: (nodeId: string) => boolean;
hasUpstreamNode: (nodeId: string) => boolean;
};
// this is our useStore hook that we can use in our components to get parts of the store and call actions
@@ -469,7 +470,7 @@ const useGraphStore = create<RFState>()(
const { updateNodeForm, edges, getOperatorTypeFromId } = get();
if (sourceHandle) {
// A handle will connect to multiple downstream nodes
let currentHandleTargets = edges
const currentHandleTargets = edges
.filter(
(x) =>
x.source === source &&
@@ -647,10 +648,14 @@ const useGraphStore = create<RFState>()(
})),
);
},
hasChildNode: (nodeId) => {
hasDownstreamNode: (nodeId) => {
const { edges } = get();
return edges.some((edge) => edge.source === nodeId);
},
hasUpstreamNode: (nodeId) => {
const { edges } = get();
return edges.some((edge) => edge.target === nodeId);
},
})),
{ name: 'graph', trace: true },
),