Skip to content

Commit ca75b50

Browse files
authored
fix(amazonq): register commands before invocation (#7346)
## Problem Commands `updateReferenceLog` and `refreshStatusBar` are not yet registered when invoked in `AuthUtil` ## Solution Register the commands before `activateAmazonqLsp`, instead of in `activateCodeWhisperer` --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 0d6d35e commit ca75b50

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

packages/amazonq/src/extension.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { authUtils, CredentialsStore, LoginManager, initializeAuth } from 'aws-core-vscode/auth'
7-
import { activate as activateCodeWhisperer, shutdown as shutdownCodeWhisperer } from 'aws-core-vscode/codewhisperer'
6+
import { authUtils, CredentialsStore, LoginManager } from 'aws-core-vscode/auth'
7+
import {
8+
activate as activateCodeWhisperer,
9+
refreshStatusBar,
10+
shutdown as shutdownCodeWhisperer,
11+
updateReferenceLog,
12+
} from 'aws-core-vscode/codewhisperer'
813
import { makeEndpointsProvider, registerGenericCommands } from 'aws-core-vscode'
914
import { CommonAuthWebview } from 'aws-core-vscode/login'
1015
import {
@@ -113,16 +118,16 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
113118

114119
await activateTelemetry(context, globals.awsContext, Settings.instance, 'Amazon Q For VS Code')
115120

116-
await initializeAuth(globals.loginManager)
117-
118121
const extContext = {
119122
extensionContext: context,
120123
}
121124

125+
activateAuthDependentCommands()
126+
122127
// Auth is dependent on LSP, needs to be activated before CW and Inline
123128
await activateAmazonqLsp(context)
124129

125-
// This contains every lsp agnostic things (auth, security scan, code scan)
130+
// This contains every lsp agnostic things (security scan, code scan)
126131
await activateCodeWhisperer(extContext as ExtContext)
127132
if (!Experiments.instance.get('amazonqLSPInline', false)) {
128133
await activateInlineCompletion()
@@ -185,6 +190,14 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
185190
}
186191
})
187192
)
193+
194+
// Activate commands that are required for activateAmazonqLsp
195+
function activateAuthDependentCommands() {
196+
// update reference log instance
197+
updateReferenceLog.register()
198+
// refresh codewhisperer status bar
199+
refreshStatusBar.register()
200+
}
188201
}
189202

190203
export async function deactivateCommon() {

packages/core/src/codewhisperer/activation.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
showLearnMore,
2828
showSsoSignIn,
2929
showFreeTierLimit,
30-
updateReferenceLog,
3130
showIntroduction,
3231
reconnect,
3332
openSecurityIssuePanel,
@@ -62,7 +61,6 @@ import {
6261
} from './service/diagnosticsProvider'
6362
import { SecurityPanelViewProvider, openEditorAtRange } from './views/securityPanelViewProvider'
6463
import { Commands, registerCommandErrorHandler, registerDeclaredCommands } from '../shared/vscode/commands2'
65-
import { refreshStatusBar } from './service/statusBar'
6664
import { AuthUtil } from './util/authUtil'
6765
import { ImportAdderProvider } from './service/importAdderProvider'
6866
import { openUrl } from '../shared/utilities/vsCodeUtils'
@@ -235,10 +233,6 @@ export async function activate(context: ExtContext): Promise<void> {
235233
showLearnMore.register(),
236234
// show free tier limit
237235
showFreeTierLimit.register(),
238-
// update reference log instance
239-
updateReferenceLog.register(),
240-
// refresh codewhisperer status bar
241-
refreshStatusBar.register(),
242236
// generate code fix
243237
generateFix.register(client, context),
244238
// regenerate code fix

0 commit comments

Comments
 (0)