diff --git a/packages/core/src/extension.ts b/packages/core/src/extension.ts index 675465bfaee..877812a2450 100644 --- a/packages/core/src/extension.ts +++ b/packages/core/src/extension.ts @@ -169,55 +169,7 @@ export async function activate(context: vscode.ExtensionContext) { dismissQTree.register() installAmazonQExtension.register() - if (!isExtensionInstalled(VSCODE_EXTENSION_ID.amazonq)) { - await telemetry.toolkit_showNotification.run(async () => { - if (isPreviousQUser()) { - await installAmazonQExtension.execute() - telemetry.record({ id: 'amazonQStandaloneInstalled' }) - void vscode.window.showInformationMessage( - "Amazon Q is now its own extension.\n\nWe've auto-installed it for you with all the same features and settings from CodeWhisperer and Amazon Q chat." - ) - } else { - const dismissedInstall = - globals.context.globalState.get(amazonQInstallDismissedKey) - if (!dismissedInstall) { - telemetry.record({ id: 'amazonQStandaloneChange' }) - void vscode.window - .showInformationMessage( - 'Amazon Q has moved to its own extension.' + - '\nInstall it to use Amazon Q, a generative AI assistant, with chat and code suggestions.', - 'Install', - 'Learn More' - ) - .then(async resp => { - await telemetry.toolkit_invokeAction.run(async () => { - telemetry.record({ - source: ExtensionUse.instance.isFirstUse() - ? ExtStartUpSources.firstStartUp - : ExtStartUpSources.none, - }) - - if (resp === 'Learn More') { - // Clicking learn more will open the q extension page - telemetry.record({ action: 'learnMore' }) - await qExtensionPageCommand.execute() - return - } - - if (resp === 'Install') { - telemetry.record({ action: 'installAmazonQ' }) - await installAmazonQExtension.execute() - } else { - telemetry.record({ action: 'dismissQNotification' }) - } - - await globals.context.globalState.update(amazonQInstallDismissedKey, true) - }) - }) - } - } - }) - } + await handleAmazonQInstall() } await activateApplicationComposer(context) await activateThreatComposerEditor(context) @@ -277,6 +229,58 @@ export async function deactivate() { await globals.resourceManager.dispose() } +async function handleAmazonQInstall() { + const dismissedInstall = globals.context.globalState.get(amazonQInstallDismissedKey) + if (isExtensionInstalled(VSCODE_EXTENSION_ID.amazonq) || dismissedInstall) { + return + } + + await telemetry.toolkit_showNotification.run(async () => { + if (isPreviousQUser()) { + await installAmazonQExtension.execute() + telemetry.record({ id: 'amazonQStandaloneInstalled' }) + void vscode.window.showInformationMessage( + "Amazon Q is now its own extension.\n\nWe've auto-installed it for you with all the same features and settings from CodeWhisperer and Amazon Q chat." + ) + await globals.context.globalState.update(amazonQInstallDismissedKey, true) + } else { + telemetry.record({ id: 'amazonQStandaloneChange' }) + void vscode.window + .showInformationMessage( + 'Amazon Q has moved to its own extension.' + + '\nInstall it to use Amazon Q, a generative AI assistant, with chat and code suggestions.', + 'Install', + 'Learn More' + ) + .then(async resp => { + await telemetry.toolkit_invokeAction.run(async () => { + telemetry.record({ + source: ExtensionUse.instance.isFirstUse() + ? ExtStartUpSources.firstStartUp + : ExtStartUpSources.none, + }) + + if (resp === 'Learn More') { + // Clicking learn more will open the q extension page + telemetry.record({ action: 'learnMore' }) + await qExtensionPageCommand.execute() + return + } + + if (resp === 'Install') { + telemetry.record({ action: 'installAmazonQ' }) + await installAmazonQExtension.execute() + } else { + telemetry.record({ action: 'dismissQNotification' }) + } + }) + + await globals.context.globalState.update(amazonQInstallDismissedKey, true) + }) + } + }) +} + function initializeCredentialsProviderManager() { const manager = CredentialsProviderManager.getInstance() manager.addProviderFactory(new SharedCredentialsProviderFactory()) diff --git a/packages/toolkit/.changes/next-release/Bug Fix-7a3ed468-dad2-4867-933b-1cfc101e99b9.json b/packages/toolkit/.changes/next-release/Bug Fix-7a3ed468-dad2-4867-933b-1cfc101e99b9.json new file mode 100644 index 00000000000..3dc673efbd4 --- /dev/null +++ b/packages/toolkit/.changes/next-release/Bug Fix-7a3ed468-dad2-4867-933b-1cfc101e99b9.json @@ -0,0 +1,4 @@ +{ + "type": "Bug Fix", + "description": "UX: Amazon Q continues to install even if users uninstall it." +}