Skip to content

fix(start): fix start block numbering - #1909

Merged
icecrasher321 merged 1 commit into
stagingfrom
fix/start-block-numbering
Nov 12, 2025
Merged

fix(start): fix start block numbering#1909
icecrasher321 merged 1 commit into
stagingfrom
fix/start-block-numbering

Conversation

@Sg312

@Sg312Sg312 commented Nov 12, 2025

Copy link
Copy Markdown
Collaborator

Summary

Fixes start block numbering issue. Prevents duplication and if deleted then added, doesn't have a number suffix

Type of Change

  • Bug fix

Testing

Manual

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 12, 2025

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentPreviewCommentsUpdated (UTC)
docsSkippedSkippedNov 12, 2025 1:43am

@Sg312Sg312 changed the title Fix start block numberingfix(start): fix start block numberingNov 12, 2025
@greptile-apps

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR implements consistent handling of start blocks across both legacy (starter) and unified (start_trigger) types to prevent duplication and numbering issues.

Key changes:

  • Unified block naming to always return "Start" without numbers for start blocks in getUniqueBlockName
  • Added duplication prevention for both starter and start_trigger types in the collaborative workflow hook
  • Updated START_CONFLICT_TYPES to include legacy TRIGGER_TYPES.STARTER to prevent coexistence with modern triggers
  • Modified action bar to handle both start block types consistently, enabling delete functionality for unified start blocks

How it fits with the codebase:
The changes build upon the existing trigger classification system in lib/workflows/triggers.ts, which already distinguishes between legacy starter blocks and the unified start_trigger. By treating both types uniformly in UI components and workflow operations, this ensures a smooth migration path from the legacy system to the unified trigger approach while maintaining backward compatibility.

Confidence Score: 4/5

  • This PR is safe to merge with one minor verification needed around duplicate name handling
  • The changes correctly implement start block handling across multiple layers (UI, workflow operations, naming). The logic is sound and consistent. Score is 4/5 due to one concern: the early return in getUniqueBlockName bypasses duplicate checking, relying on upstream validation to prevent conflicts. This should be verified in testing.
  • Verify apps/sim/stores/workflows/utils.ts - ensure the early return for start blocks doesn't cause naming conflicts in edge cases

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/stores/workflows/utils.ts4/5Added special case to always name start blocks as 'Start' without numbering, preventing duplication
apps/sim/lib/workflows/triggers.ts5/5Added legacy TRIGGER_TYPES.STARTER to START_CONFLICT_TYPES array to prevent coexistence with unified start_trigger
apps/sim/hooks/use-collaborative-workflow.ts5/5Added duplication prevention for both starter and start_trigger block types in collaborativeDuplicateBlock function
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/action-bar/action-bar.tsx5/5Unified handling of starter and start_trigger blocks by introducing isStartBlock check, enabled delete button for start blocks

Sequence Diagram

sequenceDiagram
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
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.

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +24 to +26
if (normalizedBaseName === 'start' || normalizedBaseName === 'starter') {
return 'Start'
}

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.

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.

@icecrasher321
icecrasher321 merged commit 7695556 into stagingNov 12, 2025
9 checks passed
waleedlatif1 pushed a commit that referenced this pull request Nov 12, 2025
waleedlatif1 pushed a commit that referenced this pull request Nov 12, 2025
@waleedlatif1waleedlatif1 mentioned this pull request Nov 12, 2025
10 tasks
@waleedlatif1
waleedlatif1 deleted the fix/start-block-numbering branch November 18, 2025 01:28
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.

2 participants

@Sg312@icecrasher321