Skip to content

Commit c153b02

Browse files
authored
feat(amazonq): "View Summary" button in chat #6270
## Problem A "View summary" button was missing in the chat, which made it difficult for users to re-open their transformation summary once they closed it. ## Solution Add the button.
1 parent 060b0a0 commit c153b02

File tree

8 files changed

+56
-14
lines changed

8 files changed

+56
-14
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": "Amazon Q Code Transformation: add view summary button in chat"
4+
}

packages/amazonq/test/e2e/amazonq/transformByQ.test.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import assert from 'assert'
77
import { qTestingFramework } from './framework/framework'
88
import sinon from 'sinon'
99
import { Messenger } from './framework/messenger'
10-
import { JDKVersion, TransformationType, transformByQState } from 'aws-core-vscode/codewhisperer'
10+
import {
11+
CodeWhispererConstants,
12+
JDKVersion,
13+
TransformationType,
14+
transformByQState,
15+
} from 'aws-core-vscode/codewhisperer'
1116
import { GumbyController, setMaven, startTransformByQ, TabsStorage } from 'aws-core-vscode/amazonqGumby'
1217
import { using, registerAuthHook, TestFolder } from 'aws-core-vscode/test'
1318
import { loginToIdC } from './utils/setup'
@@ -153,6 +158,27 @@ describe('Amazon Q Code Transformation', function () {
153158
const jdkPathResponse = tab.getChatItems().pop()
154159
// this 'Sorry' message is OK - just making sure that the UI components are working correctly
155160
assert.strictEqual(jdkPathResponse?.body?.includes("Sorry, I couldn't locate your Java installation"), true)
161+
162+
const tmpDir = (await TestFolder.create()).path
163+
164+
transformByQState.setSummaryFilePath(path.join(tmpDir, 'summary.md'))
165+
166+
transformByQState
167+
.getChatMessenger()
168+
?.sendJobFinishedMessage(tab.tabID, CodeWhispererConstants.viewProposedChangesChatMessage)
169+
170+
tab.clickCustomFormButton({
171+
id: 'gumbyViewSummary',
172+
text: 'View summary',
173+
})
174+
175+
await tab.waitForEvent(() => tab.getChatItems().length > 14, {
176+
waitTimeoutInMs: 5000,
177+
waitIntervalInMs: 1000,
178+
})
179+
180+
const viewSummaryChatItem = tab.getChatItems().pop()
181+
assert.strictEqual(viewSummaryChatItem?.body?.includes('view a summary'), true)
156182
})
157183

