Skip to content

fix: don't allow adding condition in condition or loop in the loop - #3651

Merged
Kiryous merged 2 commits into
mainfrom
fix/3639-wf-ui-edge-cases
Feb 24, 2025
Merged

Kiryous merged 2 commits into
mainfrom
fix/3639-wf-ui-edge-cases

Conversation

@Kiryous

@Kiryous Kiryous commented Feb 24, 2025

Copy link
Copy Markdown
Contributor

Closes #3639

@vercel

vercel Bot commented Feb 24, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
keep ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 24, 2025 3:20pm

@Kiryous

Kiryous commented Feb 24, 2025

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@Kiryous Kiryous changed the title refactor & fix: don't allow adding condition in condition or loop in the loop fix: don't allow adding condition in condition or loop in the loop Feb 24, 2025
@coderabbitai

coderabbitai Bot commented Feb 24, 2025

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This pull request updates various workflow modules to improve type safety and clarity. Unused imports are removed and several function signatures are updated to adopt new YAML-based types. The changes introduce new Zod schemas for enrich data, consolidate step and action types, and refine node data structures. UI components, utility functions, and tests have been modified to work with the new types and naming conventions (e.g., renaming getWorkflowFromDefinition to getYamlWorkflowDefinition), while edge validations and branch processing in workflow reconstruction are enhanced.

Changes

File(s) Change Summary
keep-ui/.../getLayoutedWorkflowElements.ts Removed unused import of triggerTypes.
keep-ui/.../parser.ts, keep-ui/.../types.ts, keep-ui/.../yaml.types.ts Updated function signatures and types, replaced YamlAction and YamlStep with YamlStepOrAction, and introduced new Zod schemas (EnrichAlertSchema, EnrichIncidentSchema) with updated NodeData definitions.
keep-ui/.../__tests__/types.test.ts, keep-ui/.../__tests__/workflow-store.test.ts Added comprehensive tests for schema validations and updated node data structure, including nested properties.
keep-ui/.../workflow-store.ts, keep-ui/utils/reactFlow.ts Modified logic for adding nodes (addNodeBetween, addNodeBetweenSafe) with enhanced condition and trigger validations; removed the unused getKeyBasedSquence function and improved type assertions.
keep-ui/.../useWorkflowActions.ts, keep-ui/.../workflow-test-run-modal.tsx, keep-ui/.../workflow-builder.tsx Renamed workflow definition function calls from getWorkflowFromDefinition to getYamlWorkflowDefinition.
keep-ui/.../NodeTriggerIcon.tsx, keep-ui/features/workflows/builder/ui/Editor/ReactFlowEditor.tsx, keep-ui/features/workflows/builder/ui/Editor/StepEditor.tsx, keep-ui/features/workflows/builder/ui/Editor/TriggerEditor.tsx, keep-ui/features/workflows/builder/ui/WorkflowEdge.tsx, keep-ui/features/workflows/builder/ui/WorkflowNode.tsx, keep-ui/features/workflows/builder/ui/WorkflowToolbox.tsx Revised component signatures and control flows, updated conditional rendering, simplified state initialization, refined subtitle and icon logic, and enhanced event handling.
keep-ui/features/workflows/ai-assistant/lib/utils.ts, keep-ui/features/workflows/builder/lib/utils.tsx Renamed functions (e.g., edgeCanAddTrigger → canAddTriggerBeforeEdge) and added new utilities for checking conditions and foreach scenarios.

Sequence Diagram(s)

sequenceDiagram
    participant UI as Editor UI
    participant Store as WorkflowStore
    participant Utils as Workflow Utils
    participant YAML as getYamlWorkflowDefinition

    UI->>Store: addNodeBetween(nodeId, step)
    Store->>Utils: Validate edge addition (trigger, step, condition, foreach)
    Utils-->>Store: Return validation result
    Store->>YAML: Generate YAML workflow definition
    YAML-->>Store: Return workflow definition
Loading

Suggested labels

Bug, Feature, size:XXL, lgtm

