Skip to content

Commit 008fbe0

Browse files
j15zclaude
andcommitted
fix(workflow): cover workflow-as-tool and custom-tool fallbacks in static naming
Address review findings: resolveToolsLabel now returns the static 'Workflow' label for workflow/workflow_input entries instead of falling through to the stored title, matching the panel chip; the panel's custom-tool name priority now matches resolveToolsLabel (record title, record schema function name, then stored title); and the display-name comment no longer overstates the guarantee. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent c67c08b commit 008fbe0

3 files changed

Lines changed: 16 additions & 7 deletions

File tree

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,9 +1713,6 @@ export const ToolInput = memo(function ToolInput({
17131713
? resolveCustomToolFromReference(tool, customTools)
17141714
: null
17151715

1716-
const customToolTitle = isCustomTool
1717-
? tool.title || resolvedCustomTool?.title || 'Unknown Tool'
1718-
: null
17191716
const customToolSchema = isCustomTool ? tool.schema || resolvedCustomTool?.schema : null
17201717
const customToolParams =
17211718
isCustomTool && customToolSchema?.function?.parameters?.properties
@@ -1747,11 +1744,14 @@ export const ToolInput = memo(function ToolInput({
17471744
)
17481745
: []
17491746

1750-
// Display name comes from static sources (registry / canonical records),
1751-
// never from the workflow JSON's mutable `title`, so edits to the stored
1752-
// state cannot change what the UI shows.
1747+
// Display name comes from static sources (registry / canonical records)
1748+
// where available; the stored `title` is only a last-resort fallback for
1749+
// MCP tools while server data is loading and for deleted custom-tool records.
17531750
const toolDisplayName = isCustomTool
1754-
? resolvedCustomTool?.title || customToolTitle
1751+
? resolvedCustomTool?.title ||
1752+
resolvedCustomTool?.schema?.function?.name ||
1753+
tool.title ||
1754+
'Unknown Tool'
17551755
: isMcpTool
17561756
? mcpTool?.name || tool.title
17571757
: isWorkflowTool

apps/sim/lib/workflows/subblocks/display.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ describe('resolveToolsLabel', () => {
128128
).toBe('not_a_real_block')
129129
})
130130

131+
it('renders the static label for workflow-as-tool entries regardless of stored title', () => {
132+
expect(
133+
resolveToolsLabel(toolInput, [{ type: 'workflow', title: 'Renamed By Copilot' }], [])
134+
).toBe('Workflow')
135+
expect(resolveToolsLabel(toolInput, [{ type: 'workflow_input' }], [])).toBe('Workflow')
136+
})
137+
131138
it('prefers the custom tool record over the stored title', () => {
132139
expect(
133140
resolveToolsLabel(

apps/sim/lib/workflows/subblocks/display.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,8 @@ export function resolveToolsLabel(
458458
return t.type
459459
}
460460

461+
if (t.type === 'workflow' || t.type === 'workflow_input') return 'Workflow'
462+
461463
if (t.type === 'custom-tool' && typeof t.customToolId === 'string') {
462464
const customTool = customTools.find((candidate) => candidate.id === t.customToolId)
463465
if (customTool?.title) return customTool.title

0 commit comments

Comments
 (0)