From 4bbe8926e0779f16e1390f51570fdc70f8f123eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Caplette?= Date: Wed, 30 Jul 2025 15:19:30 -0400 Subject: [PATCH] poc --- .../components/work_item_assignees.vue | 49 ++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/work_items/components/work_item_assignees.vue b/app/assets/javascripts/work_items/components/work_item_assignees.vue index c31b70706fb6aa..d82c635552fc63 100644 --- a/app/assets/javascripts/work_items/components/work_item_assignees.vue +++ b/app/assets/javascripts/work_items/components/work_item_assignees.vue @@ -2,6 +2,8 @@ import { GlButton } from '@gitlab/ui'; import { unionBy } from 'lodash'; import fuzzaldrinPlus from 'fuzzaldrin-plus'; +import axios from '~/lib/utils/axios_utils'; +import { createAlert } from '~/alert'; import { sortNameAlphabetically, newWorkItemId } from '~/work_items/utils'; import currentUserQuery from '~/graphql_shared/queries/current_user.query.graphql'; import usersSearchQuery from '~/graphql_shared/queries/workspace_autocomplete_users.query.graphql'; @@ -94,7 +96,8 @@ export default { return !this.searchStarted; }, update(data) { - return this.isGroup ? data.groupWorkspace?.users : data.workspace?.users; + const aiUsers = this.glFeatures.aiDuoAgentIssueToMr ? [this.$options.DuoDeveloperUser] : []; + return this.isGroup ? [data.groupWorkspace?.users, ...aiUsers] : data.workspace?.users; }, result({ data }) { if (!data) { @@ -244,6 +247,9 @@ export default { handler(newVal) { this.localAssigneeIds = newVal.map(({ id }) => id); this.assigneeIdsToShowAtTopOfTheListbox = this.localAssigneeIds; + if (this.localAssigneeIds.includes(this.$options.DuoDeveloperUser.id)) { + this.startAgentFlow(); + } }, deep: true, immediate: true, @@ -315,6 +321,36 @@ export default { this.searchKey = value; this.searchStarted = true; }, + // TODO: This should live higher up in work items, so emit event instead + startAgentFlow() { + const requestData = { + project_id: this.projectId, + start_workflow: true, + goal: this.workItemId, // Make this be the issue full path + environment: 'web', + workflow_definition: 'issue_to_mr', + agent_privileges: [1, 2, 5], + }; + + axios + .post(this.duoWorkflowInvokePath, requestData) // TODO: pass the invoke path + .then(({ data }) => { + createAlert({ + message: __(`Duo Developer started working on this issue.`), + captureError: true, + variant: 'success', + data, + renderMessageHTML: true, + }); + }) + .catch((error) => { + createAlert({ + message: __('Error occurred when starting the workflow'), + captureError: true, + error, + }); + }); + }, assignToCurrentUser() { const assignees = this.allowsMultipleAssignees ? [this.currentUser.id] : this.currentUser.id; this.setLocalAssigneeIdsOnEvent(assignees); @@ -333,6 +369,17 @@ export default { this.assigneeIdsToShowAtTopOfTheListbox = this.localAssigneeIds; }, }, + DuoDeveloperUser: { + id: 'gid://gitlab/User/duo_developer', + avatarUrl: + 'https://secure.gravatar.com/avatar/080c46e96c93aa45b8a6cb10b30cf7615997641104f6f64369ea88f2413bdc5d?s=80\u0026d=identicon', + name: s__('DuoAgentPlatform|Duo Developer'), + username: 'duo_developer', + webUrl: '', + webPath: '', + __typename: 'AutocompletedUser', + status: null, + }, }; -- GitLab