Skip to content

Commit b8e30b5

Browse files
authored
Merge branch 'aws:master' into feature/rubysecurityscans
2 parents 1494819 + 16ccd1b commit b8e30b5

29 files changed

+390
-195
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Amazon Q: Input prompt gets wrapped to new line which avoids focusing"
4+
}

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4353,7 +4353,7 @@
43534353
"@aws-sdk/shared-ini-file-loader": "^3.46.0",
43544354
"@aws-sdk/smithy-client": "^3.46.0",
43554355
"@aws-sdk/util-arn-parser": "^3.46.0",
4356-
"@aws/mynah-ui-chat": "npm:@aws/[email protected].9",
4356+
"@aws/mynah-ui-chat": "npm:@aws/[email protected].10",
43574357
"@gerhobbelt/gitignore-parser": "^0.2.0-9",
43584358
"@iarna/toml": "^2.2.5",
43594359
"@vscode/debugprotocol": "^1.57.0",

src/amazonq/commons/externalBrowser/externalBrowserUtils.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/amazonqFeatureDev/controllers/chat/controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import { AuthController } from '../../../amazonq/auth/controller'
2323
import { getLogger } from '../../../shared/logger'
2424
import { submitFeedback } from '../../../feedback/vue/submitFeedback'
2525
import { placeholder } from '../../../shared/vscode/commands2'
26-
import { ExternalBrowserUtils } from '../../../amazonq/commons/externalBrowser/externalBrowserUtils'
2726
import { userGuideURL } from '../../../amazonq/webview/ui/texts/constants'
2827
import { EditorContentController } from '../../../amazonq/commons/controllers/contentController'
28+
import { openUrl } from '../../../shared/utilities/vsCodeUtils'
2929

3030
export interface ChatControllerEventEmitters {
3131
readonly processHumanChatMessage: EventEmitter<any>
@@ -441,7 +441,7 @@ To learn more, visit the _[Amazon Q User Guide](${userGuideURL})_.
441441
}
442442

443443
private processLink(message: any) {
444-
ExternalBrowserUtils.instance.openLink(message.link)
444+
openUrl(vscode.Uri.parse(message.link))
445445
}
446446

