Skip to content

Comments

fix(copilot): handle negated operation conditions in block config extraction#3282

Merged
waleedlatif1 merged 2 commits intostagingfrom
fix/slack-blocks
Feb 21, 2026
Merged

fix(copilot): handle negated operation conditions in block config extraction#3282
waleedlatif1 merged 2 commits intostagingfrom
fix/slack-blocks

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • Fix copilot's extractInputsFromSubBlocks to pass operation context to function-based conditions
  • Fix matchesOperation to properly handle not: true operation conditions
  • Without this, the copilot excluded required fields (e.g. channel for Slack ephemeral, spreadsheetId for Google Sheets read) from its input schema

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 Feb 21, 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 21, 2026 1:57am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 21, 2026

Greptile Summary

Fixed a bug where the copilot's extractInputsFromSubBlocks function wasn't properly evaluating operation-specific conditions for block configuration fields. The fix ensures that function-based conditions receive the operation context, and that the matchesOperation helper correctly handles negated conditions (not: true). This prevented required fields like Slack's channel parameter from being included in the copilot's input schema when using the ephemeral operation.

Key Changes:

  • Updated matchesOperation to pass { operation } context when evaluating function-based conditions
  • Added proper handling of not: true flag in operation matching logic
  • Simplified extractInputsFromSubBlocks to use the centralized matchesOperation function instead of duplicating logic

Confidence Score: 5/5

  • Safe to merge - targeted bug fix with clear improvement
  • The changes are minimal, well-focused, and fix a specific bug in condition evaluation. The refactoring consolidates duplicate logic into a single helper function, making the code more maintainable. The fix properly handles both function-based conditions and negation logic, which were previously broken.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts Fixed operation context passing to function-based conditions and negation handling in matchesOperation

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[extractInputsFromSubBlocks] --> B{Has operation?}
    B -->|Yes| C[Evaluate condition]
    B -->|No| D[Include field]
    C --> E{Is condition a function?}
    E -->|Yes| F["Call with { operation }"]
    E -->|No| G[Use condition as-is]
    F --> H[matchesOperation]
    G --> H
    H --> I{field === operation?}
    I -->|Yes| J[Check if op in values]
    I -->|No| K[Return false]
    J --> L{Has not flag?}
    L -->|Yes| M[Return negated result]
    L -->|No| N[Return included result]
    M --> O{Matches?}
    N --> O
    K --> O
    O -->|Yes| D
    O -->|No| P[Skip field]
Loading

Last reviewed commit: 619cc14

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.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 21, 2026

Additional Comments (1)

apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts
Incomplete fix - condition.not is still not handled here. If a condition has not: true, this code block still checks !condition.not and won't handle negated conditions properly. Consider using matchesOperation for all operation conditions instead of duplicating the logic.

        if (condition.field === 'operation') {
          // This is an operation-specific field
          if (!matchesOperation(condition, operation)) {
            continue // Skip if doesn't match our operation
          }

@waleedlatif1
Copy link
Collaborator Author

@greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

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.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@waleedlatif1 waleedlatif1 merged commit a98463a into staging Feb 21, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/slack-blocks branch February 21, 2026 02:08
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.

1 participant