Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's not for public users to access this feature, i think we probably dont want to mention it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it is still customer facing

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,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'
import { isSsoConnection } from '../../../auth/connection'

export interface ChatControllerMessagePublishers {
Expand Down Expand Up @@ -633,17 +633,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
14 changes: 3 additions & 11 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 @@ -65,10 +64,6 @@ export class FeatureConfigProvider {
return (this.#instance ??= new this())
}

isAmznDataCollectionGroup(): boolean {
return this._isDataCollectionGroup
}

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
Loading