Skip to content

Commit d0b4754

Browse files
committed
UX Changes
1 parent f38bb48 commit d0b4754

File tree

4 files changed

+41
-52
lines changed

4 files changed

+41
-52
lines changed

packages/core/src/amazonqTest/chat/controller/controller.ts

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
testGenProgressField,
2323
testGenSummaryMessage,
2424
maxUserPromptLength,
25+
fixingTestProgressField,
2526
} from '../../models/constants'
2627
import MessengerUtils, { ButtonActions } from './messenger/messengerUtils'
2728
import { getTelemetryReasonDesc, isAwsError } from '../../../shared/errors'
@@ -377,6 +378,7 @@ export class TestController {
377378
break
378379
case ButtonActions.STOP_BUILD:
379380
cancelBuild()
381+
testGenState.setToCancelling()
380382
void this.handleUpdatePromptProgress({ status: 'cancel', tabID: data.tabID })
381383
telemetry.ui_click.emit({ elementId: 'unitTestGeneration_cancelBuildProgress' })
382384
this.messenger.sendChatInputEnabled(data.tabID, true)
@@ -433,12 +435,6 @@ export class TestController {
433435
)
434436
return
435437
}
436-
if (testGenState.isCancelling()) {
437-
void vscode.window.showInformationMessage(
438-
'There is a test generation job being cancelled. Please wait for cancellation to finish.'
439-
)
440-
return
441-
}
442438
// Truncating the user prompt if the prompt is more than 4096.
443439
userPrompt = message.prompt.slice(0, maxUserPromptLength)
444440

@@ -1235,6 +1231,7 @@ export class TestController {
12351231
canBeVoted: false,
12361232
messageId: TestNamedMessages.TEST_GENERATION_BUILD_STATUS_MESSAGE,
12371233
})
1234+
this.messenger.sendUpdatePromptProgress(data.tabID, fixingTestProgressField)
12381235
await startTestGenerationProcess(session.sourceFilePath, '', data.tabID, false)
12391236
}
12401237
// TODO: Skip this if startTestGenerationProcess timeouts
@@ -1261,24 +1258,6 @@ export class TestController {
12611258
})
12621259
}
12631260

