Skip to content

Commit a514965

Browse files
Merge master into feature/emr
2 parents abcdc97 + 4235561 commit a514965

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Enable default `@workspace` context of Amazon Q chat for certain users"
4+
}

packages/core/src/codewhispererChat/controllers/chat/controller.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ import { randomUUID } from '../../../shared/crypto'
4747
import { LspController } from '../../../amazonq/lsp/lspController'
4848
import { CodeWhispererSettings } from '../../../codewhisperer/util/codewhispererSettings'
4949
import { getSelectedCustomization } from '../../../codewhisperer/util/customizationUtil'
50-
import { FeatureConfigProvider } from '../../../shared/featureConfig'
5150
import { getHttpStatusCode, AwsClientResponseError } from '../../../shared/errors'
5251
import { uiEventRecorder } from '../../../amazonq/util/eventRecorder'
53-
import { globals } from '../../../shared'
52+
import { globals, waitUntil } from '../../../shared'
5453
import { telemetry } from '../../../shared/telemetry'
54+
import { Auth } from '../../../auth'
5555
import { isSsoConnection } from '../../../auth/connection'
5656

5757
export interface ChatControllerMessagePublishers {
@@ -633,17 +633,23 @@ export class ChatController {
633633
return
634634
}
635635
}
636-
// if user does not have @workspace in the prompt, but user is in the data collection group
637-
// If the user is in the data collection group but turned off local index to opt-out, do not collect data.
638-
// TODO: Remove this entire block of code in one month as requested
636+
// if user does not have @workspace in the prompt, but user is Amazon internal
637+
// add project context by default
639638
else if (
640-
FeatureConfigProvider.instance.isAmznDataCollectionGroup() &&
639+
Auth.instance.isInternalAmazonUser() &&
641640
!LspController.instance.isIndexingInProgress() &&
642641
CodeWhispererSettings.instance.isLocalIndexEnabled()
643642
) {
644-
getLogger().info(`amazonq: User is in data collection group`)
645643
const start = performance.now()
646-
triggerPayload.relevantTextDocuments = await LspController.instance.query(triggerPayload.message)
644+
triggerPayload.relevantTextDocuments = await waitUntil(
645+
async function () {
646+
if (triggerPayload.message) {
647+
return await LspController.instance.query(triggerPayload.message)
648+
}
649+
return []
650+
},
651+
{ timeout: 500, interval: 200, truthy: false }
652+
)
647653
triggerPayload.projectContextQueryLatencyMs = performance.now() - start
648654
}
649655
}

packages/core/src/shared/featureConfig.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import globals from './extensionGlobals'
1818
import { getClientId, getOperatingSystem } from './telemetry/util'
1919
import { extensionVersion } from './vscode/env'
2020
import { telemetry } from './telemetry'
21+
import { Auth } from '../auth'
2122

2223
export class FeatureContext {
2324
constructor(
@@ -51,8 +52,6 @@ export class FeatureConfigProvider {
5152

5253
static #instance: FeatureConfigProvider
5354

54-
private _isDataCollectionGroup = false
55-
5655
constructor() {
5756
this.fetchFeatureConfigs().catch((e) => {
5857
getLogger().error('fetchFeatureConfigs failed: %s', (e as Error).message)
@@ -65,10 +64,6 @@ export class FeatureConfigProvider {
6564
return (this.#instance ??= new this())
6665
}
6766

68-
isAmznDataCollectionGroup(): boolean {
69-
return this._isDataCollectionGroup
70-
}
71-
7267
isNewProjectContextGroup(): boolean {
7368
return this.featureConfigs.get(Features.projectContextFeature)?.variation === 'TREATMENT'
7469
}
@@ -145,11 +140,8 @@ export class FeatureConfigProvider {
145140
}
146141
}
147142
}
148-
149-
const dataCollectionValue = this.featureConfigs.get(Features.dataCollectionFeature)?.value.stringValue
150-
if (dataCollectionValue === 'data-collection') {
151-
this._isDataCollectionGroup = true
152-
// Enable local workspace index by default, for Amzn users.
143+
if (Auth.instance.isInternalAmazonUser()) {
144+
// Enable local workspace index by default only once, for Amzn users.
153145
const isSet = globals.globalState.get<boolean>('aws.amazonq.workspaceIndexToggleOn') || false
154146
if (!isSet) {
155147
await CodeWhispererSettings.instance.enableLocalIndex()

0 commit comments

Comments
 (0)