Suggested reviewers

  • talboren

Poem

I'm a hoppin' rabbit with a joyful code spree,
Lines dance like carrots in a field of glee,
Functions renamed and types set right,
In workflows and edges, all shines bright,
With each edit, I hop in delight!

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (11)
keep-ui/features/workflows/builder/ui/Editor/ReactFlowEditor.tsx (1)

2-6: Consider adding a type check for selectedNode.

While the changes improve type safety with new imports, consider adding a type guard for selectedNode to ensure it matches the expected V2ActionOrStep type before rendering StepEditorV2.

-  {isStepEditor && <StepEditorV2 key={selectedNode} />}
+  {isStepEditor && selectedNode && (
+    <StepEditorV2
+      key={selectedNode}
+    />
+  )}

Also applies to: 93-93

keep-ui/features/workflows/builder/ui/WorkflowNode.tsx (1)

161-165: Consider using a more stable key for NodeTriggerIcon.

The current key implementation might cause unnecessary re-renders if the alert source changes frequently.

Consider using a composite key or memoizing the key generation:

-key={
-  data?.type === "alert"
-    ? data?.properties?.alert?.source
-    : data?.id
-}
+key={`${data?.id}-${data?.type === "alert" ? data?.properties?.alert?.source : ""}`}
keep-ui/features/workflows/builder/ui/Editor/StepEditor.tsx (2)

479-559: Condensed logic for StepEditorV2
This newly introduced StepEditorV2 function parses node data with NodeDataStepSchema and conditionally renders editors for threshold, assert, foreach, or default cases. Consider adding a fallback for unexpected componentType or type to prevent uncaught parse errors, and ensure comprehensive unit tests for each branch.


600-600: Type assertion in update
Casting to ConditionsAndMiscFormDataType might be unnecessary if updatedFormData is always the correct shape. Consider refining the type to remove the need for this assertion.

keep-ui/utils/reactFlow.ts (2)

199-200: Consider removing TODO comments and improving type assertions.

The TODO comments for type assertions could be replaced with proper type definitions or interfaces.

-        // FIX: type assertion
-      } as NodeData,
+      } satisfies NodeData,

Also applies to: 218-219


253-254: Consider adding type annotation for TODO comment.

The TODO comment about fixing types should be addressed with a proper type definition.

-                  // TODO: fix type
-                  steps={group.steps as any}
+                  steps={group.steps as V2StepTrigger[] | Omit<V2Step, "id">[]}
keep-ui/entities/workflows/model/yaml.types.ts (1)

17-21: Consider adding JSDoc comments for the YamlCondition interface.

The interface would benefit from documentation explaining the purpose of the alias property and its relationship with conditions.

+/**
+ * Represents a base condition in a YAML workflow.
+ * @property id - Optional unique identifier for the condition
+ * @property name - Display name of the condition
+ * @property alias - Optional alias for condition reference
+ */
 interface YamlCondition {
   id?: string;
   name: string;
   alias?: string;
 }
keep-ui/features/workflows/builder/ui/WorkflowToolbox.tsx (1)

178-183: Consider removing explicit any type.

The explicit any type in the reduce function could be replaced with a more specific type.

