Skip to content

Commit 5ea4b68

Browse files
committed
Name the workflow in deployment and workflow-scoped tool titles
'Checked deployment status' never said which workflow — nor did the deployed- state read, run settings, block outputs/inputs, redeploy, promote, or the global-variable write. These tools carry a workflowId (often defaulting to the current workflow), so only the client can resolve a name: the enrichment layer now resolves it for the whole workflow-scoped family and passes it as workflowName, which every workflow title already reads. Titles: Checking {workflow} deployment status, Reading deployed {workflow}, Checking {workflow} run settings, Reading {workflow} block outputs, Tracing {workflow} block inputs, Redeploying {workflow}, Promoting {workflow} version {n} to live, and 'Adding workflow variable {name} in {workflow}' — each falling back to its unnamed form when no workflow resolves.
1 parent 8d44459 commit 5ea4b68

2 files changed

Lines changed: 71 additions & 7 deletions

File tree

apps/sim/app/workspace/[workspaceId]/home/hooks/stream/stream-helpers.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,28 @@ export function resolveIntegrationToolDisplayTitle(tool: {
186186
return tool.integrationDescription
187187
}
188188

189+
/**
190+
* Tools whose subject is one workflow. They accept a `workflowId` (or imply
191+
* the current workflow), so their titles can only name the workflow once the
192+
* client resolves the id against the workflow registry.
193+
*/
194+
const WORKFLOW_SCOPED_TOOL_IDS = new Set<string>([
195+
'deploy_as_api',
196+
'deploy_as_chat',
197+
'deploy_as_mcp',
198+
'get_block_outputs',
199+
'get_block_upstream_references',
200+
'get_deployed_workflow_state',
201+
'get_deployment_status',
202+
'get_workflow_data',
203+
'get_workflow_run_options',
204+
'promote_to_live',
205+
'redeploy',
206+
'run_block',
207+
'set_block_enabled',
208+
'set_global_workflow_variables',
209+
])
210+
189211
export function resolveToolDisplayTitle(name: string, args?: Record<string, unknown>): string {
190212
// Cases that enrich the title with live workspace/block names from the client
191213
// stores. Everything else is resolved by the shared name+args resolver, which
@@ -224,6 +246,15 @@ export function resolveToolDisplayTitle(name: string, args?: Record<string, unkn
224246
if (workflowName) return `Querying logs for ${workflowName}`
225247
}
226248

249+
// Workflow-scoped tools carry an id, not a name — and often not even that,
250+
// defaulting to the current workflow. Resolve the name here and hand it to
251+
// the shared resolver as `workflowName`, which every workflow title already
252+
// reads, so deployments, reads, and block work all say WHICH workflow.
253+
if (WORKFLOW_SCOPED_TOOL_IDS.has(name) && !stringParam(args?.workflowName)) {
254+
const workflowName = resolveTargetWorkflowName(args)
255+
if (workflowName) return getToolDisplayTitle(name, { ...args, workflowName })
256+
}
257+
227258
return getToolDisplayTitle(name, args)
228259
}
229260

apps/sim/lib/copilot/tools/tool-display.ts

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,14 @@ function openResourceTitle(args: ToolArgs): string {
425425
}
426426

427427
function setGlobalWorkflowVariablesTitle(args: ToolArgs): string {
428+
// Enrichment resolves the workflow id to a name; "in {workflow}" is dropped
429+
// when the call targets the workflow already in view and none resolves.
430+
const workflow = firstStringArg(args, 'workflowName', 'name')
431+
const scope = workflow ? ` in ${workflow}` : ''
428432
const operations = args?.operations
429-
if (!Array.isArray(operations) || operations.length === 0) return 'Setting workflow variables'
433+
if (!Array.isArray(operations) || operations.length === 0) {
434+
return `Setting workflow variables${scope}`
435+
}
430436

431437
const parsed = operations.filter((operation): operation is Record<string, unknown> =>
432438
isRecordLike(operation)
@@ -444,9 +450,9 @@ function setGlobalWorkflowVariablesTitle(args: ToolArgs): string {
444450

445451
if (parsed.length === 1) {
446452
const variableName = stringArg(parsed[0], 'name')
447-
return `${verb} workflow variable${variableName ? ` ${variableName}` : ''}`
453+
return `${verb} workflow variable${variableName ? ` ${variableName}` : ''}${scope}`
448454
}
449-
return `${verb} ${parsed.length} workflow variables`
455+
return `${verb} ${parsed.length} workflow variables${scope}`
450456
}
451457

452458
/**
@@ -847,10 +853,6 @@ export function getToolDisplayTitle(name: string, args?: Record<string, unknown>
847853
? 'Loading live deployment'
848854
: `Loading deployment version ${version}`
849855
}
850-
case 'promote_to_live': {
851-
const version = stringOrNumberArg(args, 'version')
852-
return version ? `Promoting version ${version} to live` : 'Promoting to live'
853-
}
854856
case 'update_deployment_version': {
855857
const version = stringOrNumberArg(args, 'version')
856858
return version ? `Updating deployment version ${version}` : 'Updating deployment'
@@ -1067,6 +1069,37 @@ export function getToolDisplayTitle(name: string, args?: Record<string, unknown>
10671069
delete: { verb: 'Deleting', resource: 'credential' },
10681070
})
10691071
}
1072+
case 'get_deployment_status': {
1073+
const workflow = firstStringArg(args, 'workflowName', 'name')
1074+
return workflow ? `Checking ${workflow} deployment status` : 'Checking deployment status'
1075+
}
1076+
case 'get_deployed_workflow_state': {
1077+
const workflow = firstStringArg(args, 'workflowName', 'name')
1078+
return workflow ? `Reading deployed ${workflow}` : 'Reading the deployed version'
1079+
}
1080+
case 'get_workflow_run_options': {
1081+
const workflow = firstStringArg(args, 'workflowName', 'name')
1082+
return workflow ? `Checking ${workflow} run settings` : 'Checking run settings'
1083+
}
1084+
case 'get_block_outputs': {
1085+
const workflow = firstStringArg(args, 'workflowName', 'name')
1086+
return workflow ? `Reading ${workflow} block outputs` : 'Reading block outputs'
1087+
}
1088+
case 'get_block_upstream_references': {
1089+
const workflow = firstStringArg(args, 'workflowName', 'name')
1090+
return workflow ? `Tracing ${workflow} block inputs` : 'Tracing block inputs'
1091+
}
1092+
case 'redeploy': {
1093+
const workflow = firstStringArg(args, 'workflowName', 'name')
1094+
return workflow ? `Redeploying ${workflow}` : 'Redeploying API'
1095+
}
1096+
case 'promote_to_live': {
1097+
const workflow = firstStringArg(args, 'workflowName', 'name')
1098+
const version = stringOrNumberArg(args, 'version')
1099+
if (workflow && version) return `Promoting ${workflow} version ${version} to live`
1100+
if (workflow) return `Promoting ${workflow} to live`
1101+
return version ? `Promoting version ${version} to live` : 'Promoting to live'
1102+
}
10701103
case 'run_workflow': {
10711104
const workflow = firstStringArg(args, 'workflowName', 'name')
10721105
return workflow ? `Running ${workflow}` : 'Running workflow'

0 commit comments

Comments
 (0)