From 17edf0405b8d2359aefaf46660617b56eed80484 Mon Sep 17 00:00:00 2001 From: Vikhyath Mondreti Date: Tue, 30 Sep 2025 11:31:54 -0700 Subject: [PATCH] improvement(triggers): uuid, autolayout, copilot context (#1503) * make trigger select uuid consistent with sidebar selection * add trigger allowed flag for core triggers * fix autolayout with new triggers --- .../workspace/[workspaceId]/w/[workflowId]/workflow.tsx | 2 +- apps/sim/blocks/blocks/api_trigger.ts | 1 + apps/sim/blocks/blocks/chat_trigger.ts | 1 + apps/sim/blocks/blocks/input_trigger.ts | 1 + apps/sim/blocks/blocks/manual_trigger.ts | 1 + apps/sim/blocks/blocks/schedule.ts | 1 + apps/sim/lib/workflows/autolayout/utils.ts | 7 ++++++- 7 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx index 90f43f4e33..c4e1018f6b 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx @@ -781,7 +781,7 @@ const WorkflowContent = React.memo(() => { // Create the trigger block at the center of the viewport const centerPosition = project({ x: window.innerWidth / 2, y: window.innerHeight / 2 }) - const id = `${triggerId}_${Date.now()}` + const id = crypto.randomUUID() // Add the trigger block with trigger mode if specified addBlock( diff --git a/apps/sim/blocks/blocks/api_trigger.ts b/apps/sim/blocks/blocks/api_trigger.ts index 66f7e91904..5a830f9b6c 100644 --- a/apps/sim/blocks/blocks/api_trigger.ts +++ b/apps/sim/blocks/blocks/api_trigger.ts @@ -3,6 +3,7 @@ import type { BlockConfig } from '@/blocks/types' export const ApiTriggerBlock: BlockConfig = { type: 'api_trigger', + triggerAllowed: true, name: 'API', description: 'Expose as HTTP API endpoint', longDescription: diff --git a/apps/sim/blocks/blocks/chat_trigger.ts b/apps/sim/blocks/blocks/chat_trigger.ts index 9dc98f0b1c..7276489ac4 100644 --- a/apps/sim/blocks/blocks/chat_trigger.ts +++ b/apps/sim/blocks/blocks/chat_trigger.ts @@ -7,6 +7,7 @@ const ChatTriggerIcon = (props: SVGProps) => createElement(Messag export const ChatTriggerBlock: BlockConfig = { type: 'chat_trigger', + triggerAllowed: true, name: 'Chat', description: 'Start workflow from a chat deployment', longDescription: 'Chat trigger to run the workflow via deployed chat interfaces.', diff --git a/apps/sim/blocks/blocks/input_trigger.ts b/apps/sim/blocks/blocks/input_trigger.ts index 954c31bc1a..073c38ad7e 100644 --- a/apps/sim/blocks/blocks/input_trigger.ts +++ b/apps/sim/blocks/blocks/input_trigger.ts @@ -7,6 +7,7 @@ const InputTriggerIcon = (props: SVGProps) => createElement(FormI export const InputTriggerBlock: BlockConfig = { type: 'input_trigger', + triggerAllowed: true, name: 'Input Form', description: 'Start workflow manually with a defined input schema', longDescription: diff --git a/apps/sim/blocks/blocks/manual_trigger.ts b/apps/sim/blocks/blocks/manual_trigger.ts index 508ef3f792..4d8a433d6d 100644 --- a/apps/sim/blocks/blocks/manual_trigger.ts +++ b/apps/sim/blocks/blocks/manual_trigger.ts @@ -7,6 +7,7 @@ const ManualTriggerIcon = (props: SVGProps) => createElement(Play export const ManualTriggerBlock: BlockConfig = { type: 'manual_trigger', + triggerAllowed: true, name: 'Manual', description: 'Start workflow manually from the editor', longDescription: diff --git a/apps/sim/blocks/blocks/schedule.ts b/apps/sim/blocks/blocks/schedule.ts index 72a54d6811..c1e8aef79b 100644 --- a/apps/sim/blocks/blocks/schedule.ts +++ b/apps/sim/blocks/blocks/schedule.ts @@ -7,6 +7,7 @@ const ScheduleIcon = (props: SVGProps) => createElement(Clock, pr export const ScheduleBlock: BlockConfig = { type: 'schedule', + triggerAllowed: true, name: 'Schedule', description: 'Trigger workflow execution on a schedule', longDescription: diff --git a/apps/sim/lib/workflows/autolayout/utils.ts b/apps/sim/lib/workflows/autolayout/utils.ts index 87cc71cd52..71f7cace53 100644 --- a/apps/sim/lib/workflows/autolayout/utils.ts +++ b/apps/sim/lib/workflows/autolayout/utils.ts @@ -1,3 +1,4 @@ +import { TriggerUtils } from '@/lib/workflows/triggers' import type { BlockState } from '@/stores/workflows/workflow/types' import type { BlockDimensions, BoundingBox } from './types' @@ -70,5 +71,9 @@ export function getBlocksByParent(blocks: Record): { } export function isStarterBlock(block: BlockState): boolean { - return block.type === 'starter' || block.type === 'webhook' || block.type === 'schedule' + if (TriggerUtils.isTriggerBlock({ type: block.type, triggerMode: block.triggerMode })) { + return true + } + + return block.triggerMode === true }