1264-
this.messenger.sendBuildProgressMessage({
1265-
tabID: data.tabID,
1266-
messageType: 'answer-part',
1267-
codeGenerationId: TestNamedMessages.TEST_GENERATION_BUILD_STATUS_MESSAGE,
1268-
message: testGenBuildProgressMessage(TestGenerationBuildStep.PROCESS_TEST_RESULTS, 'current'),
1269-
canBeVoted: false,
1270-
messageId: TestNamedMessages.TEST_GENERATION_BUILD_STATUS_MESSAGE,
1271-
})
1272-
1273-
this.messenger.sendBuildProgressMessage({
1274-
tabID: data.tabID,
1275-
messageType: 'answer-part',
1276-
codeGenerationId: TestNamedMessages.TEST_GENERATION_BUILD_STATUS_MESSAGE,
1277-
message: testGenBuildProgressMessage(TestGenerationBuildStep.PROCESS_TEST_RESULTS, 'done'),
1278-
canBeVoted: false,
1279-
messageId: TestNamedMessages.TEST_GENERATION_BUILD_STATUS_MESSAGE,
1280-
})
1281-
12821261
const followUps: FollowUps = {
12831262
text: '',
12841263
options: [

packages/core/src/amazonqTest/models/constants.ts

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ export const buildProgressField: ProgressField = {
5353
actions: [cancelBuildProgressButton],
5454
}
5555

56+
export const fixingTestProgressField: ProgressField = {
57+
status: 'default',
58+
value: -1,
59+
text: 'Fixing test failures...',
60+
actions: [cancelBuildProgressButton],
61+
}
62+
5663
export const errorProgressField: ProgressField = {
5764
status: 'error',
5865
text: 'Error...Input needed',
@@ -70,8 +77,8 @@ ${planSummary ? `\n\n${planSummary}` : ''}
7077
`
7178

7279
const checkIcons = {
73-
wait: '☐',
74-
current: '☐',
80+
wait: '⏳',
81+
current: '⏳',
7582
done: '<span style="color: green;">&#10004;</span>',
7683
error: '&#10060;',
7784
}
@@ -85,8 +92,6 @@ const stepStatuses: StepStatus[] = []
8592

8693
export const testGenBuildProgressMessage = (currentStep: TestGenerationBuildStep, status?: string) => {
8794
const session = ChatSessionManager.Instance.getSession()
88-
const statusText = BuildStatus[session.buildStatus].toLowerCase()
89-
const icon = session.buildStatus === BuildStatus.SUCCESS ? checkIcons['done'] : checkIcons['error']
9095
let message = `Sure. This may take a few minutes and I'll update the progress here.\n
9196
**Progress summary**\n\n`
9297

@@ -114,32 +119,35 @@ export const testGenBuildProgressMessage = (currentStep: TestGenerationBuildStep
114119
currentStep >= TestGenerationBuildStep.FIXING_TEST_CASES &&
115120
session.buildStatus === BuildStatus.FAILURE
116121
) {
117-
message += `${getIconForStep(TestGenerationBuildStep.FIXING_TEST_CASES)} Fixed test failures\n\n`
122+
message += `${checkIcons['done']} Fixed test failures\n\n`
118123
}
119124

120-
if (currentStep > TestGenerationBuildStep.PROCESS_TEST_RESULTS) {
121-
message += `**Test case summary**
122-
${session.shortAnswer?.testCoverage ? `- Unit test coverage ${session.shortAnswer?.testCoverage}%` : ``}
123-
${icon} Build ${statusText}
124-
${icon} Assertion ${statusText}`
125-
// TODO: Update Assertion %
125+
if (currentStep > TestGenerationBuildStep.PROCESS_TEST_RESULTS && session.buildStatus === BuildStatus.FAILURE) {
126+
message += `**Results**\n
127+
Amazon Q executed the tests and identified at least one failure. Below are the suggested fixes.\n\n`
126128
}
127129

128130
return message.trim()
129131
}
130-
// TODO: Work on UX to show the build error in the progress message
132+
131133
const updateStepStatuses = (currentStep: TestGenerationBuildStep, status?: string) => {
134+
const session = ChatSessionManager.Instance.getSession()
132135
for (let step = TestGenerationBuildStep.INSTALL_DEPENDENCIES; step <= currentStep; step++) {
133136
const stepStatus: StepStatus = {
134137
step: step,
135138
status: 'wait',
136139
}
137140

138-
if (step === currentStep) {
139-
stepStatus.status = status === 'failed' ? 'error' : 'current'
140-
} else if (step < currentStep) {
141-
stepStatus.status = 'done'
142-
}
141+
stepStatus.status =
142+
step === currentStep
143+
? status === 'error' || status === 'done'
144+
? status
145+
: 'current'
146+
: step < currentStep
147+
? session.buildStatus === BuildStatus.FAILURE
148+
? 'error'
149+
: 'done'
150+
: stepStatus.status
143151

144152
const existingIndex = stepStatuses.findIndex((s) => s.step === step)
145153
if (existingIndex !== -1) {

packages/core/src/codewhisperer/commands/startTestGeneration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export async function startTestGenerationProcess(
4444
logger.verbose(`Tab ID mismatch: ${tabID} !== ${session.tabID}`)
4545
return
4646
}
47+
testGenState.setToNotStarted()
4748
/**
4849
* Step 1: Zip the project
4950
*/

packages/core/src/codewhisperer/service/testGenHandler.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import fs from '../../shared/fs/fs'
4141
export function throwIfCancelled() {
4242
// TODO: fileName will be '' if user gives propt without opening
4343
if (testGenState.isCancelling()) {
44+
testGenState.setToNotStarted()
4445
throw new TestGenStoppedError()
4546
}
4647
}
@@ -151,11 +152,13 @@ export async function pollTestJobStatus(
151152
logger.debug('pollTestJobStatus testGenerationJob %O', resp.testGenerationJob)
152153
ChatSessionManager.Instance.getSession().testGenerationJob = resp.testGenerationJob
153154
const progressRate = resp.testGenerationJob?.progressRate ?? 0
154-
testGenState.getChatControllers()?.sendUpdatePromptProgress.fire({
155-
tabID: ChatSessionManager.Instance.getSession().tabID,
156-
status: 'InProgress',
157-
progressRate,
158-
})
155+
if (initialExecution) {
156+
testGenState.getChatControllers()?.sendUpdatePromptProgress.fire({
157+
tabID: ChatSessionManager.Instance.getSession().tabID,
158+
status: 'InProgress',
159+
progressRate,
160+
})
161+
}
159162
const shortAnswerString = resp.testGenerationJob?.shortAnswer
160163
if (shortAnswerString) {
161164
const parsedShortAnswer = JSON.parse(shortAnswerString)
@@ -253,13 +256,11 @@ export async function exportResultsArchive(
253256
filePath: testFilePath,
254257
projectName,
255258
})
256-
257-
// If User accepts the diff
258-
testGenState.getChatControllers()?.sendUpdatePromptProgress.fire({
259-
tabID: ChatSessionManager.Instance.getSession().tabID,
260-
status: 'Completed',
261-
})
262259
}
260+
testGenState.getChatControllers()?.sendUpdatePromptProgress.fire({
261+
tabID: ChatSessionManager.Instance.getSession().tabID,
262+
status: 'Completed',
263+
})
263264
} catch (e) {
264265
session.numberOfTestsGenerated = 0
265266
downloadErrorMessage = (e as Error).message

0 commit comments

Comments
 (0)