Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • Created dedicated workflow-selector sub-block type using existing selector infrastructure
  • Workflow dropdown now reads directly from Zustand registry with staleTime: 0 for fresh data
  • Filters out current workflow from selection options
  • Follows same pattern as Slack, Jira, Linear selectors

Type of Change

  • Bug fix

Testing

Tested 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 Jan 22, 2026

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

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 22, 2026 2:24am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 22, 2026

Greptile Summary

Refactored workflow dropdown to use dedicated workflow-selector sub-block type that leverages the existing selector infrastructure. The workflow dropdown now reads fresh data directly from the Zustand registry with staleTime: 0 and automatically filters out the current workflow to prevent recursion.

Key Changes:

  • Created new WorkflowSelectorInput component following the same pattern as Slack/Jira/Linear selectors
  • Added sim.workflows selector to the registry with proper context support for excludeWorkflowId
  • Simplified workflow.ts and workflow_input.ts by removing inline getAvailableWorkflows functions
  • Integrated the new selector type into the sub-block component's case handler

Benefits:

  • Consistent with other selector components in the codebase
  • Leverages React Query through the selector infrastructure for proper caching and refetching
  • Cleaner separation of concerns - block configs no longer contain fetching logic
  • Fresh data on every render with staleTime: 0 ensures workflow list is always up-to-date

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes follow established patterns (Slack, Jira, Linear selectors), properly use the selector infrastructure with correct type definitions, and simplify code by removing inline logic. All components follow the project's architectural patterns and style guidelines.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/workflow-selector/workflow-selector-input.tsx New dedicated workflow selector component following established selector pattern with proper context handling
apps/sim/blocks/blocks/workflow.ts Simplified by removing inline workflow fetching logic, now uses workflow-selector type
apps/sim/blocks/blocks/workflow_input.ts Simplified by removing inline workflow fetching logic, now uses workflow-selector type
apps/sim/hooks/selectors/registry.ts Added sim.workflows selector with staleTime: 0 for fresh Zustand data and excludeWorkflowId context support

Sequence Diagram

sequenceDiagram
    participant User
    participant SubBlock as SubBlock Component
    participant WorkflowSelector as WorkflowSelectorInput
    participant SelectorCombo as SelectorCombobox
    participant SelectorRegistry as Selector Registry
    participant WorkflowStore as Zustand Store
    
    User->>SubBlock: Render workflow block
    SubBlock->>WorkflowSelector: Render workflow-selector type
    WorkflowSelector->>WorkflowStore: Get activeWorkflowId
    WorkflowStore-->>WorkflowSelector: Return current workflow ID
    WorkflowSelector->>WorkflowSelector: Create context with excludeWorkflowId
    WorkflowSelector->>SelectorCombo: Pass selectorKey and context
    SelectorCombo->>SelectorRegistry: Query sim.workflows selector
    SelectorRegistry->>WorkflowStore: Call getState() to fetch workflows
    WorkflowStore-->>SelectorRegistry: Return workflows object
    SelectorRegistry->>SelectorRegistry: Filter out current workflow
    SelectorRegistry->>SelectorRegistry: Map workflows to options
    SelectorRegistry-->>SelectorCombo: Return workflow options
    SelectorCombo-->>User: Display workflow dropdown
    User->>SelectorCombo: Select workflow
    SelectorCombo->>SubBlock: Update block value
Loading

@waleedlatif1 waleedlatif1 merged commit 900d3ef into staging Jan 22, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/workflow-selector branch January 22, 2026 02:38
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