Skip to content

Commit 26ca373

Browse files
fix(conditions): make outputs correct (#2437)
1 parent 731997f commit 26ca373

File tree

5 files changed

+7
-16
lines changed

5 files changed

+7
-16
lines changed

apps/docs/content/docs/en/connections/data-structure.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,26 +106,24 @@ Different block types produce different output structures. Here's what you can e
106106
<Tab>
107107
```json
108108
{
109-
"content": "Original content passed through",
110109
"conditionResult": true,
111110
"selectedPath": {
112111
"blockId": "2acd9007-27e8-4510-a487-73d3b825e7c1",
113112
"blockType": "agent",
114113
"blockTitle": "Follow-up Agent"
115114
},
116-
"selectedConditionId": "condition-1"
115+
"selectedOption": "condition-1"
117116
}
118117
```
119118

120119
### Condition Block Output Fields
121120

122-
- **content**: The original content passed through
123121
- **conditionResult**: Boolean result of the condition evaluation
124122
- **selectedPath**: Information about the selected path
125123
- **blockId**: ID of the next block in the selected path
126124
- **blockType**: Type of the next block
127125
- **blockTitle**: Title of the next block
128-
- **selectedConditionId**: ID of the selected condition
126+
- **selectedOption**: ID of the selected condition
129127

130128
</Tab>
131129
<Tab>

apps/sim/blocks/blocks/condition.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ import type { BlockConfig } from '@/blocks/types'
44
interface ConditionBlockOutput {
55
success: boolean
66
output: {
7-
content: string
87
conditionResult: boolean
98
selectedPath: {
109
blockId: string
1110
blockType: string
1211
blockTitle: string
1312
}
14-
selectedConditionId: string
13+
selectedOption: string
1514
}
1615
}
1716

@@ -40,9 +39,8 @@ export const ConditionBlock: BlockConfig<ConditionBlockOutput> = {
4039
},
4140
inputs: {},
4241
outputs: {
43-
content: { type: 'string', description: 'Condition evaluation content' },
4442
conditionResult: { type: 'boolean', description: 'Condition result' },
4543
selectedPath: { type: 'json', description: 'Selected execution path' },
46-
selectedConditionId: { type: 'string', description: 'Selected condition identifier' },
44+
selectedOption: { type: 'string', description: 'Selected condition option ID' },
4745
},
4846
}

apps/sim/executor/handlers/condition/condition-handler.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ describe('ConditionBlockHandler', () => {
170170
blockType: 'target',
171171
blockTitle: 'Target Block 1',
172172
},
173-
selectedConditionId: 'cond1',
174173
selectedOption: 'cond1',
175174
}
176175

@@ -210,7 +209,6 @@ describe('ConditionBlockHandler', () => {
210209
blockType: 'target',
211210
blockTitle: 'Target Block 2',
212211
},
213-
selectedConditionId: 'else1',
214212
selectedOption: 'else1',
215213
}
216214

@@ -371,7 +369,7 @@ describe('ConditionBlockHandler', () => {
371369
const result = await handler.execute(contextWithoutSource, mockBlock, inputs)
372370

373371
expect(result).toHaveProperty('conditionResult', true)
374-
expect(result).toHaveProperty('selectedConditionId', 'cond1')
372+
expect(result).toHaveProperty('selectedOption', 'cond1')
375373
})
376374

377375
it('should throw error if target block is missing', async () => {
@@ -419,7 +417,6 @@ describe('ConditionBlockHandler', () => {
419417

420418
expect((result as any).conditionResult).toBe(false)
421419
expect((result as any).selectedPath).toBeNull()
422-
expect((result as any).selectedConditionId).toBeNull()
423420
expect((result as any).selectedOption).toBeNull()
424421
expect(mockContext.decisions.condition.has(mockBlock.id)).toBe(false)
425422
})
@@ -438,6 +435,6 @@ describe('ConditionBlockHandler', () => {
438435
const result = await handler.execute(mockContext, mockBlock, inputs)
439436

440437
expect(mockContext.decisions.condition.get(mockBlock.id)).toBe('else1')
441-
expect((result as any).selectedConditionId).toBe('else1')
438+
expect((result as any).selectedOption).toBe('else1')
442439
})
443440
})

apps/sim/executor/handlers/condition/condition-handler.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ export class ConditionBlockHandler implements BlockHandler {
117117
...((sourceOutput as any) || {}),
118118
conditionResult: false,
119119
selectedPath: null,
120-
selectedConditionId: null,
121120
selectedOption: null,
122121
}
123122
}
@@ -139,7 +138,6 @@ export class ConditionBlockHandler implements BlockHandler {
139138
blockTitle: targetBlock.metadata?.name || DEFAULTS.BLOCK_TITLE,
140139
},
141140
selectedOption: selectedCondition.id,
142-
selectedConditionId: selectedCondition.id,
143141
}
144142
}
145143

apps/sim/executor/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export interface NormalizedBlockOutput {
8383
blockType?: string
8484
blockTitle?: string
8585
}
86-
selectedConditionId?: string
86+
selectedOption?: string
8787
conditionResult?: boolean
8888
result?: any
8989
stdout?: string

0 commit comments

Comments
 (0)