Skip to content

Commit 75d16a7

Browse files
committed
addressing comments from PR and adding feature flag
1 parent d57d3f8 commit 75d16a7

File tree

6 files changed

+32
-44
lines changed

6 files changed

+32
-44
lines changed

packages/amazonq/.changes/next-release/Feature-735529a9-8424-4f78-9989-58ec972af100.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/amazonq/test/unit/amazonqGumby/transformationResultsHandler.test.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@ import assert from 'assert'
66
import sinon from 'sinon'
77
import { DiffModel, AddedChangeNode, ModifiedChangeNode } from 'aws-core-vscode/codewhisperer/node'
88
import { DescriptionContent } from 'aws-core-vscode/codewhisperer'
9-
import path from 'path'
109
import { getTestResourceFilePath } from './amazonQGumbyUtil'
1110
import { fs } from 'aws-core-vscode/shared'
1211
import { createTestWorkspace } from 'aws-core-vscode/test'
1312

1413
describe('DiffModel', function () {
1514
let parsedTestDescriptions: DescriptionContent
16-
beforeEach(() => {
17-
const fs = require('fs')
18-
parsedTestDescriptions = JSON.parse(
19-
fs.readFileSync(getTestResourceFilePath('resources/files/diff.json'), 'utf-8')
20-
)
15+
beforeEach(async () => {
16+
parsedTestDescriptions = JSON.parse(await fs.readFileText(getTestResourceFilePath('resources/files/diff.json')))
2117
})
2218

2319
afterEach(() => {
@@ -60,13 +56,6 @@ describe('DiffModel', function () {
6056
const fileAmount = 1
6157
const workspaceFolder = await createTestWorkspace(fileAmount, { fileContent: '' })
6258

63-
sinon.replace(fs, 'exists', async (path) => true)
64-
65-
await fs.writeFile(
66-
path.join(workspaceFolder.uri.fsPath, 'README.md'),
67-
'This guide walks you through using Gradle to build a simple Java project.'
68-
)
69-
7059
testDiffModel.parseDiff(
7160
getTestResourceFilePath('resources/files/modifiedFile.diff'),
7261
workspaceFolder.uri.fsPath,
@@ -90,13 +79,6 @@ describe('DiffModel', function () {
9079
const fileAmount = 1
9180
const workspaceFolder = await createTestWorkspace(fileAmount, { fileContent: '' })
9281

93-
sinon.replace(fs, 'exists', async (path) => true)
94-
95-
await fs.writeFile(
96-
path.join(workspaceFolder.uri.fsPath, 'README.md'),
97-
'This guide walks you through using Gradle to build a simple Java project.'
98-
)
99-
10082
testDiffModel.parseDiff(
10183
getTestResourceFilePath('resources/files/modifiedFile.diff'),
10284
workspaceFolder.uri.fsPath,

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import { getStringHash } from '../../../shared/utilities/textUtilities'
6262
import { getVersionData } from '../../../codewhisperer/service/transformByQ/transformMavenHandler'
6363
import AdmZip from 'adm-zip'
6464
import { AuthError } from '../../../auth/sso/server'
65-
import { isSQLTransformReady } from '../../../dev/config'
65+
import { isSelectiveTransformationReady, isSQLTransformReady } from '../../../dev/config'
6666

6767
// These events can be interactions within the chat,
6868
// or elsewhere in the IDE
@@ -408,7 +408,12 @@ export class GumbyController {
408408
result: MetadataResult.Pass,
409409
})
410410
this.messenger.sendSkipTestsSelectionMessage(skipTestsSelection, message.tabID)
411-
await this.messenger.sendOneOrMultipleDiffsPrompt(message.tabID)
411+
if (!isSelectiveTransformationReady) {
412+
// perform local build
413+
await this.validateBuildWithPromptOnError(message)
414+
} else {
415+
await this.messenger.sendOneOrMultipleDiffsPrompt(message.tabID)
416+
}
412417
}
413418

414419
private async handleOneOrMultipleDiffs(message: any) {

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { DescriptionContent } from '..'
7-
86
/**
97
* Automated and manual trigger
108
*/
@@ -35,8 +33,8 @@ const patchDescriptions: { [key: string]: string } = {
3533
'This diff patch covers the set of upgrades for ArchUnit, Mockito, TestContainers, Cucumber, and additionally, Jenkins plugins and the Maven Wrapper.',
3634
'Miscellaneous Processing Documentation upgrade':
3735
'This diff patch covers a diverse set of upgrades spanning ORMs, XML processing, API documentation, and more.',
38-
'Upgrade Deprecated API': '',
39-
'Updated dependencies to latest version': '',
36+
'Deprecated API replacement and dependency upgrades':
37+
'This diff patch replaces deprecated APIs and makes additional dependency version upgrades.',
4038
}
4139

4240
export const JsonConfigFileNamingConvention = new Set([
@@ -479,6 +477,8 @@ I can now divide the transformation results into diff patches (if applicable to
479477
• Testing Tools Frameworks: Testing tools like ArchUnit, Mockito, and TestContainers and build tools like Jenkins and Maven Wrapper.
480478
481479
• Miscellaneous Processing Documentation: Upgrades ORMs, XML processing, and Swagger to SpringDoc/OpenAPI.
480+
481+
• Deprecated API replacement and dependency upgrades: Replaces deprecated APIs and makes additional dependency version upgrades.
482482
`
483483

484484
export const uploadingCodeStepMessage = 'Upload your code'
@@ -616,19 +616,19 @@ export const diffMessage = (multipleDiffs: boolean) => {
616616
}
617617

618618
export const jobCompletedChatMessage = (multipleDiffsString: string) => {
619-
return `I upgraded your code. ${multipleDiffsString} The transformation summary has details about the files I updated.`
619+
return `I transformed your code. ${multipleDiffsString} The transformation summary has details about the files I updated.`
620620
}
621621

622622
export const jobCompletedNotification = (multipleDiffsString: string) => {
623-
return `Amazon Q upgraded your code. ${multipleDiffsString} The transformation summary has details about the files I updated.`
623+
return `Amazon Q transformed your code. ${multipleDiffsString} The transformation summary has details about the files I updated.`
624624
}
625625

626626
export const jobPartiallyCompletedChatMessage = (multipleDiffsString: string) => {
627-
return `I upgraded part of your code. ${multipleDiffsString} The transformation summary has details about the files I updated and the errors that prevented a complete transformation.`
627+
return `I transformed part of your code. ${multipleDiffsString} The transformation summary has details about the files I updated and the errors that prevented a complete transformation.`
628628
}
629629

630630
export const jobPartiallyCompletedNotification = (multipleDiffsString: string) => {
631-
return `Amazon Q upgraded part of your code. ${multipleDiffsString} The transformation summary has details about the files I updated and the errors that prevented a complete transformation.`
631+
return `Amazon Q transformed part of your code. ${multipleDiffsString} The transformation summary has details about the files I updated and the errors that prevented a complete transformation.`
632632
}
633633

634634
export const noPomXmlFoundChatMessage = `I couldn\'t find a project that I can upgrade. Your Java project must be built on Maven and contain a pom.xml file. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
@@ -680,14 +680,13 @@ export const changesAppliedChatMessageMultipleDiffs = (
680680

681681
export const changesAppliedNotificationOneDiff = 'Amazon Q applied the changes to your project'
682682

683-
export const changesAppliedNotificationMultipleDiffs = (
684-
currentPatchIndex: number,
685-
totalPatchFiles: number,
686-
patchFilesDescriptions: DescriptionContent | undefined
687-
) =>
688-
patchFilesDescriptions
689-
? `Amazon Q applied the changes in diff patch ${currentPatchIndex + 1} of ${totalPatchFiles} to your project.`
690-
: 'Amazon Q applied the changes to your project.'
683+
export const changesAppliedNotificationMultipleDiffs = (currentPatchIndex: number, totalPatchFiles: number) => {
684+
if (totalPatchFiles === 1) {
685+
return 'Amazon Q applied the changes to your project.'
686+
} else {
687+
return `Amazon Q applied the changes in diff patch ${currentPatchIndex + 1} of ${totalPatchFiles} to your project.`
688+
}
689+
}
691690

692691
export const noOpenProjectsFoundChatMessage = `I couldn\'t find a project that I can upgrade. Currently, I support Java 8, Java 11, and Java 17 projects built on Maven. Make sure your project is open in the IDE. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
693692

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,13 +527,16 @@ export class ProposedTransformationExplorer {
527527

528528
vscode.commands.registerCommand('aws.amazonq.transformationHub.reviewChanges.acceptChanges', async () => {
529529
diffModel.saveChanges()
530+
telemetry.codeTransform_submitSelection.emit({
531+
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
532+
userChoice: `acceptChanges-${patchFilesDescriptions?.content[diffModel.currentPatchIndex].name}`,
533+
})
530534
telemetry.ui_click.emit({ elementId: 'transformationHub_acceptChanges' })
531535
if (transformByQState.getMultipleDiffs()) {
532536
void vscode.window.showInformationMessage(
533537
CodeWhispererConstants.changesAppliedNotificationMultipleDiffs(
534538
diffModel.currentPatchIndex,
535-
patchFiles.length,
536-
patchFilesDescriptions
539+
patchFiles.length
537540
)
538541
)
539542
} else {

packages/core/src/dev/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ export const betaUrl = {
1313

1414
// feature flag for SQL transformations
1515
export const isSQLTransformReady = false
16+
17+
//feature flag for Selective Transformation
18+
export const isSelectiveTransformationReady = false

0 commit comments

Comments
 (0)