Skip to content

improvement(trigger-subflow): reuse helper code - #1885

Merged
icecrasher321 merged 1 commit into
stagingfrom
improvement/block-insubflow-check
Nov 11, 2025
Merged

improvement(trigger-subflow): reuse helper code#1885
icecrasher321 merged 1 commit into
stagingfrom
improvement/block-insubflow-check

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

Reuse trigger utils func to check if trigger is in subflow.

Type of Change

  • Other: code cleanup

Testing

Tested manually

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)

@vercel

vercelBot commented Nov 11, 2025

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentPreviewCommentsUpdated (UTC)
docsSkippedSkippedNov 11, 2025 5:48am

@icecrasher321
icecrasher321 merged commit ec70f6f into stagingNov 11, 2025
4 checks passed
@greptile-apps

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

Refactored duplicate subflow validation logic by extracting it into a reusable TriggerUtils.isBlockInSubflow() helper function. This change eliminates code duplication between use-collaborative-workflow.ts and workflow/store.ts.

Key changes:

  • Replaced inline parent block lookup and type checking with centralized TriggerUtils.isBlockInSubflow() call
  • Simplified logging in workflow store by removing redundant parentId and parentType fields
  • Improved code maintainability by consolidating the subflow detection logic in a single location

Confidence Score: 5/5

  • This PR is safe to merge with no concerns - it's a clean refactoring that reduces code duplication
  • Score reflects a straightforward refactoring with no logic changes, proper code reuse, and maintained functionality
  • No files require special attention

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/hooks/use-collaborative-workflow.ts5/5Refactored duplicate subflow check logic to use centralized TriggerUtils.isBlockInSubflow() helper function
apps/sim/stores/workflows/workflow/store.ts5/5Refactored duplicate subflow check logic to use centralized TriggerUtils.isBlockInSubflow() helper function, simplified logging

Sequence Diagram

sequenceDiagram
participant User
participant CollaborativeHook as use-collaborative-workflow
participant WorkflowStore as workflow/store
participant TriggerUtils as TriggerUtils.isBlockInSubflow()
participant Blocks as blocks Record
User->>CollaborativeHook: Toggle trigger mode
CollaborativeHook->>TriggerUtils: isBlockInSubflow(id, blocks)
TriggerUtils->>Blocks: Find block by id
Blocks-->>TriggerUtils: block
TriggerUtils->>Blocks: Find parent by parentId
Blocks-->>TriggerUtils: parent
TriggerUtils->>TriggerUtils: Check parent.type === 'loop' || 'parallel'
TriggerUtils-->>CollaborativeHook: isInSubflow result
alt Block is in subflow
CollaborativeHook->>User: Dispatch warning event
else Block not in subflow
CollaborativeHook->>WorkflowStore: Execute toggle operation
end
User->>WorkflowStore: Toggle trigger mode (direct)
WorkflowStore->>TriggerUtils: isBlockInSubflow(id, blocks)
TriggerUtils->>Blocks: Find block by id
Blocks-->>TriggerUtils: block
TriggerUtils->>Blocks: Find parent by parentId
Blocks-->>TriggerUtils: parent
TriggerUtils->>TriggerUtils: Check parent.type === 'loop' || 'parallel'
TriggerUtils-->>WorkflowStore: isInSubflow result
alt Block is in subflow
WorkflowStore->>WorkflowStore: Log warning & return early
else Block not in subflow
WorkflowStore->>WorkflowStore: Toggle trigger mode & remove edges
end
Loading

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
waleedlatif1 deleted the improvement/block-insubflow-check branch November 11, 2025 18:25
@waleedlatif1waleedlatif1 mentioned this pull request Nov 12, 2025
10 tasks
Sign up for freeto 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.

1 participant

@icecrasher321