mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
fix(ring): duplicate should clear original block (#2916)
* fix(ring): duplicate should clear original block * rename correctly
This commit is contained in:
committed by
GitHub
parent
145db9d8c3
commit
5988d0e46f
@@ -17,7 +17,7 @@ import {
|
||||
type GetBlockUpstreamReferencesResultType,
|
||||
} from '@/lib/copilot/tools/shared/schemas'
|
||||
import { BlockPathCalculator } from '@/lib/workflows/blocks/block-path-calculator'
|
||||
import { isValidStartBlockType } from '@/lib/workflows/triggers/start-block-types'
|
||||
import { isInputDefinitionTrigger } from '@/lib/workflows/triggers/input-definition-triggers'
|
||||
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
|
||||
import { useWorkflowStore } from '@/stores/workflows/workflow/store'
|
||||
import type { Loop, Parallel } from '@/stores/workflows/workflow/types'
|
||||
@@ -141,7 +141,7 @@ export class GetBlockUpstreamReferencesClientTool extends BaseClientTool {
|
||||
const accessibleIds = new Set<string>(ancestorIds)
|
||||
accessibleIds.add(blockId)
|
||||
|
||||
const starterBlock = Object.values(blocks).find((b) => isValidStartBlockType(b.type))
|
||||
const starterBlock = Object.values(blocks).find((b) => isInputDefinitionTrigger(b.type))
|
||||
if (starterBlock && ancestorIds.includes(starterBlock.id)) {
|
||||
accessibleIds.add(starterBlock.id)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { z } from 'zod'
|
||||
import { normalizeInputFormatValue } from '@/lib/workflows/input-format'
|
||||
import { isValidStartBlockType } from '@/lib/workflows/triggers/start-block-types'
|
||||
import { isInputDefinitionTrigger } from '@/lib/workflows/triggers/input-definition-triggers'
|
||||
import type { InputFormatField } from '@/lib/workflows/types'
|
||||
import type { McpToolSchema } from './types'
|
||||
|
||||
@@ -217,7 +217,7 @@ export function extractInputFormatFromBlocks(
|
||||
const blockObj = block as Record<string, unknown>
|
||||
const blockType = blockObj.type as string
|
||||
|
||||
if (isValidStartBlockType(blockType)) {
|
||||
if (isInputDefinitionTrigger(blockType)) {
|
||||
// Try to get inputFormat from subBlocks.inputFormat.value
|
||||
const subBlocks = blockObj.subBlocks as Record<string, { value?: unknown }> | undefined
|
||||
const subBlockValue = subBlocks?.inputFormat?.value
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { isValidStartBlockType } from '@/lib/workflows/triggers/start-block-types'
|
||||
import { isInputDefinitionTrigger } from '@/lib/workflows/triggers/input-definition-triggers'
|
||||
import type { InputFormatField } from '@/lib/workflows/types'
|
||||
|
||||
/**
|
||||
@@ -25,7 +25,7 @@ export function extractInputFieldsFromBlocks(
|
||||
// Find trigger block
|
||||
const triggerEntry = Object.entries(blocks).find(([, block]) => {
|
||||
const b = block as Record<string, unknown>
|
||||
return typeof b.type === 'string' && isValidStartBlockType(b.type)
|
||||
return typeof b.type === 'string' && isInputDefinitionTrigger(b.type)
|
||||
})
|
||||
|
||||
if (!triggerEntry) return []
|
||||
|
||||
28
apps/sim/lib/workflows/triggers/input-definition-triggers.ts
Normal file
28
apps/sim/lib/workflows/triggers/input-definition-triggers.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Trigger types that define workflow input parameters (inputFormat).
|
||||
* These are triggers where users can configure input schema for the workflow.
|
||||
*
|
||||
* This module is kept lightweight with no dependencies to avoid circular imports.
|
||||
*
|
||||
* Note: External triggers like webhook/schedule are NOT included here because
|
||||
* they receive input from external event payloads, not user-defined inputFormat.
|
||||
*/
|
||||
export const INPUT_DEFINITION_TRIGGER_TYPES = [
|
||||
'starter',
|
||||
'start',
|
||||
'start_trigger',
|
||||
'api_trigger',
|
||||
'input_trigger',
|
||||
] as const
|
||||
|
||||
export type InputDefinitionTriggerType = (typeof INPUT_DEFINITION_TRIGGER_TYPES)[number]
|
||||
|
||||
/**
|
||||
* Check if a block type is a trigger that defines workflow input parameters.
|
||||
* Used to find blocks that have inputFormat subblock for workflow input schema.
|
||||
*/
|
||||
export function isInputDefinitionTrigger(
|
||||
blockType: string
|
||||
): blockType is InputDefinitionTriggerType {
|
||||
return INPUT_DEFINITION_TRIGGER_TYPES.includes(blockType as InputDefinitionTriggerType)
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/**
|
||||
* Valid start block types that can trigger a workflow
|
||||
* This module is kept lightweight with no dependencies to avoid circular imports
|
||||
*/
|
||||
export const VALID_START_BLOCK_TYPES = [
|
||||
'starter',
|
||||
'start',
|
||||
'start_trigger',
|
||||
'api',
|
||||
'api_trigger',
|
||||
'input_trigger',
|
||||
] as const
|
||||
|
||||
export type ValidStartBlockType = (typeof VALID_START_BLOCK_TYPES)[number]
|
||||
|
||||
/**
|
||||
* Check if a block type is a valid start block type
|
||||
*/
|
||||
export function isValidStartBlockType(blockType: string): blockType is ValidStartBlockType {
|
||||
return VALID_START_BLOCK_TYPES.includes(blockType as ValidStartBlockType)
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { isValidStartBlockType } from '@/lib/workflows/triggers/start-block-types'
|
||||
import { isInputDefinitionTrigger } from '@/lib/workflows/triggers/input-definition-triggers'
|
||||
import {
|
||||
type StartBlockCandidate,
|
||||
StartBlockPath,
|
||||
@@ -22,7 +22,7 @@ export function hasValidStartBlockInState(state: WorkflowState | null | undefine
|
||||
|
||||
const startBlock = Object.values(state.blocks).find((block: BlockState) => {
|
||||
const blockType = block?.type
|
||||
return isValidStartBlockType(blockType)
|
||||
return isInputDefinitionTrigger(blockType)
|
||||
})
|
||||
|
||||
return !!startBlock
|
||||
|
||||
Reference in New Issue
Block a user