Skip to content

Commit

Permalink
fix: only install Q once for previous users
Browse files Browse the repository at this point in the history
Problem: Q installs whenever a past connection is detected. If users don't log out of that connection, then they will forever have Q auto-installed on startup even if they don't want it.
Solution: Only install once, then store to global state that we did.

- Cleanup the install code a bit
- Use the same global state key for dismissing the install q notification.

Fixes aws#4898
  • Loading branch information
hayemaxi committed Jun 10, 2024
1 parent b92bbfd commit 9e1d627
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 49 deletions.
102 changes: 53 additions & 49 deletions packages/core/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>(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)
Expand Down Expand Up @@ -277,6 +229,58 @@ export async function deactivate() {
await globals.resourceManager.dispose()
}

async function handleAmazonQInstall() {
const dismissedInstall = globals.context.globalState.get<boolean>(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())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"description": "UX: Amazon Q continues to install even if users uninstall it."
}

0 comments on commit 9e1d627

Please sign in to comment.