🐛 (flowStore.ts): fix assignment to correct property in newFlowPool data structure
This commit is contained in:
parent
749469e100
commit
d804303e94
1 changed files with 26 additions and 26 deletions
|
|
@ -74,7 +74,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
updateFlowPool: (
|
updateFlowPool: (
|
||||||
nodeId: string,
|
nodeId: string,
|
||||||
data: VertexBuildTypeAPI | ChatOutputType | ChatInputType,
|
data: VertexBuildTypeAPI | ChatOutputType | ChatInputType,
|
||||||
buildId?: string
|
buildId?: string,
|
||||||
) => {
|
) => {
|
||||||
let newFlowPool = cloneDeep({ ...get().flowPool });
|
let newFlowPool = cloneDeep({ ...get().flowPool });
|
||||||
if (!newFlowPool[nodeId]) {
|
if (!newFlowPool[nodeId]) {
|
||||||
|
|
@ -90,7 +90,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
}
|
}
|
||||||
//update data results
|
//update data results
|
||||||
else {
|
else {
|
||||||
newFlowPool[nodeId][index].data.message = data as
|
newFlowPool[nodeId][index].data.messages[0] = data as
|
||||||
| ChatOutputType
|
| ChatOutputType
|
||||||
| ChatInputType;
|
| ChatInputType;
|
||||||
}
|
}
|
||||||
|
|
@ -167,7 +167,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
flowsManager.autoSaveCurrentFlow(
|
flowsManager.autoSaveCurrentFlow(
|
||||||
newChange,
|
newChange,
|
||||||
newEdges,
|
newEdges,
|
||||||
get().reactFlowInstance?.getViewport() ?? { x: 0, y: 0, zoom: 1 }
|
get().reactFlowInstance?.getViewport() ?? { x: 0, y: 0, zoom: 1 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -183,7 +183,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
flowsManager.autoSaveCurrentFlow(
|
flowsManager.autoSaveCurrentFlow(
|
||||||
get().nodes,
|
get().nodes,
|
||||||
newChange,
|
newChange,
|
||||||
get().reactFlowInstance?.getViewport() ?? { x: 0, y: 0, zoom: 1 }
|
get().reactFlowInstance?.getViewport() ?? { x: 0, y: 0, zoom: 1 },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -201,7 +201,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
return newChange;
|
return newChange;
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
getNode: (id: string) => {
|
getNode: (id: string) => {
|
||||||
|
|
@ -212,8 +212,8 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
get().nodes.filter((node) =>
|
get().nodes.filter((node) =>
|
||||||
typeof nodeId === "string"
|
typeof nodeId === "string"
|
||||||
? node.id !== nodeId
|
? node.id !== nodeId
|
||||||
: !nodeId.includes(node.id)
|
: !nodeId.includes(node.id),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
deleteEdge: (edgeId) => {
|
deleteEdge: (edgeId) => {
|
||||||
|
|
@ -221,8 +221,8 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
get().edges.filter((edge) =>
|
get().edges.filter((edge) =>
|
||||||
typeof edgeId === "string"
|
typeof edgeId === "string"
|
||||||
? edge.id !== edgeId
|
? edge.id !== edgeId
|
||||||
: !edgeId.includes(edge.id)
|
: !edgeId.includes(edge.id),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
paste: (selection, position) => {
|
paste: (selection, position) => {
|
||||||
|
|
@ -288,7 +288,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
let source = idsMap[edge.source];
|
let source = idsMap[edge.source];
|
||||||
let target = idsMap[edge.target];
|
let target = idsMap[edge.target];
|
||||||
const sourceHandleObject: sourceHandleType = scapeJSONParse(
|
const sourceHandleObject: sourceHandleType = scapeJSONParse(
|
||||||
edge.sourceHandle!
|
edge.sourceHandle!,
|
||||||
);
|
);
|
||||||
let sourceHandle = scapedJSONStringfy({
|
let sourceHandle = scapedJSONStringfy({
|
||||||
...sourceHandleObject,
|
...sourceHandleObject,
|
||||||
|
|
@ -298,7 +298,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
|
|
||||||
edge.data.sourceHandle = sourceHandleObject;
|
edge.data.sourceHandle = sourceHandleObject;
|
||||||
const targetHandleObject: targetHandleType = scapeJSONParse(
|
const targetHandleObject: targetHandleType = scapeJSONParse(
|
||||||
edge.targetHandle!
|
edge.targetHandle!,
|
||||||
);
|
);
|
||||||
let targetHandle = scapedJSONStringfy({
|
let targetHandle = scapedJSONStringfy({
|
||||||
...targetHandleObject,
|
...targetHandleObject,
|
||||||
|
|
@ -319,7 +319,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
className: "stroke-gray-900 ",
|
className: "stroke-gray-900 ",
|
||||||
selected: false,
|
selected: false,
|
||||||
},
|
},
|
||||||
newEdges.map((edge) => ({ ...edge, selected: false }))
|
newEdges.map((edge) => ({ ...edge, selected: false })),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
get().setEdges(newEdges);
|
get().setEdges(newEdges);
|
||||||
|
|
@ -338,10 +338,10 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
});
|
});
|
||||||
|
|
||||||
const newNodes = get().nodes.filter(
|
const newNodes = get().nodes.filter(
|
||||||
(node) => !nodesIdsSelected.includes(node.id)
|
(node) => !nodesIdsSelected.includes(node.id),
|
||||||
);
|
);
|
||||||
const newEdges = get().edges.filter(
|
const newEdges = get().edges.filter(
|
||||||
(edge) => !edgesIdsSelected.includes(edge.id)
|
(edge) => !edgesIdsSelected.includes(edge.id),
|
||||||
);
|
);
|
||||||
|
|
||||||
set({ nodes: newNodes, edges: newEdges });
|
set({ nodes: newNodes, edges: newEdges });
|
||||||
|
|
@ -399,7 +399,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
style: { stroke: "#555" },
|
style: { stroke: "#555" },
|
||||||
className: "stroke-foreground stroke-connection",
|
className: "stroke-foreground stroke-connection",
|
||||||
},
|
},
|
||||||
oldEdges
|
oldEdges,
|
||||||
);
|
);
|
||||||
|
|
||||||
return newEdges;
|
return newEdges;
|
||||||
|
|
@ -409,7 +409,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
.autoSaveCurrentFlow(
|
.autoSaveCurrentFlow(
|
||||||
get().nodes,
|
get().nodes,
|
||||||
newEdges,
|
newEdges,
|
||||||
get().reactFlowInstance?.getViewport() ?? { x: 0, y: 0, zoom: 1 }
|
get().reactFlowInstance?.getViewport() ?? { x: 0, y: 0, zoom: 1 },
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
unselectAll: () => {
|
unselectAll: () => {
|
||||||
|
|
@ -444,7 +444,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
function validateSubgraph(nodes: string[]) {
|
function validateSubgraph(nodes: string[]) {
|
||||||
const errorsObjs = validateNodes(
|
const errorsObjs = validateNodes(
|
||||||
get().nodes.filter((node) => nodes.includes(node.id)),
|
get().nodes.filter((node) => nodes.includes(node.id)),
|
||||||
get().edges
|
get().edges,
|
||||||
);
|
);
|
||||||
|
|
||||||
const errors = errorsObjs.map((obj) => obj.errors).flat();
|
const errors = errorsObjs.map((obj) => obj.errors).flat();
|
||||||
|
|
@ -463,13 +463,13 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
function handleBuildUpdate(
|
function handleBuildUpdate(
|
||||||
vertexBuildData: VertexBuildTypeAPI,
|
vertexBuildData: VertexBuildTypeAPI,
|
||||||
status: BuildStatus,
|
status: BuildStatus,
|
||||||
runId: string
|
runId: string,
|
||||||
) {
|
) {
|
||||||
if (vertexBuildData && vertexBuildData.inactivated_vertices) {
|
if (vertexBuildData && vertexBuildData.inactivated_vertices) {
|
||||||
get().removeFromVerticesBuild(vertexBuildData.inactivated_vertices);
|
get().removeFromVerticesBuild(vertexBuildData.inactivated_vertices);
|
||||||
get().updateBuildStatus(
|
get().updateBuildStatus(
|
||||||
vertexBuildData.inactivated_vertices,
|
vertexBuildData.inactivated_vertices,
|
||||||
BuildStatus.INACTIVE
|
BuildStatus.INACTIVE,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -485,14 +485,14 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
|
|
||||||
// next_vertices_ids should be next_vertices_ids without the inactivated vertices
|
// next_vertices_ids should be next_vertices_ids without the inactivated vertices
|
||||||
const next_vertices_ids = vertexBuildData.next_vertices_ids.filter(
|
const next_vertices_ids = vertexBuildData.next_vertices_ids.filter(
|
||||||
(id) => !vertexBuildData.inactivated_vertices?.includes(id)
|
(id) => !vertexBuildData.inactivated_vertices?.includes(id),
|
||||||
);
|
);
|
||||||
const top_level_vertices = vertexBuildData.top_level_vertices.filter(
|
const top_level_vertices = vertexBuildData.top_level_vertices.filter(
|
||||||
(vertex) => !vertexBuildData.inactivated_vertices?.includes(vertex)
|
(vertex) => !vertexBuildData.inactivated_vertices?.includes(vertex),
|
||||||
);
|
);
|
||||||
const nextVertices: VertexLayerElementType[] = zip(
|
const nextVertices: VertexLayerElementType[] = zip(
|
||||||
next_vertices_ids,
|
next_vertices_ids,
|
||||||
top_level_vertices
|
top_level_vertices,
|
||||||
).map(([id, reference]) => ({ id: id!, reference }));
|
).map(([id, reference]) => ({ id: id!, reference }));
|
||||||
|
|
||||||
const newLayers = [
|
const newLayers = [
|
||||||
|
|
@ -514,7 +514,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
|
|
||||||
get().addDataToFlowPool(
|
get().addDataToFlowPool(
|
||||||
{ ...vertexBuildData, run_id: runId },
|
{ ...vertexBuildData, run_id: runId },
|
||||||
vertexBuildData.id
|
vertexBuildData.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
useFlowStore.getState().updateBuildStatus([vertexBuildData.id], status);
|
useFlowStore.getState().updateBuildStatus([vertexBuildData.id], status);
|
||||||
|
|
@ -523,7 +523,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
const newFlowBuildStatus = { ...get().flowBuildStatus };
|
const newFlowBuildStatus = { ...get().flowBuildStatus };
|
||||||
// filter out the vertices that are not status
|
// filter out the vertices that are not status
|
||||||
const verticesToUpdate = verticesIds?.filter(
|
const verticesToUpdate = verticesIds?.filter(
|
||||||
(id) => newFlowBuildStatus[id]?.status !== BuildStatus.BUILT
|
(id) => newFlowBuildStatus[id]?.status !== BuildStatus.BUILT,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (verticesToUpdate) {
|
if (verticesToUpdate) {
|
||||||
|
|
@ -593,7 +593,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
verticesLayers: VertexLayerElementType[][];
|
verticesLayers: VertexLayerElementType[][];
|
||||||
runId: string;
|
runId: string;
|
||||||
verticesToRun: string[];
|
verticesToRun: string[];
|
||||||
} | null
|
} | null,
|
||||||
) => {
|
) => {
|
||||||
set({ verticesBuild: vertices });
|
set({ verticesBuild: vertices });
|
||||||
},
|
},
|
||||||
|
|
@ -618,7 +618,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
// that are going to be built
|
// that are going to be built
|
||||||
verticesIds: get().verticesBuild!.verticesIds.filter(
|
verticesIds: get().verticesBuild!.verticesIds.filter(
|
||||||
// keep the vertices that are not in the list of vertices to remove
|
// keep the vertices that are not in the list of vertices to remove
|
||||||
(vertex) => !vertices.includes(vertex)
|
(vertex) => !vertices.includes(vertex),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue