-
Notifications
You must be signed in to change notification settings - Fork 3.3k
improvement(triggers): uuid, autolayout, copilot context #1503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Summary
This PR implements consistency improvements for trigger block handling in the workflow system. The changes standardize how trigger blocks are created and identified throughout the application by making two key modifications:-
Consistent UUID Generation: The workflow creation code now uses
crypto.randomUUID()instead of timestamp-based IDs (${triggerId}_${Date.now()}) when creating trigger blocks. This ensures all blocks use the same ID format regardless of whether they're created through the toolbar or trigger list, resolving inconsistencies with sidebar selection behavior. -
Trigger Block Identification: All core trigger blocks (
ApiTriggerBlock,ChatTriggerBlock,InputTriggerBlock,ManualTriggerBlock, andScheduleBlock) now include atriggerAllowed: trueproperty in their configuration. This flag serves as a standardized way to identify which blocks can function as workflow triggers, providing better context for copilot functionality and system-wide trigger handling.
These changes integrate well with the existing block configuration system, following the same patterns used elsewhere in the codebase. The BlockConfig type already supports the optional triggerAllowed property, and other block creation methods throughout the workflow file already use crypto.randomUUID(), making this a natural alignment with established conventions.
Changed Files
| Filename | Score | Overview |
|---|---|---|
| apps/sim/blocks/blocks/schedule.ts | 5/5 | Added triggerAllowed: true flag to ScheduleBlock configuration for trigger identification |
| apps/sim/blocks/blocks/chat_trigger.ts | 5/5 | Added triggerAllowed: true flag to ChatTriggerBlock configuration for consistency |
| apps/sim/blocks/blocks/manual_trigger.ts | 5/5 | Added triggerAllowed: true flag to ManualTriggerBlock configuration for trigger categorization |
| apps/sim/blocks/blocks/api_trigger.ts | 5/5 | Added triggerAllowed: true flag to ApiTriggerBlock configuration for proper trigger identification |
| apps/sim/blocks/blocks/input_trigger.ts | 5/5 | Added triggerAllowed: true flag to InputTriggerBlock configuration to align with other triggers |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx | 5/5 | Replaced timestamp-based ID generation with crypto.randomUUID() for trigger block creation consistency |
Confidence score: 5/5
- This PR is safe to merge with minimal risk as it implements straightforward consistency improvements
- Score reflects simple, well-aligned changes that follow existing codebase patterns and conventions
- No files require special attention as all changes are minor configuration additions and standard library usage
Sequence Diagram
sequenceDiagram
participant User
participant Toolbar
participant WorkflowContent
participant TriggerUtils
participant WorkflowStore as "Workflow Store"
participant ReactFlow
User->>Toolbar: "Click trigger block"
Toolbar->>WorkflowContent: "Dispatch 'add-block-from-toolbar' event"
WorkflowContent->>WorkflowContent: "Check effectivePermissions.canEdit"
WorkflowContent->>WorkflowContent: "Extract type from event.detail"
WorkflowContent->>WorkflowContent: "Generate crypto.randomUUID()"
WorkflowContent->>TriggerUtils: "getDefaultTriggerName(type)"
TriggerUtils-->>WorkflowContent: "Return trigger name"
WorkflowContent->>WorkflowStore: "getUniqueBlockName(baseName, blocks)"
WorkflowStore-->>WorkflowContent: "Return unique name"
WorkflowContent->>ReactFlow: "project({ x: window.innerWidth/2, y: window.innerHeight/2 })"
ReactFlow-->>WorkflowContent: "Return center position"
WorkflowContent->>TriggerUtils: "getTriggerAdditionIssue(blocks, type)"
TriggerUtils-->>WorkflowContent: "Return null (no issue)"
WorkflowContent->>WorkflowStore: "addBlock(id, type, name, centerPosition, ...)"
WorkflowStore-->>ReactFlow: "Update workflow state"
ReactFlow-->>User: "Display new trigger block"
6 files reviewed, no comments
Summary
Type of Change
Testing
Manually
Checklist