Skip to content

Commit e692467

Browse files
committed
revert: amazon q standalone special handling
Removes code that should no longer be necessary anymore. - Remove autoinstall Amazon Q if you were a CodeWhisperer user on 2.x versions of toolkit - The prompt to install Amazon Q will still appear, if you don't have it. It has been slightly reworded. - If Amazon Q is installed, then you uninstall, it you will not see the prompt again in toolkit (previously you could). - Remove settings migrations from codewhisperer settings - Remove amazon Q telemetry enabled setting being initialized by the value from toolkit. We are still getting hits in telemetry for people getting auto install (172 in last 2 months). However, they are mostly on old versions. Let's simplyify our codebase by removing support for these dated codepaths.
1 parent 3d90772 commit e692467

File tree

9 files changed

+47
-101
lines changed

9 files changed

+47
-101
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Removal",
3+
"description": "Settings: No longer migrate old CodeWhisperer settings or initialize telemetry setting from AWS Toolkit."
4+
}

packages/core/src/amazonq/explorer/amazonQTreeNode.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as vscode from 'vscode'
77
import { ResourceTreeDataProvider, TreeNode } from '../../shared/treeview/resourceTreeDataProvider'
8-
import { AuthState, isPreviousQUser } from '../../codewhisperer/util/authUtil'
8+
import { AuthState } from '../../codewhisperer/util/authUtil'
99
import { createLearnMoreNode, createInstallQNode, createDismissNode } from './amazonQChildrenNodes'
1010
import { Commands } from '../../shared/vscode/commands2'
1111

@@ -40,10 +40,7 @@ export class AmazonQNode implements TreeNode {
4040
}
4141

4242
public getChildren() {
43-
const children = [createInstallQNode(), createLearnMoreNode()]
44-
if (!isPreviousQUser()) {
45-
children.push(createDismissNode())
46-
}
43+
const children = [createInstallQNode(), createLearnMoreNode(), createDismissNode()]
4744
return children
4845
}
4946

packages/core/src/codewhisperer/activation.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ export async function activate(context: ExtContext): Promise<void> {
106106
localize = nls.loadMessageBundle()
107107
const codewhispererSettings = CodeWhispererSettings.instance
108108

109-
// Import old CodeWhisperer settings into Amazon Q
110-
await CodeWhispererSettings.instance.importSettings()
111-
112109
// initialize AuthUtil earlier to make sure it can listen to connection change events.
113110
const auth = AuthUtil.instance
114111
auth.initCodeWhispererHooks()

packages/core/src/codewhisperer/util/authUtil.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -501,30 +501,6 @@ export class AuthUtil {
501501
}
502502
}
503503

504-
/**
505-
* Returns true if an SSO connection with AmazonQ and CodeWhisperer scopes are found,
506-
* even if the connection is expired.
507-
*
508-
* Note: This function will become irrelevant if/when the Amazon Q view tree is removed
509-
* from the toolkit.
510-
*/
511-
export function isPreviousQUser() {
512-
const auth = AuthUtil.instance
513-
514-
if (!auth.isConnected() || !isSsoConnection(auth.conn)) {
515-
return false
516-
}
517-
const missingScopes =
518-
(auth.isEnterpriseSsoInUse() && !hasScopes(auth.conn, amazonQScopes)) ||
519-
!hasScopes(auth.conn, codeWhispererChatScopes)
520-
521-
if (missingScopes) {
522-
return false
523-
}
524-
525-
return true
526-
}
527-
528504
export type FeatureAuthState = { [feature in Feature]: AuthState }
529505
export type Feature = (typeof Features)[keyof typeof Features]
530506
export type AuthState = (typeof AuthStates)[keyof typeof AuthStates]

packages/core/src/codewhisperer/util/codewhispererSettings.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
5-
import { fromExtensionManifest, migrateSetting } from '../../shared/settings'
5+
import { fromExtensionManifest } from '../../shared/settings'
66
import { ArrayConstructor } from '../../shared/utilities/typeConstructors'
77

