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
3 changes: 3 additions & 0 deletions packages/core/src/amazonqTest/chat/controller/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ export class TestController {
cwsprChatProgrammingLanguage: session.fileLanguage ?? 'plaintext',
jobId: session.listOfTestGenerationJobId[0], // For RIV, UTG does only one StartTestGeneration API call
jobGroup: session.testGenerationJobGroupName,
requestId: session.startTestGenerationRequestId,
hasUserPromptSupplied: session.hasUserPromptSupplied,
isCodeBlockSelected: session.isCodeBlockSelected,
buildPayloadBytes: session.srcPayloadSize,
Expand Down Expand Up @@ -725,6 +726,7 @@ export class TestController {
cwsprChatProgrammingLanguage: session.fileLanguage ?? 'plaintext',
jobId: session.listOfTestGenerationJobId[0], // For RIV, UTG does only one StartTestGeneration API call so jobId = session.listOfTestGenerationJobId[0]
jobGroup: session.testGenerationJobGroupName,
requestId: session.startTestGenerationRequestId,
buildPayloadBytes: session.srcPayloadSize,
buildZipFileBytes: session.srcZipFileSize,
artifactsUploadDuration: session.artifactsUploadDuration,
Expand Down Expand Up @@ -848,6 +850,7 @@ export class TestController {
cwsprChatProgrammingLanguage: session.fileLanguage ?? 'plaintext',
jobId: session.listOfTestGenerationJobId[0], // For RIV, UTG does only one StartTestGeneration API call so jobId = session.listOfTestGenerationJobId[0]
jobGroup: session.testGenerationJobGroupName,
requestId: session.startTestGenerationRequestId,
buildPayloadBytes: session.srcPayloadSize,
buildZipFileBytes: session.srcZipFileSize,
artifactsUploadDuration: session.artifactsUploadDuration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class Messenger {
fileName: string
) {
let message = ''
const messageId = response.$metadata.requestId ?? ''
let messageId = response.$metadata.requestId ?? ''
let codeReference: CodeReference[] = []

if (response.generateAssistantResponseResponse === undefined) {
Expand Down Expand Up @@ -267,6 +267,7 @@ export class Messenger {
}

if (requestID !== undefined) {
messageId = requestID
message += `\n\nRequest ID: ${requestID}`
}
this.sendMessage(message.trim(), tabID, 'answer')
Expand All @@ -282,6 +283,7 @@ export class Messenger {
reasonDesc: getTelemetryReasonDesc(CodeWhispererConstants.unitTestGenerationCancelMessage),
isSupportedLanguage: false,
credentialStartUrl: AuthUtil.instance.startUrl,
requestId: messageId,
})

this.dispatcher.sendUpdatePromptProgress(
Expand All @@ -296,6 +298,7 @@ export class Messenger {
result: 'Succeeded',
isSupportedLanguage: false,
credentialStartUrl: AuthUtil.instance.startUrl,
requestId: messageId,
})
this.dispatcher.sendUpdatePromptProgress(
new UpdatePromptProgressMessage(tabID, testGenCompletedField)
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/amazonqTest/chat/session/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class Session {
//This is unique per each test generation cycle
public testGenerationJobGroupName: string | undefined = undefined
public listOfTestGenerationJobId: string[] = []
public startTestGenerationRequestId: string | undefined = undefined
public testGenerationJob: TestGenerationJob | undefined

// Start Test generation
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/codewhisperer/service/testGenHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ export async function createTestJob(
logger.debug('target line range end: %O', firstTargetLineRangeList?.end)

const resp = await codewhispererClient.codeWhispererClient.startTestGeneration(req).catch((err) => {
ChatSessionManager.Instance.getSession().startTestGenerationRequestId = err.requestId
Copy link
Contributor

Choose a reason for hiding this comment

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

so ChatSessionManager.Instance.getSession() is global, shared, mutable state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, its global and mutable.

Copy link
Contributor

@justinmk3 justinmk3 Dec 9, 2024

Choose a reason for hiding this comment

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

It's clear that will be a source of bugs, right? Any random codepath can update requestId at any time, and it may be completely wrong.

logger.error(`Failed creating test job. Request id: ${err.requestId}`)
throw err
})
logger.info('Unit test generation request id: %s', resp.$response.requestId)
logger.debug('Unit test generation data: %O', resp.$response.data)
ChatSessionManager.Instance.getSession().startTestGenerationRequestId = resp.$response.requestId
if (resp.$response.error) {
logger.error('Unit test generation error: %O', resp.$response.error)
}
Expand Down
Loading