Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config(chat): try opt in implicit @workspace context once if users are in treatment group [WIP] #6217

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
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 in the 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
38 changes: 36 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 @@
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 { 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 @@
customizationArnOverride: 'customizationArnOverride',
dataCollectionFeature: 'IDEProjectContextDataCollection',
projectContextFeature: 'ProjectContextV2',
workspaceContextFeature: 'WorkspaceContext',
test: 'testFeature',
} as const

Expand Down Expand Up @@ -83,6 +87,21 @@
}
}

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,27 @@
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)

// todo: finalize string
await vscode.window
.showInformationMessage(
localize(
'AWS.amazonq.chat.workspacecontext.enable.message',
'Amazon Q: Workspace index is now enabled. You can disable it in the Amazon Q settings.'
),
localize('AWS.amazonq.opensettings', 'Open settings')
)
.then((r) => {
if (r === 'Open settings') {
Commands.tryExecute('aws.amazonq.configure')

Check failure on line 194 in packages/core/src/shared/featureConfig.ts

View workflow job for this annotation

GitHub Actions / lint (18.x, stable)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
}
})
}
}
} catch (e) {
Expand Down
Loading