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