diff --git a/src/locales/en/main.json b/src/locales/en/main.json index 8caf989d9c7..0bbcaf318d8 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -5221,6 +5221,7 @@ "workflowEditNotice": "The agent can now edit {workflow}. It works on 1 workflow at a time, and you can switch workflows during chat.", "runApproval": { "lead": "This tool wants to run the workflow:", + "leadBound": "This tool wants to run this workflow.", "question": "Do you approve?", "thisWorkflow": "this workflow", "cancel": "Cancel", diff --git a/src/workbench/extensions/agent/AgentPanelRoot.vue b/src/workbench/extensions/agent/AgentPanelRoot.vue index 6899bb48bf9..99914de06e7 100644 --- a/src/workbench/extensions/agent/AgentPanelRoot.vue +++ b/src/workbench/extensions/agent/AgentPanelRoot.vue @@ -67,6 +67,7 @@ import { } from './composables/agent/useOnboarding' import AgentPanel from './components/agent/AgentPanel.vue' +import { agentBoundWorkflowIdKey } from './components/agent/agentBoundWorkflowId' import AgentGraphActivityBar from './components/AgentGraphActivityBar.vue' import OnboardingCoach from './components/agent/OnboardingCoach.vue' import { @@ -505,6 +506,7 @@ const editableWorkflowId = computed(() => { const target = selectedTarget.value return target ? cloudIdFor(target) : undefined }) +provide(agentBoundWorkflowIdKey, editableWorkflowId) const workflowTabs = computed(() => workflowStore.openWorkflows.map((tab) => ({ diff --git a/src/workbench/extensions/agent/components/agent/agentBoundWorkflowId.ts b/src/workbench/extensions/agent/components/agent/agentBoundWorkflowId.ts new file mode 100644 index 00000000000..712a28d2da2 --- /dev/null +++ b/src/workbench/extensions/agent/components/agent/agentBoundWorkflowId.ts @@ -0,0 +1,5 @@ +import type { InjectionKey, Ref } from 'vue' + +export const agentBoundWorkflowIdKey: InjectionKey< + Readonly> +> = Symbol('agentBoundWorkflowId') diff --git a/src/workbench/extensions/agent/components/agent/message/AgentMessage.test.ts b/src/workbench/extensions/agent/components/agent/message/AgentMessage.test.ts index 54fb4644b03..b9c55951fd2 100644 --- a/src/workbench/extensions/agent/components/agent/message/AgentMessage.test.ts +++ b/src/workbench/extensions/agent/components/agent/message/AgentMessage.test.ts @@ -1,6 +1,7 @@ import { render, screen, within } from '@testing-library/vue' import userEvent from '@testing-library/user-event' import { describe, expect, it, vi } from 'vitest' +import { ref } from 'vue' import { i18n } from '@/i18n' import type { TurnId } from '../../../schemas/agentApiSchema' import { createAgentEventTransport } from '../../../services/agent/agentEventTransport' @@ -11,6 +12,7 @@ import type { import { createAssistantMessage } from '../../../services/agent/agentMessageParts' import AgentMessage from './AgentMessage.vue' +import { agentBoundWorkflowIdKey } from '../agentBoundWorkflowId' function thinkingMessage(thinkingText?: string): AssistantMessage { return { @@ -649,6 +651,24 @@ describe('AgentMessage run approval', () => { } }) + it('omits the redundant workflow name for a 1:1 bound chat', () => { + render(AgentMessage, { + props: { + message: approvalMessage() + }, + global: { + plugins: [i18n], + provide: { [agentBoundWorkflowIdKey as symbol]: ref('workflow-1') } + } + }) + + expect( + screen.getByText('This tool wants to run this workflow.') + ).toBeInTheDocument() + expect(screen.queryByText('Portrait workflow')).not.toBeInTheDocument() + expect(screen.getByText('Do you approve?')).toBeInTheDocument() + }) + it.for([ { approval: { workflowName: ' ' }, diff --git a/src/workbench/extensions/agent/components/agent/message/RunApprovalCard.vue b/src/workbench/extensions/agent/components/agent/message/RunApprovalCard.vue index ee441da6020..5c176f3c60f 100644 --- a/src/workbench/extensions/agent/components/agent/message/RunApprovalCard.vue +++ b/src/workbench/extensions/agent/components/agent/message/RunApprovalCard.vue @@ -1,15 +1,20 @@