@open-mercato/core 0.6.6-develop.6524.1.a78cc4694e → 0.6.6-develop.6526.1.6df9b3dd84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -388,10 +388,15 @@ function calculateSmartLayout(
388
388
  const { id, level } = queue.shift()!
389
389
  const currentLevel = levels.get(id)
390
390
 
391
- // Take the maximum level (longest path)
392
- if (currentLevel === undefined || level > currentLevel) {
393
- levels.set(id, level)
394
- }
391
+ // Only propagate when this path improves the node's level (longest path).
392
+ // Without this guard a cyclic graph (renegotiation/revision loops) keeps
393
+ // re-enqueuing children forever and freezes the browser (script timeout).
394
+ if (currentLevel !== undefined && level <= currentLevel) continue
395
+ levels.set(id, level)
396
+
397
+ // Safety cap: in a DAG a node's level is bounded by the node count; a
398
+ // higher value means we are walking a cycle, so stop descending.
399
+ if (level > steps.length) continue
395
400
 
396
401
  const children = outgoing.get(id) || []
397
402
  for (const child of children) {