Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions src/workbench/extensions/agent/AgentPanelRoot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -634,6 +635,11 @@ const {
}
})

provide(
agentBoundWorkflowIdKey,
computed(() => boundWorkflowId.value ?? undefined)
)

const isSending = computed(
() => sessionIsSending.value || composerStore.submission?.phase === 'pending'
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { InjectionKey, Ref } from 'vue'

export const agentBoundWorkflowIdKey: InjectionKey<
Readonly<Ref<string | undefined>>
> = Symbol('agentBoundWorkflowId')
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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 {
Expand Down Expand Up @@ -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: ' ' },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<script setup lang="ts">
import { computed } from 'vue'
import { computed, inject, ref } from 'vue'
import { useI18n } from 'vue-i18n'

import Button from '@/components/ui/button/Button.vue'

import type { RunApprovalPart } from '../../../services/agent/agentMessageParts'
import { agentBoundWorkflowIdKey } from '../agentBoundWorkflowId'

const { part, answering = false } = defineProps<{
part: RunApprovalPart
answering?: boolean
}>()
const boundWorkflowId = inject(agentBoundWorkflowIdKey, ref(undefined))
const hideWorkflowName = computed(
() => !!boundWorkflowId.value && part.workflowId === boundWorkflowId.value
)
const emit = defineEmits<{
answer: [askId: string, selection: 'run' | 'cancel']
openWorkflow: [workflowId: string, workflowName?: string]
Expand All @@ -30,9 +35,18 @@ const workflowLabel = computed(
>
<div class="flex min-w-0 flex-col gap-0.5 text-sm/5">
<p class="m-0 text-base-foreground">
{{ t('agent.runApproval.lead') }}
{{
t(
hideWorkflowName
? 'agent.runApproval.leadBound'
: 'agent.runApproval.lead'
)
}}
</p>
<ul class="m-0 min-w-0 list-disc pl-5 text-muted-foreground">
<ul
v-if="!hideWorkflowName"
class="m-0 min-w-0 list-disc pl-5 text-muted-foreground"
>
<li>
<Button
v-if="part.workflowId"
Expand Down
Loading