Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
leigaol committed Oct 24, 2024
1 parent fb62929 commit f6ee8ce
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "Enable default `@workspace` context of Amazon Q chat for certain users"
}
22 changes: 14 additions & 8 deletions packages/core/src/codewhispererChat/controllers/chat/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ import { randomUUID } from '../../../shared/crypto'
import { LspController } from '../../../amazonq/lsp/lspController'
import { CodeWhispererSettings } from '../../../codewhisperer/util/codewhispererSettings'
import { getSelectedCustomization } from '../../../codewhisperer/util/customizationUtil'
import { FeatureConfigProvider } from '../../../shared/featureConfig'
import { getHttpStatusCode, AwsClientResponseError } from '../../../shared/errors'
import { uiEventRecorder } from '../../../amazonq/util/eventRecorder'
import { globals } from '../../../shared'
import { globals, waitUntil } from '../../../shared'
import { telemetry } from '../../../shared/telemetry'
import { Auth } from '../../../auth'

export interface ChatControllerMessagePublishers {
readonly processPromptChatMessage: MessagePublisher<PromptMessage>
Expand Down Expand Up @@ -634,17 +634,23 @@ export class ChatController {
return
}
}
// if user does not have @workspace in the prompt, but user is in the data collection group
// If the user is in the data collection group but turned off local index to opt-out, do not collect data.
// TODO: Remove this entire block of code in one month as requested
// if user does not have @workspace in the prompt, but user is Amazon internal
// add project context by default
else if (
FeatureConfigProvider.instance.isAmznDataCollectionGroup() &&
Auth.instance.isInternalAmazonUser() &&
!LspController.instance.isIndexingInProgress() &&
CodeWhispererSettings.instance.isLocalIndexEnabled()
) {
getLogger().info(`amazonq: User is in data collection group`)
const start = performance.now()
triggerPayload.relevantTextDocuments = await LspController.instance.query(triggerPayload.message)
triggerPayload.relevantTextDocuments = await waitUntil(
async function () {
if (triggerPayload.message) {
return await LspController.instance.query(triggerPayload.message)
}
return []
},
{ timeout: 500, interval: 200, truthy: false }
)
triggerPayload.projectContextQueryLatencyMs = performance.now() - start
}
}
Expand Down
16 changes: 4 additions & 12 deletions packages/core/src/shared/featureConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import globals from './extensionGlobals'
import { getClientId, getOperatingSystem } from './telemetry/util'
import { extensionVersion } from './vscode/env'
import { telemetry } from './telemetry'
import { Auth } from '../auth'

export class FeatureContext {
constructor(
Expand Down Expand Up @@ -51,8 +52,6 @@ export class FeatureConfigProvider {

static #instance: FeatureConfigProvider

private _isDataCollectionGroup = false

constructor() {
this.fetchFeatureConfigs().catch((e) => {
getLogger().error('fetchFeatureConfigs failed: %s', (e as Error).message)
Expand All @@ -64,11 +63,7 @@ export class FeatureConfigProvider {
public static get instance() {
return (this.#instance ??= new this())
}

isAmznDataCollectionGroup(): boolean {
return this._isDataCollectionGroup
}


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

View workflow job for this annotation

GitHub Actions / lint (18.x, stable)

Delete `····`
isNewProjectContextGroup(): boolean {
return this.featureConfigs.get(Features.projectContextFeature)?.variation === 'TREATMENT'
}
Expand Down Expand Up @@ -145,11 +140,8 @@ export class FeatureConfigProvider {
}
}
}

const dataCollectionValue = this.featureConfigs.get(Features.dataCollectionFeature)?.value.stringValue
if (dataCollectionValue === 'data-collection') {
this._isDataCollectionGroup = true
// Enable local workspace index by default, for Amzn users.
if (Auth.instance.isInternalAmazonUser()) {
// 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()
Expand Down

0 comments on commit f6ee8ce

Please sign in to comment.