From 33cb3ed678785478d1b651658a57ca0ae0fb6856 Mon Sep 17 00:00:00 2001 From: waleed Date: Fri, 20 Feb 2026 17:52:08 -0800 Subject: [PATCH 1/2] fix(copilot): handle negated operation conditions in block config extraction --- .../copilot/tools/server/blocks/get-block-config.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts b/apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts index b9df7fa2c9a..fb44652b22d 100644 --- a/apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts +++ b/apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts @@ -135,12 +135,13 @@ interface OutputFieldSchema { function matchesOperation(condition: any, operation: string): boolean { if (!condition) return false - const cond = typeof condition === 'function' ? condition() : condition + const cond = typeof condition === 'function' ? condition({ operation }) : condition if (!cond) return false - if (cond.field === 'operation' && !cond.not) { + if (cond.field === 'operation') { const values = Array.isArray(cond.value) ? cond.value : [cond.value] - return values.includes(operation) + const included = values.includes(operation) + return cond.not ? !included : included } return false @@ -173,7 +174,10 @@ function extractInputsFromSubBlocks( // 1. Have no condition (common parameters) // 2. Have a condition matching the operation if (operation) { - const condition = typeof sb.condition === 'function' ? sb.condition() : sb.condition + const condition = + typeof sb.condition === 'function' + ? sb.condition(operation ? { operation } : undefined) + : sb.condition if (condition) { if (condition.field === 'operation' && !condition.not) { // This is an operation-specific field From 619cc1443b9d04c3ebd4fde1fc1b96ddf07dbb6d Mon Sep 17 00:00:00 2001 From: waleed Date: Fri, 20 Feb 2026 17:57:40 -0800 Subject: [PATCH 2/2] fix(copilot): simplify condition evaluation to single matchesOperation call --- .../tools/server/blocks/get-block-config.ts | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts b/apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts index fb44652b22d..11c7f73caa1 100644 --- a/apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts +++ b/apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts @@ -175,20 +175,9 @@ function extractInputsFromSubBlocks( // 2. Have a condition matching the operation if (operation) { const condition = - typeof sb.condition === 'function' - ? sb.condition(operation ? { operation } : undefined) - : sb.condition - if (condition) { - if (condition.field === 'operation' && !condition.not) { - // This is an operation-specific field - const values = Array.isArray(condition.value) ? condition.value : [condition.value] - if (!values.includes(operation)) { - continue // Skip if doesn't match our operation - } - } else if (!matchesOperation(condition, operation)) { - // Other condition that doesn't match - continue - } + typeof sb.condition === 'function' ? sb.condition({ operation }) : sb.condition + if (condition && !matchesOperation(condition, operation)) { + continue } }