447447
private insertCodeAtPosition(message: any) {

src/codewhisperer/activation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
applySecurityFix,
4040
signoutCodeWhisperer,
4141
showManageCwConnections,
42+
fetchFeatureConfigsCmd,
4243
} from './commands/basicCommands'
4344
import { sleep } from '../shared/utilities/timeoutUtils'
4445
import { ReferenceLogViewProvider } from './service/referenceLogViewProvider'
@@ -206,6 +207,8 @@ export async function activate(context: ExtContext): Promise<void> {
206207
selectCustomizationPrompt.register(),
207208
// notify new customizations
208209
notifyNewCustomizationsCmd.register(),
210+
// fetch feature configs
211+
fetchFeatureConfigsCmd.register(),
209212
/**
210213
* On recommendation acceptance
211214
*/

src/codewhisperer/client/codewhisperer.ts

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import { AWSError, Credentials, Service } from 'aws-sdk'
77
import globals from '../../shared/extensionGlobals'
88
import * as CodeWhispererClient from './codewhispererclient'
99
import * as CodeWhispererUserClient from './codewhispereruserclient'
10-
import { ListAvailableCustomizationsResponse, SendTelemetryEventRequest } from './codewhispereruserclient'
10+
import {
11+
ListAvailableCustomizationsResponse,
12+
ListFeatureEvaluationsRequest,
13+
ListFeatureEvaluationsResponse,
14+
SendTelemetryEventRequest,
15+
} from './codewhispereruserclient'
1116
import * as CodeWhispererConstants from '../models/constants'
1217
import { ServiceOptions } from '../../shared/awsClientBuilder'
1318
import { hasVendedIamCredentials } from '../../auth/auth'
@@ -22,6 +27,9 @@ import { session } from '../util/codeWhispererSession'
2227
import { getLogger } from '../../shared/logger'
2328
import { indent } from '../../shared/utilities/textUtilities'
2429
import { keepAliveHeader } from './agent'
30+
import { getOptOutPreference } from '../util/commonUtil'
31+
import * as os from 'os'
32+
import { getClientId } from '../../shared/telemetry/util'
2533

2634
export type ProgrammingLanguage = Readonly<
2735
CodeWhispererClient.ProgrammingLanguage | CodeWhispererUserClient.ProgrammingLanguage
@@ -219,17 +227,46 @@ export class DefaultCodeWhispererClient {
219227
}
220228

221229
public async sendTelemetryEvent(request: SendTelemetryEventRequest) {
222-
const requestWithOptOut: SendTelemetryEventRequest = {
230+
const requestWithCommonFields: SendTelemetryEventRequest = {
223231
...request,
224-
optOutPreference: globals.telemetry.telemetryEnabled ? 'OPTIN' : 'OPTOUT',
232+
optOutPreference: getOptOutPreference(),
233+
userContext: {
234+
ideCategory: 'VSCODE',
235+
operatingSystem: this.getOperatingSystem(),
236+
product: 'CodeWhisperer',
237+
clientId: await getClientId(globals.context.globalState),
238+
},
225239
}
226240
if (!AuthUtil.instance.isValidEnterpriseSsoInUse() && !globals.telemetry.telemetryEnabled) {
227241
return
228242
}
229-
const response = await (await this.createUserSdkClient()).sendTelemetryEvent(requestWithOptOut).promise()
243+
const response = await (await this.createUserSdkClient()).sendTelemetryEvent(requestWithCommonFields).promise()
230244
getLogger().debug(`codewhisperer: sendTelemetryEvent requestID: ${response.$response.requestId}`)
231245
}
232246

247+
public async listFeatureEvaluations(): Promise<ListFeatureEvaluationsResponse> {
248+
const request: ListFeatureEvaluationsRequest = {
249+
userContext: {
250+
ideCategory: 'VSCODE',
251+
operatingSystem: this.getOperatingSystem(),
252+
product: 'CodeWhisperer',
253+
clientId: await getClientId(globals.context.globalState),
254+
},
255+
}
256+
return (await this.createUserSdkClient()).listFeatureEvaluations(request).promise()
257+
}
258+
259+
private getOperatingSystem(): string {
260+
const osId = os.platform() // 'darwin', 'win32', 'linux', etc.
261+
if (osId === 'darwin') {
262+
return 'MAC'
263+
} else if (osId === 'win32') {
264+
return 'WINDOWS'
265+
} else {
266+
return 'LINUX'
267+
}
268+
}
269+
233270
/**
234271
* @description Use this function to start the transformation job.
235272
* @param request

src/codewhisperer/client/user-service-2.json

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
"output": { "shape": "CreateUploadUrlResponse" },
5454
"errors": [
5555
{ "shape": "ThrottlingException" },
56+
{ "shape": "ConflictException" },
57+
{ "shape": "ResourceNotFoundException" },
5658
{ "shape": "InternalServerException" },
5759
{ "shape": "ValidationException" },
5860
{ "shape": "AccessDeniedException" }
@@ -116,6 +118,8 @@
116118
"output": { "shape": "GetTaskAssistCodeGenerationResponse" },
117119
"errors": [
118120
{ "shape": "ThrottlingException" },
121+
{ "shape": "ConflictException" },
122+
{ "shape": "ResourceNotFoundException" },
119123
{ "shape": "InternalServerException" },
120124
{ "shape": "ValidationException" },
121125
{ "shape": "AccessDeniedException" }
@@ -241,6 +245,8 @@
241245
"output": { "shape": "StartTaskAssistCodeGenerationResponse" },
242246
"errors": [
243247
{ "shape": "ThrottlingException" },
248+
{ "shape": "ConflictException" },
249+
{ "shape": "ResourceNotFoundException" },
244250
{ "shape": "InternalServerException" },
245251
{ "shape": "ValidationException" },
246252
{ "shape": "AccessDeniedException" }
@@ -474,6 +480,7 @@
474480
"contentMd5": { "shape": "CreateUploadUrlRequestContentMd5String" },
475481
"contentChecksum": { "shape": "CreateUploadUrlRequestContentChecksumString" },
476482
"contentChecksumType": { "shape": "ContentChecksumType" },
483+
"contentLength": { "shape": "CreateUploadUrlRequestContentLengthLong" },
477484
"artifactType": { "shape": "ArtifactType" },
478485
"uploadIntent": { "shape": "UploadIntent" },
479486
"uploadContext": { "shape": "UploadContext" }
@@ -485,6 +492,11 @@
485492
"min": 1,
486493
"sensitive": true
487494
},
495+
"CreateUploadUrlRequestContentLengthLong": {
496+
"type": "long",
497+
"box": true,
498+
"min": 1
499+
},
488500
"CreateUploadUrlRequestContentMd5String": {
489501
"type": "string",
490502
"max": 128,
@@ -521,7 +533,7 @@
521533
"type": "string",
522534
"max": 950,
523535
"min": 0,
524-
"pattern": "$|^arn:[-.a-z0-9]{1,63}:codewhisperer:([-.a-z0-9]{0,63}:){2}([a-zA-Z0-9-_:/]){1,1023}"
536+
"pattern": "arn:[-.a-z0-9]{1,63}:codewhisperer:([-.a-z0-9]{0,63}:){2}([a-zA-Z0-9-_:/]){1,1023}"
525537
},
526538
"CustomizationName": {
527539
"type": "string",
@@ -955,7 +967,8 @@
955967
"PreSignedUrl": {
956968
"type": "string",
957969
"max": 2048,
958-
"min": 1
970+
"min": 1,
971+
"sensitive": true
959972
},
960973
"PrimitiveInteger": { "type": "integer" },
961974
"ProgrammingLanguage": {
@@ -1442,7 +1455,8 @@
14421455
"members": {
14431456
"ideCategory": { "shape": "IdeCategory" },
14441457
"operatingSystem": { "shape": "OperatingSystem" },
1445-
"product": { "shape": "UserContextProductString" }
1458+
"product": { "shape": "UserContextProductString" },
1459+
"clientId": { "shape": "UUID" }
14461460
}
14471461
},
14481462
"UserContextProductString": {
@@ -1518,7 +1532,8 @@
15181532
"recommendationLatencyMilliseconds": { "shape": "Double" },
15191533
"timestamp": { "shape": "Timestamp" },
15201534
"suggestionReferenceCount": { "shape": "PrimitiveInteger" },
1521-
"generatedLine": { "shape": "PrimitiveInteger" }
1535+
"generatedLine": { "shape": "PrimitiveInteger" },
1536+
"numberOfRecommendations": { "shape": "PrimitiveInteger" }
15221537
}
15231538
},
15241539
"ValidationException": {

src/codewhisperer/commands/basicCommands.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { FileSystemCommon } from '../../srcShared/fs'
3232
import { Mutable } from '../../shared/utilities/tsUtils'
3333
import { CodeWhispererSource } from './types'
3434
import { showManageConnections } from '../../auth/ui/vue/show'
35+
import { FeatureConfigProvider } from '../service/featureConfigProvider'
3536

3637
export const toggleCodeSuggestions = Commands.declare(
3738
{ id: 'aws.codeWhisperer.toggleCodeSuggestion', compositeKey: { 1: 'source' } },
@@ -246,6 +247,13 @@ export const notifyNewCustomizationsCmd = Commands.declare(
246247
}
247248
)
248249

250+
export const fetchFeatureConfigsCmd = Commands.declare(
251+
{ id: 'aws.codeWhisperer.fetchFeatureConfigs', logging: false },
252+
() => () => {
253+
FeatureConfigProvider.instance.fetchFeatureConfigs()
254+
}
255+
)
256+
249257
export const applySecurityFix = Commands.declare(
250258
'aws.codeWhisperer.applySecurityFix',
251259
() => async (issue: CodeScanIssue, filePath: string, source: Component) => {

src/codewhisperer/service/completionProvider.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import * as CodeWhispererConstants from '../models/constants'
88
import { runtimeLanguageContext } from '../util/runtimeLanguageContext'
99
import { Recommendation } from '../client/codewhisperer'
1010
import { LicenseUtil } from '../util/licenseUtil'
11-
import { TelemetryHelper } from '../util/telemetryHelper'
1211
import { RecommendationHandler } from './recommendationHandler'
1312
import { session } from '../util/codeWhispererSession'
1413
/**
@@ -60,7 +59,7 @@ export function getCompletionItem(
6059
recommendation,
6160
RecommendationHandler.instance.requestId,
6261
session.sessionId,
63-
TelemetryHelper.instance.triggerType,
62+
session.triggerType,
6463
session.getCompletionType(recommendationIndex),
6564
languageContext.language,
6665
references,

0 commit comments

Comments
 (0)