Skip to content

Commit 7b85bfb

Browse files
committed
addressing comments from PR and adding feature flag
1 parent 9342606 commit 7b85bfb

File tree

6 files changed

+32
-43
lines changed

6 files changed

+32
-43
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +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 { isSelectiveTransformationReady } from '../../../dev/config'
6566

6667
// These events can be interactions within the chat,
6768
// or elsewhere in the IDE
@@ -423,7 +424,12 @@ export class GumbyController {
423424
result: MetadataResult.Pass,
424425
})
425426
this.messenger.sendSkipTestsSelectionMessage(skipTestsSelection, message.tabID)
426-
await this.messenger.sendOneOrMultipleDiffsPrompt(message.tabID)
427+
if (!isSelectiveTransformationReady) {
428+
// perform local build
429+
await this.validateBuildWithPromptOnError(message)
430+
} else {
431+
await this.messenger.sendOneOrMultipleDiffsPrompt(message.tabID)
432+
}
427433
}
428434

429435
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([
@@ -483,6 +481,8 @@ I can now divide the transformation results into diff patches (if applicable to
483481
• Testing Tools Frameworks: Testing tools like ArchUnit, Mockito, and TestContainers and build tools like Jenkins and Maven Wrapper.
484482
485483
• Miscellaneous Processing Documentation: Upgrades ORMs, XML processing, and Swagger to SpringDoc/OpenAPI.
484+
485+
• Deprecated API replacement and dependency upgrades: Replaces deprecated APIs and makes additional dependency version upgrades.
486486
`
487487

488488
export const uploadingCodeStepMessage = 'Upload your code'
@@ -621,19 +621,19 @@ export const diffMessage = (multipleDiffs: boolean) => {
621621
}
622622

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

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

631631
export const jobPartiallyCompletedChatMessage = (multipleDiffsString: string) => {
632-
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.`
632+
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.`
633633
}
634634

635635
export const jobPartiallyCompletedNotification = (multipleDiffsString: string) => {
636-
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.`
636+
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.`
637637
}
638638

639639
export const noPomXmlFoundChatMessage = `I couldn\'t find a project that I can upgrade. I couldn\'t find a pom.xml file in any of your open projects, nor could I find any embedded SQL statements. Currently, I can upgrade Java 8 or Java 11 projects built on Maven, or Oracle SQL to PostgreSQL statements in Java projects. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
@@ -685,14 +685,13 @@ export const changesAppliedChatMessageMultipleDiffs = (
685685

686686
export const changesAppliedNotificationOneDiff = 'Amazon Q applied the changes to your project'
687687

688-
export const changesAppliedNotificationMultipleDiffs = (
689-
currentPatchIndex: number,
690-
totalPatchFiles: number,
691-
patchFilesDescriptions: DescriptionContent | undefined
692-
) =>
693-
patchFilesDescriptions
694-
? `Amazon Q applied the changes in diff patch ${currentPatchIndex + 1} of ${totalPatchFiles} to your project.`
695-
: 'Amazon Q applied the changes to your project.'
688+
export const changesAppliedNotificationMultipleDiffs = (currentPatchIndex: number, totalPatchFiles: number) => {
689+
if (totalPatchFiles === 1) {
690+
return 'Amazon Q applied the changes to your project.'
691+
} else {
692+
return `Amazon Q applied the changes in diff patch ${currentPatchIndex + 1} of ${totalPatchFiles} to your project.`
693+
}
694+
}
696695

697696
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}).`
698697

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

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

534534
vscode.commands.registerCommand('aws.amazonq.transformationHub.reviewChanges.acceptChanges', async () => {
535535
diffModel.saveChanges()
536+
telemetry.codeTransform_submitSelection.emit({
537+
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
538+
userChoice: `acceptChanges-${patchFilesDescriptions?.content[diffModel.currentPatchIndex].name}`,
539+
})
536540
telemetry.ui_click.emit({ elementId: 'transformationHub_acceptChanges' })
537541
if (transformByQState.getMultipleDiffs()) {
538542
void vscode.window.showInformationMessage(
539543
CodeWhispererConstants.changesAppliedNotificationMultipleDiffs(
540544
diffModel.currentPatchIndex,
541-
patchFiles.length,
542-
patchFilesDescriptions
545+
patchFiles.length
543546
)
544547
)
545548
} else {

packages/core/src/dev/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ export const betaUrl = {
1010
amazonq: '',
1111
toolkit: '',
1212
}
13+
14+
//feature flag for Selective Transformation
15+
export const isSelectiveTransformationReady = false

0 commit comments

Comments
 (0)