Skip to content

Commit eaee37d

Browse files
committed
Merge branch 'master' into fix-unreliable-test
2 parents 557a823 + c153b02 commit eaee37d

File tree

10 files changed

+95
-36
lines changed

10 files changed

+95
-36
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "/transform: use correct documentation link in SQL conversion help message"
4+
}
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: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -269,29 +269,41 @@ export class GumbyController {
269269
}
270270

271271
private async handleLanguageUpgrade(message: any) {
272-
try {
273-
await this.beginTransformation(message)
274-
const validProjects = await this.validateLanguageUpgradeProjects(message)
275-
if (validProjects.length > 0) {
276-
this.sessionStorage.getSession().updateCandidateProjects(validProjects)
277-
await this.messenger.sendLanguageUpgradeProjectPrompt(validProjects, message.tabID)
278-
}
279-
} catch (err: any) {
280-
getLogger().error(`Error handling language upgrade: ${err}`)
281-
}
272+
await telemetry.codeTransform_submitSelection
273+
.run(async () => {
274+
telemetry.record({
275+
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
276+
userChoice: 'language upgrade',
277+
})
278+
await this.beginTransformation(message)
279+
const validProjects = await this.validateLanguageUpgradeProjects(message)
280+
if (validProjects.length > 0) {
281+
this.sessionStorage.getSession().updateCandidateProjects(validProjects)
282+
await this.messenger.sendLanguageUpgradeProjectPrompt(validProjects, message.tabID)
283+
}
284+
})
285+
.catch((err) => {
286+
getLogger().error(`Error handling language upgrade: ${err}`)
287+
})
282288
}
283289

284290
private async handleSQLConversion(message: any) {
285-
try {
286-
await this.beginTransformation(message)
287-
const validProjects = await this.validateSQLConversionProjects(message)
288-
if (validProjects.length > 0) {
289-
this.sessionStorage.getSession().updateCandidateProjects(validProjects)
290-
await this.messenger.sendSelectSQLMetadataFileMessage(message.tabID)
291-
}
292-
} catch (err: any) {
293-
getLogger().error(`Error handling SQL conversion: ${err}`)
294-
}
291+
await telemetry.codeTransform_submitSelection
292+
.run(async () => {
293+
telemetry.record({
294+
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
295+
userChoice: 'sql conversion',
296+
})
297+
await this.beginTransformation(message)
298+
const validProjects = await this.validateSQLConversionProjects(message)
299+
if (validProjects.length > 0) {
300+
this.sessionStorage.getSession().updateCandidateProjects(validProjects)
301+
await this.messenger.sendSelectSQLMetadataFileMessage(message.tabID)
302+
}
303+
})
304+
.catch((err) => {
305+
getLogger().error(`Error handling SQL conversion: ${err}`)
306+
})
295307
}
296308

297309
private async validateLanguageUpgradeProjects(message: any) {
@@ -383,7 +395,9 @@ export class GumbyController {
383395
break
384396
case ButtonActions.VIEW_TRANSFORMATION_HUB:
385397
await vscode.commands.executeCommand(GumbyCommands.FOCUS_TRANSFORMATION_HUB, CancelActionPositions.Chat)
386-
this.messenger.sendJobSubmittedMessage(message.tabID)
398+
break
399+
case ButtonActions.VIEW_SUMMARY:
400+
await vscode.commands.executeCommand('aws.amazonq.transformationHub.summary.reveal')
387401
break
388402
case ButtonActions.STOP_TRANSFORMATION_JOB:
389403
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/client/codewhisperer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ export class DefaultCodeWhispererClient {
318318
public async codeModernizerGetCodeTransformationPlan(
319319
request: CodeWhispererUserClient.GetTransformationPlanRequest
320320
): Promise<PromiseResult<CodeWhispererUserClient.GetTransformationPlanResponse, AWSError>> {
321-
return (await this.createUserSdkClient()).getTransformationPlan(request).promise()
321+
// instead of the default of 3 retries, use 8 retries for this API which is polled every 5 seconds
322+
return (await this.createUserSdkClient(8)).getTransformationPlan(request).promise()
322323
}
323324

324325
public async startCodeFixJob(

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: 3 additions & 5 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...'
@@ -579,7 +579,7 @@ export const absolutePathDetectedMessage = (numPaths: number, buildFile: string,
579579
`I detected ${numPaths} potential absolute file path(s) in your ${buildFile} file: **${listOfPaths}**. Absolute file paths might cause issues when I build your code. Any errors will show up in the build log.`
580580

581581
export const selectSQLMetadataFileHelpMessage =
582-
'Okay, I can convert the embedded SQL code for your Oracle to PostgreSQL transformation. To get started, upload the zipped metadata file from your schema conversion in AWS Data Migration Service (DMS). To retrieve the metadata file:\n1. Open your database migration project in the AWS DMS console.\n2. Open the schema conversion and choose **Convert the embedded SQL in your application**.\n3. Once you complete the conversion, close the project and go to the S3 bucket where your project is stored.\n4. Open the folder and find the project folder ("sct-project").\n5. Download the object inside the project folder. This will be a zip file.\n\nFor more info, refer to the [documentation](https://docs.aws.amazon.com/dms/latest/userguide/schema-conversion-save-apply.html#schema-conversion-save).'
582+
'Okay, I can convert the embedded SQL code for your Oracle to PostgreSQL transformation. To get started, upload the zipped metadata file from your schema conversion in AWS Data Migration Service (DMS). To retrieve the metadata file:\n1. Open your database migration project in the AWS DMS console.\n2. Open the schema conversion and choose **Convert the embedded SQL in your application**.\n3. Once you complete the conversion, close the project and go to the S3 bucket where your project is stored.\n4. Open the folder and find the project folder ("sct-project").\n5. Download the object inside the project folder. This will be a zip file.\n\nFor more info, refer to the [documentation](https://docs.aws.amazon.com/dms/latest/userguide/schema-conversion-embedded-sql.html).'
583583

584584
export const invalidMetadataFileUnsupportedSourceDB =
585585
'I can only convert SQL for migrations from an Oracle source database. The provided .sct file indicates another source database for this migration.'
@@ -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)