diff --git a/src/ui/src/components/visualizer/app_service.ts b/src/ui/src/components/visualizer/app_service.ts index a57ca882..6d44f55f 100644 --- a/src/ui/src/components/visualizer/app_service.ts +++ b/src/ui/src/components/visualizer/app_service.ts @@ -172,7 +172,10 @@ export class AppService { } graph.subGraphIds.push(...node.subgraphIds); for (const subgraphId of node.subgraphIds) { - graphById[subgraphId].parentGraphId = graph.id; + const subgraph = graphById[subgraphId]; + if (subgraph) { + subgraph.parentGraphId = graph.id; + } } } } @@ -190,7 +193,9 @@ export class AppService { if (root == null) { graphs = rootGraphs; } else { - graphs = (root.subGraphIds || []).map((id) => graphById[id]); + graphs = (root.subGraphIds || []) + .map((id) => graphById[id]) + .filter((graphs) => graphs != null); } // Sort by node count. graphs.sort((g1, g2) => g2.nodes.length - g1.nodes.length); diff --git a/src/ui/src/components/visualizer/webgl_renderer.ts b/src/ui/src/components/visualizer/webgl_renderer.ts index ec1b4f5f..3e0f4560 100644 --- a/src/ui/src/components/visualizer/webgl_renderer.ts +++ b/src/ui/src/components/visualizer/webgl_renderer.ts @@ -2820,6 +2820,14 @@ export class WebglRenderer implements OnInit, OnDestroy { } private async openSubgraph(subgraphId: string) { + const graph = this.appService.getGraphById(subgraphId); + if (!graph) { + const msg = `No graph found for subgraph id: "${subgraphId}"`; + console.warn(msg); + this.snackBar.open(msg, 'Dismiss'); + return; + } + // Add breadcrumb. this.appService.addSubgraphBreadcrumbItem( this.paneId, @@ -2829,14 +2837,11 @@ export class WebglRenderer implements OnInit, OnDestroy { ); // Open the subgraph in current pane. - const graph = this.appService.getGraphById(subgraphId); - if (graph) { - this.appService.selectNode(this.paneId, undefined); - this.appService.setFlattenLayersInCurrentPane(false); - this.appService.curInitialUiState.set(undefined); - this.appService.curToLocateNodeInfo.set(undefined); - this.appService.selectGraphInCurrentPane(graph); - } + this.appService.selectNode(this.paneId, undefined); + this.appService.setFlattenLayersInCurrentPane(false); + this.appService.curInitialUiState.set(undefined); + this.appService.curToLocateNodeInfo.set(undefined); + this.appService.selectGraphInCurrentPane(graph); } private getGroupNodeLabelSeparatorId(