fix: skip edges that cross ELK root graph boundaries
Edges connecting main flow nodes to handler section nodes (ON_EXCEPTION, ON_COMPLETION) now span different ELK root graphs. ELK throws UnsupportedGraphException when an edge connects nodes in different layout hierarchies. Skip these cross-root edges — the frontend doesn't render them anyway (handler sections are separated visually). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -250,7 +250,8 @@ public class ElkDiagramRenderer implements DiagramRenderer {
|
|||||||
handlerRoots.add(handlerRoot);
|
handlerRoots.add(handlerRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create ELK edges
|
// Create ELK edges — skip edges that cross between different ELK root graphs
|
||||||
|
// (e.g., main flow → handler section). These cannot be laid out by ELK.
|
||||||
if (graph.getEdges() != null) {
|
if (graph.getEdges() != null) {
|
||||||
for (RouteEdge re : graph.getEdges()) {
|
for (RouteEdge re : graph.getEdges()) {
|
||||||
ElkNode sourceElk = elkNodeMap.get(re.getSource());
|
ElkNode sourceElk = elkNodeMap.get(re.getSource());
|
||||||
@@ -259,6 +260,13 @@ public class ElkDiagramRenderer implements DiagramRenderer {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip edges that cross ELK root boundaries
|
||||||
|
ElkNode sourceRoot = getElkRoot(sourceElk);
|
||||||
|
ElkNode targetRoot = getElkRoot(targetElk);
|
||||||
|
if (sourceRoot != targetRoot) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Determine the containing node for the edge
|
// Determine the containing node for the edge
|
||||||
ElkNode containingNode = findCommonParent(sourceElk, targetElk);
|
ElkNode containingNode = findCommonParent(sourceElk, targetElk);
|
||||||
|
|
||||||
@@ -542,6 +550,15 @@ public class ElkDiagramRenderer implements DiagramRenderer {
|
|||||||
// ELK graph helpers
|
// ELK graph helpers
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
|
|
||||||
|
/** Walk up to the top-level root of an ELK node's hierarchy. */
|
||||||
|
private ElkNode getElkRoot(ElkNode node) {
|
||||||
|
ElkNode current = node;
|
||||||
|
while (current.getParent() != null) {
|
||||||
|
current = current.getParent();
|
||||||
|
}
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
|
||||||
private ElkNode findCommonParent(ElkNode a, ElkNode b) {
|
private ElkNode findCommonParent(ElkNode a, ElkNode b) {
|
||||||
if (a.getParent() == b.getParent()) {
|
if (a.getParent() == b.getParent()) {
|
||||||
return a.getParent();
|
return a.getParent();
|
||||||
|
|||||||
Reference in New Issue
Block a user