Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

@icecrasher321 icecrasher321 commented Jan 23, 2026

Summary

Tag dropdown + Resolution logic should work correctly.

  1. Maintain existing behavior except with tag dropdown aware of the logic: Within loop maintain selection conversion to "loop" and "parallel". Outside you don't do this conversion -- so <loopName.results> works.

  2. Resolve root level objects correctly for subflow.

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 23, 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 23, 2026 1:52am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 23, 2026

Greptile Summary

Fixed loop and parallel tag dropdown behavior and reference resolution logic in subflows. The tag dropdown now displays contextual tags with block name prefixes (e.g., loopName.index) inside loops/parallels, but converts them to generic references (<loop.index>) when inserted. Outside subflows, block outputs like loopName.results work correctly without conversion. The resolvers now support bare <loop> and <parallel> references that return full context objects, and validate properties to throw helpful errors for unknown fields. Added protection against using reserved names (loop, parallel, variable) for blocks.

Key improvements:

  • Tag dropdown aware of loop/parallel context, showing named tags (e.g., myLoop.index) but inserting generic references (<loop.index>)
  • Root-level block outputs (e.g., loopName.results) work correctly outside subflows
  • Loop and parallel resolvers enhanced with property validation and bare reference support
  • Reserved name validation prevents naming conflicts
  • Comprehensive test coverage for new behaviors

Confidence Score: 4/5

  • This PR is safe to merge with minor considerations for edge case testing
  • The implementation is well-structured with comprehensive test coverage. The logic correctly distinguishes between contextual loop/parallel tags (inside subflows) and root-level block outputs (outside subflows). Reserved name validation is properly implemented across all entry points. The conversion logic in tag-dropdown.tsx uses isContextual flag appropriately. However, the complex conditional logic in tag selection (lines 1800-1814) could benefit from additional manual testing of edge cases.
  • tag-dropdown.tsx requires careful testing of the tag selection conversion logic, especially the interaction between isContextual flag and the nested conditionals

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown.tsx Updated loop/parallel contextual tags to include block name prefix (e.g., loopName.index instead of just index), and conversion logic to map named tags back to generic <loop.property> format
apps/sim/executor/variables/resolvers/loop.ts Enhanced to support bare <loop> reference returning full context object, validates properties against known list, throws InvalidFieldError for unknown properties
apps/sim/executor/variables/resolvers/parallel.ts Enhanced to support bare <parallel> reference returning full context object, validates properties against known list, throws InvalidFieldError for unknown properties
apps/sim/hooks/use-collaborative-workflow.ts Added validation to prevent renaming blocks to reserved names (loop, parallel, variable)
apps/sim/lib/copilot/tools/server/workflow/edit-workflow.ts Added validation in both add and edit operations to prevent using reserved names for blocks

Sequence Diagram

sequenceDiagram
    participant User
    participant TagDropdown
    participant LoopResolver
    participant ParallelResolver
    participant Workflow

    Note over User,Workflow: Inside Loop/Parallel Subflow

    User->>TagDropdown: Type < to open dropdown
    TagDropdown->>Workflow: Get loop/parallel config
    Workflow-->>TagDropdown: Loop/parallel metadata
    TagDropdown->>TagDropdown: Build contextual tags with block name prefix<br/>(e.g., loopName.index, loopName.currentItem)
    TagDropdown->>TagDropdown: Mark as isContextual=true
    TagDropdown-->>User: Show tags: loopName.index, loopName.currentItem, etc.

    User->>TagDropdown: Select "loopName.index"
    TagDropdown->>TagDropdown: Check if isContextual=true
    TagDropdown->>TagDropdown: Convert to generic format: loop.index
    TagDropdown-->>User: Insert <loop.index> into input

    Note over User,Workflow: Runtime Resolution

    User->>Workflow: Execute workflow with <loop.index>
    Workflow->>LoopResolver: Resolve <loop.index>
    LoopResolver->>LoopResolver: Validate property against KNOWN_PROPERTIES
    LoopResolver->>LoopResolver: Return iteration value from loopScope
    LoopResolver-->>Workflow: Resolved value (e.g., 2)

    Note over User,Workflow: Root Level Reference (Outside Loop)

    User->>TagDropdown: Type < outside loop
    TagDropdown->>Workflow: Get available blocks
    Workflow-->>TagDropdown: Block outputs (e.g., loopName.results)
    TagDropdown->>TagDropdown: NOT marked as contextual
    TagDropdown-->>User: Show: loopName.results
    User->>TagDropdown: Select "loopName.results"
    TagDropdown->>TagDropdown: No conversion (not contextual)
    TagDropdown-->>User: Insert <loopName.results>

    Note over User,Workflow: Reserved Name Protection

    User->>Workflow: Attempt to rename block to "loop"
    Workflow->>Workflow: Check against RESERVED_BLOCK_NAMES
    Workflow-->>User: Error: "loop" is reserved
Loading

@icecrasher321 icecrasher321 merged commit aa99db6 into staging Jan 23, 2026
10 checks passed
@icecrasher321 icecrasher321 deleted the fix/subflow-tag-dropdown branch January 23, 2026 01:58
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