Skip to content

Commit b085942

Browse files
committed
moved remove from subflow one position to the right
1 parent c97bc69 commit b085942

File tree

21 files changed

+87
-67
lines changed

21 files changed

+87
-67
lines changed

apps/sim/app/api/chat/[identifier]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ export async function POST(
253253
userId: deployment.userId,
254254
workspaceId,
255255
isDeployed: workflowRecord?.isDeployed ?? false,
256-
variables: workflowRecord?.variables || {},
256+
variables: (workflowRecord?.variables as Record<string, unknown>) ?? undefined,
257257
}
258258

259259
const stream = await createStreamingResponse({

apps/sim/app/api/templates/[id]/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
extractRequiredCredentials,
1111
sanitizeCredentials,
1212
} from '@/lib/workflows/credentials/credential-extractor'
13+
import type { WorkflowState } from '@/stores/workflows/workflow/types'
1314

1415
const logger = createLogger('TemplateByIdAPI')
1516

@@ -189,12 +190,12 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<{
189190
.where(eq(workflow.id, template.workflowId))
190191
.limit(1)
191192

192-
const currentState = {
193+
const currentState: Partial<WorkflowState> = {
193194
blocks: normalizedData.blocks,
194195
edges: normalizedData.edges,
195196
loops: normalizedData.loops,
196197
parallels: normalizedData.parallels,
197-
variables: workflowRecord?.variables || undefined,
198+
variables: (workflowRecord?.variables as WorkflowState['variables']) ?? undefined,
198199
lastSaved: Date.now(),
199200
}
200201

apps/sim/app/api/templates/[id]/use/route.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import { v4 as uuidv4 } from 'uuid'
77
import { getSession } from '@/lib/auth'
88
import { generateRequestId } from '@/lib/core/utils/request'
99
import { getBaseUrl } from '@/lib/core/utils/urls'
10-
import { regenerateWorkflowStateIds } from '@/lib/workflows/persistence/utils'
10+
import {
11+
type RegenerateStateInput,
12+
regenerateWorkflowStateIds,
13+
} from '@/lib/workflows/persistence/utils'
1114

1215
const logger = createLogger('TemplateUseAPI')
1316

@@ -104,9 +107,10 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{
104107
// Step 2: Regenerate IDs when creating a copy (not when connecting/editing template)
105108
// When connecting to template (edit mode), keep original IDs
106109
// When using template (copy mode), regenerate all IDs to avoid conflicts
110+
const templateState = templateData.state as RegenerateStateInput
107111
const workflowState = connectToTemplate
108-
? templateData.state
109-
: regenerateWorkflowStateIds(templateData.state)
112+
? templateState
113+
: regenerateWorkflowStateIds(templateState)
110114

111115
// Step 3: Save the workflow state using the existing state endpoint (like imports do)
112116
// Ensure variables in state are remapped for the new workflow as well

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/schedule-info/schedule-info.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ export function ScheduleInfo({ blockId, isPreview = false }: ScheduleInfoProps)
1919
const params = useParams()
2020
const workflowId = params.workflowId as string
2121

22-
const scheduleTimezone = useSubBlockStore((state) => state.getValue(blockId, 'timezone'))
22+
const scheduleTimezone = useSubBlockStore((state) => state.getValue(blockId, 'timezone')) as
23+
| string
24+
| undefined
2325

2426
const { data: schedule, isLoading } = useScheduleQuery(workflowId, blockId, {
2527
enabled: !isPreview,

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/trigger-save/trigger-save.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ export function TriggerSave({
4343
const [showDeleteDialog, setShowDeleteDialog] = useState(false)
4444
const [isGeneratingTestUrl, setIsGeneratingTestUrl] = useState(false)
4545

46-
const storedTestUrl = useSubBlockStore((state) => state.getValue(blockId, 'testUrl'))
46+
const storedTestUrl = useSubBlockStore((state) => state.getValue(blockId, 'testUrl')) as
47+
| string
48+
| null
4749
const storedTestUrlExpiresAt = useSubBlockStore((state) =>
4850
state.getValue(blockId, 'testUrlExpiresAt')
49-
)
51+
) as string | null
5052

5153
const isTestUrlExpired = useMemo(() => {
5254
if (!storedTestUrlExpiresAt) return true

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/action-bar/action-bar.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -161,53 +161,53 @@ export const ActionBar = memo(
161161
</Tooltip.Root>
162162
)}
163163

164-
{!isStartBlock && parentId && (parentType === 'loop' || parentType === 'parallel') && (
164+
{!isNoteBlock && (
165165
<Tooltip.Root>
166166
<Tooltip.Trigger asChild>
167167
<Button
168168
variant='ghost'
169169
onClick={(e) => {
170170
e.stopPropagation()
171-
if (!disabled && userPermissions.canEdit) {
172-
window.dispatchEvent(
173-
new CustomEvent('remove-from-subflow', { detail: { blockId } })
174-
)
171+
if (!disabled) {
172+
collaborativeBatchToggleBlockHandles([blockId])
175173
}
176174
}}
177175
className='hover:!text-[var(--text-inverse)] h-[23px] w-[23px] rounded-[8px] bg-[var(--surface-7)] p-0 text-[var(--text-secondary)] hover:bg-[var(--brand-secondary)]'
178-
disabled={disabled || !userPermissions.canEdit}
176+
disabled={disabled}
179177
>
180-
<LogOut className='h-[11px] w-[11px]' />
178+
{horizontalHandles ? (
179+
<ArrowLeftRight className='h-[11px] w-[11px]' />
180+
) : (
181+
<ArrowUpDown className='h-[11px] w-[11px]' />
182+
)}
181183
</Button>
182184
</Tooltip.Trigger>
183-
<Tooltip.Content side='top'>{getTooltipMessage('Remove from Subflow')}</Tooltip.Content>
185+
<Tooltip.Content side='top'>
186+
{getTooltipMessage(horizontalHandles ? 'Vertical Ports' : 'Horizontal Ports')}
187+
</Tooltip.Content>
184188
</Tooltip.Root>
185189
)}
186190

187-
{!isNoteBlock && (
191+
{!isStartBlock && parentId && (parentType === 'loop' || parentType === 'parallel') && (
188192
<Tooltip.Root>
189193
<Tooltip.Trigger asChild>
190194
<Button
191195
variant='ghost'
192196
onClick={(e) => {
193197
e.stopPropagation()
194-
if (!disabled) {
195-
collaborativeBatchToggleBlockHandles([blockId])
198+
if (!disabled && userPermissions.canEdit) {
199+
window.dispatchEvent(
200+
new CustomEvent('remove-from-subflow', { detail: { blockIds: [blockId] } })
201+
)
196202
}
197203
}}
198204
className='hover:!text-[var(--text-inverse)] h-[23px] w-[23px] rounded-[8px] bg-[var(--surface-7)] p-0 text-[var(--text-secondary)] hover:bg-[var(--brand-secondary)]'
199-
disabled={disabled}
205+
disabled={disabled || !userPermissions.canEdit}
200206
>
201-
{horizontalHandles ? (
202-
<ArrowLeftRight className='h-[11px] w-[11px]' />
203-
) : (
204-
<ArrowUpDown className='h-[11px] w-[11px]' />
205-
)}
207+
<LogOut className='h-[11px] w-[11px]' />
206208
</Button>
207209
</Tooltip.Trigger>
208-
<Tooltip.Content side='top'>
209-
{getTooltipMessage(horizontalHandles ? 'Vertical Ports' : 'Horizontal Ports')}
210-
</Tooltip.Content>
210+
<Tooltip.Content side='top'>{getTooltipMessage('Remove from Subflow')}</Tooltip.Content>
211211
</Tooltip.Root>
212212
)}
213213

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/hooks/use-webhook-info.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ export function useWebhookInfo(blockId: string, workflowId: string): UseWebhookI
5454
useCallback(
5555
(state) => {
5656
if (!activeWorkflowId) return undefined
57-
return state.workflowValues[activeWorkflowId]?.[blockId]?.webhookProvider?.value as
58-
| string
59-
| undefined
57+
const value = state.workflowValues[activeWorkflowId]?.[blockId]?.webhookProvider
58+
if (typeof value === 'object' && value !== null && 'value' in value) {
59+
return (value as { value?: unknown }).value as string | undefined
60+
}
61+
return value as string | undefined
6062
},
6163
[activeWorkflowId, blockId]
6264
)

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,11 @@ export const WorkflowBlock = memo(function WorkflowBlock({
624624
if (!activeWorkflowId) return
625625
const current = useSubBlockStore.getState().workflowValues[activeWorkflowId]?.[id]
626626
if (!current) return
627-
const cred = current.credential?.value as string | undefined
627+
const credValue = current.credential
628+
const cred =
629+
typeof credValue === 'object' && credValue !== null && 'value' in credValue
630+
? ((credValue as { value?: unknown }).value as string | undefined)
631+
: (credValue as string | undefined)
628632
if (prevCredRef.current !== cred) {
629633
prevCredRef.current = cred
630634
const keys = Object.keys(current)

apps/sim/executor/__test-utils__/executor-mocks.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,7 @@ export const createWorkflowWithResponse = (): SerializedWorkflow => ({
427427
input: 'json',
428428
},
429429
outputs: {
430-
response: {
431-
input: 'json',
432-
},
430+
response: { type: 'json', description: 'Input response' },
433431
},
434432
enabled: true,
435433
metadata: { id: 'starter', name: 'Starter Block' },
@@ -444,11 +442,9 @@ export const createWorkflowWithResponse = (): SerializedWorkflow => ({
444442
headers: 'json',
445443
},
446444
outputs: {
447-
response: {
448-
data: 'json',
449-
status: 'number',
450-
headers: 'json',
451-
},
445+
data: { type: 'json', description: 'Response data' },
446+
status: { type: 'number', description: 'Response status' },
447+
headers: { type: 'json', description: 'Response headers' },
452448
},
453449
enabled: true,
454450
metadata: { id: 'response', name: 'Response Block' },

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,12 @@ export class RouterBlockHandler implements BlockHandler {
366366

367367
let systemPrompt = ''
368368
if (isAgentBlockType(targetBlock.metadata?.id)) {
369+
const paramsPrompt = targetBlock.config?.params?.systemPrompt
370+
const inputsPrompt = targetBlock.inputs?.systemPrompt
369371
systemPrompt =
370-
targetBlock.config?.params?.systemPrompt || targetBlock.inputs?.systemPrompt || ''
371-
372-
if (!systemPrompt && targetBlock.inputs) {
373-
systemPrompt = targetBlock.inputs.systemPrompt || ''
374-
}
372+
(typeof paramsPrompt === 'string' ? paramsPrompt : '') ||
373+
(typeof inputsPrompt === 'string' ? inputsPrompt : '') ||
374+
''
375375
}
376376

377377
return {

0 commit comments

Comments
 (0)