Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(amazonq): add view summary button in chat #6270

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "Amazon Q Code Transformation: add view summary button in chat"
}
17 changes: 17 additions & 0 deletions packages/amazonq/test/e2e/amazonq/transformByQ.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,23 @@ describe('Amazon Q Code Transformation', function () {
const jdkPathResponse = tab.getChatItems().pop()
// this 'Sorry' message is OK - just making sure that the UI components are working correctly
assert.strictEqual(jdkPathResponse?.body?.includes("Sorry, I couldn't locate your Java installation"), true)

const tmpDir = (await TestFolder.create()).path

transformByQState.setSummaryFilePath(path.join(tmpDir, 'summary.md'))

tab.clickCustomFormButton({
id: 'gumbyViewSummary',
text: 'View summary',
})

await tab.waitForEvent(() => tab.getChatItems().length > 14, {
waitTimeoutInMs: 5000,
waitIntervalInMs: 1000,
})

const viewSummaryChatItem = tab.getChatItems().pop()
assert.strictEqual(viewSummaryChatItem?.body?.includes('view a summary'), true)
})

it('Can provide metadata file for a SQL conversion', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,14 @@ export class GumbyController {
await vscode.commands.executeCommand(GumbyCommands.FOCUS_TRANSFORMATION_HUB, CancelActionPositions.Chat)
this.messenger.sendJobSubmittedMessage(message.tabID)
break
case ButtonActions.VIEW_SUMMARY:
await vscode.commands.executeCommand('aws.amazonq.transformationHub.summary.reveal')
this.transformationFinished({
message: CodeWhispererConstants.viewProposedChangesChatMessage,
tabID: message.tabID,
includeStartNewTransformationButton: true,
})
break
case ButtonActions.STOP_TRANSFORMATION_JOB:
await stopTransformByQ(transformByQState.getJobId())
await postTransformationJob()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ export class Messenger {
mandatory: true,
options: [
{
value: JDKVersion.JDK17.toString(),
label: JDKVersion.JDK17.toString(),
value: JDKVersion.JDK17,
label: JDKVersion.JDK17,
},
],
})
Expand Down Expand Up @@ -517,6 +517,14 @@ export class Messenger {
})
}

if (transformByQState.getSummaryFilePath()) {
buttons.push({
keepCardAfterClick: true,
text: CodeWhispererConstants.viewSummaryButtonText,
id: ButtonActions.VIEW_SUMMARY,
})
}

this.dispatcher.sendChatMessage(
new ChatMessage(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import DependencyVersions from '../../../models/dependencies'
export enum ButtonActions {
STOP_TRANSFORMATION_JOB = 'gumbyStopTransformationJob',
VIEW_TRANSFORMATION_HUB = 'gumbyViewTransformationHub',
VIEW_SUMMARY = 'gumbyViewSummary',
CONFIRM_LANGUAGE_UPGRADE_TRANSFORMATION_FORM = 'gumbyLanguageUpgradeTransformFormConfirm',
CONFIRM_SQL_CONVERSION_TRANSFORMATION_FORM = 'gumbySQLConversionTransformFormConfirm',
CANCEL_TRANSFORMATION_FORM = 'gumbyTransformFormCancel', // shared between Language Upgrade & SQL Conversion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as fs from 'fs' // eslint-disable-line no-restricted-imports
import path from 'path'
import { getLogger } from '../../shared/logger'
import * as CodeWhispererConstants from '../models/constants'
import * as localizedText from '../../shared/localizedText'
import {
transformByQState,
StepProgress,
Expand Down Expand Up @@ -233,7 +234,7 @@ export async function preTransformationUploadCode() {
await vscode.commands.executeCommand('aws.amazonq.transformationHub.focus')

void vscode.window.showInformationMessage(CodeWhispererConstants.jobStartedNotification, {
title: CodeWhispererConstants.jobStartedTitle,
title: localizedText.ok,
})

let uploadId = ''
Expand Down Expand Up @@ -750,7 +751,7 @@ export async function postTransformationJob() {

if (transformByQState.isSucceeded()) {
void vscode.window.showInformationMessage(CodeWhispererConstants.jobCompletedNotification(diffMessage), {
title: CodeWhispererConstants.transformationCompletedTitle,
title: localizedText.ok,
})
} else if (transformByQState.isPartiallySucceeded()) {
void vscode.window
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/codewhisperer/models/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,15 +554,15 @@ export const noOngoingJobMessage = 'No ongoing job.'

export const nothingToShowMessage = 'Nothing to show'

export const jobStartedTitle = 'Transformation started'

export const jobStartedNotification =
'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.'

export const openTransformationHubButtonText = 'Open Transformation Hub'

export const startTransformationButtonText = 'Start a new transformation'

export const viewSummaryButtonText = 'View summary'

export const stopTransformationButtonText = 'Stop transformation'

export const checkingForProjectsChatMessage = 'Checking for eligible projects...'
Expand Down Expand Up @@ -638,8 +638,6 @@ export const jobCancelledChatMessage =

export const jobCancelledNotification = 'You cancelled the transformation.'

export const transformationCompletedTitle = 'Transformation complete'

export const diffMessage = (multipleDiffs: boolean) => {
return multipleDiffs
? '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.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ export class ProposedTransformationExplorer {
'markdown.showPreview',
vscode.Uri.file(transformByQState.getSummaryFilePath())
)
telemetry.ui_click.emit({ elementId: 'transformationHub_viewSummary' })
}
})

Expand Down
Loading