Skip to content

Commit 67e9d9f

Browse files
committed
Merge branch 'master' into loggingNestedObj
2 parents 8c27467 + 4235561 commit 67e9d9f

File tree

5 files changed

+26
-22
lines changed

5 files changed

+26
-22
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/codewhisperer/util/editorContext.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,11 @@ export async function buildGenerateRecommendationRequest(editor: vscode.TextEdit
130130
const fileContext = extractContextForCodeWhisperer(editor)
131131

132132
const tokenSource = new vscode.CancellationTokenSource()
133+
// the supplement context fetch mechanisms each has a timeout of supplementalContextTimeoutInMs
134+
// adding 10 ms for overall timeout as buffer
133135
setTimeout(() => {
134136
tokenSource.cancel()
135-
}, supplementalContextTimeoutInMs)
137+
}, supplementalContextTimeoutInMs + 10)
136138
const supplementalContexts = await fetchSupplementalContext(editor, tokenSource.token)
137139

138140
logSupplementalContext(supplementalContexts)

packages/core/src/codewhisperer/util/supplementalContext/crossFileContextUtil.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ export async function fetchSupplementalContextForSrc(
7171
async function () {
7272
return await fetchSupplementalContextForSrcV1(editor, cancellationToken)
7373
},
74-
{ timeout: supplementalContextTimeoutInMs, interval: 10, truthy: false }
74+
{ timeout: supplementalContextTimeoutInMs, interval: 5, truthy: false }
7575
)
7676
const promiseV2 = waitUntil(
7777
async function () {
7878
return await fetchSupplementalContextForSrcV2(editor)
7979
},
80-
{ timeout: supplementalContextTimeoutInMs, interval: 10, truthy: false }
80+
{ timeout: supplementalContextTimeoutInMs, interval: 5, truthy: false }
8181
)
8282
const [resultV1, resultV2] = await Promise.all([promiseV1, promiseV2])
8383
return resultV2 ?? resultV1

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
import { inspect } from '../../../shared/utilities/collectionUtils'
5757

@@ -636,17 +636,23 @@ export class ChatController {
636636
return
637637
}
638638
}
639-
// if user does not have @workspace in the prompt, but user is in the data collection group
640-
// If the user is in the data collection group but turned off local index to opt-out, do not collect data.
641-
// TODO: Remove this entire block of code in one month as requested
639+
// if user does not have @workspace in the prompt, but user is Amazon internal
640+
// add project context by default
642641
else if (
643-
FeatureConfigProvider.instance.isAmznDataCollectionGroup() &&
642+
Auth.instance.isInternalAmazonUser() &&
644643
!LspController.instance.isIndexingInProgress() &&
645644
CodeWhispererSettings.instance.isLocalIndexEnabled()
646645
) {
647-
getLogger().info(`amazonq: User is in data collection group`)
648646
const start = performance.now()
649-
triggerPayload.relevantTextDocuments = await LspController.instance.query(triggerPayload.message)
647+
triggerPayload.relevantTextDocuments = await waitUntil(
648+
async function () {
649+
if (triggerPayload.message) {
650+
return await LspController.instance.query(triggerPayload.message)
651+
}
652+
return []
653+
},
654+
{ timeout: 500, interval: 200, truthy: false }
655+
)
650656
triggerPayload.projectContextQueryLatencyMs = performance.now() - start
651657
}
652658
}

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)