fix(start): fix start block numbering#1909
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile OverviewGreptile SummaryThis PR implements consistent handling of start blocks across both legacy ( Key changes:
How it fits with the codebase: Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant ActionBar
participant CollaborativeWorkflow
participant WorkflowStore
participant Utils
participant TriggerUtils
Note over User,TriggerUtils: Start Block Duplication Prevention Flow
User->>ActionBar: Attempts to duplicate start block
ActionBar->>ActionBar: Check isStartBlock (starter OR start_trigger)
ActionBar->>CollaborativeWorkflow: collaborativeDuplicateBlock(blockId)
CollaborativeWorkflow->>WorkflowStore: Get source block
CollaborativeWorkflow->>CollaborativeWorkflow: Check if starter OR start_trigger
alt Is Start Block
CollaborativeWorkflow->>CollaborativeWorkflow: Log warning & return early
CollaborativeWorkflow-->>User: Duplication prevented
else Not Start Block
CollaborativeWorkflow->>Utils: getUniqueBlockName(sourceName, blocks)
alt Block name is "Start" or "Starter"
Utils->>Utils: Normalize name (lowercase, remove spaces)
Utils-->>CollaborativeWorkflow: Return "Start" (no number)
else Other block types
Utils->>Utils: Find highest number suffix
Utils-->>CollaborativeWorkflow: Return "BlockName N+1"
end
CollaborativeWorkflow->>WorkflowStore: Create new block with unique name
CollaborativeWorkflow-->>User: Block duplicated successfully
end
Note over User,TriggerUtils: Start Block Conflict Prevention Flow
User->>WorkflowStore: Attempts to add start_trigger
WorkflowStore->>TriggerUtils: wouldViolateSingleInstance(blocks, type)
TriggerUtils->>TriggerUtils: Check START_CONFLICT_TYPES array
alt Has legacy starter OR existing start_trigger
TriggerUtils-->>WorkflowStore: Violation detected
WorkflowStore-->>User: Addition blocked
else No conflicts
TriggerUtils-->>WorkflowStore: Allowed
WorkflowStore->>WorkflowStore: Add block
WorkflowStore-->>User: Block added successfully
end
|
| if (normalizedBaseName === 'start' || normalizedBaseName === 'starter') { | ||
| return 'Start' | ||
| } |
There was a problem hiding this comment.
style: early return bypasses duplicate name checking - verify that duplication prevention in use-collaborative-workflow.ts:1197 prevents naming conflicts when adding start blocks
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/stores/workflows/utils.ts
Line: 24:26
Comment:
**style:** early return bypasses duplicate name checking - verify that duplication prevention in `use-collaborative-workflow.ts:1197` prevents naming conflicts when adding start blocks
How can I resolve this? If you propose a fix, please make it concise.
Summary
Fixes start block numbering issue. Prevents duplication and if deleted then added, doesn't have a number suffix
Type of Change
Testing
Manual
Checklist