88
const description = {
@@ -17,22 +17,6 @@ const description = {
1717
}
1818

1919
export class CodeWhispererSettings extends fromExtensionManifest('amazonQ', description) {
20-
// TODO: Remove after a few releases
21-
public async importSettings() {
22-
await migrateSetting(
23-
{ key: 'aws.codeWhisperer.includeSuggestionsWithCodeReferences', type: Boolean },
24-
{ key: 'amazonQ.showInlineCodeSuggestionsWithCodeReferences' }
25-
)
26-
await migrateSetting(
27-
{ key: 'aws.codeWhisperer.importRecommendation', type: Boolean },
28-
{ key: 'amazonQ.importRecommendationForInlineCodeSuggestions' }
29-
)
30-
await migrateSetting(
31-
{ key: 'aws.codeWhisperer.shareCodeWhispererContentWithAWS', type: Boolean },
32-
{ key: 'amazonQ.shareContentWithAWS' }
33-
)
34-
}
35-
3620
public isSuggestionsWithCodeReferencesEnabled(): boolean {
3721
return this.get(`showInlineCodeSuggestionsWithCodeReferences`, false)
3822
}

packages/core/src/extensionNode.ts

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import { getTelemetryMetadataForConn } from './auth/connection'
5151
import { registerSubmitFeedback } from './feedback/vue/submitFeedback'
5252
import { activateCommon, deactivateCommon } from './extension'
5353
import { learnMoreAmazonQCommand, qExtensionPageCommand, dismissQTree } from './amazonq/explorer/amazonQChildrenNodes'
54-
import { AuthUtil, codeWhispererCoreScopes, isPreviousQUser } from './codewhisperer/util/authUtil'
54+
import { AuthUtil, codeWhispererCoreScopes } from './codewhisperer/util/authUtil'
5555
import { installAmazonQExtension } from './codewhisperer/commands/basicCommands'
5656
import { isExtensionInstalled, VSCODE_EXTENSION_ID } from './shared/utilities'
5757
import { ExtensionUse, getAuthFormIdsFromConnection, initializeCredentialsProviderManager } from './auth/utils'
@@ -272,52 +272,47 @@ export async function deactivate() {
272272

273273
async function handleAmazonQInstall() {
274274
const dismissedInstall = globals.globalState.get<boolean>('aws.toolkit.amazonqInstall.dismissed')
275-
if (isExtensionInstalled(VSCODE_EXTENSION_ID.amazonq) || dismissedInstall) {
275+
if (dismissedInstall) {
276+
return
277+
}
278+
279+
if (isExtensionInstalled(VSCODE_EXTENSION_ID.amazonq)) {
280+
await globals.globalState.update('aws.toolkit.amazonqInstall.dismissed', true)
276281
return
277282
}
278283

279284
await telemetry.toolkit_showNotification.run(async () => {
280-
if (isPreviousQUser()) {
281-
await installAmazonQExtension.execute()
282-
telemetry.record({ id: 'amazonQStandaloneInstalled' })
283-
void vscode.window.showInformationMessage(
284-
"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."
285+
telemetry.record({ id: 'amazonQStandaloneChange' })
286+
void vscode.window
287+
.showInformationMessage(
288+
'Try Amazon Q, a generative AI assistant, with chat and code suggestions.',
289+
'Install',
290+
'Learn More'
285291
)
286-
await globals.globalState.update('aws.toolkit.amazonqInstall.dismissed', true)
287-
} else {
288-
telemetry.record({ id: 'amazonQStandaloneChange' })
289-
void vscode.window
290-
.showInformationMessage(
291-
'Amazon Q has moved to its own extension.' +
292-
'\nInstall it to use Amazon Q, a generative AI assistant, with chat and code suggestions.',
293-
'Install',
294-
'Learn More'
295-
)
296-
.then(async (resp) => {
297-
await telemetry.toolkit_invokeAction.run(async () => {
298-
telemetry.record({
299-
source: ExtensionUse.instance.isFirstUse()
300-
? ExtStartUpSources.firstStartUp
301-
: ExtStartUpSources.none,
302-
})
303-
304-
if (resp === 'Learn More') {
305-
// Clicking learn more will open the q extension page
306-
telemetry.record({ action: 'learnMore' })
307-
await qExtensionPageCommand.execute()
308-
return
309-
}
310-
311-
if (resp === 'Install') {
312-
telemetry.record({ action: 'installAmazonQ' })
313-
await installAmazonQExtension.execute()
314-
} else {
315-
telemetry.record({ action: 'dismissQNotification' })
316-
}
317-
await globals.globalState.update('aws.toolkit.amazonqInstall.dismissed', true)
292+
.then(async (resp) => {
293+
await telemetry.toolkit_invokeAction.run(async () => {
294+
telemetry.record({
295+
source: ExtensionUse.instance.isFirstUse()
296+
? ExtStartUpSources.firstStartUp
297+
: ExtStartUpSources.none,
318298
})
299+
300+
if (resp === 'Learn More') {
301+
// Clicking learn more will open the q extension page
302+
telemetry.record({ action: 'learnMore' })
303+
await qExtensionPageCommand.execute()
304+
return
305+
}
306+
307+
if (resp === 'Install') {
308+
telemetry.record({ action: 'installAmazonQ' })
309+
await installAmazonQExtension.execute()
310+
} else {
311+
telemetry.record({ action: 'dismissQNotification' })
312+
}
313+
await globals.globalState.update('aws.toolkit.amazonqInstall.dismissed', true)
319314
})
320-
}
315+
})
321316
})
322317
}
323318

packages/core/src/shared/telemetry/activation.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export async function activate(
4040
productName: AWSProduct
4141
) {
4242
const config = new TelemetryConfig(settings)
43-
await config.initAmazonQSetting() // TODO: Remove after a few releases.
4443

4544
DefaultTelemetryClient.productName = productName
4645
globals.telemetry = await DefaultTelemetryService.create(awsContext, getComputeRegion())

packages/core/src/shared/telemetry/util.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as vscode from 'vscode'
77
import { env, version } from 'vscode'
88
import * as os from 'os'
99
import { getLogger } from '../logger'
10-
import { fromExtensionManifest, migrateSetting, Settings } from '../settings'
10+
import { fromExtensionManifest, Settings } from '../settings'
1111
import { memoize, once } from '../utilities/functionUtils'
1212
import {
1313
isInDevEnv,
@@ -65,16 +65,6 @@ export class TelemetryConfig {
6565
public isEnabled(): boolean {
6666
return (isAmazonQ() ? this.amazonQConfig : this.toolkitConfig).get(`telemetry`, true)
6767
}
68-
69-
public async initAmazonQSetting() {
70-
if (!isAmazonQ() || globals.globalState.tryGet('amazonq.telemetry.migrated', Boolean, false)) {
71-
return
72-
}
73-
// aws.telemetry isn't deprecated, we are just initializing amazonQ.telemetry with its value.
74-
// This is also why we need to check that we only try this migration once.
75-
await migrateSetting({ key: 'aws.telemetry', type: Boolean }, { key: 'amazonQ.telemetry' })
76-
await globals.globalState.update('amazonq.telemetry.migrated', true)
77-
}
7868
}
7969

8070
export function convertLegacy(value: unknown): boolean {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Removal",
3+
"description": "Amazon Q: No longer autoinstall Amazon Q if the user had used CodeWhisperer in old Toolkit versions."
4+
}

0 commit comments

Comments
 (0)