From dce853326baabaf7c746cad2a0361786da571db6 Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Sat, 26 Sep 2026 23:27:38 -0700 Subject: [PATCH] fix(agent): omit redundant workflow name in bound run approvals (#19054) - omit the workflow label when a run approval targets the chat-bound workflow - retain the linked workflow label for cross-workflow and missing-binding cases - preserve the current `shown` lifecycle event added on `main` Replaces #18399 after that fork branch conflicted with `main`. Linear: PM-1307, PM-1316 - `pnpm test:unit src/workbench/extensions/agent/components/agent/message/AgentMessage.test.ts` (23 passed) - `pnpm typecheck` - ESLint and oxfmt on all five changed files - pre-push knip/fallow gate (five-file diff) Justification: The original author is performing a stale-branch recovery for a small, tested UI fix; if no independent approval arrives, merge will use the documented unreviewed-change path after CI is green. --- src/locales/en/main.json | 1 + .../extensions/agent/AgentPanelRoot.vue | 6 ++++++ .../components/agent/agentBoundWorkflowId.ts | 5 +++++ .../agent/message/AgentMessage.test.ts | 20 +++++++++++++++++++ .../agent/message/RunApprovalCard.vue | 20 ++++++++++++++++--- 5 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 src/workbench/extensions/agent/components/agent/agentBoundWorkflowId.ts 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 @@