mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix(triggers): update filtering logic for edges (#1856)
This commit is contained in:
@@ -111,7 +111,7 @@ export function useBlockConnections(blockId: string) {
|
||||
return merged
|
||||
}
|
||||
|
||||
// Filter out edges between trigger blocks - triggers are independent entry points
|
||||
// Filter out all incoming edges to trigger blocks - triggers are independent entry points
|
||||
// This ensures UI tags only show blocks that are actually connected in execution
|
||||
const filteredEdges = edges.filter((edge) => {
|
||||
const sourceBlock = blocks[edge.source]
|
||||
@@ -122,19 +122,14 @@ export function useBlockConnections(blockId: string) {
|
||||
return true
|
||||
}
|
||||
|
||||
const sourceIsTrigger = TriggerUtils.isTriggerBlock({
|
||||
type: sourceBlock.type,
|
||||
triggerMode: sourceBlock.triggerMode,
|
||||
})
|
||||
|
||||
const targetIsTrigger = TriggerUtils.isTriggerBlock({
|
||||
type: targetBlock.type,
|
||||
triggerMode: targetBlock.triggerMode,
|
||||
})
|
||||
|
||||
// Filter out edges where source is trigger AND target is trigger
|
||||
// Keep edges from triggers to regular blocks
|
||||
return !(sourceIsTrigger && targetIsTrigger)
|
||||
// Filter out ALL incoming edges to trigger blocks
|
||||
// Triggers are independent entry points and should not have incoming connections
|
||||
return !targetIsTrigger
|
||||
})
|
||||
|
||||
// Find all blocks along paths leading to this block (using filtered edges)
|
||||
|
||||
+2
-10
@@ -56,7 +56,7 @@ export async function executeWorkflowWithFullLogging(
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter out edges between trigger blocks - triggers are independent entry points
|
||||
* Filter out all incoming edges to trigger blocks - triggers are independent entry points
|
||||
* This ensures execution and UI only show edges that are actually connected in execution
|
||||
* @param blocks - Record of blocks keyed by block ID
|
||||
* @param edges - Array of edges to filter
|
||||
@@ -67,23 +67,15 @@ export function filterEdgesFromTriggerBlocks(blocks: Record<string, any>, edges:
|
||||
const sourceBlock = blocks[edge.source]
|
||||
const targetBlock = blocks[edge.target]
|
||||
|
||||
// If either block not found, keep the edge (might be in a different state structure)
|
||||
if (!sourceBlock || !targetBlock) {
|
||||
return true
|
||||
}
|
||||
|
||||
const sourceIsTrigger = TriggerUtils.isTriggerBlock({
|
||||
type: sourceBlock.type,
|
||||
triggerMode: sourceBlock.triggerMode,
|
||||
})
|
||||
|
||||
const targetIsTrigger = TriggerUtils.isTriggerBlock({
|
||||
type: targetBlock.type,
|
||||
triggerMode: targetBlock.triggerMode,
|
||||
})
|
||||
|
||||
// Filter out edges where source is trigger AND target is trigger
|
||||
// Keep edges from triggers to regular blocks
|
||||
return !(sourceIsTrigger && targetIsTrigger)
|
||||
return !targetIsTrigger
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user