Skip to content

Commit 0e36ec0

Browse files
committed
fix: Re-dispatch backend ready event after a tick and refine curved edge detection to treat middle parallel edges as straight.
1 parent 92a728b commit 0e36ec0

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

src/NodeCanvas.jsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10512,9 +10512,15 @@ function NodeCanvas() {
1051210512
? edge.directionality.arrowsToward
1051310513
: new Set(Array.isArray(edge.directionality?.arrowsToward) ? edge.directionality.arrowsToward : []);
1051410514

10515-
// Check if this is a curved edge (parallel edge)
10515+
// Check if this is a curved edge (parallel edge with non-zero offset)
10516+
// The middle edge in an odd-numbered group has offset 0 and is straight
1051610517
const curveInfo = edgeCurveInfo.get(edge.id);
10517-
const isCurvedEdge = curveInfo && curveInfo.totalInPair > 1;
10518+
let isCurvedEdge = false;
10519+
if (curveInfo && curveInfo.totalInPair > 1) {
10520+
const centerIndex = (curveInfo.totalInPair - 1) / 2;
10521+
const offsetSteps = curveInfo.pairIndex - centerIndex;
10522+
isCurvedEdge = offsetSteps !== 0;
10523+
}
1051810524

1051910525
// Only shorten connections at ends with arrows or hover state
1052010526
// For curved edges, NEVER change endpoints - we use trimmed paths instead
@@ -11724,9 +11730,15 @@ function NodeCanvas() {
1172411730
? edge.directionality.arrowsToward
1172511731
: new Set(Array.isArray(edge.directionality?.arrowsToward) ? edge.directionality.arrowsToward : []);
1172611732

11727-
// Check if this is a curved edge (parallel edge)
11733+
// Check if this is a curved edge (parallel edge with non-zero offset)
11734+
// The middle edge in an odd-numbered group has offset 0 and is straight
1172811735
const curveInfo = edgeCurveInfo.get(edge.id);
11729-
const isCurvedEdge = curveInfo && curveInfo.totalInPair > 1;
11736+
let isCurvedEdge = false;
11737+
if (curveInfo && curveInfo.totalInPair > 1) {
11738+
const centerIndex = (curveInfo.totalInPair - 1) / 2;
11739+
const offsetSteps = curveInfo.pairIndex - centerIndex;
11740+
isCurvedEdge = offsetSteps !== 0;
11741+
}
1173011742

1173111743
// Only shorten connections at ends with arrows or hover state
1173211744
// For curved edges, NEVER change endpoints - we use trimmed paths instead

src/components/GitFederationBootstrap.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export default function GitFederationBootstrap({ enableEagerInit = false }) {
5353
backendRef.current = backend;
5454
window._universeBackendReady = true;
5555
window.dispatchEvent(new CustomEvent('universe-backend-ready'));
56+
// Safety: Re-dispatch after a tick to catch listeners mounting in same cycle
57+
setTimeout(() => window.dispatchEvent(new CustomEvent('universe-backend-ready')), 100);
5658
console.log('[GitFederationBootstrap] Backend ready for commands (initialization continuing in background)');
5759

5860
// Start initialization in background with a warning if it takes too long

0 commit comments

Comments
 (0)