fix: guard getActiveNodes against undefined graph.nodes

This commit is contained in:
Youzini-afk
2026-04-23 12:38:57 +08:00
parent 2fd714d35c
commit 1f6e15190a

View File

@@ -287,6 +287,7 @@ export function removeNode(graph, nodeId, visited = new Set()) {
* @returns {object[]}
*/
export function getActiveNodes(graph, typeFilter = null) {
if (!Array.isArray(graph?.nodes)) return [];
let nodes = graph.nodes.filter((n) => !n.archived);
if (typeFilter) {
nodes = nodes.filter((n) => n.type === typeFilter);