Skip to content

Commit 33cb3ed

Browse files
committed
fix(copilot): handle negated operation conditions in block config extraction
1 parent 765a481 commit 33cb3ed

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

apps/sim/lib/copilot/tools/server/blocks/get-block-config.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,13 @@ interface OutputFieldSchema {
135135
function matchesOperation(condition: any, operation: string): boolean {
136136
if (!condition) return false
137137

138-
const cond = typeof condition === 'function' ? condition() : condition
138+
const cond = typeof condition === 'function' ? condition({ operation }) : condition
139139
if (!cond) return false
140140

141-
if (cond.field === 'operation' && !cond.not) {
141+
if (cond.field === 'operation') {
142142
const values = Array.isArray(cond.value) ? cond.value : [cond.value]
143-
return values.includes(operation)
143+
const included = values.includes(operation)
144+
return cond.not ? !included : included
144145
}
145146

146147
return false
@@ -173,7 +174,10 @@ function extractInputsFromSubBlocks(
173174
// 1. Have no condition (common parameters)
174175
// 2. Have a condition matching the operation
175176
if (operation) {
176-
const condition = typeof sb.condition === 'function' ? sb.condition() : sb.condition
177+
const condition =
178+
typeof sb.condition === 'function'
179+
? sb.condition(operation ? { operation } : undefined)
180+
: sb.condition
177181
if (condition) {
178182
if (condition.field === 'operation' && !condition.not) {
179183
// This is an operation-specific field

0 commit comments

Comments
 (0)