Skip to content

Commit f93a1bf

Browse files
Adam GoughAdam Gough
authored andcommitted
resolved comments
1 parent 0d4849b commit f93a1bf

File tree

4 files changed

+17
-30
lines changed

4 files changed

+17
-30
lines changed

apps/sim/app/w/[id]/components/control-bar/components/deployment-controls/components/deployed-workflow-card.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export function DeployedWorkflowCard({
2727
const workflowToShow = showingDeployed ? deployedWorkflowState : currentWorkflowState
2828
const activeWorkflowId = useWorkflowRegistry((state) => state.activeWorkflowId)
2929

30-
// // Generate a unique key for the workflow preview
3130
const previewKey = useMemo(() => {
3231
return `${showingDeployed ? 'deployed' : 'current'}-preview-${activeWorkflowId}}`
3332
}, [showingDeployed, activeWorkflowId])

apps/sim/app/w/[id]/components/control-bar/control-bar.test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
1212

13-
// Mock the stores
1413
const mockWorkflowStore = {
1514
getState: vi.fn(),
1615
subscribe: vi.fn(),
@@ -52,7 +51,6 @@ vi.mock('@/stores/workflows/utils', () => ({
5251
mergeSubblockState: vi.fn((blocks) => blocks),
5352
}))
5453

55-
// Mock other dependencies
5654
vi.mock('@/lib/logs/console-logger', () => ({
5755
createLogger: () => ({
5856
error: vi.fn(),
@@ -62,8 +60,6 @@ vi.mock('@/lib/logs/console-logger', () => ({
6260
}),
6361
}))
6462

65-
// Import the function we want to test
66-
// Since it's inside a component, we'll extract it for testing
6763
const normalizeBlocksForComparison = (blocks: Record<string, any>) => {
6864
if (!blocks) return []
6965

@@ -121,13 +117,11 @@ describe('normalizeBlocksForComparison', () => {
121117

122118
expect(result).toHaveLength(2)
123119

124-
// Should only contain type, name, and subBlocks
125120
result.forEach((block) => {
126121
expect(block).toHaveProperty('type')
127122
expect(block).toHaveProperty('name')
128123
expect(block).toHaveProperty('subBlocks')
129124

130-
// Should NOT contain metadata properties
131125
expect(block).not.toHaveProperty('id')
132126
expect(block).not.toHaveProperty('position')
133127
expect(block).not.toHaveProperty('height')
@@ -145,7 +139,6 @@ describe('normalizeBlocksForComparison', () => {
145139

146140
const result = normalizeBlocksForComparison(blocks)
147141

148-
// Should be sorted: agent blocks first (by name), then api blocks (by name)
149142
expect(result[0]).toEqual({ type: 'agent', name: 'Agent 1', subBlocks: {} })
150143
expect(result[1]).toEqual({ type: 'agent', name: 'Agent 2', subBlocks: {} })
151144
expect(result[2]).toEqual({ type: 'api', name: 'API 1', subBlocks: {} })
@@ -164,7 +157,6 @@ describe('normalizeBlocksForComparison', () => {
164157
'block-2': {
165158
type: 'agent',
166159
name: 'Agent 1',
167-
// subBlocks missing
168160
},
169161
}
170162

apps/sim/app/w/[id]/components/workflow-block/components/sub-block/components/code.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ReactElement } from 'react'
2-
import { useEffect, useMemo, useRef, useState } from 'react'
2+
import { useEffect, useRef, useState } from 'react'
33
import { Wand2 } from 'lucide-react'
44
import { highlight, languages } from 'prismjs'
55
import 'prismjs/components/prism-javascript'
@@ -60,11 +60,10 @@ export function Code({
6060
previewValue,
6161
}: CodeProps) {
6262
// Determine the AI prompt placeholder based on language
63-
const aiPromptPlaceholder = useMemo(() => {
64-
return language === 'json'
65-
? 'Describe the JSON schema you need...'
66-
: 'Describe the function you need...'
67-
}, [language])
63+
const aiPromptPlaceholder =
64+
language === 'json'
65+
? 'Describe the JSON schema to generate...'
66+
: 'Describe the JavaScript code to generate...'
6867

6968
// State management
7069
const [storeValue, setStoreValue] = useSubBlockValue(blockId, subBlockId)

apps/sim/app/w/[id]/components/workflow-block/components/sub-block/components/eval-input.tsx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,21 @@ export function EvalInput({
8585
)
8686
}
8787

88-
const updateThreshold = (id: string, value: string) => {
89-
if (isPreview) return
90-
91-
// Allow empty values for clearing
92-
const sanitizedValue = value.replace(/[^0-9.-]/g, '')
93-
if (sanitizedValue === '') {
94-
setStoreValue(
95-
metrics.map((metric) => (metric.id === id ? { ...metric, threshold: undefined } : metric))
96-
)
97-
return
98-
}
99-
88+
// Validation handlers
89+
const handleRangeBlur = (id: string, field: 'min' | 'max', value: string) => {
90+
const sanitizedValue = value.replace(/[^\d.-]/g, '')
10091
const numValue = Number.parseFloat(sanitizedValue)
10192

10293
setStoreValue(
10394
metrics.map((metric) =>
10495
metric.id === id
105-
? { ...metric, threshold: Number.isNaN(numValue) ? undefined : numValue }
96+
? {
97+
...metric,
98+
range: {
99+
...metric.range,
100+
[field]: !Number.isNaN(numValue) ? numValue : 0,
101+
},
102+
}
106103
: metric
107104
)
108105
)
@@ -190,7 +187,7 @@ export function EvalInput({
190187
type='text'
191188
value={metric.range.min}
192189
onChange={(e) => updateRange(metric.id, 'min', e.target.value)}
193-
onBlur={(e) => updateThreshold(metric.id, e.target.value)}
190+
onBlur={(e) => handleRangeBlur(metric.id, 'min', e.target.value)}
194191
disabled={isPreview}
195192
className='placeholder:text-muted-foreground/50'
196193
/>
@@ -201,7 +198,7 @@ export function EvalInput({
201198
type='text'
202199
value={metric.range.max}
203200
onChange={(e) => updateRange(metric.id, 'max', e.target.value)}
204-
onBlur={(e) => updateThreshold(metric.id, e.target.value)}
201+
onBlur={(e) => handleRangeBlur(metric.id, 'max', e.target.value)}
205202
disabled={isPreview}
206203
className='placeholder:text-muted-foreground/50'
207204
/>

0 commit comments

Comments
 (0)