Skip to content

Commit 5c84887

Browse files
authored
Multiple copilots added (#6875)
Fixes #6862
1 parent 51b90bc commit 5c84887

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

webviews/components/sidebar.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import React, { useContext } from 'react';
6+
import React, { useContext, useState } from 'react';
77
import { COPILOT_LOGINS } from '../../src/common/copilot';
88
import { gitHubLabelColor } from '../../src/common/utils';
99
import { IMilestone, IProjectItem, reviewerId } from '../../src/github/interface';
@@ -28,6 +28,8 @@ export default function Sidebar({ reviewers, labels, hasWritePermission, isIssue
2828
pr,
2929
} = useContext(PullRequestContext);
3030

31+
const [assigningCopilot, setAssigningCopilot] = useState(false);
32+
3133
const shouldShowCopilotButton = canAssignCopilot && assignees.every(assignee => !COPILOT_LOGINS.includes(assignee.login));
3234

3335
const updateProjects = async () => {
@@ -84,9 +86,15 @@ export default function Sidebar({ reviewers, labels, hasWritePermission, isIssue
8486
id="assign-copilot-btn"
8587
className="icon-button"
8688
title="Assign to Copilot"
89+
disabled={assigningCopilot}
8790
onClick={async () => {
88-
const newAssignees = await addAssigneeCopilot();
89-
updatePR({ assignees: newAssignees.assignees, events: newAssignees.events });
91+
setAssigningCopilot(true);
92+
try {
93+
const newAssignees = await addAssigneeCopilot();
94+
updatePR({ assignees: newAssignees.assignees, events: newAssignees.events });
95+
} finally {
96+
setAssigningCopilot(false);
97+
}
9098
}}>
9199
{copilotIcon}
92100
</button>

0 commit comments

Comments
 (0)