158184
it('Can provide metadata file for a SQL conversion', async () => {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,9 @@ export class GumbyController {
395395
break
396396
case ButtonActions.VIEW_TRANSFORMATION_HUB:
397397
await vscode.commands.executeCommand(GumbyCommands.FOCUS_TRANSFORMATION_HUB, CancelActionPositions.Chat)
398-
this.messenger.sendJobSubmittedMessage(message.tabID)
398+
break
399+
case ButtonActions.VIEW_SUMMARY:
400+
await vscode.commands.executeCommand('aws.amazonq.transformationHub.summary.reveal')
399401
break
400402
case ButtonActions.STOP_TRANSFORMATION_JOB:
401403
await stopTransformByQ(transformByQState.getJobId())

packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ export class Messenger {
243243
mandatory: true,
244244
options: [
245245
{
246-
value: JDKVersion.JDK17.toString(),
247-
label: JDKVersion.JDK17.toString(),
246+
value: JDKVersion.JDK17,
247+
label: JDKVersion.JDK17,
248248
},
249249
],
250250
})
@@ -376,19 +376,20 @@ export class Messenger {
376376
) {
377377
const buttons: ChatItemButton[] = []
378378

379+
// don't show these buttons when server build fails
379380
if (!disableJobActions) {
380-
// Note: buttons can only be clicked once.
381-
// To get around this, we remove the card after it's clicked and then resubmit the message.
382381
buttons.push({
383382
keepCardAfterClick: true,
384383
text: CodeWhispererConstants.openTransformationHubButtonText,
385384
id: ButtonActions.VIEW_TRANSFORMATION_HUB,
385+
disabled: false, // allow button to be re-clicked
386386
})
387387

388388
buttons.push({
389389
keepCardAfterClick: true,
390390
text: CodeWhispererConstants.stopTransformationButtonText,
391391
id: ButtonActions.STOP_TRANSFORMATION_JOB,
392+
disabled: false,
392393
})
393394
}
394395

@@ -514,6 +515,16 @@ export class Messenger {
514515
keepCardAfterClick: false,
515516
text: CodeWhispererConstants.startTransformationButtonText,
516517
id: ButtonActions.CONFIRM_START_TRANSFORMATION_FLOW,
518+
disabled: false,
519+
})
520+
}
521+
522+
if (transformByQState.getSummaryFilePath()) {
523+
buttons.push({
524+
keepCardAfterClick: true,
525+
text: CodeWhispererConstants.viewSummaryButtonText,
526+
id: ButtonActions.VIEW_SUMMARY,
527+
disabled: false,
517528
})
518529
}
519530

packages/core/src/amazonqGumby/chat/controller/messenger/messengerUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import DependencyVersions from '../../../models/dependencies'
1313
export enum ButtonActions {
1414
STOP_TRANSFORMATION_JOB = 'gumbyStopTransformationJob',
1515
VIEW_TRANSFORMATION_HUB = 'gumbyViewTransformationHub',
16+
VIEW_SUMMARY = 'gumbyViewSummary',
1617
CONFIRM_LANGUAGE_UPGRADE_TRANSFORMATION_FORM = 'gumbyLanguageUpgradeTransformFormConfirm',
1718
CONFIRM_SQL_CONVERSION_TRANSFORMATION_FORM = 'gumbySQLConversionTransformFormConfirm',
1819
CANCEL_TRANSFORMATION_FORM = 'gumbyTransformFormCancel', // shared between Language Upgrade & SQL Conversion

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as fs from 'fs' // eslint-disable-line no-restricted-imports
88
import path from 'path'
99
import { getLogger } from '../../shared/logger'
1010
import * as CodeWhispererConstants from '../models/constants'
11+
import * as localizedText from '../../shared/localizedText'
1112
import {
1213
transformByQState,
1314
StepProgress,
@@ -233,7 +234,7 @@ export async function preTransformationUploadCode() {
233234
await vscode.commands.executeCommand('aws.amazonq.transformationHub.focus')
234235

235236
void vscode.window.showInformationMessage(CodeWhispererConstants.jobStartedNotification, {
236-
title: CodeWhispererConstants.jobStartedTitle,
237+
title: localizedText.ok,
237238
})
238239

239240
let uploadId = ''
@@ -750,7 +751,7 @@ export async function postTransformationJob() {
750751

751752
if (transformByQState.isSucceeded()) {
752753
void vscode.window.showInformationMessage(CodeWhispererConstants.jobCompletedNotification(diffMessage), {
753-
title: CodeWhispererConstants.transformationCompletedTitle,
754+
title: localizedText.ok,
754755
})
755756
} else if (transformByQState.isPartiallySucceeded()) {
756757
void vscode.window

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -554,15 +554,15 @@ export const noOngoingJobMessage = 'No ongoing job.'
554554

555555
export const nothingToShowMessage = 'Nothing to show'
556556

557-
export const jobStartedTitle = 'Transformation started'
558-
559557
export const jobStartedNotification =
560558
'Amazon Q is transforming your code. It can take 10 to 30 minutes to upgrade your code, depending on the size of your project. To monitor progress, go to the Transformation Hub.'
561559

562560
export const openTransformationHubButtonText = 'Open Transformation Hub'
563561

564562
export const startTransformationButtonText = 'Start a new transformation'
565563

564+
export const viewSummaryButtonText = 'View summary'
565+
566566
export const stopTransformationButtonText = 'Stop transformation'
567567

568568
export const checkingForProjectsChatMessage = 'Checking for eligible projects...'
@@ -638,8 +638,6 @@ export const jobCancelledChatMessage =
638638

639639
export const jobCancelledNotification = 'You cancelled the transformation.'
640640

641-
export const transformationCompletedTitle = 'Transformation complete'
642-
643641
export const diffMessage = (multipleDiffs: boolean) => {
644642
return multipleDiffs
645643
? 'You can review the diffs to see my proposed changes and accept or reject them. You will be able to accept changes from one diff at a time. If you reject changes in one diff, you will not be able to view or accept changes in the other diffs.'

packages/core/src/codewhisperer/service/transformByQ/transformationResultsViewProvider.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,11 @@ export class ProposedTransformationExplorer {
365365
})
366366

367367
vscode.commands.registerCommand('aws.amazonq.transformationHub.summary.reveal', async () => {
368-
if (transformByQState.getSummaryFilePath() !== '') {
368+
if (fs.existsSync(transformByQState.getSummaryFilePath())) {
369369
await vscode.commands.executeCommand(
370370
'markdown.showPreview',
371371
vscode.Uri.file(transformByQState.getSummaryFilePath())
372372
)
373-
telemetry.ui_click.emit({ elementId: 'transformationHub_viewSummary' })
374373
}
375374
})
376375

0 commit comments

Comments
 (0)