-      (obj: any, node) => {
+      (obj: Record<string, boolean>, node) => {
keep-ui/entities/workflows/model/types.ts (1)

179-180: Address TODO comment with generic type.

The TODO comment about making a generic sequence type should be implemented.

-  // TODO: make a generic sequence type
-  sequence: z.array(z.union([V2ActionOrStepSchema, V2StepConditionSchema])),
+  sequence: z.array(
+    z.union([V2ActionOrStepSchema, V2StepConditionSchema])
+  ).describe('Sequence of workflow steps or conditions'),
keep-ui/entities/workflows/lib/parser.ts (2)

81-111: Consider reducing duplication in threshold vs assert logic.
Both condition branches repeat several fields (e.g., id, name, componentType, alias), which can be factored out into a shared object.

For example, you could unify repeated fields and then apply condition-specific properties:

 function generateCondition(condition, action, stepType, providers) {
+  const baseCondition = {
+    id: condition.id || uuidv4(),
+    name: condition.name,
+    componentType: "switch" as const,
+    alias: condition.alias
+  };
   const generatedConditionStep =
     condition.type === "threshold"
       ? {
-          id: condition.id || uuidv4(),
-          name: condition.name,
           type: "condition-threshold" as const,
-          componentType: "switch" as const,
-          alias: condition.alias,
+          ...baseCondition,
           properties: {
             ...
           },
           branches: {
             true: [getActionOrStepObj(action, stepType, providers)],
             false: [],
           },
         }
       : {
-          id: condition.id || uuidv4(),
-          name: condition.name,
           type: "condition-assert" as const,
-          componentType: "switch" as const,
-          alias: condition.alias,
+          ...baseCondition,
           properties: {
             ...
           },
           branches: {
             ...
           },
         };
   ...
 }

293-306: Refactor or unify repeated condition-building logic.
Similar to earlier threshold vs. assert duplication, consolidating logic for getActionsFromCondition can streamline maintainability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a64da1d and b3efc10.

📒 Files selected for processing (20)
  • keep-ui/entities/workflows/lib/getLayoutedWorkflowElements.ts (0 hunks)
  • keep-ui/entities/workflows/lib/parser.ts (11 hunks)
  • keep-ui/entities/workflows/model/__tests__/types.test.ts (1 hunks)
  • keep-ui/entities/workflows/model/__tests__/workflow-store.test.tsx (4 hunks)
  • keep-ui/entities/workflows/model/types.ts (9 hunks)
  • keep-ui/entities/workflows/model/useWorkflowActions.ts (3 hunks)
  • keep-ui/entities/workflows/model/workflow-store.ts (7 hunks)
  • keep-ui/entities/workflows/model/yaml.types.ts (1 hunks)
  • keep-ui/entities/workflows/ui/NodeTriggerIcon.tsx (1 hunks)
  • keep-ui/features/workflows/ai-assistant/lib/utils.ts (1 hunks)
  • keep-ui/features/workflows/builder/lib/utils.tsx (1 hunks)
  • keep-ui/features/workflows/builder/ui/Editor/ReactFlowEditor.tsx (2 hunks)
  • keep-ui/features/workflows/builder/ui/Editor/StepEditor.tsx (3 hunks)
  • keep-ui/features/workflows/builder/ui/Editor/TriggerEditor.tsx (1 hunks)
  • keep-ui/features/workflows/builder/ui/WorkflowEdge.tsx (1 hunks)
  • keep-ui/features/workflows/builder/ui/WorkflowNode.tsx (4 hunks)
  • keep-ui/features/workflows/builder/ui/WorkflowToolbox.tsx (8 hunks)
  • keep-ui/features/workflows/test-run/ui/workflow-test-run-modal.tsx (2 hunks)
  • keep-ui/utils/reactFlow.ts (8 hunks)
  • keep-ui/widgets/workflow-builder/workflow-builder.tsx (3 hunks)
💤 Files with no reviewable changes (1)
  • keep-ui/entities/workflows/lib/getLayoutedWorkflowElements.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: tests-e2e (postgres)
  • GitHub Check: tests-e2e (mysql)
🔇 Additional comments (73)
keep-ui/features/workflows/ai-assistant/lib/utils.ts (1)

39-40: LGTM! Improved node data handling with fallback mechanism.

The changes consolidate the data spreading operation while adding a robust fallback mechanism for node IDs. This maintains backward compatibility while making the code more resilient.

keep-ui/features/workflows/builder/ui/WorkflowEdge.tsx (1)

33-33: LGTM! Enhanced debug information accessibility and presentation.

The changes improve the debugging experience by:

  1. Enabling interaction with debug info through pointer events
  2. Adding a collapsible UI for cleaner presentation
  3. Structuring the debug data in a readable JSON format

Also applies to: 37-40

keep-ui/features/workflows/test-run/ui/workflow-test-run-modal.tsx (1)

13-13: LGTM! Aligned with YAML-based workflow definition standard.

The changes consistently adopt the new YAML-based workflow definition approach while maintaining the same functionality.

Also applies to: 52-52

keep-ui/entities/workflows/model/useWorkflowActions.ts (1)

8-8: LGTM! Function renaming is consistent.

The renaming of getWorkflowFromDefinition to getYamlWorkflowDefinition is applied consistently across the file.

Also applies to: 37-37, 67-67

keep-ui/features/workflows/builder/ui/Editor/TriggerEditor.tsx (1)

38-38: LGTM! Alert filter data structure is properly updated.

The change ensures alert filters are correctly structured under the 'alert' key in the node properties, maintaining consistency with the updated NodeData structure.

keep-ui/features/workflows/builder/ui/WorkflowNode.tsx (1)

65-66: LGTM! Improved trigger node identification.

The updated condition properly checks both componentType and type, making trigger identification more robust.

keep-ui/entities/workflows/ui/NodeTriggerIcon.tsx (3)

7-7: LGTM! Improved type safety with NodeData.

The change from FlowNode["data"] to NodeData provides better type safety and clarity.

Also applies to: 9-9


10-12: LGTM! Added performance optimization.

Early return for non-trigger components prevents unnecessary processing.


19-19: LGTM! Updated alert source path.

The alert source path now correctly reflects the updated data structure.

keep-ui/widgets/workflow-builder/workflow-builder.tsx (3)

15-19: LGTM! Import statement updated for better clarity.

The renaming from getWorkflowFromDefinition to getYamlWorkflowDefinition improves code readability by being more explicit about the function's purpose.


100-113: LGTM! Workflow definition generation is properly structured.

The workflow definition generation is well-organized with clear parameter separation and proper spreading into the wrapDefinitionV2 function.


155-155: LGTM! YAML workflow definition is properly stringified.

The use of getYamlWorkflowDefinition in the workflowYaml memoized value ensures consistent YAML generation.

keep-ui/entities/workflows/model/__tests__/workflow-store.test.tsx (2)

265-265: LGTM! Switch node type updated to be more specific.

The change from type: "switch" to type: "condition-threshold" improves type safety and better represents the node's purpose.


370-374: LGTM! Node data structure improved.

The node data structure has been enhanced to include:

  • Explicit componentType field
  • Properties encapsulation
  • Better type organization

This change improves type safety and code organization.

Also applies to: 400-406

keep-ui/entities/workflows/model/__tests__/types.test.ts (5)

1-12: LGTM! Well-organized imports and dependencies.

The imports are properly structured, separating schema imports from utility imports.


13-87: LGTM! Comprehensive action schema validation tests.

The tests thoroughly validate:

  • Jira ticket creation with enrichment
  • Multiple enrichment types
  • Complex nested properties

89-134: LGTM! Thorough condition and foreach schema tests.

Tests properly validate:

  • Condition threshold templates
  • Required fields (ID)
  • Branch structures
  • Foreach step validation

136-204: LGTM! Comprehensive step schema validation.

Tests cover:

  • Basic step validation
  • Optional fields
  • Invalid cases
  • Type prefix validation

206-294: LGTM! Thorough condition assert schema tests.

Tests validate:

  • Basic assertions
  • Branch structures
  • Required fields
  • Error cases
keep-ui/features/workflows/builder/ui/Editor/StepEditor.tsx (5)

26-26: Use of additional React hooks
This import of useState, useCallback, and useMemo ensures local state, memoization, and callback optimizations.


29-29: Imported NodeDataStepSchema
This new import helps parse and validate the node data. Ensure that schema parsing errors are handled gracefully in the calling code.


35-35: Imported V2StepSchema
Usage of V2StepSchema is consistent with the approach of validating steps before rendering.


561-576: Required name property for conditions & foreach
These updates make the name field mandatory in ConditionsAndMiscFormDataType. Verify that all call sites provide a non-empty name to avoid runtime errors.

Would you like me to generate a script to confirm references to ConditionsAndMiscEditor are always passed a valid name?


581-583: Initialize condition or foreach form data
Accepting initialFormData into local state ensures type safety for condition or foreach properties. This approach looks good; confirm that all usage points pass the required fields.

keep-ui/features/workflows/builder/lib/utils.tsx (4)

200-202: Ensure trigger placement
canAddTriggerBeforeEdge correctly restricts triggers to edges between trigger_start and trigger_end, preserving workflow logic.


204-210: Prevent step insertion before start or trigger end
canAddStepBeforeEdge disallows steps at disallowed positions, avoiding conflicts with the start node or a trigger endpoint.


212-214: Block condition usage on empty branches
canAddConditionBeforeEdge prevents conditions if a target ends in empty_true or empty_false, enforcing valid condition usage.


216-218: Restrict nested foreach
canAddForeachBeforeEdge disallows adding a foreach immediately before another foreach target, preserving simpler control flow.

keep-ui/entities/workflows/model/workflow-store.ts (8)

41-44: Import new helper functions
These imports integrate the condition, foreach, step, and trigger checks for restricting node insertion.


71-71: Extended rawStep parameter
Allowing V2StepTemplate | V2StepTrigger | Omit<V2Step, "id"> supports more flexible insertion scenarios. Confirm that any new usage aligns with these types.


128-131: Trigger insertion guard
Using canAddTriggerBeforeEdge prevents placing triggers in invalid positions, aligning with workflow constraints.


132-137: Condition insertion guard
Refusing to add conditions if canAddConditionBeforeEdge fails ensures condition nodes appear only in valid contexts.


139-145: Foreach insertion check
Forbids adding a foreach if canAddForeachBeforeEdge disallows it, reducing potential nesting issues.


159-159: Step insertion check
Requiring canAddStepBeforeEdge for non-trigger components enforces consistent step placement rules.


327-327: Refined addNodeBetween signature
Accepting triggers or partial steps in the step parameter supports a unified approach to node insertion.


336-337: Safe insertion logic
addNodeBetweenSafe mirrors the broader signature from addNodeBetween, catching and rendering Zod or runtime errors gracefully.

keep-ui/utils/reactFlow.ts (2)

79-81: Enhance type safety in condition node handling.

The type definition for conditionNode has been improved to explicitly include the branches property with strongly typed arrays for true/false branches.


93-93: Add type assertions for better type safety.

Type assertions have been added to ensure proper type checking:

  • Line 93: tempSequence is explicitly typed as V2Step[]
  • Line 117-118: Node data is properly typed as V2Step
  • Line 132: Node data is properly typed as V2Step

Also applies to: 117-117, 132-132

keep-ui/entities/workflows/model/yaml.types.ts (2)

7-15: Improve type safety with consolidated step and action interface.

The YamlStepOrAction interface effectively combines step and action functionality while maintaining type safety through optional properties.


35-46: Enhance type safety in workflow definition interface.

The YamlWorkflowDefinition interface has been updated to use the consolidated YamlStepOrAction type, improving type consistency across the workflow definition.

keep-ui/features/workflows/builder/ui/WorkflowToolbox.tsx (2)

12-28: Well-structured type definitions for menu props.

The separation of base props and specific props using discriminated unions provides excellent type safety and clarity.


154-164: Clear and descriptive control flow conditions.

The conditions for showing different workflow components are well-documented and logically structured:

  • showOnlyTriggers for trigger-specific views
  • showConditions prevents nested conditions
  • showForeach prevents nested foreach loops
keep-ui/entities/workflows/model/types.ts (2)

67-79: Well-structured schemas for data enrichment.

The EnrichAlertSchema and EnrichIncidentSchema provide clear and consistent validation for enrichment data.


307-332: Well-defined node data types for conditions.

The addition of specific node data types for condition ends improves type safety and clarity in the workflow system.

keep-ui/entities/workflows/lib/parser.ts (29)

15-17: Nice introduction of typed condition references.
These new imports clearly separate threshold and assert conditions, improving readability and maintainability.


21-22: Well-typed function parameter.
Changing actionOrStep from any to YamlStepOrAction strengthens type safety.


51-59: Strong typing for foreach generation.
Using an intersection type (YamlStepOrAction & { foreach: string }) ensures the required field is present, which helps prevent runtime errors.


75-80: Enhanced type coverage for condition generation.
Accepting YamlAssertCondition | YamlThresholdCondition and returning the union type is a clear approach to condition handling. Make sure to expand this union if new condition types emerge.


115-120: Good use of foreach fallback.
Condition steps automatically become part of a foreach sequence when action.foreach is defined. This is a clear structure for nested logic.


123-123: No further comment.
This simple return statement is self-explanatory.


175-175: No content changed of significance.


177-178: Mapping steps to typed objects.
Assigning type: "step" here keeps the code consistent when building step definitions.


179-183: Clear separation of logic for workflow actions.
By mapping actions to type: "action", you unify their shape for downstream processing.


185-185: No content changed of significance.


186-188: Consolidating steps and actions.
Merging them into one array streamlines iteration without losing type specificity.


189-189: No content changed of significance.


190-191: Dual-purpose iteration.
Differentiating between a ‘step’ vs. an ‘action’ inside the loop is straightforward and effective.


194-194: Straightforward push.
steps.push(getActionOrStepObj(...)) is clear.


195-195: Conditional branching.
This else-if properly handles items that rely on if conditions.


203-203: Appending to existing condition.
Pushing to existingCondition.branches.true is a good approach for reusing condition branches.


207-213: Foreach branch logic.
Wrapping an action in a foreach container is consistent with your typed approach.


215-215: Fallback push.
Using getActionOrStepObj again ensures consistent creation of step/action objects.


219-225: Foreach logic repeated for new condition block.
Good reuse of generateForeach for any item with a foreach property.


226-226: Condition-based expansion.
This else if (action.condition) helps keep condition actions separate from standard steps.


227-230: Iterating over multi-condition arrays.
Pushing each generated condition into conditions is a solid approach for layered scenario coverage.


319-319: Compiled action typed as YamlStepOrAction.
This promotes a consistent shape when returning compiled actions.


323-323: Storing condition array.
Nestling each compiled condition in condition: [compiledCondition] is a neat, consistent structure.


330-330: Typed function for step conversion.
Returning YamlStepOrAction from a V2StepStep ensures uniform usage throughout the codebase.


340-340: Inline object creation.
Initializing step as a YamlStepOrAction clarifies the type mapping from V2 step fields.


350-350: Exporting typed action conversion.
This preserves clarity and consistency in how V2 actions are transformed into YAML-based objects.


361-361: Constructing the final action object.
Once again, relying on YamlStepOrAction avoids confusion about which fields are allowed.


375-380: Accurate documentation.
Renaming the function's purpose in this docstring clarifies the transformation is specifically for YAML workflow definitions.


406-406: Foreach actions array typed.
Explicitly indicating [] as YamlStepOrAction[] ensures consistent usage with your typed approach.

@Kiryous
Kiryous marked this pull request as ready for review February 24, 2025 15:14
@dosubot dosubot Bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Feb 24, 2025
@dosubot dosubot Bot added Bug Something isn't working UI User interface related issues labels Feb 24, 2025
@Kiryous
Kiryous merged commit fbb35dc into main Feb 24, 2025
@Kiryous
Kiryous deleted the fix/3639-wf-ui-edge-cases branch February 24, 2025 15:27
wsimon1982 pushed a commit to wsimon1982/keep that referenced this pull request May 12, 2026

This branch was successfully deployed

1 active deployment
Preview — 18751b20 Deployed Feb 24, 2025 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working size:XXL This PR changes 1000+ lines, ignoring generated files. UI User interface related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: workflow ui builder allow impossible conditions and incorrect foreach

2 participants