Skip to content

improvement(selectors): consolidate selector input logic#3375

Merged
waleedlatif1 merged 1 commit intostagingfrom
improvement/selector-consolidation
Feb 27, 2026
Merged

improvement(selectors): consolidate selector input logic#3375
waleedlatif1 merged 1 commit intostagingfrom
improvement/selector-consolidation

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Consolidate selector input logic.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: Code quality improvement

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 Feb 27, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 27, 2026 4:47pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 27, 2026

Greptile Summary

Consolidates 6 specific selector components (FileSelectorInput, SheetSelectorInput, ProjectSelectorInput, FolderSelectorInput, SlackSelectorInput, DocumentSelector) into a single unified SelectorInput component, reducing code by 748 lines.

Key Changes

  • Created selector-input.tsx component that handles all selector types declaratively via selectorKey property
  • Created use-selector-setup.ts hook that builds SelectorContext by mapping dependencies through the canonical index
  • Enhanced use-depends-on-gate.ts to expose dependencyValues and canonicalIndex for reuse
  • Added override pattern for special cases (Slack auth methods, Gmail INBOX default)
  • Simplified document-tag-entry and knowledge-tag-filters to use shared dependency resolution logic
  • Added explicit dependsOn declarations to knowledge block sub-blocks

Benefits

  • Significantly improved maintainability by eliminating duplicate logic across 6 components
  • More declarative approach using selectorKey and dependsOn configuration
  • Centralized selector context building logic makes it easier to add new selector types
  • Better performance through shared memoization and stable dependencies

Confidence Score: 5/5

  • This PR is safe to merge - well-architected refactoring with no logical issues
  • Excellent code consolidation that preserves all existing functionality while reducing complexity. The refactoring follows established patterns, maintains type safety, and includes proper dependency handling. Manual testing confirmed by author.
  • 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/selector-input/selector-input.tsx New unified selector component that consolidates all selector input logic with override support
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-selector-setup.ts New hook that builds selector context declaratively from sub-block dependencies via canonical mapping
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-depends-on-gate.ts Enhanced to return dependencyValues and canonicalIndex for reuse by useSelectorSetup
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/sub-block.tsx Replaces 6 specific selector components with unified SelectorInput, adds Slack and folder overrides

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[SubBlock Component] --> B{Selector Type?}
    B -->|file/sheet/project/folder/document/slack/channel/user| C[SelectorInput]
    
    C --> D[useSelectorSetup Hook]
    D --> E[useDependsOnGate Hook]
    
    E --> F[Get Dependency Values]
    F --> G[Build Canonical Index]
    G --> H[Map to SelectorContext]
    
    H --> I{Overrides?}
    I -->|Slack| J[Transform Context for Auth]
    I -->|Folder| K[Apply Gmail INBOX Default]
    I -->|None| L[Use Auto Context]
    
    J --> M[SelectorCombobox]
    K --> M
    L --> M
    
    M --> N[Render Selector UI]
    
    style C fill:#4ade80
    style D fill:#60a5fa
    style E fill:#60a5fa
    style M fill:#a78bfa
Loading

Last reviewed commit: 2a84016

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.

14 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 49db3ca into staging Feb 27, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the improvement/selector-consolidation branch February 27, 2026 18:18
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