diff --git a/src/locales/en/main.json b/src/locales/en/main.json index 0bd7c8d1a86..8e5388c3428 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -5228,6 +5228,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 159e576c541..d8397268b71 100644 --- a/src/workbench/extensions/agent/AgentPanelRoot.vue +++ b/src/workbench/extensions/agent/AgentPanelRoot.vue @@ -71,6 +71,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 { @@ -634,6 +635,11 @@ const { } }) +provide( + agentBoundWorkflowIdKey, + computed(() => boundWorkflowId.value ?? undefined) +) + const isSending = computed( () => sessionIsSending.value || composerStore.submission?.phase === 'pending' ) 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 95d55522d8e..6610a55f4d9 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 285b597fc04..96017c6d817 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 @@