Skip to content

Commit 63d109d

Browse files
committed
added description for inputs to workflow
1 parent c9239b5 commit 63d109d

File tree

4 files changed

+86
-8
lines changed

4 files changed

+86
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</p>
1515

1616
<p align="center">
17-
<a href="https://deepwiki.com/simstudioai/sim" target="_blank" rel="noopener noreferrer"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a> <a href="https://cursor.com/link/prompt?text=Help%20me%20set%20up%20Sim%20Studio%20locally.%20Follow%20these%20steps%3A%0A%0A1.%20First%2C%20verify%20Docker%20is%20installed%20and%20running%3A%0A%20%20%20docker%20--version%0A%20%20%20docker%20info%0A%0A2.%20Clone%20the%20repository%3A%0A%20%20%20git%20clone%20https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim.git%0A%20%20%20cd%20sim%0A%0A3.%20Start%20the%20services%20with%20Docker%20Compose%3A%0A%20%20%20docker%20compose%20-f%20docker-compose.prod.yml%20up%20-d%0A%0A4.%20Wait%20for%20all%20containers%20to%20be%20healthy%20(this%20may%20take%201-2%20minutes)%3A%0A%20%20%20docker%20compose%20-f%20docker-compose.prod.yml%20ps%0A%0A5.%20Verify%20the%20app%20is%20accessible%20at%20http%3A%2F%2Flocalhost%3A3000%0A%0AIf%20there%20are%20any%20errors%2C%20help%20me%20troubleshoot%20them.%20Common%20issues%3A%0A-%20Port%203000%2C%203002%2C%20or%205432%20already%20in%20use%0A-%20Docker%20not%20running%0A-%20Insufficient%20memory%20(needs%2012GB%2B%20RAM)%0A%0AFor%20local%20AI%20models%20with%20Ollama%2C%20use%20this%20instead%20of%20step%203%3A%0A%20%20%20docker%20compose%20-f%20docker-compose.ollama.yml%20--profile%20setup%20up%20-d"><img src="https://img.shields.io/badge/Set%20Up%20with-Cursor-000000?logo=cursor&logoColor=white" alt="Set Up with Cursor"></a>
17+
<a href="https://deepwiki.com/simstudioai/sim" target="_blank" rel="noopener noreferrer"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a> <a href="https://cursor.com/link/prompt?text=Help%20me%20set%20up%20Sim%20locally.%20Follow%20these%20steps%3A%0A%0A1.%20First%2C%20verify%20Docker%20is%20installed%20and%20running%3A%0A%20%20%20docker%20--version%0A%20%20%20docker%20info%0A%0A2.%20Clone%20the%20repository%3A%0A%20%20%20git%20clone%20https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim.git%0A%20%20%20cd%20sim%0A%0A3.%20Start%20the%20services%20with%20Docker%20Compose%3A%0A%20%20%20docker%20compose%20-f%20docker-compose.prod.yml%20up%20-d%0A%0A4.%20Wait%20for%20all%20containers%20to%20be%20healthy%20(this%20may%20take%201-2%20minutes)%3A%0A%20%20%20docker%20compose%20-f%20docker-compose.prod.yml%20ps%0A%0A5.%20Verify%20the%20app%20is%20accessible%20at%20http%3A%2F%2Flocalhost%3A3000%0A%0AIf%20there%20are%20any%20errors%2C%20help%20me%20troubleshoot%20them.%20Common%20issues%3A%0A-%20Port%203000%2C%203002%2C%20or%205432%20already%20in%20use%0A-%20Docker%20not%20running%0A-%20Insufficient%20memory%20(needs%2012GB%2B%20RAM)%0A%0AFor%20local%20AI%20models%20with%20Ollama%2C%20use%20this%20instead%20of%20step%203%3A%0A%20%20%20docker%20compose%20-f%20docker-compose.ollama.yml%20--profile%20setup%20up%20-d"><img src="https://img.shields.io/badge/Set%20Up%20with-Cursor-000000?logo=cursor&logoColor=white" alt="Set Up with Cursor"></a>
1818
</p>
1919

2020
### Build Workflows with Ease

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/starter/input-format.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ interface Field {
2828
name: string
2929
type?: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'files'
3030
value?: string
31+
description?: string
3132
collapsed?: boolean
3233
}
3334

@@ -41,7 +42,9 @@ interface FieldFormatProps {
4142
placeholder?: string
4243
showType?: boolean
4344
showValue?: boolean
45+
showDescription?: boolean
4446
valuePlaceholder?: string
47+
descriptionPlaceholder?: string
4548
config?: any
4649
}
4750

@@ -73,6 +76,7 @@ const createDefaultField = (): Field => ({
7376
name: '',
7477
type: 'string',
7578
value: '',
79+
description: '',
7680
collapsed: false,
7781
})
7882

