Skip to content

Commit b791a2b

Browse files
committed
refactor(amazonqFeatureDev): add logic for codeGenerationId
1 parent ba2db03 commit b791a2b

File tree

3 files changed

+40
-35
lines changed

3 files changed

+40
-35
lines changed

packages/core/src/amazonqFeatureDev/client/codewhispererruntime-2022-11-11.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,8 @@
439439
"acceptedCharacterCount": { "shape": "Integer" },
440440
"acceptedLineCount": { "shape": "Integer" },
441441
"acceptedSnippetHasReference": { "shape": "Boolean" },
442-
"hasProjectLevelContext": { "shape": "Boolean" }
442+
"hasProjectLevelContext": { "shape": "Boolean" },
443+
"userIntent": { "shape": "UserIntent" }
443444
}
444445
},
445446
"ChatInteractWithMessageEventInteractionTargetString": {
@@ -1564,6 +1565,7 @@
15641565
"conversationState": { "shape": "ConversationState" },
15651566
"workspaceState": { "shape": "WorkspaceState" },
15661567
"taskAssistPlan": { "shape": "TaskAssistPlan" },
1568+
"codeGenerationId": { "shape": "CodeGenerationId" },
15671569
"currentCodeGenerationId": { "shape": "CodeGenerationId" }
15681570
}
15691571
},
@@ -2107,7 +2109,8 @@
21072109
"CITE_SOURCES",
21082110
"EXPLAIN_LINE_BY_LINE",
21092111
"EXPLAIN_CODE_SELECTION",
2110-
"GENERATE_CLOUDFORMATION_TEMPLATE"
2112+
"GENERATE_CLOUDFORMATION_TEMPLATE",
2113+
"GENERATE_UNIT_TESTS"
21112114
]
21122115
},
21132116
"UserModificationEvent": {

packages/core/src/amazonqFeatureDev/client/featureDev.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,13 @@ export class FeatureDevClient {
121121
conversationId: string,
122122
uploadId: string,
123123
message: string,
124+
codeGenerationId: string,
124125
currentCodeGenerationId?: string
125126
) {
126127
try {
127128
const client = await this.getClient()
128129
const params = {
130+
codeGenerationId,
129131
conversationState: {
130132
conversationId,
131133
currentMessage: {

packages/core/src/amazonqFeatureDev/session/sessionState.ts

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,12 @@ export class CodeGenState extends CodeGenBase implements SessionState {
281281

282282
action.telemetry.setGenerateCodeIteration(this.currentIteration)
283283
action.telemetry.setGenerateCodeLastInvocationTime()
284-
285-
const { codeGenerationId } = await this.config.proxyClient.startCodeGeneration(
284+
const codeGenerationId = randomUUID()
285+
await this.config.proxyClient.startCodeGeneration(
286286
this.config.conversationId,
287287
this.config.uploadId,
288288
action.msg,
289+
codeGenerationId,
289290
this.currentCodeGenerationId
290291
)
291292

@@ -465,41 +466,40 @@ export class PrepareCodeGenState implements SessionState {
465466
})
466467

467468
action.messenger.sendUpdatePlaceholder(this.tabID, i18n('AWS.amazonq.featureDev.pillText.uploadingCode'))
468-
if (!this.uploadId) {
469-
const uploadId = await telemetry.amazonq_createUpload.run(async (span) => {
470-
span.record({
471-
amazonqConversationId: this.config.conversationId,
472-
credentialStartUrl: AuthUtil.instance.startUrl,
473-
})
474-
const { zipFileBuffer, zipFileChecksum } = await prepareRepoData(
475-
this.config.workspaceRoots,
476-
this.config.workspaceFolders,
477-
action.telemetry,
478-
span
479-
)
469+
const uploadId = await telemetry.amazonq_createUpload.run(async (span) => {
470+
span.record({
471+
amazonqConversationId: this.config.conversationId,
472+
credentialStartUrl: AuthUtil.instance.startUrl,
473+
})
474+
const { zipFileBuffer, zipFileChecksum } = await prepareRepoData(
475+
this.config.workspaceRoots,
476+
this.config.workspaceFolders,
477+
action.telemetry,
478+
span
479+
)
480480

481-
const { uploadUrl, uploadId, kmsKeyArn } = await this.config.proxyClient.createUploadUrl(
482-
this.config.conversationId,
483-
zipFileChecksum,
484-
zipFileBuffer.length
485-
)
481+
const { uploadUrl, uploadId, kmsKeyArn } = await this.config.proxyClient.createUploadUrl(
482+
this.config.conversationId,
483+
zipFileChecksum,
484+
zipFileBuffer.length
485+
)
486486

487-
await uploadCode(uploadUrl, zipFileBuffer, zipFileChecksum, kmsKeyArn)
488-
action.messenger.sendAnswer({
489-
message: i18n('AWS.amazonq.featureDev.pillText.contextGatheringCompleted'),
490-
type: 'answer-part',
491-
tabID: this.tabID,
492-
})
487+
await uploadCode(uploadUrl, zipFileBuffer, zipFileChecksum, kmsKeyArn)
488+
action.messenger.sendAnswer({
489+
message: i18n('AWS.amazonq.featureDev.pillText.contextGatheringCompleted'),
490+
type: 'answer-part',
491+
tabID: this.tabID,
492+
})
493493

494-
action.messenger.sendUpdatePlaceholder(
495-
this.tabID,
496-
i18n('AWS.amazonq.featureDev.pillText.contextGatheringCompleted')
497-
)
494+
action.messenger.sendUpdatePlaceholder(
495+
this.tabID,
496+
i18n('AWS.amazonq.featureDev.pillText.contextGatheringCompleted')
497+
)
498+
499+
return uploadId
500+
})
501+
this.uploadId = uploadId
498502

499-
return uploadId
500-
})
501-
this.uploadId = uploadId
502-
}
503503
const nextState = new CodeGenState(
504504
{ ...this.config, uploadId: this.uploadId, currentCodeGenerationId: this.currentCodeGenerationId },
505505
this.filePaths,

0 commit comments

Comments
 (0)