MCPcopy Index your code
hub / github.com/simstudioai/sim / restoreLoopEdges

Method restoreLoopEdges

apps/sim/executor/orchestrators/loop.ts:576–609  ·  view source on GitHub ↗
(loopId: string)

Source from the content-addressed store, hash-verified

574 }
575
576 restoreLoopEdges(loopId: string): void {
577 const loopConfig = this.dag.loopConfigs.get(loopId) as LoopConfigWithNodes | undefined
578 if (!loopConfig) {
579 logger.warn('Loop config not found for edge restoration', { loopId })
580 return
581 }
582
583 const allLoopNodeIds = this.collectAllLoopNodeIds(loopId)
584
585 if (this.edgeManager) {
586 this.edgeManager.clearDeactivatedEdgesForNodes(allLoopNodeIds)
587 }
588
589 for (const nodeId of allLoopNodeIds) {
590 const nodeToRestore = this.dag.nodes.get(nodeId)
591 if (!nodeToRestore) continue
592
593 for (const potentialSourceId of allLoopNodeIds) {
594 const potentialSourceNode = this.dag.nodes.get(potentialSourceId)
595 if (!potentialSourceNode) continue
596
597 for (const [, edge] of potentialSourceNode.outgoingEdges) {
598 if (edge.target === nodeId) {
599 if (
600 !this.isSubflowStartExitBypassEdge(potentialSourceId, nodeId, edge.sourceHandle) &&
601 (edge.sourceHandle === undefined || !CONTROL_BACK_EDGE_HANDLES.has(edge.sourceHandle))
602 ) {
603 nodeToRestore.incomingEdges.add(potentialSourceId)
604 }
605 }
606 }
607 }
608 }
609 }
610
611 private isSubflowStartExitBypassEdge(
612 sourceId: string,

Callers 2

loop.test.tsFile · 0.80

Calls 6

collectAllLoopNodeIdsMethod · 0.95
getMethod · 0.65
warnMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected