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

Merged
merged 6 commits into from
Dec 31, 2024
Merged
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"
}
28 changes: 27 additions & 1 deletion packages/amazonq/test/e2e/amazonq/transformByQ.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import assert from 'assert'
import { qTestingFramework } from './framework/framework'
import sinon from 'sinon'
import { Messenger } from './framework/messenger'
import { JDKVersion, TransformationType, transformByQState } from 'aws-core-vscode/codewhisperer'
import {
CodeWhispererConstants,
JDKVersion,
TransformationType,
transformByQState,
} from 'aws-core-vscode/codewhisperer'
import { GumbyController, setMaven, startTransformByQ, TabsStorage } from 'aws-core-vscode/amazonqGumby'
import { using, registerAuthHook, TestFolder } from 'aws-core-vscode/test'
import { loginToIdC } from './utils/setup'
Expand Down Expand Up @@ -153,6 +158,27 @@ 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'))

transformByQState
.getChatMessenger()
?.sendJobFinishedMessage(tab.tabID, CodeWhispererConstants.viewProposedChangesChatMessage)

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 @@ -383,7 +383,9 @@ export class GumbyController {
break
case ButtonActions.VIEW_TRANSFORMATION_HUB:
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')
break
case ButtonActions.STOP_TRANSFORMATION_JOB:
await stopTransformByQ(transformByQState.getJobId())
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 @@ -376,19 +376,20 @@ export class Messenger {
) {
const buttons: ChatItemButton[] = []

// don't show these buttons when server build fails
if (!disableJobActions) {
// Note: buttons can only be clicked once.
// To get around this, we remove the card after it's clicked and then resubmit the message.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not true. We can set disabled: false to allow buttons to be re-clicked, removing the need to call sendJobSubmittedMessage redundantly on line 386 in the file above.

buttons.push({
keepCardAfterClick: true,
text: CodeWhispererConstants.openTransformationHubButtonText,
id: ButtonActions.VIEW_TRANSFORMATION_HUB,
disabled: false, // allow button to be re-clicked
})

buttons.push({
keepCardAfterClick: true,
text: CodeWhispererConstants.stopTransformationButtonText,
id: ButtonActions.STOP_TRANSFORMATION_JOB,
disabled: false,
})
}

Expand Down Expand Up @@ -514,6 +515,16 @@ export class Messenger {
keepCardAfterClick: false,
text: CodeWhispererConstants.startTransformationButtonText,
id: ButtonActions.CONFIRM_START_TRANSFORMATION_FLOW,
disabled: false,
})
}

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

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 @@ -365,12 +365,11 @@ export class ProposedTransformationExplorer {
})

vscode.commands.registerCommand('aws.amazonq.transformationHub.summary.reveal', async () => {
if (transformByQState.getSummaryFilePath() !== '') {
if (fs.existsSync(transformByQState.getSummaryFilePath())) {
await vscode.commands.executeCommand(
'markdown.showPreview',
vscode.Uri.file(transformByQState.getSummaryFilePath())
)
telemetry.ui_click.emit({ elementId: 'transformationHub_viewSummary' })
}
})

Expand Down
Loading