Skip to content

Commit 80d2f0b

Browse files
committed
refactor(amazonqFeatureDev): add logic for codeGenerationId
1 parent 7c896d1 commit 80d2f0b

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
@@ -273,11 +273,12 @@ export class CodeGenState extends CodeGenBase implements SessionState {
273273

274274
action.telemetry.setGenerateCodeIteration(this.currentIteration)
275275
action.telemetry.setGenerateCodeLastInvocationTime()
276-
277-
const { codeGenerationId } = await this.config.proxyClient.startCodeGeneration(
276+
const codeGenerationId = randomUUID()
277+
await this.config.proxyClient.startCodeGeneration(
278278
this.config.conversationId,
279279
this.config.uploadId,
280280
action.msg,
281+
codeGenerationId,
281282
this.currentCodeGenerationId
282283
)
283284

@@ -457,41 +458,40 @@ export class PrepareCodeGenState implements SessionState {
457458
})
458459

459460
action.messenger.sendUpdatePlaceholder(this.tabID, i18n('AWS.amazonq.featureDev.pillText.uploadingCode'))
460-
if (!this.uploadId) {
461-
const uploadId = await telemetry.amazonq_createUpload.run(async (span) => {
462-
span.record({
463-
amazonqConversationId: this.config.conversationId,
464-
credentialStartUrl: AuthUtil.instance.startUrl,
465-
})
466-
const { zipFileBuffer, zipFileChecksum } = await prepareRepoData(
467-
this.config.workspaceRoots,
468-
this.config.workspaceFolders,
469-
action.telemetry,
470-
span
471-
)
461+
const uploadId = await telemetry.amazonq_createUpload.run(async (span) => {
462+
span.record({
463+
amazonqConversationId: this.config.conversationId,
464+
credentialStartUrl: AuthUtil.instance.startUrl,
465+
})
466+
const { zipFileBuffer, zipFileChecksum } = await prepareRepoData(
467+
this.config.workspaceRoots,
468+
this.config.workspaceFolders,
469+
action.telemetry,
470+
span
471+
)
472472

473-
const { uploadUrl, uploadId, kmsKeyArn } = await this.config.proxyClient.createUploadUrl(
474-
this.config.conversationId,
475-
zipFileChecksum,
476-
zipFileBuffer.length
477-
)
473+
const { uploadUrl, uploadId, kmsKeyArn } = await this.config.proxyClient.createUploadUrl(
474+
this.config.conversationId,
475+
zipFileChecksum,
476+
zipFileBuffer.length
477+
)
478478

479-
await uploadCode(uploadUrl, zipFileBuffer, zipFileChecksum, kmsKeyArn)
480-
action.messenger.sendAnswer({
481-
message: i18n('AWS.amazonq.featureDev.pillText.contextGatheringCompleted'),
482-
type: 'answer-part',
483-
tabID: this.tabID,
484-
})
479+
await uploadCode(uploadUrl, zipFileBuffer, zipFileChecksum, kmsKeyArn)
480+
action.messenger.sendAnswer({
481+
message: i18n('AWS.amazonq.featureDev.pillText.contextGatheringCompleted'),
482+
type: 'answer-part',
483+
tabID: this.tabID,
484+
})
485485

486-
action.messenger.sendUpdatePlaceholder(
487-
this.tabID,
488-
i18n('AWS.amazonq.featureDev.pillText.contextGatheringCompleted')
489-
)
486+
action.messenger.sendUpdatePlaceholder(
487+
this.tabID,
488+
i18n('AWS.amazonq.featureDev.pillText.contextGatheringCompleted')
489+
)
490+
491+
return uploadId
492+
})
493+
this.uploadId = uploadId
490494

491-
return uploadId
492-
})
493-
this.uploadId = uploadId
494-
}
495495
const nextState = new CodeGenState(
496496
{ ...this.config, uploadId: this.uploadId, currentCodeGenerationId: this.currentCodeGenerationId },
497497
this.filePaths,

0 commit comments

Comments
 (0)