Skip to content

Commit f6ee8ce

Browse files
committed
update
1 parent fb62929 commit f6ee8ce

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
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
@@ -49,11 +49,11 @@ import { randomUUID } from '../../../shared/crypto'
4949
import { LspController } from '../../../amazonq/lsp/lspController'
5050
import { CodeWhispererSettings } from '../../../codewhisperer/util/codewhispererSettings'
5151
import { getSelectedCustomization } from '../../../codewhisperer/util/customizationUtil'
52-
import { FeatureConfigProvider } from '../../../shared/featureConfig'
5352
import { getHttpStatusCode, AwsClientResponseError } from '../../../shared/errors'
5453
import { uiEventRecorder } from '../../../amazonq/util/eventRecorder'
55-
import { globals } from '../../../shared'
54+
import { globals, waitUntil } from '../../../shared'
5655
import { telemetry } from '../../../shared/telemetry'
56+
import { Auth } from '../../../auth'
5757

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

packages/core/src/shared/featureConfig.ts

Lines changed: 4 additions & 12 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)
@@ -64,11 +63,7 @@ export class FeatureConfigProvider {
6463
public static get instance() {
6564
return (this.#instance ??= new this())
6665
}
67-
68-
isAmznDataCollectionGroup(): boolean {
69-
return this._isDataCollectionGroup
70-
}
71-
66+
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)