@@ -87,26 +87,16 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
87
87
) {
88
88
// 1st API call: Zip project and call CreateUploadUrl
89
89
val session = codeTestChatHelper.getActiveSession()
90
- session.isGeneratingTests = true
91
- session.iteration++
92
90
if (session.testGenerationJobGroupName.isEmpty()) {
93
91
session.testGenerationJobGroupName = UUID .randomUUID().toString()
94
92
}
95
- val final = session.testGenerationJobGroupName
96
93
97
- if (session.iteration == 1 ) {
98
- codeTestChatHelper.updateUI(
99
- promptInputDisabledState = true ,
100
- promptInputProgress = testGenProgressField(0 ),
101
- )
102
- } else {
103
- codeTestChatHelper.updateUI(
104
- promptInputDisabledState = true ,
105
- promptInputProgress = buildAndExecuteProgrogressField,
106
- )
107
- }
108
-
109
- // Set the Progress bar to "Generating unit tests..."
94
+ codeTestChatHelper.updateUI(
95
+ promptInputDisabledState = true ,
96
+ promptInputProgress = session.listOfTestGenerationJobId.takeUnless { it.isEmpty() }
97
+ ?.let { buildAndExecuteProgrogressField }
98
+ ? : testGenProgressField(0 )
99
+ )
110
100
111
101
val codeTestResponseContext = createUploadUrl(codeTestChatHelper, previousIterationContext)
112
102
session.srcPayloadSize = codeTestResponseContext.payloadContext.srcPayloadSize
@@ -117,7 +107,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
117
107
fileTooLarge()
118
108
}
119
109
120
- val createUploadUrlResponse = codeTestResponseContext.createUploadUrlResponse ? : return
110
+ val createUploadUrlResponse = codeTestResponseContext.createUploadUrlResponse
121
111
throwIfCancelled(session)
122
112
123
113
LOG .debug {
@@ -150,7 +140,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
150
140
.build()
151
141
),
152
142
userInput = prompt,
153
- testGenerationJobGroupName = final
143
+ testGenerationJobGroupName = session.testGenerationJobGroupName
154
144
)
155
145
delay(200 )
156
146
response?.testGenerationJob() != null
@@ -179,11 +169,12 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
179
169
session.startTestGenerationRequestId = startTestGenerationResponse.responseMetadata().requestId()
180
170
session.testGenerationJobGroupName = job.testGenerationJobGroupName()
181
171
session.testGenerationJob = job.testGenerationJobId()
172
+ session.listOfTestGenerationJobId + = job.testGenerationJobId()
182
173
throwIfCancelled(session)
183
174
184
175
// 3rd API call: Step 3: Polling mechanism on test job status with getTestGenStatus getTestGeneration
185
176
var finished = false
186
- var testGenerationResponse: GetTestGenerationResponse ? = null
177
+ var testGenerationResponse: GetTestGenerationResponse ?
187
178
188
179
var shortAnswer = ShortAnswer ()
189
180
LOG .debug {
@@ -275,8 +266,8 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
275
266
}
276
267
codeTestChatHelper.updateUI(
277
268
promptInputDisabledState = true ,
278
- promptInputProgress = if (session.iteration == 1 ) {
279
- testGenProgressField(0 )
269
+ promptInputProgress = if (session.listOfTestGenerationJobId.size == 1 ) {
270
+ testGenProgressField(progressRate )
280
271
} else {
281
272
buildAndExecuteProgrogressField
282
273
}
@@ -312,7 +303,6 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
312
303
val result = byteArray.reduce { acc, next -> acc + next } // To map the result it is needed to combine the full byte array
313
304
storeGeneratedTestDiffs(result, session)
314
305
if (! session.isGeneratingTests) {
315
- // TODO: Modify text according to FnF
316
306
codeTestChatHelper.addAnswer(
317
307
CodeTestChatMessageContent (
318
308
message = message(" testgen.error.generic_technical_error_message" ),
@@ -360,7 +350,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
360
350
session.viewDiffMessageId = viewDiffMessageId
361
351
codeTestChatHelper.updateUI(
362
352
promptInputDisabledState = false ,
363
- promptInputPlaceholder = " Specify a function(s) in the current file(optional)" ,
353
+ // promptInputPlaceholder = "Specify a function(s) in the current file(optional)",
364
354
promptInputProgress = testGenCompletedField,
365
355
)
366
356
} else {
@@ -486,10 +476,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
486
476
} else {
487
477
previousIterationContext.selectedFile
488
478
}
489
-
490
- val combinedBuildAndExecuteLogFile =
491
- previousIterationContext?.buildLogFile
492
- val codeTestSessionConfig = CodeTestSessionConfig (file, project, combinedBuildAndExecuteLogFile)
479
+ val codeTestSessionConfig = CodeTestSessionConfig (file, project, previousIterationContext?.buildLogFile)
493
480
codeTestChatHelper.getActiveSession().projectRoot = codeTestSessionConfig.projectRoot.path
494
481
495
482
val codeTestSessionContext = CodeTestSessionContext (project, codeTestSessionConfig)
@@ -587,7 +574,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
587
574
canBeVoted = false
588
575
)
589
576
)
590
- if (session.iteration == 1 ) {
577
+ if (session.listOfTestGenerationJobId.size < 2 ) {
591
578
AmazonqTelemetry .utgGenerateTests(
592
579
cwsprChatProgrammingLanguage = session.programmingLanguage.languageId,
593
580
hasUserPromptSupplied = session.hasUserPromptSupplied,
@@ -624,10 +611,10 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
624
611
requestId = session.startTestGenerationRequestId
625
612
)
626
613
}
627
-
628
614
session.isGeneratingTests = false
629
615
} finally {
630
616
// Reset the flow if there is any error
617
+ codeTestChatHelper.sendUpdatePromptProgress(session.tabId, null )
631
618
if (! session.isGeneratingTests) {
632
619
codeTestChatHelper.updateUI(
633
620
promptInputProgress = cancellingProgressField
0 commit comments