Skip to content

Conversation

thomtrp
Copy link
Contributor

@thomtrp thomtrp commented Sep 11, 2025

  • Create empty node on iterator creation
  • Add options on step creation to insert in loop
  • Handle properly when a step is removed from loop
  • Remove loopNextStepIds from frontend action
  • Add a frontend skeleton for empty action
Enregistrement.de.l.ecran.2025-09-11.a.16.56.29.mov

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 Summary

This PR introduces comprehensive support for inserting workflow steps into iterator loop structures. The main changes include:

Backend Changes:

  • Adds a new WorkflowStepCreationOptions type with iterator-specific settings (iteratorStepId, shouldInsertToLoop)
  • Introduces an optional options field to the CreateWorkflowVersionStepInput DTO for controlling step insertion behavior
  • Refactors the insertStep utility to handle loop insertion via new updateStepsWithOptions function that manages initialLoopStepIds arrays
  • Updates removeStep utility to properly clean up iterator references when steps are deleted from loops
  • Adds automatic empty node creation when iterator steps are created through the new createEmptyNodeForIteratorStep method
  • Simplifies type handling by removing legacy string/array union types for initialLoopStepIds, standardizing to string[] only

Frontend Changes:

  • Introduces a new EMPTY workflow action type with corresponding schema and UI components
  • Adds WorkflowEditActionEmpty component as a placeholder/skeleton for empty workflow steps
  • Updates workflow rendering components to handle the new EMPTY action type with appropriate styling (tertiary font color)
  • Removes manual UI input for initialLoopStepIds in the iterator component, moving to automated management

Schema Changes:

  • Adds workflowEmptyActionSchema and workflowEmptyActionSettingsSchema to support placeholder nodes
  • Updates the workflow action discriminated union to include the new EMPTY type
  • Standardizes initialLoopStepIds typing by removing the temporary string union workaround

The implementation follows a pattern where iterator creation automatically generates empty placeholder nodes that provide visual insertion points for users to add steps within loop structures. This replaces the previous manual step ID management approach with a more intuitive drag-and-drop style workflow builder experience.

Confidence score: 3/5

  • This PR introduces significant complexity around iterator loop management that could cause issues if edge cases aren't properly handled
  • Score reflects the extensive changes to core workflow logic including step creation, removal, and iterator handling that require careful testing
  • Pay close attention to the iterator step creation logic in workflow-version-step.workspace-service.ts and the loop insertion handling in insert-step.ts

21 files reviewed, 2 comments

Edit Code Review Bot Settings | Greptile

Comment on lines 165 to 181
const iteratorStep: WorkflowIteratorAction = {
id: '1',
name: 'Iterator 1',
type: WorkflowActionType.ITERATOR,
settings: {
input: {
initialLoopStepIds: ['existing-loop-step'],
items: [],
},
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: { value: false },
continueOnFailure: { value: false },
},
},
valid: true,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider extracting this iterator step mock to a helper function since it's duplicated in both test cases

Suggested change
const iteratorStep: WorkflowIteratorAction = {
id: '1',
name: 'Iterator 1',
type: WorkflowActionType.ITERATOR,
settings: {
input: {
initialLoopStepIds: ['existing-loop-step'],
items: [],
},
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: { value: false },
continueOnFailure: { value: false },
},
},
valid: true,
};
const createMockIteratorAction = (
id: string,
initialLoopStepIds: string[] = [],
): WorkflowIteratorAction => ({
id,
name: `Iterator ${id}`,
type: WorkflowActionType.ITERATOR,
settings: {
input: {
initialLoopStepIds,
items: [],
},
outputSchema: {},
errorHandlingOptions: {
retryOnFailure: { value: false },
continueOnFailure: { value: false },
},
},
valid: true,
});

@thomtrp thomtrp force-pushed the tt-improve-loop-insertion branch from 446ff66 to 3b517ef Compare September 11, 2025 15:06
Copy link
Contributor

github-actions bot commented Sep 11, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:31607

This environment will automatically shut down when the PR is closed or after 5 hours.

@@ -722,6 +733,12 @@ export class WorkflowVersionStepWorkspaceService {
};
}
case WorkflowActionType.ITERATOR: {
const emptyNodeStep = await this.createEmptyNodeForIteratorStep({
Copy link
Contributor

Choose a reason for hiding this comment

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

As we do that we should update the front in order to avoid adding a fake loop step. Maybe in another PR if you prefer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

leaving it to @Devessier 😏

@Devessier Devessier self-requested a review September 11, 2025 16:19
Copy link
Contributor

@Devessier Devessier left a comment

Choose a reason for hiding this comment

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

Great job! As we discussed, I suggest a small renaming.

@thomtrp thomtrp enabled auto-merge (squash) September 12, 2025 07:17
@thomtrp thomtrp force-pushed the tt-improve-loop-insertion branch from 330525e to 30d25ef Compare September 12, 2025 07:21
@thomtrp thomtrp merged commit 231d1a9 into main Sep 12, 2025
57 checks passed
@thomtrp thomtrp deleted the tt-improve-loop-insertion branch September 12, 2025 07:30
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.

3 participants