Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

@icecrasher321 icecrasher321 commented Sep 30, 2025

Summary

  • Generate trigger block with random uuid -- consistent with sidebar selection
  • Add triggerAllowed flag to core triggers for copilot context
  • Fix isStarterBlock function to recognize new triggers in autolayout

Type of Change

  • Other: General Improvement

Testing

Manually

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
Copy link

vercel bot commented Sep 30, 2025

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

Project Deployment Preview Comments Updated (UTC)
sim Ready Ready Preview Comment Sep 30, 2025 6:30pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Sep 30, 2025 6:30pm

@icecrasher321 icecrasher321 changed the title improvment(trigger-uuid): generate random uuid for block for consistency improvement(trigger-uuid): generate random uuid for block for consistency Sep 30, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a 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:
  1. 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.

  2. Trigger Block Identification: All core trigger blocks (ApiTriggerBlock, ChatTriggerBlock, InputTriggerBlock, ManualTriggerBlock, and ScheduleBlock) now include a triggerAllowed: true property 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"
Loading

6 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@icecrasher321 icecrasher321 changed the title improvement(trigger-uuid): generate random uuid for block for consistency improvement(triggers): uuid, autolayout, copilot context Sep 30, 2025
@vercel vercel bot temporarily deployed to Preview – docs September 30, 2025 18:26 Inactive
@icecrasher321 icecrasher321 merged commit 17edf04 into staging Sep 30, 2025
8 checks passed
@waleedlatif1 waleedlatif1 deleted the improvement/uuid-trigger-select branch October 7, 2025 23:22
Sign up for free to 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