Skip to content

Commit f243990

Browse files
authored
fix(codewhisperer): auto-connect on vscode startup #3359
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.
1 parent ea2d84c commit f243990

File tree

5 files changed

+4
-11
lines changed

5 files changed

+4
-11
lines changed

src/codewhisperer/activation.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,7 @@ export async function activate(context: ExtContext): Promise<void> {
202202
)
203203
)
204204

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

210207
function activateSecurityScan() {
211208
context.extensionContext.subscriptions.push(

src/codewhisperer/explorer/codewhispererNode.ts

-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ export class CodeWhispererNode implements RootNode {
3434
constructor() {}
3535

3636
public getTreeItem() {
37-
if (!isCloud9()) {
38-
AuthUtil.instance.restore()
39-
}
40-
4137
const item = new vscode.TreeItem('CodeWhisperer')
4238
item.description = this.getDescription()
4339
item.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed

src/codewhisperer/service/inlineCompletionService.ts

+1
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ export class InlineCompletionService {
320320
vsCodeState.isCodeWhispererEditing = false
321321
ReferenceInlineProvider.instance.removeInlineReference()
322322
ImportAdderProvider.instance.clear()
323+
await InlineCompletionService.instance.clearInlineCompletionStates(vscode.window.activeTextEditor)
323324
}
324325

325326
async onCursorChange(e: vscode.TextEditorSelectionChangeEvent) {

src/codewhisperer/util/authUtil.ts

-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ export class AuthUtil {
230230
}
231231

232232
public async notifyReauthenticate(isAutoTrigger?: boolean) {
233-
await this.refreshCodeWhisperer()
234233
this.showReauthenticatePrompt(isAutoTrigger)
235234
}
236235

src/extension.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ export async function activate(context: vscode.ExtensionContext) {
195195

196196
await activateCloudFormationTemplateRegistry(context)
197197

198+
await activateCodeWhisperer(extContext)
199+
198200
await activateAwsExplorer({
199201
context: extContext,
200202
regionProvider,
@@ -217,8 +219,6 @@ export async function activate(context: vscode.ExtensionContext) {
217219

218220
await activateS3(extContext)
219221

220-
await activateCodeWhisperer(extContext)
221-
222222
await activateEcr(context)
223223

224224
await activateCloudWatchLogs(context, settings)

0 commit comments

Comments
 (0)