Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • added workflow, kb, and function as a tool for agent block
  • fix keyboard nav in tool input

Type of Change

  • New feature

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 Nov 23, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Nov 24, 2025 6:07pm

@waleedlatif1 waleedlatif1 marked this pull request as ready for review November 23, 2025 05:26
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 23, 2025

Greptile Overview

Greptile Summary

This PR adds workflow, knowledge base, and function as tool options for agent blocks, alongside keyboard navigation improvements for the tool input selector.

Major changes:

  • Added workflow-selector and workflow-input-mapper UI component types to support selecting and configuring child workflows as agent tools
  • Refactored ToolCredentialSelector to use the Combobox component instead of custom Command/Popover implementation
  • Enhanced Command component with forwardRef support and automatic scroll-into-view for keyboard navigation
  • Extended getToolParametersConfig in tools/params.ts to handle special cases for workflow_executor, function_execute, and knowledge base tools
  • Added dynamic workflow input field extraction and mapping UI that fetches child workflow schemas

Implementation notes:

  • The workflow input mapper correctly handles both new (subBlocks.inputFormat.value) and legacy (config.params.inputFormat) formats for workflow input definitions
  • Credential selector now properly calculates effectiveServiceId using getServiceIdFromScopes when serviceId prop is not provided
  • Added event listeners for credential-disconnected, visibilitychange, and pageshow to keep credentials fresh

Confidence Score: 3/5

  • Safe to merge with one critical keyboard event handling issue that needs fixing
  • The PR implements substantial new functionality for agent tool configuration. Most changes are well-structured, but there is a critical logic issue with keyboard event dispatching in tool-input.tsx that will prevent the keyboard navigation from working properly. The native KeyboardEvent constructor won't trigger React's synthetic event handlers. Once this is fixed, the implementation appears solid with proper error handling, loading states, and backwards compatibility for legacy formats.
  • tool-input.tsx requires fixing the keyboard event dispatching logic at line 678-690

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/components/tool-command/tool-command.tsx 4/5 Refactored Command component to use forwardRef and added auto-scrolling for keyboard navigation
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/components/tool-credential-selector.tsx 3/5 Major refactor replacing custom popover with Combobox component, improved credential refresh logic
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx 3/5 Added workflow/kb/function tool support with WorkflowSelectorSyncWrapper and WorkflowInputMapperSyncWrapper
apps/sim/tools/params.ts 4/5 Added special handling for workflow_executor and function_execute tools with dynamic schema generation

Sequence Diagram

sequenceDiagram
    participant User
    participant ToolInput
    participant WorkflowSelector
    participant WorkflowInputMapper
    participant API
    participant ToolCommand
    participant ToolCredentialSelector
    participant Combobox

    User->>ToolInput: Select workflow/kb/function tool
    ToolInput->>ToolCommand: Open tool selection popover
    ToolCommand->>ToolCommand: Handle keyboard navigation
    Note over ToolCommand: Arrow keys scroll active item<br/>into view automatically
    User->>ToolCommand: Select tool (Enter/Click)
    ToolCommand->>ToolInput: Tool selected
    
    alt Tool is workflow_executor
        ToolInput->>WorkflowSelector: Render workflow selector
        User->>WorkflowSelector: Select workflow
        WorkflowSelector->>API: Fetch workflows list
        API-->>WorkflowSelector: Return workflows
        User->>WorkflowSelector: Choose workflow
        WorkflowSelector->>ToolInput: Update workflowId param
        
        ToolInput->>WorkflowInputMapper: Render input mapper
        WorkflowInputMapper->>API: GET /api/workflows/:id
        API-->>WorkflowInputMapper: Return workflow data
        WorkflowInputMapper->>WorkflowInputMapper: Extract input fields from trigger block
        WorkflowInputMapper->>WorkflowInputMapper: Render ShortInput for each field
        User->>WorkflowInputMapper: Fill input values
        WorkflowInputMapper->>ToolInput: Update inputMapping JSON
    end
    
    alt Tool requires OAuth
        ToolInput->>ToolCredentialSelector: Render credential selector
        ToolCredentialSelector->>ToolCredentialSelector: Calculate effectiveServiceId
        ToolCredentialSelector->>API: Fetch OAuth credentials
        API-->>ToolCredentialSelector: Return credentials
        ToolCredentialSelector->>Combobox: Display credentials
        User->>Combobox: Search/select credential
        Combobox->>ToolCredentialSelector: Credential selected
        ToolCredentialSelector->>ToolInput: Update credential param
        
        Note over ToolCredentialSelector: Listens to credential-disconnected<br/>event for auto-refresh
    end
    
    ToolInput->>ToolInput: Store tool configuration
    Note over ToolInput: Tool ready for agent execution
Loading

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.

12 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

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