Skip to content

Commit 36e9ba5

Browse files
committed
Editor component
1 parent b387ab1 commit 36e9ba5

File tree

1 file changed

+55
-26
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call

1 file changed

+55
-26
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/tool-call/tool-call.tsx

Lines changed: 55 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,34 +1025,63 @@ function WorkflowEditSummary({ toolCall }: { toolCall: CopilotToolCall }) {
10251025
const inputs = op.params.inputs as Record<string, unknown>
10261026
const blockConfig = getBlock(blockType)
10271027

1028-
// Filter visible subblocks from config (same logic as canvas)
1029-
const visibleSubBlocks =
1030-
blockConfig?.subBlocks?.filter((sb) => {
1031-
// Skip hidden subblocks
1032-
if (sb.hidden) return false
1033-
if (sb.hideFromPreview) return false
1034-
// Skip advanced mode subblocks (not visible by default)
1035-
if (sb.mode === 'advanced') return false
1036-
// Skip trigger mode subblocks
1037-
if (sb.mode === 'trigger') return false
1038-
return true
1039-
}) ?? []
1040-
1041-
// Build subBlocks array respecting config order
1028+
// Build subBlocks array
10421029
const subBlocks: SubBlockPreview[] = []
10431030

1044-
// Add subblocks that are visible in config, in config order
1045-
for (const subBlockConfig of visibleSubBlocks) {
1046-
if (subBlockConfig.id in inputs) {
1047-
const value = inputs[subBlockConfig.id]
1048-
// Skip empty values and connections
1049-
if (value === null || value === undefined || value === '') continue
1050-
subBlocks.push({
1051-
id: subBlockConfig.id,
1052-
title: subBlockConfig.title ?? subBlockConfig.id,
1053-
value,
1054-
isPassword: subBlockConfig.password === true,
1055-
})
1031+
// Special handling for condition blocks - parse conditions JSON and render as separate rows
1032+
// This matches how the canvas renders condition blocks with "if", "else if", "else" rows
1033+
if (blockType === 'condition' && 'conditions' in inputs) {
1034+
const conditionsValue = inputs.conditions
1035+
const raw = typeof conditionsValue === 'string' ? conditionsValue : undefined
1036+
1037+
try {
1038+
if (raw) {
1039+
const parsed = JSON.parse(raw) as unknown
1040+
if (Array.isArray(parsed)) {
1041+
parsed.forEach((item: unknown, index: number) => {
1042+
const conditionItem = item as { id?: string; value?: unknown }
1043+
const title = index === 0 ? 'if' : index === parsed.length - 1 ? 'else' : 'else if'
1044+
subBlocks.push({
1045+
id: conditionItem?.id ?? `cond-${index}`,
1046+
title,
1047+
value: typeof conditionItem?.value === 'string' ? conditionItem.value : '',
1048+
isPassword: false,
1049+
})
1050+
})
1051+
}
1052+
}
1053+
} catch {
1054+
// Fallback: show default if/else
1055+
subBlocks.push({ id: 'if', title: 'if', value: '', isPassword: false })
1056+
subBlocks.push({ id: 'else', title: 'else', value: '', isPassword: false })
1057+
}
1058+
} else {
1059+
// Filter visible subblocks from config (same logic as canvas)
1060+
const visibleSubBlocks =
1061+
blockConfig?.subBlocks?.filter((sb) => {
1062+
// Skip hidden subblocks
1063+
if (sb.hidden) return false
1064+
if (sb.hideFromPreview) return false
1065+
// Skip advanced mode subblocks (not visible by default)
1066+
if (sb.mode === 'advanced') return false
1067+
// Skip trigger mode subblocks
1068+
if (sb.mode === 'trigger') return false
1069+
return true
1070+
}) ?? []
1071+
1072+
// Add subblocks that are visible in config, in config order
1073+
for (const subBlockConfig of visibleSubBlocks) {
1074+
if (subBlockConfig.id in inputs) {
1075+
const value = inputs[subBlockConfig.id]
1076+
// Skip empty values and connections
1077+
if (value === null || value === undefined || value === '') continue
1078+
subBlocks.push({
1079+
id: subBlockConfig.id,
1080+
title: subBlockConfig.title ?? subBlockConfig.id,
1081+
value,
1082+
isPassword: subBlockConfig.password === true,
1083+
})
1084+
}
10561085
}
10571086
}
10581087

0 commit comments

Comments
 (0)