Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • support multiple blocks in parallel subflow, enhance logs to group by iteration for parallels/loop
  • moved avatars in changelog next to the version number to make it more dense
  • enhance log grouping for parallels/loops to group by iteration

Type of Change

  • Bug fix
  • New feature

Testing

Tested manually, added tests

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots

New grouping for subflow logs:
Screenshot 2025-09-23 at 10 57 52 AM

@vercel
Copy link

vercel bot commented Sep 23, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
sim Error Error Sep 23, 2025 10:14pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Sep 23, 2025 10:14pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Summary

This PR enhances parallel subflow execution to support multiple blocks per iteration and improves log grouping for better debugging. The core executor logic was refactored to properly handle dependency ordering within parallel iterations using virtual block IDs. The loop handler was simplified to use 1-based iteration counting and improved forEach item access. Additionally, the changelog UI was updated to show contributor avatars inline with version numbers for a more compact display.

Key Changes:

  • Parallel Execution: Added support for multiple blocks within parallel subflow iterations with proper dependency resolution
  • Loop Iterations: Changed from 0-based to 1-based iteration counting for better user understanding
  • Trace Spans: Enhanced log grouping to organize parallel and loop execution by iteration for clearer debugging
  • UI Enhancement: Moved contributor avatars next to version numbers in changelog for improved layout density

Issues Found:

  • Loop iteration counter update timing could cause inconsistency if child activation fails
  • Early return in parallel processing might skip other blocks in the same iteration
  • Array access in forEach loops needs adjustment for 1-based iteration counting

Confidence Score: 3/5

  • This PR contains important execution logic changes that require careful testing before merge
  • Score reflects complex executor refactoring with potential edge case issues around timing and iteration handling that could impact workflow execution reliability
  • Pay close attention to apps/sim/executor/index.ts and apps/sim/executor/handlers/loop/loop-handler.ts for execution logic changes

Important Files Changed

File Analysis

Filename        Score        Overview
apps/sim/executor/handlers/loop/loop-handler.ts 4/5 Changed loop iteration to start from 1 instead of 0, simplified logic for forEach items, and improved item access handling
apps/sim/executor/index.ts 3/5 Significant refactor to support parallel block execution with multiple blocks per iteration, added proper dependency handling and iteration completion tracking
apps/sim/lib/logs/execution/trace-spans/trace-spans.ts 4/5 Enhanced groupIterationBlocks function to better organize parallel and loop execution logs with proper iteration grouping
apps/sim/executor/index.test.ts 4/5 Added comprehensive tests for parallel execution ordering, iteration completion detection, and edge cases

Sequence Diagram

sequenceDiagram
    participant E as Executor
    participant PM as ParallelManager
    participant LH as LoopHandler
    participant PB as ParallelBlock
    participant WF as Workflow

    Note over E,WF: Enhanced Parallel Subflow Execution

    E->>E: getNextLayer()
    E->>E: processParallelBlocks()
    
    loop For each active parallel
        E->>E: processParallelIteration(parallelId, iteration)
        
        loop For each node in parallel.nodes
            E->>E: Build dependency graph for iteration
            Note right of E: Creates virtual block IDs:<br/>nodeId_parallel_parallelId_iteration_N
            
            E->>E: Check internal dependencies
            alt All dependencies met
                E->>E: Add to pendingBlocks
                E->>E: Store parallelBlockMapping
            else Dependencies unmet
                E->>E: Skip this block
            end
        end
    end
    
    E->>E: executeLayer(pendingBlocks)
    
    loop For each pending block
        alt Is virtual parallel block
            E->>PM: Get original block from mapping
            E->>LH: Execute with iteration context
            LH->>LH: Set currentIteration (1-based)
            LH->>LH: activateChildNodes()
            LH->>LH: Update loopIterations counter
        else Regular block
            E->>PB: execute()
        end
    end
    
    E->>E: isIterationComplete()
    loop Check all nodes in parallel
        E->>E: Verify virtual block execution
        Note right of E: nodeId_parallel_parallelId_iteration_N
    end
    
    alt All iterations complete
        E->>E: hasMoreParallelWork() = false
        Note over E: Exit execution loop
    else More work available
        E->>E: Continue to next layer
    end
Loading

10 files reviewed, 3 comments

Edit Code Review Bot Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants