Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sign out of GitHub Copilot #25014

Merged
merged 19 commits into from
Jan 6, 2024
Merged

Sign out of GitHub Copilot #25014

merged 19 commits into from
Jan 6, 2024

Conversation

lewis-sanchez
Copy link
Contributor

@lewis-sanchez lewis-sanchez commented Nov 21, 2023

This PR closes #24478

The PR adds functionality to sign out of GitHub Copilot in Azure Data Studio.

The accounts section in ADS will show any active GitHub Copilot sessions that can be signed out of:
image

Clicking on the 'X' will then sign the user out and GitHub Copilot will then show a dialog informing the user to log in to the GitHub Copilot extension:
image

@coveralls
Copy link

coveralls commented Nov 21, 2023

Pull Request Test Coverage Report for Build 7147208485

Warning: This coverage report may be inaccurate.

We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
To ensure accuracy in future PRs, please see these guidelines.
A quick fix for this PR: rebase it; your next report should be accurate.

  • 27 of 56 (48.21%) changed or added relevant lines in 5 files are covered.
  • 263 unchanged lines in 4 files lost coverage.
  • Overall coverage increased (+0.04%) to 41.6%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/sql/workbench/services/accountManagement/browser/accountListRenderer.ts 0 5 0.0%
src/sql/workbench/services/accountManagement/browser/accountManagementService.ts 7 12 58.33%
src/sql/platform/accounts/common/accountViewModel.ts 16 25 64.0%
src/sql/platform/accounts/common/accountActions.ts 3 13 23.08%
Files with Coverage Reduction New Missed Lines %
src/sql/workbench/services/connection/browser/connectionDialogService.ts 11 79.2%
extensions/azurecore/src/azureResource/tree/treeProvider.ts 14 60.61%
src/sql/workbench/contrib/commandLine/electron-sandbox/commandLine.ts 14 82.99%
src/sql/workbench/contrib/query/browser/gridPanel.ts 224 2.12%
Totals Coverage Status
Change from base Build 6948030524: 0.04%
Covered Lines: 30832
Relevant Lines: 69428

💛 - Coveralls

@IAccountManagementService private _accountManagementService: IAccountManagementService,
@ILogService private _logService: ILogService,
@IAuthenticationService private readonly _authenticationService: IAuthenticationService
) {
// Create our event emitters
this._addProviderEmitter = new Emitter<AccountProviderAddedEventParams>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These emitters are likely undisposed..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, although I'd suggest going through and fixing those as a follow up PR to avoid cluttering up this PR even more

src/sql/platform/accounts/common/accountViewModel.ts Outdated Show resolved Hide resolved
const providerId = this._account.key.providerId;
const allSessions = await this.authenticationService.getSessions(providerId);
const sessionsForAccount = allSessions.filter(s => s.account.label === this._account.displayInfo.userId);
await this.authenticationService.removeAccountSessions(providerId, this._account.displayInfo.userId, sessionsForAccount);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully signed out popup doesn't go away and requires user interaction, please make sure it goes away in 5-10 seconds.

const providerId = this._account.key.providerId;
const allSessions = await this.authenticationService.getSessions(providerId);
const sessionsForAccount = allSessions.filter(s => s.account.label === this._account.displayInfo.userId);
await this.authenticationService.removeAccountSessions(providerId, this._account.displayInfo.userId, sessionsForAccount);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does user sign in to Copilot again?

image
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe ADS should be restarted to complete the sign out process to make sure the copilot extension sign in notification is triggered?

Copy link
Contributor

@Charles-Gagnon Charles-Gagnon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tests would be fantastic as well - at least some focused on ensuring that the view model is updated correctly when accounts/sessions are added/removed.

src/sql/platform/accounts/common/accountActions.ts Outdated Show resolved Hide resolved
src/sql/platform/accounts/common/accountActions.ts Outdated Show resolved Hide resolved
@IAccountManagementService private _accountManagementService: IAccountManagementService,
@ILogService private _logService: ILogService,
@IAuthenticationService private readonly _authenticationService: IAuthenticationService
) {
// Create our event emitters
this._addProviderEmitter = new Emitter<AccountProviderAddedEventParams>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, although I'd suggest going through and fixing those as a follow up PR to avoid cluttering up this PR even more

src/sql/platform/accounts/common/accountViewModel.ts Outdated Show resolved Hide resolved
src/sql/platform/accounts/common/accountViewModel.ts Outdated Show resolved Hide resolved
src/vs/workbench/api/browser/mainThreadAuthentication.ts Outdated Show resolved Hide resolved
@lewis-sanchez lewis-sanchez merged commit 6071176 into main Jan 6, 2024
12 checks passed
@lewis-sanchez lewis-sanchez deleted the lewissanchez/copilot/signout branch January 6, 2024 00:21
siyao-Siyang pushed a commit that referenced this pull request Jan 11, 2024
* Sign out of GitHub Copilot

* Code review changes

* Remove unnecessary loop in action

* Replace forEach call with map

* Add hook to remove account after sign out

* Revert "Add hook to remove account after sign out"

This reverts commit 46b5f3c.

* Revert "Revert "Add hook to remove account after sign out""

This reverts commit 5a401fa.

* Comment out faulty code

* Return empty array

* Display provider name correctly

* Add github logo for github accounts

* Function argument rename

* Remove account on sign out confirmation

* Add missing semicolon

* Code review changes

* Implements mock auth service

* Fix failing unit tests

* Replaces callback hook with event handler

* Remove updateAccountList hook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to logout of GitHub account from Copilot extension
5 participants