Skip to content

Commit d139695

Browse files
committed
Revert "Refactoring Build and execute"
This reverts commit 3c6c33c.
1 parent 3c6c33c commit d139695

File tree

9 files changed

+157
-132
lines changed

9 files changed

+157
-132
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "feature",
3+
"description" : "Add back build and execute for Internal Amazon Customers."
4+
}

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/CodeTestChatItems.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ val cancelTestGenButton = Button(
2929
icon = "cancel"
3030
)
3131

32-
val cancelTestGenBuildAndExecuteButton = Button(
33-
id = CodeTestButtonId.StopTestGenBuildAndExecution.id,
34-
text = message("general.cancel"),
35-
icon = "cancel"
36-
)
37-
3832
fun testGenProgressField(value: Int) = ProgressField(
3933
status = "default",
4034
text = message("testgen.progressbar.generate_unit_tests"),
@@ -46,5 +40,5 @@ fun testGenProgressField(value: Int) = ProgressField(
4640
val buildAndExecuteProgrogressField = ProgressField(
4741
status = "default",
4842
text = message("testgen.progressbar.build_and_execute"),
49-
actions = listOf(cancelTestGenBuildAndExecuteButton)
43+
actions = listOf(cancelTestGenButton)
5044
)

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqCodeTest/CodeWhispererUTGChatManager.kt

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,26 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
8787
) {
8888
// 1st API call: Zip project and call CreateUploadUrl
8989
val session = codeTestChatHelper.getActiveSession()
90+
session.isGeneratingTests = true
91+
session.iteration++
9092
if (session.testGenerationJobGroupName.isEmpty()) {
9193
session.testGenerationJobGroupName = UUID.randomUUID().toString()
9294
}
95+
val final = session.testGenerationJobGroupName
9396

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..."
100110

101111
val codeTestResponseContext = createUploadUrl(codeTestChatHelper, previousIterationContext)
102112
session.srcPayloadSize = codeTestResponseContext.payloadContext.srcPayloadSize
@@ -107,7 +117,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
107117
fileTooLarge()
108118
}
109119

110-
val createUploadUrlResponse = codeTestResponseContext.createUploadUrlResponse
120+
val createUploadUrlResponse = codeTestResponseContext.createUploadUrlResponse ?: return
111121
throwIfCancelled(session)
112122

113123
LOG.debug {
@@ -140,7 +150,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
140150
.build()
141151
),
142152
userInput = prompt,
143-
testGenerationJobGroupName = session.testGenerationJobGroupName
153+
testGenerationJobGroupName = final
144154
)
145155
delay(200)
146156
response?.testGenerationJob() != null
@@ -169,12 +179,11 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
169179
session.startTestGenerationRequestId = startTestGenerationResponse.responseMetadata().requestId()
170180
session.testGenerationJobGroupName = job.testGenerationJobGroupName()
171181
session.testGenerationJob = job.testGenerationJobId()
172-
session.listOfTestGenerationJobId += job.testGenerationJobId()
173182
throwIfCancelled(session)
174183

175184
// 3rd API call: Step 3: Polling mechanism on test job status with getTestGenStatus getTestGeneration
176185
var finished = false
177-
var testGenerationResponse: GetTestGenerationResponse?
186+
var testGenerationResponse: GetTestGenerationResponse? = null
178187

179188
var shortAnswer = ShortAnswer()
180189
LOG.debug {
@@ -266,8 +275,8 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
266275
}
267276
codeTestChatHelper.updateUI(
268277
promptInputDisabledState = true,
269-
promptInputProgress = if (session.listOfTestGenerationJobId.size == 1) {
270-
testGenProgressField(progressRate)
278+
promptInputProgress = if (session.iteration == 1) {
279+
testGenProgressField(0)
271280
} else {
272281
buildAndExecuteProgrogressField
273282
}
@@ -303,6 +312,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
303312
val result = byteArray.reduce { acc, next -> acc + next } // To map the result it is needed to combine the full byte array
304313
storeGeneratedTestDiffs(result, session)
305314
if (!session.isGeneratingTests) {
315+
// TODO: Modify text according to FnF
306316
codeTestChatHelper.addAnswer(
307317
CodeTestChatMessageContent(
308318
message = message("testgen.error.generic_technical_error_message"),
@@ -350,7 +360,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
350360
session.viewDiffMessageId = viewDiffMessageId
351361
codeTestChatHelper.updateUI(
352362
promptInputDisabledState = false,
353-
// promptInputPlaceholder = "Specify a function(s) in the current file(optional)",
363+
promptInputPlaceholder = "Specify a function(s) in the current file(optional)",
354364
promptInputProgress = testGenCompletedField,
355365
)
356366
} else {
@@ -476,7 +486,10 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
476486
} else {
477487
previousIterationContext.selectedFile
478488
}
479-
val codeTestSessionConfig = CodeTestSessionConfig(file, project, previousIterationContext?.buildLogFile)
489+
490+
val combinedBuildAndExecuteLogFile =
491+
previousIterationContext?.buildLogFile
492+
val codeTestSessionConfig = CodeTestSessionConfig(file, project, combinedBuildAndExecuteLogFile)
480493
codeTestChatHelper.getActiveSession().projectRoot = codeTestSessionConfig.projectRoot.path
481494

482495
val codeTestSessionContext = CodeTestSessionContext(project, codeTestSessionConfig)
@@ -574,7 +587,7 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
574587
canBeVoted = false
575588
)
576589
)
577-
if (session.listOfTestGenerationJobId.size < 2) {
590+
if (session.iteration == 1) {
578591
AmazonqTelemetry.utgGenerateTests(
579592
cwsprChatProgrammingLanguage = session.programmingLanguage.languageId,
580593
hasUserPromptSupplied = session.hasUserPromptSupplied,
@@ -611,10 +624,10 @@ class CodeWhispererUTGChatManager(val project: Project, private val cs: Coroutin
611624
requestId = session.startTestGenerationRequestId
612625
)
613626
}
627+
614628
session.isGeneratingTests = false
615629
} finally {
616630
// Reset the flow if there is any error
617-
codeTestChatHelper.sendUpdatePromptProgress(session.tabId, null)
618631
if (!session.isGeneratingTests) {
619632
codeTestChatHelper.updateUI(
620633
promptInputProgress = cancellingProgressField

0 commit comments

Comments
 (0)