Skip to content

Commit 7695556

Browse files
authored
Fix start block numbering (#1909)
1 parent 679c341 commit 7695556

File tree

4 files changed

+39
-22
lines changed

4 files changed

+39
-22
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/action-bar/action-bar.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ export const ActionBar = memo(
5555
const userPermissions = useUserPermissionsContext()
5656

5757
const isStarterBlock = blockType === 'starter'
58+
// Check for start_trigger (unified start block) - prevent duplication but allow deletion
59+
const isStartBlock = blockType === 'starter' || blockType === 'start_trigger'
5860

5961
/**
6062
* Get appropriate tooltip message based on disabled state
@@ -103,7 +105,7 @@ export const ActionBar = memo(
103105
</Tooltip.Content>
104106
</Tooltip.Root>
105107

106-
{!isStarterBlock && (
108+
{!isStartBlock && (
107109
<Tooltip.Root>
108110
<Tooltip.Trigger asChild>
109111
<Button
@@ -124,7 +126,7 @@ export const ActionBar = memo(
124126
</Tooltip.Root>
125127
)}
126128

127-
{!isStarterBlock && parentId && (parentType === 'loop' || parentType === 'parallel') && (
129+
{!isStartBlock && parentId && (parentType === 'loop' || parentType === 'parallel') && (
128130
<Tooltip.Root>
129131
<Tooltip.Trigger asChild>
130132
<Button
@@ -174,26 +176,24 @@ export const ActionBar = memo(
174176
</Tooltip.Content>
175177
</Tooltip.Root>
176178

177-
{!isStarterBlock && (
178-
<Tooltip.Root>
179-
<Tooltip.Trigger asChild>
180-
<Button
181-
variant='ghost'
182-
onClick={(e) => {
183-
e.stopPropagation()
184-
if (!disabled) {
185-
collaborativeRemoveBlock(blockId)
186-
}
187-
}}
188-
className='h-[30px] w-[30px] rounded-[8px] bg-[#363636] p-0 text-[#868686] hover:bg-[#33B4FF] hover:text-[#1B1B1B] dark:text-[#868686] dark:hover:bg-[#33B4FF] dark:hover:text-[#1B1B1B]'
189-
disabled={disabled}
190-
>
191-
<Trash2 className='h-[14px] w-[14px]' />
192-
</Button>
193-
</Tooltip.Trigger>
194-
<Tooltip.Content side='right'>{getTooltipMessage('Delete Block')}</Tooltip.Content>
195-
</Tooltip.Root>
196-
)}
179+
<Tooltip.Root>
180+
<Tooltip.Trigger asChild>
181+
<Button
182+
variant='ghost'
183+
onClick={(e) => {
184+
e.stopPropagation()
185+
if (!disabled) {
186+
collaborativeRemoveBlock(blockId)
187+
}
188+
}}
189+
className='h-[30px] w-[30px] rounded-[8px] bg-[#363636] p-0 text-[#868686] hover:bg-[#33B4FF] hover:text-[#1B1B1B] dark:text-[#868686] dark:hover:bg-[#33B4FF] dark:hover:text-[#1B1B1B]'
190+
disabled={disabled}
191+
>
192+
<Trash2 className='h-[14px] w-[14px]' />
193+
</Button>
194+
</Tooltip.Trigger>
195+
<Tooltip.Content side='right'>{getTooltipMessage('Delete Block')}</Tooltip.Content>
196+
</Tooltip.Root>
197197
</div>
198198
)
199199
},

apps/sim/hooks/use-collaborative-workflow.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,15 @@ export function useCollaborativeWorkflow() {
11931193
const sourceBlock = workflowStore.blocks[sourceId]
11941194
if (!sourceBlock) return
11951195

1196+
// Prevent duplication of start blocks (both legacy starter and unified start_trigger)
1197+
if (sourceBlock.type === 'starter' || sourceBlock.type === 'start_trigger') {
1198+
logger.warn('Cannot duplicate start block - only one start block allowed per workflow', {
1199+
blockId: sourceId,
1200+
blockType: sourceBlock.type,
1201+
})
1202+
return
1203+
}
1204+
11961205
// Generate new ID and calculate position
11971206
const newId = crypto.randomUUID()
11981207
const offsetPosition = {

apps/sim/lib/workflows/triggers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const START_CONFLICT_TYPES: TriggerType[] = [
5959
TRIGGER_TYPES.INPUT,
6060
TRIGGER_TYPES.MANUAL,
6161
TRIGGER_TYPES.CHAT,
62+
TRIGGER_TYPES.STARTER, // Legacy starter also conflicts with start_trigger
6263
]
6364

6465
type BlockWithType = { type: string; subBlocks?: Record<string, unknown> | undefined }

apps/sim/stores/workflows/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ export function normalizeBlockName(name: string): string {
1818
* @returns A unique block name with an appropriate number suffix
1919
*/
2020
export function getUniqueBlockName(baseName: string, existingBlocks: Record<string, any>): string {
21+
// Special case: Start blocks should always be named "Start" without numbers
22+
// This applies to both "Start" and "Starter" base names
23+
const normalizedBaseName = normalizeBlockName(baseName)
24+
if (normalizedBaseName === 'start' || normalizedBaseName === 'starter') {
25+
return 'Start'
26+
}
27+
2128
const baseNameMatch = baseName.match(/^(.*?)(\s+\d+)?$/)
2229
const namePrefix = baseNameMatch ? baseNameMatch[1].trim() : baseName
2330

0 commit comments

Comments
 (0)