EAGLE-1688: Minor fixes and optimisations to GraphRenderer - #1069
Open
james-strauss-uwa wants to merge 8 commits into
Open
EAGLE-1688: Minor fixes and optimisations to GraphRenderer#1069james-strauss-uwa wants to merge 8 commits into
james-strauss-uwa wants to merge 8 commits into
Conversation
Contributor
Reviewer's GuideGraphRenderer receives interaction and zoom robustness fixes, iterable- and set-based edge selection optimization with E2E coverage, cycle-safe ancestry/depth traversal, and squared-distance port matching. Sequence diagram for optimized edge selectionsequenceDiagram
participant GraphRenderer
participant NodeCollection
participant EdgeCollection
participant Edge
GraphRenderer->>NodeCollection: iterate selected nodes
NodeCollection-->>GraphRenderer: Node iterable
GraphRenderer->>GraphRenderer: node.getId()
GraphRenderer->>GraphRenderer: node.getInputApplication()
GraphRenderer->>GraphRenderer: node.getOutputApplication()
GraphRenderer->>EdgeCollection: iterate edges
EdgeCollection-->>GraphRenderer: Edge iterable
GraphRenderer->>Edge: getSrcNode() and getDestNode()
GraphRenderer->>GraphRenderer: findEdgesContainedByNodes()
GraphRenderer-->>GraphRenderer: edges with both endpoints in nodeIds
Sequence diagram for cycle-safe ancestry traversalsequenceDiagram
participant GraphRenderer
participant Node
GraphRenderer->>Node: getId()
GraphRenderer->>GraphRenderer: visitedIds.has(nodeId)
alt ancestor found
GraphRenderer-->>GraphRenderer: return true
else unvisited parent
GraphRenderer->>GraphRenderer: visitedIds.add(nodeId)
GraphRenderer->>Node: getParent()
Node-->>GraphRenderer: parent or null
else cycle detected
GraphRenderer-->>GraphRenderer: return false
end
Flow diagram for robust graph zoom scalingflowchart TD
A[Wheel zoom input] --> B[Read current global scale]
B --> C[Compute newScale]
C --> D[Take absolute value]
D --> E[Clamp to MIN_GRAPH_SCALE]
E --> F[Update eagle.globalScale]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/GraphRenderer.ts" line_range="2286-2288" />
<code_context>
while (nodeParent != null){
- if (iterations > MAX_ITERATIONS){
- console.error("too many iterations in findDepthOfNode()");
+ nodeId = node.getId();
+ if (visitedIds.has(nodeId)){
+ console.error("cycle detected in findDepthOfNode()");
break;
}
</code_context>
<issue_to_address>
**issue (bug_risk):** `nodeId` is assigned from the original `node` on every parent-traversal iteration, so the second iteration always sees the original node ID in `visitedIds` and breaks. Nodes nested more than one parent deep therefore receive an incomplete depth, producing incorrect draw order and selection ordering.
**Triggers:** When a node has a parent that itself has a parent.
**Suggested fix:** Track the node currently being traversed, such as using `nodeParent.getId()` for cycle detection and advancing the traversal node after each parent lookup.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: src/GraphRenderer.ts:2288
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed bug where selecting a node would become a drag, even if the node didn't move or hardly moved.
Prevent possible divide-by-zero when scaling graph.
Use squared distance when finding nearby matching ports.
Better way to detect cycles in graphs (no arbitrary 32 edge or 10 edge limits)
Optimised method for depth first traversal of nodes when determining draw order.
Optimised method for determining which edges are contained within a selection area.
Summary by Sourcery
Improve GraphRenderer interaction reliability and graph traversal performance while adding safeguards for scaling and cyclic hierarchies.
Bug Fixes:
Enhancements:
Tests: