Skip to content
Merged
2 changes: 2 additions & 0 deletions packages/core/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"AWS.codewhisperer.customization.notification.new_customizations.learn_more": "Learn More",
"AWS.amazonq.title": "Amazon Q",
"AWS.amazonq.chat": "Chat",
"AWS.amazonq.chat.workspacecontext.enable.message": "Amazon Q: Workspace index is now enabled. You can disable it from Amazon Q settings.",
"AWS.amazonq.security": "Code Issues",
"AWS.amazonq.login": "Login",
"AWS.amazonq.learnMore": "Learn More About Amazon Q",
Expand Down Expand Up @@ -404,6 +405,7 @@
"AWS.amazonq.doc.pillText.reject": "Reject",
"AWS.amazonq.doc.pillText.makeChanges": "Make changes",
"AWS.amazonq.inline.invokeChat": "Inline chat",
"AWS.amazonq.opensettings:": "Open settings",
"AWS.toolkit.lambda.walkthrough.quickpickTitle": "Application Builder Walkthrough",
"AWS.toolkit.lambda.walkthrough.title": "Get started building your application",
"AWS.toolkit.lambda.walkthrough.description": "Your quick guide to build an application visually, iterate locally, and deploy to the cloud!",
Expand Down
37 changes: 35 additions & 2 deletions packages/core/src/shared/featureConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ListFeatureEvaluationsResponse,
} from '../codewhisperer/client/codewhispereruserclient'
import * as vscode from 'vscode'
import * as nls from 'vscode-nls'
import { codeWhispererClient as client } from '../codewhisperer/client/codewhisperer'
import { AuthUtil } from '../codewhisperer/util/authUtil'
import { getLogger } from './logger'
Expand All @@ -19,7 +20,9 @@ import globals from './extensionGlobals'
import { getClientId, getOperatingSystem } from './telemetry/util'
import { extensionVersion } from './vscode/env'
import { telemetry } from './telemetry'
import { Auth } from '../auth'
import { Commands } from './vscode/commands2'

const localize = nls.loadMessageBundle()

export class FeatureContext {
constructor(
Expand All @@ -35,6 +38,7 @@ export const Features = {
customizationArnOverride: 'customizationArnOverride',
dataCollectionFeature: 'IDEProjectContextDataCollection',
projectContextFeature: 'ProjectContextV2',
workspaceContextFeature: 'WorkspaceContext',
test: 'testFeature',
} as const

Expand Down Expand Up @@ -83,6 +87,21 @@ export class FeatureConfigProvider {
}
}

getWorkspaceContextGroup(): 'control' | 'treatment' {
const variation = this.featureConfigs.get(Features.projectContextFeature)?.variation

switch (variation) {
case 'CONTROL':
return 'control'

case 'TREATMENT':
return 'treatment'

default:
return 'control'
}
}

public async listFeatureEvaluations(): Promise<ListFeatureEvaluationsResponse> {
const request: ListFeatureEvaluationsRequest = {
userContext: {
Expand Down Expand Up @@ -154,12 +173,26 @@ export class FeatureConfigProvider {
await vscode.commands.executeCommand('aws.amazonq.refreshStatusBar')
}
}
if (Auth.instance.isInternalAmazonUser()) {
if (this.getWorkspaceContextGroup() === 'treatment') {
// Enable local workspace index by default only once, for Amzn users.
const isSet = globals.globalState.get<boolean>('aws.amazonq.workspaceIndexToggleOn') || false
if (!isSet) {
await CodeWhispererSettings.instance.enableLocalIndex()
globals.globalState.tryUpdate('aws.amazonq.workspaceIndexToggleOn', true)

await vscode.window
.showInformationMessage(
localize(
'AWS.amazonq.chat.workspacecontext.enable.message',
'Amazon Q: Workspace index is now enabled. You can disable it from Amazon Q settings.'
),
localize('AWS.amazonq.opensettings', 'Open settings')
)
.then((r) => {
if (r === 'Open settings') {
void Commands.tryExecute('aws.amazonq.configure').then()
}
})
}
}
} catch (e) {
Expand Down
Loading