Skip to content

Commit c1f3cb2

Browse files
Merge master into feature/sdkv3
2 parents cd0483b + c32c8f0 commit c1f3cb2

File tree

14 files changed

+53
-197
lines changed

14 files changed

+53
-197
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/auth/auth.ts

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,6 @@ export class Auth implements AuthService, ConnectionManager {
339339
metadata: { connectionState: 'unauthenticated' },
340340
})
341341

342-
// Remove the split session logout prompt, if it exists.
343-
if (!isAmazonQ()) {
344-
await globals.globalState.update('aws.toolkit.separationPromptDismissed', true)
345-
}
346-
347342
try {
348343
;(await tokenProvider.getToken()) ?? (await tokenProvider.createToken())
349344
const storedProfile = await this.store.addProfile(id, profile)
@@ -1136,71 +1131,3 @@ export function hasVendedIamCredentials(isC9?: boolean, isSM?: boolean) {
11361131
isSM ??= isSageMaker()
11371132
return isSM || isC9
11381133
}
1139-
1140-
type LoginCommand = 'aws.toolkit.auth.manageConnections' | 'aws.codecatalyst.manageConnections'
1141-
/**
1142-
* Temporary class that handles notifiting users who were logged out as part of
1143-
* splitting auth sessions between extensions.
1144-
*
1145-
* TODO: Remove after some time.
1146-
*/
1147-
export class SessionSeparationPrompt {
1148-
// Local variable handles per session displays, e.g. we forgot a CodeCatalyst connection AND
1149-
// an Explorer only connection. We only want to display once in this case.
1150-
// However, we don't want to set this at the global state level until a user interacts with the
1151-
// notification in case they miss it the first time.
1152-
#separationPromptDisplayed = false
1153-
1154-
/**
1155-
* Open a prompt for that last used command name (or do nothing if no command name has ever been passed),
1156-
* which is useful to redisplay the prompt after reloads in case a user misses it.
1157-
*/
1158-
public async showAnyPreviousPrompt() {
1159-
const cmd = globals.globalState.tryGet('aws.toolkit.separationPromptCommand', String)
1160-
return cmd ? await this.showForCommand(cmd as LoginCommand) : undefined
1161-
}
1162-
1163-
/**
1164-
* Displays a sign in prompt to the user if they have been logged out of the Toolkit as part of
1165-
* separating auth sessions between extensions. It will executed the passed command for sign in,
1166-
* (e.g. codecatalyst sign in vs explorer)
1167-
*/
1168-
public async showForCommand(cmd: LoginCommand) {
1169-
if (
1170-
this.#separationPromptDisplayed ||
1171-
globals.globalState.get<boolean>('aws.toolkit.separationPromptDismissed')
1172-
) {
1173-
return
1174-
}
1175-
1176-
await globals.globalState.update('aws.toolkit.separationPromptCommand', cmd)
1177-
1178-
await telemetry.toolkit_showNotification.run(async () => {
1179-
telemetry.record({ id: 'sessionSeparation' })
1180-
this.#separationPromptDisplayed = true
1181-
void vscode.window
1182-
.showWarningMessage(
1183-
'Amazon Q and AWS Toolkit no longer share connections. Please sign in again to use AWS Toolkit.',
1184-
'Sign In'
1185-
)
1186-
.then(async (resp) => {
1187-
await telemetry.toolkit_invokeAction.run(async () => {
1188-
telemetry.record({ source: 'sessionSeparationNotification' })
1189-
if (resp === 'Sign In') {
1190-
telemetry.record({ action: 'signIn' })
1191-
await vscode.commands.executeCommand(cmd)
1192-
} else {
1193-
telemetry.record({ action: 'dismiss' })
1194-
}
1195-
1196-
await globals.globalState.update('aws.toolkit.separationPromptDismissed', true)
1197-
})
1198-
})
1199-
})
1200-
}
1201-
1202-
static #instance: SessionSeparationPrompt
1203-
public static get instance() {
1204-
return (this.#instance ??= new SessionSeparationPrompt())
1205-
}
1206-
}

packages/core/src/codecatalyst/activation.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { DevEnvActivityStarter } from './devEnv'
2626
import { learnMoreCommand, onboardCommand, reauth } from './explorer'
2727
import { isInDevEnv } from '../shared/vscode/env'
2828
import { hasScopes, scopesCodeWhispererCore, getTelemetryMetadataForConn } from '../auth/connection'
29-
import { SessionSeparationPrompt } from '../auth/auth'
3029
import { telemetry } from '../shared/telemetry/telemetry'
3130
import { asStringifiedStack } from '../shared/telemetry/spans'
3231

@@ -64,7 +63,6 @@ export async function activate(ctx: ExtContext): Promise<void> {
6463
})
6564

6665
await authProvider.secondaryAuth.forgetConnection()
67-
await SessionSeparationPrompt.instance.showForCommand('aws.codecatalyst.manageConnections')
6866
})
6967
},
7068
{ emit: false, functionId: { name: 'activate', class: 'CodeCatalyst' } }

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: 36 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ import globals from './shared/extensionGlobals'
4646
import { Experiments, Settings, showSettingsFailedMsg } from './shared/settings'
4747
import { isReleaseVersion } from './shared/vscode/env'
4848
import { AuthStatus, AuthUserState, telemetry } from './shared/telemetry/telemetry'
49-
import { Auth, SessionSeparationPrompt } from './auth/auth'
49+
import { Auth } from './auth/auth'
5050
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 { 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'
@@ -139,16 +139,8 @@ export async function activate(context: vscode.ExtensionContext) {
139139
conn.scopes
140140
)
141141
await Auth.instance.forgetConnection(conn)
142-
await SessionSeparationPrompt.instance.showForCommand('aws.toolkit.auth.manageConnections')
143142
}
144143
}
145-
146-
// Display last prompt if connections were forgotten in prior sessions
147-
// but the user did not interact or sign in again. Useful in case the user misses it the first time.
148-
await SessionSeparationPrompt.instance.showAnyPreviousPrompt()
149-
150-
// MUST restore CW/Q auth so that we can see if this user is already a Q user.
151-
await AuthUtil.instance.restore()
152144
},
153145
{ emit: false, functionId: { name: 'activate', class: 'ExtensionNodeCore' } }
154146
)
@@ -272,52 +264,47 @@ export async function deactivate() {
272264

273265
async function handleAmazonQInstall() {
274266
const dismissedInstall = globals.globalState.get<boolean>('aws.toolkit.amazonqInstall.dismissed')
275-
if (isExtensionInstalled(VSCODE_EXTENSION_ID.amazonq) || dismissedInstall) {
267+
if (dismissedInstall) {
268+
return
269+
}
270+
271+
if (isExtensionInstalled(VSCODE_EXTENSION_ID.amazonq)) {
272+
await globals.globalState.update('aws.toolkit.amazonqInstall.dismissed', true)
276273
return
277274
}
278275

279276
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."
277+
telemetry.record({ id: 'amazonQStandaloneChange' })
278+
void vscode.window
279+
.showInformationMessage(
280+
'Try Amazon Q, a generative AI assistant, with chat and code suggestions.',
281+
'Install',
282+
'Learn More'
285283
)
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)
284+
.then(async (resp) => {
285+
await telemetry.toolkit_invokeAction.run(async () => {
286+
telemetry.record({
287+
source: ExtensionUse.instance.isFirstUse()
288+
? ExtStartUpSources.firstStartUp
289+
: ExtStartUpSources.none,
318290
})
291+
292+
if (resp === 'Learn More') {
293+
// Clicking learn more will open the q extension page
294+
telemetry.record({ action: 'learnMore' })
295+
await qExtensionPageCommand.execute()
296+
return
297+
}
298+
299+
if (resp === 'Install') {
300+
telemetry.record({ action: 'installAmazonQ' })
301+
await installAmazonQExtension.execute()
302+
} else {
303+
telemetry.record({ action: 'dismissQNotification' })
304+
}
305+
await globals.globalState.update('aws.toolkit.amazonqInstall.dismissed', true)
319306
})
320-
}
307+
})
321308
})
322309
}
323310

packages/core/src/shared/globalState.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ export type globalKey =
4444
| 'aws.toolkit.amazonq.dismissed'
4545
| 'aws.toolkit.amazonqInstall.dismissed'
4646
| 'aws.amazonq.workspaceIndexToggleOn'
47-
| 'aws.toolkit.separationPromptCommand'
48-
| 'aws.toolkit.separationPromptDismissed'
4947
// Deprecated/legacy names. New keys should start with "aws.".
5048
| '#sessionCreationDates' // Legacy name from `ssoAccessTokenProvider.ts`.
5149
| 'CODECATALYST_RECONNECT'

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())

0 commit comments

Comments
 (0)