@@ -93,7 +97,9 @@ export function FieldFormat({
9397
placeholder = 'fieldName',
9498
showType = true,
9599
showValue = false,
100+
showDescription = false,
96101
valuePlaceholder = 'Enter default value',
102+
descriptionPlaceholder = 'Describe this field',
97103
}: FieldFormatProps) {
98104
const [storeValue, setStoreValue] = useSubBlockValue<Field[]>(blockId, subBlockId)
99105
const valueInputRefs = useRef<Record<string, HTMLInputElement | HTMLTextAreaElement>>({})
@@ -554,6 +560,18 @@ export function FieldFormat({
554560
</div>
555561
)}
556562

563+
{showDescription && (
564+
<div className='flex flex-col gap-[6px]'>
565+
<Label className='text-[13px]'>Description</Label>
566+
<Input
567+
value={field.description ?? ''}
568+
onChange={(e) => updateField(field.id, 'description', e.target.value)}
569+
placeholder={descriptionPlaceholder}
570+
disabled={isReadOnly}
571+
/>
572+
</div>
573+
)}
574+
557575
{showValue && (
558576
<div className='flex flex-col gap-[6px]'>
559577
<Label className='text-[13px]'>Value</Label>
@@ -568,8 +586,10 @@ export function FieldFormat({
568586
)
569587
}
570588

571-
export function InputFormat(props: Omit<FieldFormatProps, 'title' | 'placeholder'>) {
572-
return <FieldFormat {...props} title='Input' placeholder='firstName' />
589+
export function InputFormat(
590+
props: Omit<FieldFormatProps, 'title' | 'placeholder' | 'showDescription'>
591+
) {
592+
return <FieldFormat {...props} title='Input' placeholder='firstName' showDescription={true} />
573593
}
574594

575595
export function ResponseFormat(

apps/sim/providers/utils.ts

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,51 @@ import { mergeToolParameters } from '@/tools/params'
3434

3535
const logger = createLogger('ProviderUtils')
3636

37+
/**
38+
* Checks if a workflow description is a default/placeholder description
39+
*/
40+
function isDefaultWorkflowDescription(
41+
description: string | null | undefined,
42+
name?: string
43+
): boolean {
44+
if (!description) return true
45+
const normalizedDesc = description.toLowerCase().trim()
46+
return (
47+
description === name ||
48+
normalizedDesc === 'new workflow' ||
49+
normalizedDesc === 'your first workflow - start building here!'
50+
)
51+
}
52+
53+
/**
54+
* Fetches workflow metadata (name and description) from the API
55+
*/
56+
async function fetchWorkflowMetadata(
57+
workflowId: string
58+
): Promise<{ name: string; description: string | null } | null> {
59+
try {
60+
const { buildAuthHeaders, buildAPIUrl } = await import('@/executor/utils/http')
61+
62+
const headers = await buildAuthHeaders()
63+
const url = buildAPIUrl(`/api/workflows/${workflowId}`)
64+
65+
const response = await fetch(url.toString(), { headers })
66+
if (!response.ok) {
67+
logger.warn(`Failed to fetch workflow metadata for ${workflowId}`)
68+
return null
69+
}
70+
71+
const { data } = await response.json()
72+
return {
73+
name: data?.name || 'Workflow',
74+
description: data?.description || null,
75+
}
76+
} catch (error) {
77+
logger.error('Error fetching workflow metadata:', error)
78+
return null
79+
}
80+
}
81+
3782
/**
3883
* Client-safe provider metadata.
3984
* This object contains only model lists and patterns - no executeRequest implementations.
@@ -479,16 +524,30 @@ export async function transformBlockTool(
479524
const llmSchema = await createLLMToolSchema(toolConfig, userProvidedParams)
480525

481526
let uniqueToolId = toolConfig.id
527+
let toolName = toolConfig.name
528+
let toolDescription = toolConfig.description
529+
482530
if (toolId === 'workflow_executor' && userProvidedParams.workflowId) {
483531
uniqueToolId = `${toolConfig.id}_${userProvidedParams.workflowId}`
532+
533+
const workflowMetadata = await fetchWorkflowMetadata(userProvidedParams.workflowId)
534+
if (workflowMetadata) {
535+
toolName = workflowMetadata.name || toolConfig.name
536+
if (
537+
workflowMetadata.description &&
538+
!isDefaultWorkflowDescription(workflowMetadata.description, workflowMetadata.name)
539+
) {
540+
toolDescription = workflowMetadata.description
541+
}
542+
}
484543
} else if (toolId.startsWith('knowledge_') && userProvidedParams.knowledgeBaseId) {
485544
uniqueToolId = `${toolConfig.id}_${userProvidedParams.knowledgeBaseId}`
486545
}
487546

488547
return {
489548
id: uniqueToolId,
490-
name: toolConfig.name,
491-
description: toolConfig.description,
549+
name: toolName,
550+
description: toolDescription,
492551
params: userProvidedParams,
493552
parameters: llmSchema,
494553
}

apps/sim/tools/params.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ async function applyDynamicSchemaForWorkflow(
518518
for (const field of workflowInputFields) {
519519
propertySchema.properties[field.name] = {
520520
type: field.type || 'string',
521-
description: `Input field: ${field.name}`,
521+
description: field.description || `Input field: ${field.name}`,
522522
}
523523
propertySchema.required.push(field.name)
524524
}
@@ -533,11 +533,10 @@ async function applyDynamicSchemaForWorkflow(
533533

534534
/**
535535
* Fetches workflow input fields from the API.
536-
* No local caching - relies on React Query caching on the client side.
537536
*/
538537
async function fetchWorkflowInputFields(
539538
workflowId: string
540-
): Promise<Array<{ name: string; type: string }>> {
539+
): Promise<Array<{ name: string; type: string; description?: string }>> {
541540
try {
542541
const { buildAuthHeaders, buildAPIUrl } = await import('@/executor/utils/http')
543542

0 commit comments

Comments
 (0)