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 53597db39a4dd6a6df3ceea7f4320724fdda7592..ce18c148a5b76155ec55803e8424278fb4114139 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 08fc6e95447679eb1c8c66729c39d6559fc84a76..6b0085da882f3e1b71635cd6dd9be8254cc623cc 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 76012dcc885c0a64195e348d445a1809eb4f273b..c8e93116ce0beafcc9e29c10163bb1619b1fc1b2 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 7354e554a6d80fd088da058003635774604b83e6..a41b78a96aac7abf7fc930f32204044e7348ff40 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 } }