Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions GUI/src/components/FlowElementsPopup/PreviousVariables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ const PreviousVariables: FC<PreviousVariablesProps> = ({ node }) => {
key: 'Empty Content Type',
value: stringToTemplate(''),
},
{
id: predefinedInputKeys[1],
key: 'Chat Id',
value: stringToTemplate('chatId'),
},
];

setAssignedVariables([...assignElements, ...predefinedInputElements, ...newAssignElements]);
Expand Down
11 changes: 10 additions & 1 deletion GUI/src/hooks/flow/useEdgeAdd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,16 @@ function useEdgeAdd(id: string) {
let newEdges: Edge[] = [];

setEdges((edges) => {
newEdges = edges.filter((e) => e.id !== id).concat([sourceEdge], targetEdge ?? [], ghostEdges);
const edgeIndex = edges.findIndex((e) => e.id === id);
const remainingEdges = edges.filter((e) => e.id !== id);
const insertIndex = edgeIndex === -1 ? remainingEdges.length : edgeIndex;
newEdges = [
...remainingEdges.slice(0, insertIndex),
sourceEdge,
...(targetEdge ? [targetEdge] : []),
...ghostEdges,
...remainingEdges.slice(insertIndex),
];
return newEdges;
});

Expand Down
7 changes: 6 additions & 1 deletion GUI/src/hooks/flow/useOnNodeDelete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ const processDeletedNodes = (
updatedNodes = [...updatedNodes.filter((n) => n.id !== node.id), ...newGhostNodes];
updatedEdges = [...getRemainingEdges(updatedEdges, getConnectedEdges([node], updatedEdges)), ...newEdges];
} else {
if (outgoers.length === 0 || outgoers.length > 1) {
const edgesWithoutDeleted = getRemainingEdges(updatedEdges, getConnectedEdges([node], updatedEdges));
if (
outgoers.length === 0 ||
outgoers.length > 1 ||
(outgoers.length === 1 && getIncomers(outgoers[0], updatedNodes, edgesWithoutDeleted).length > 0)
) {
const ghostNode: Node = {
id: generateUniqueId(),
type: 'ghost',
Expand Down
Loading