Skip to content

Commit

Permalink
fix(codewhisperer): auto-connect on vscode startup #3359
Browse files Browse the repository at this point in the history
Problem:
CodeWhisperer does not auto-connect on vscode startup. #3348 

Solution:
Call auth.restore()

Also fix some other issues:
1. Clear the inlineCompletionState on focus change so that
they should still be able to invoke CW when they invoked CW and then
switched to another app and switched back.
2. put activateCodeWhipserer() to be before activateAwsExplorer()
since the refreshStatusBar() and showReferenceLog() commands are used
within activateAwsExplorer() when the connection is changed. These
 commands are not registered until activateCodeWhisperer() has been called.
3. Remove unnecessary call to refreshCodeWhisperer(), this only needs to be
called when there's a connection change.
  • Loading branch information
andrewyuq authored Apr 20, 2023
1 parent ea2d84c commit f243990
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 11 deletions.
5 changes: 1 addition & 4 deletions src/codewhisperer/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,7 @@ export async function activate(context: ExtContext): Promise<void> {
)
)

if (!isCloud9() && !auth.isConnectionValid()) {
// this is to proactively check and reflect the state if user's connection is expired
auth.refreshCodeWhisperer()
}
await auth.restore()

function activateSecurityScan() {
context.extensionContext.subscriptions.push(
Expand Down
4 changes: 0 additions & 4 deletions src/codewhisperer/explorer/codewhispererNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ export class CodeWhispererNode implements RootNode {
constructor() {}

public getTreeItem() {
if (!isCloud9()) {
AuthUtil.instance.restore()
}

const item = new vscode.TreeItem('CodeWhisperer')
item.description = this.getDescription()
item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed
Expand Down
1 change: 1 addition & 0 deletions src/codewhisperer/service/inlineCompletionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ export class InlineCompletionService {
vsCodeState.isCodeWhispererEditing = false
ReferenceInlineProvider.instance.removeInlineReference()
ImportAdderProvider.instance.clear()
await InlineCompletionService.instance.clearInlineCompletionStates(vscode.window.activeTextEditor)
}

async onCursorChange(e: vscode.TextEditorSelectionChangeEvent) {
Expand Down
1 change: 0 additions & 1 deletion src/codewhisperer/util/authUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ export class AuthUtil {
}

public async notifyReauthenticate(isAutoTrigger?: boolean) {
await this.refreshCodeWhisperer()
this.showReauthenticatePrompt(isAutoTrigger)
}

Expand Down
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ export async function activate(context: vscode.ExtensionContext) {

await activateCloudFormationTemplateRegistry(context)

await activateCodeWhisperer(extContext)

await activateAwsExplorer({
context: extContext,
regionProvider,
Expand All @@ -217,8 +219,6 @@ export async function activate(context: vscode.ExtensionContext) {

await activateS3(extContext)

await activateCodeWhisperer(extContext)

await activateEcr(context)

await activateCloudWatchLogs(context, settings)
Expand Down

0 comments on commit f243990

Please sign in to comment.