From 424412fefd773ea697a85948ea334f232e106b7f Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 24 Jul 2025 15:36:03 +0900 Subject: [PATCH] Support namespace-level workflow in webui agentic chat --- .../javascripts/ai/duo_agentic_chat/components/app.vue | 10 +++++++++- ee/app/assets/javascripts/ai/duo_agentic_chat/index.js | 4 +++- .../ai/graphql/duo_workflow.mutation.graphql | 4 +++- ee/app/views/layouts/_tanuki_bot_chat.html.haml | 8 ++++++-- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ee/app/assets/javascripts/ai/duo_agentic_chat/components/app.vue b/ee/app/assets/javascripts/ai/duo_agentic_chat/components/app.vue index 53597db39a4dd6..ce18c148a5b761 100644 --- a/ee/app/assets/javascripts/ai/duo_agentic_chat/components/app.vue +++ b/ee/app/assets/javascripts/ai/duo_agentic_chat/components/app.vue @@ -44,6 +44,11 @@ export default { required: false, default: null, }, + namespaceId: { + type: String, + required: false, + default: null, + }, resourceId: { type: String, required: false, @@ -320,12 +325,15 @@ export default { } if (!this.workflowId) { + + const containerParam = this.projectId ? { projectId: this.projectId } : { namespaceId: this.namespaceId }; + try { const { data: { aiDuoWorkflowCreate: { workflow = {} } = {} } = {} } = await this.$apollo.mutate({ mutation: duoWorkflowMutation, variables: { - projectId: this.projectId, + ...containerParam, goal: question, workflowDefinition: DUO_WORKFLOW_CHAT_DEFINITION, agentPrivileges: DUO_WORKFLOW_AGENT_PRIVILEGES, diff --git a/ee/app/assets/javascripts/ai/duo_agentic_chat/index.js b/ee/app/assets/javascripts/ai/duo_agentic_chat/index.js index 08fc6e95447679..6b0085da882f3e 100644 --- a/ee/app/assets/javascripts/ai/duo_agentic_chat/index.js +++ b/ee/app/assets/javascripts/ai/duo_agentic_chat/index.js @@ -17,7 +17,8 @@ export const initDuoAgenticChat = () => { return false; } - const { projectId, resourceId, metadata } = el.dataset; + const { projectId, namespaceId, resourceId, metadata } = el.dataset; + console.log(`el.dataset: ${el.dataset}`); return new Vue({ el, @@ -27,6 +28,7 @@ export const initDuoAgenticChat = () => { return createElement(DuoAgenticChatApp, { props: { projectId, + namespaceId, resourceId, metadata, }, diff --git a/ee/app/assets/javascripts/ai/graphql/duo_workflow.mutation.graphql b/ee/app/assets/javascripts/ai/graphql/duo_workflow.mutation.graphql index 76012dcc885c0a..c8e93116ce0bea 100644 --- a/ee/app/assets/javascripts/ai/graphql/duo_workflow.mutation.graphql +++ b/ee/app/assets/javascripts/ai/graphql/duo_workflow.mutation.graphql @@ -1,5 +1,6 @@ mutation createAiDuoWorkflow( $projectId: ProjectID + $namespaceId: NamespaceID $goal: String! $workflowDefinition: String! $agentPrivileges: [Int!] @@ -8,7 +9,8 @@ mutation createAiDuoWorkflow( ) { aiDuoWorkflowCreate( input: { - projectId: $projectId + projectId: $projectId, + namespaceId: $namespaceId environment: WEB goal: $goal workflowDefinition: $workflowDefinition diff --git a/ee/app/views/layouts/_tanuki_bot_chat.html.haml b/ee/app/views/layouts/_tanuki_bot_chat.html.haml index 7354e554a6d80f..a41b78a96aac7a 100644 --- a/ee/app/views/layouts/_tanuki_bot_chat.html.haml +++ b/ee/app/views/layouts/_tanuki_bot_chat.html.haml @@ -1,13 +1,17 @@ - return unless ::Gitlab::Llm::TanukiBot.enabled_for?(user: current_user, container: nil) - resource_id = Gitlab::Llm::TanukiBot.resource_id - project_id = Gitlab::Llm::TanukiBot.project_id +- namespace_id = @group.try(:to_global_id) - root_namespace_id = Gitlab::Llm::TanukiBot.root_namespace_id - chat_title = ::Ai::AmazonQ.enabled? ? s_('GitLab Duo Chat with Amazon Q') : s_('GitLab Duo Chat') -- is_agentic_available = Feature.enabled?(:duo_workflow_workhorse, current_user) && project_id.present? && current_user.can?(:access_duo_agentic_chat, @project) +- is_project_agentic_available = project_id.present? && current_user.can?(:access_duo_agentic_chat, @project) +- is_group_agentic_available = @group.present? && current_user.can?(:access_duo_agentic_chat, @group) +- is_agentic_available = Feature.enabled?(:duo_workflow_workhorse, current_user) && (is_project_agentic_available || is_group_agentic_available) -- if Feature.enabled?(:duo_workflow_workhorse, current_user) && project_id.present? +- if Feature.enabled?(:duo_workflow_workhorse, current_user) #js-duo-agentic-chat-app{ data: { project_id: project_id, + namespace_id: namespace_id, resource_id: resource_id, metadata: Gitlab::DuoWorkflow::Client.metadata(current_user).to_json } } -- GitLab