Skip to content

Commit 165a060

Browse files
Merge master into feature/flare-mega
2 parents 813efa0 + 196de6f commit 165a060

File tree

13 files changed

+154
-405
lines changed

13 files changed

+154
-405
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Removal",
3+
"description": "/transform: remove option to select multiple diffs"
4+
}

packages/amazonq/test/e2e/amazonq/transformByQ.test.ts

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -123,29 +123,8 @@ describe('Amazon Q Code Transformation', function () {
123123
formItemValues: skipTestsFormValues,
124124
})
125125

126-
// 3 additional chat messages (including message with 3rd form) get sent after 2nd form submitted; wait for all of them
127-
await tab.waitForEvent(() => tab.getChatItems().length > 9, {
128-
waitTimeoutInMs: 5000,
129-
waitIntervalInMs: 1000,
130-
})
131-
const multipleDiffsForm = tab.getChatItems().pop()
132-
assert.strictEqual(
133-
multipleDiffsForm?.formItems?.[0]?.id ?? undefined,
134-
'GumbyTransformOneOrMultipleDiffsForm'
135-
)
136-
137-
const oneOrMultipleDiffsFormItemValues = {
138-
GumbyTransformOneOrMultipleDiffsForm: 'One diff',
139-
}
140-
const oneOrMultipleDiffsFormValues: Record<string, string> = { ...oneOrMultipleDiffsFormItemValues }
141-
tab.clickCustomFormButton({
142-
id: 'gumbyTransformOneOrMultipleDiffsFormConfirm',
143-
text: 'Confirm',
144-
formItemValues: oneOrMultipleDiffsFormValues,
145-
})
146-
147126
// 2 additional chat messages get sent after 3rd form submitted; wait for both of them
148-
await tab.waitForEvent(() => tab.getChatItems().length > 11, {
127+
await tab.waitForEvent(() => tab.getChatItems().length > 8, {
149128
waitTimeoutInMs: 5000,
150129
waitIntervalInMs: 1000,
151130
})
@@ -172,7 +151,7 @@ describe('Amazon Q Code Transformation', function () {
172151
tab.addChatMessage({ prompt: '/dummy/path/to/jdk8' })
173152

174153
// 2 additional chat messages get sent after JDK path submitted; wait for both of them
175-
await tab.waitForEvent(() => tab.getChatItems().length > 13, {
154+
await tab.waitForEvent(() => tab.getChatItems().length > 10, {
176155
waitTimeoutInMs: 5000,
177156
waitIntervalInMs: 1000,
178157
})
@@ -194,7 +173,7 @@ describe('Amazon Q Code Transformation', function () {
194173
text: 'View summary',
195174
})
196175

197-
await tab.waitForEvent(() => tab.getChatItems().length > 14, {
176+
await tab.waitForEvent(() => tab.getChatItems().length > 11, {
198177
waitTimeoutInMs: 5000,
199178
waitIntervalInMs: 1000,
200179
})

packages/amazonq/test/unit/amazonqGumby/resources/files/diff.json

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

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

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@
55
import assert from 'assert'
66
import sinon from 'sinon'
77
import { DiffModel, AddedChangeNode, ModifiedChangeNode } from 'aws-core-vscode/codewhisperer/node'
8-
import { DescriptionContent } from 'aws-core-vscode/codewhisperer'
98
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 () {
15-
let parsedTestDescriptions: DescriptionContent
16-
beforeEach(async () => {
17-
parsedTestDescriptions = JSON.parse(await fs.readFileText(getTestResourceFilePath('resources/files/diff.json')))
18-
})
19-
2014
afterEach(() => {
2115
sinon.restore()
2216
})
@@ -34,18 +28,12 @@ describe('DiffModel', function () {
3428

3529
return true
3630
})
37-
testDiffModel.parseDiff(
38-
getTestResourceFilePath('resources/files/addedFile.diff'),
39-
workspacePath,
40-
parsedTestDescriptions.content[0],
41-
1
42-
)
31+
testDiffModel.parseDiff(getTestResourceFilePath('resources/files/addedFile.diff'), workspacePath)
4332

4433
assert.strictEqual(
4534
testDiffModel.patchFileNodes[0].patchFilePath,
4635
getTestResourceFilePath('resources/files/addedFile.diff')
4736
)
48-
assert(testDiffModel.patchFileNodes[0].label.includes(parsedTestDescriptions.content[0].name))
4937
const change = testDiffModel.patchFileNodes[0].children[0]
5038

5139
assert.strictEqual(change instanceof AddedChangeNode, true)
@@ -64,44 +52,13 @@ describe('DiffModel', function () {
6452

6553
testDiffModel.parseDiff(
6654
getTestResourceFilePath('resources/files/modifiedFile.diff'),
67-
workspaceFolder.uri.fsPath,
68-
parsedTestDescriptions.content[0],
69-
1
70-
)
71-
72-
assert.strictEqual(
73-
testDiffModel.patchFileNodes[0].patchFilePath,
74-
getTestResourceFilePath('resources/files/modifiedFile.diff')
75-
)
76-
assert(testDiffModel.patchFileNodes[0].label.includes(parsedTestDescriptions.content[0].name))
77-
const change = testDiffModel.patchFileNodes[0].children[0]
78-
79-
assert.strictEqual(change instanceof ModifiedChangeNode, true)
80-
})
81-
82-
it('WHEN parsing a diff patch where diff.json is not present and a file was modified THEN returns an array representing the modified file', async function () {
83-
const testDiffModel = new DiffModel()
84-
85-
const fileAmount = 1
86-
const workspaceFolder = await createTestWorkspace(fileAmount, { fileContent: '' })
87-
88-
await fs.writeFile(
89-
path.join(workspaceFolder.uri.fsPath, 'README.md'),
90-
'This guide walks you through using Gradle to build a simple Java project.'
91-
)
92-
93-
testDiffModel.parseDiff(
94-
getTestResourceFilePath('resources/files/modifiedFile.diff'),
95-
workspaceFolder.uri.fsPath,
96-
undefined,
97-
1
55+
workspaceFolder.uri.fsPath
9856
)
9957

10058
assert.strictEqual(
10159
testDiffModel.patchFileNodes[0].patchFilePath,
10260
getTestResourceFilePath('resources/files/modifiedFile.diff')
10361
)
104-
assert(testDiffModel.patchFileNodes[0].label.endsWith('modifiedFile.diff'))
10562
const change = testDiffModel.patchFileNodes[0].children[0]
10663

10764
assert.strictEqual(change instanceof ModifiedChangeNode, true)

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

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -367,16 +367,12 @@ export class GumbyController {
367367
this.transformationFinished({
368368
message: CodeWhispererConstants.jobCancelledChatMessage,
369369
tabID: message.tabID,
370-
includeStartNewTransformationButton: true,
371370
})
372371
})
373372
break
374373
case ButtonActions.CONFIRM_SKIP_TESTS_FORM:
375374
await this.handleSkipTestsSelection(message)
376375
break
377-
case ButtonActions.CONFIRM_SELECTIVE_TRANSFORMATION_FORM:
378-
await this.handleOneOrMultipleDiffs(message)
379-
break
380376
case ButtonActions.CONFIRM_SQL_CONVERSION_TRANSFORMATION_FORM:
381377
await this.handleUserSQLConversionProjectSelection(message)
382378
break
@@ -441,25 +437,6 @@ export class GumbyController {
441437
userChoice: skipTestsSelection,
442438
})
443439
this.messenger.sendSkipTestsSelectionMessage(skipTestsSelection, message.tabID)
444-
await this.messenger.sendOneOrMultipleDiffsPrompt(message.tabID)
445-
})
446-
}
447-
448-
private async handleOneOrMultipleDiffs(message: any) {
449-
await telemetry.codeTransform_submitSelection.run(async () => {
450-
const oneOrMultipleDiffsSelection = message.formSelectedValues['GumbyTransformOneOrMultipleDiffsForm']
451-
if (oneOrMultipleDiffsSelection === CodeWhispererConstants.multipleDiffsMessage) {
452-
transformByQState.setMultipleDiffs(true)
453-
} else {
454-
transformByQState.setMultipleDiffs(false)
455-
}
456-
457-
telemetry.record({
458-
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
459-
userChoice: oneOrMultipleDiffsSelection,
460-
})
461-
462-
this.messenger.sendOneOrMultipleDiffsMessage(oneOrMultipleDiffsSelection, message.tabID)
463440
this.promptJavaHome('source', message.tabID)
464441
// TO-DO: delete line above and uncomment line below when releasing CSB
465442
// await this.messenger.sendCustomDependencyVersionMessage(message.tabID)
@@ -618,7 +595,6 @@ export class GumbyController {
618595
this.transformationFinished({
619596
message: CodeWhispererConstants.jobCancelledChatMessage,
620597
tabID: message.tabID,
621-
includeStartNewTransformationButton: true,
622598
})
623599
return
624600
}
@@ -647,15 +623,11 @@ export class GumbyController {
647623
)
648624
}
649625

650-
private transformationFinished(data: {
651-
message: string | undefined
652-
tabID: string
653-
includeStartNewTransformationButton: boolean
654-
}) {
626+
private transformationFinished(data: { message: string | undefined; tabID: string }) {
655627
this.resetTransformationChatFlow()
656628
// at this point job is either completed, partially_completed, cancelled, or failed
657629
if (data.message) {
658-
this.messenger.sendJobFinishedMessage(data.tabID, data.message, data.includeStartNewTransformationButton)
630+
this.messenger.sendJobFinishedMessage(data.tabID, data.message)
659631
}
660632
}
661633

@@ -783,7 +755,6 @@ export class GumbyController {
783755
this.transformationFinished({
784756
tabID: message.tabID,
785757
message: (err as Error).message,
786-
includeStartNewTransformationButton: true,
787758
})
788759
}
789760

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

Lines changed: 7 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -153,47 +153,6 @@ export class Messenger {
153153
)
154154
}
155155

156-
public async sendOneOrMultipleDiffsPrompt(tabID: string) {
157-
const formItems: ChatItemFormItem[] = []
158-
formItems.push({
159-
id: 'GumbyTransformOneOrMultipleDiffsForm',
160-
type: 'select',
161-
title: CodeWhispererConstants.selectiveTransformationFormTitle,
162-
mandatory: true,
163-
options: [
164-
{
165-
value: CodeWhispererConstants.oneDiffMessage,
166-
label: CodeWhispererConstants.oneDiffMessage,
167-
},
168-
{
169-
value: CodeWhispererConstants.multipleDiffsMessage,
170-
label: CodeWhispererConstants.multipleDiffsMessage,
171-
},
172-
],
173-
})
174-
175-
this.dispatcher.sendAsyncEventProgress(
176-
new AsyncEventProgressMessage(tabID, {
177-
inProgress: true,
178-
message: CodeWhispererConstants.userPatchDescriptionChatMessage(
179-
transformByQState.getTargetJDKVersion() ?? ''
180-
),
181-
})
182-
)
183-
184-
this.dispatcher.sendChatPrompt(
185-
new ChatPrompt(
186-
{
187-
message: 'Q Code Transformation',
188-
formItems: formItems,
189-
},
190-
'TransformOneOrMultipleDiffsForm',
191-
tabID,
192-
false
193-
)
194-
)
195-
}
196-
197156
public async sendLanguageUpgradeProjectPrompt(projects: TransformationCandidateProject[], tabID: string) {
198157
const projectFormOptions: { value: any; label: string }[] = []
199158
const detectedJavaVersions = new Array<JDKVersion | undefined>()
@@ -497,16 +456,14 @@ export class Messenger {
497456
this.dispatcher.sendCommandMessage(new SendCommandMessage(message.command, message.tabID, message.eventId))
498457
}
499458

500-
public sendJobFinishedMessage(tabID: string, message: string, includeStartNewTransformationButton: boolean = true) {
459+
public sendJobFinishedMessage(tabID: string, message: string) {
501460
const buttons: ChatItemButton[] = []
502-
if (includeStartNewTransformationButton) {
503-
buttons.push({
504-
keepCardAfterClick: false,
505-
text: CodeWhispererConstants.startTransformationButtonText,
506-
id: ButtonActions.CONFIRM_START_TRANSFORMATION_FLOW,
507-
disabled: false,
508-
})
509-
}
461+
buttons.push({
462+
keepCardAfterClick: false,
463+
text: CodeWhispererConstants.startTransformationButtonText,
464+
id: ButtonActions.CONFIRM_START_TRANSFORMATION_FLOW,
465+
disabled: false,
466+
})
510467

511468
if (transformByQState.isPartiallySucceeded() || transformByQState.isSucceeded()) {
512469
buttons.push({
@@ -594,11 +551,6 @@ export class Messenger {
594551
this.dispatcher.sendChatMessage(new ChatMessage({ message, messageType: 'ai-prompt' }, tabID))
595552
}
596553

597-
public sendOneOrMultipleDiffsMessage(selectiveTransformationSelection: string, tabID: string) {
598-
const message = `Okay, I will create ${selectiveTransformationSelection.toLowerCase()} with my proposed changes.`
599-
this.dispatcher.sendChatMessage(new ChatMessage({ message, messageType: 'ai-prompt' }, tabID))
600-
}
601-
602554
public sendHumanInTheLoopInitialMessage(tabID: string, codeSnippet: string) {
603555
let message = `I was not able to upgrade all dependencies. To resolve it, I will try to find an updated depedency in your local Maven repository. I will need additional information from you to continue.`
604556

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export enum ButtonActions {
1818
CONFIRM_SQL_CONVERSION_TRANSFORMATION_FORM = 'gumbySQLConversionTransformFormConfirm',
1919
CANCEL_TRANSFORMATION_FORM = 'gumbyTransformFormCancel', // shared between Language Upgrade & SQL Conversion
2020
CONFIRM_SKIP_TESTS_FORM = 'gumbyTransformSkipTestsFormConfirm',
21-
CONFIRM_SELECTIVE_TRANSFORMATION_FORM = 'gumbyTransformOneOrMultipleDiffsFormConfirm',
2221
SELECT_SQL_CONVERSION_METADATA_FILE = 'gumbySQLConversionMetadataTransformFormConfirm',
2322
SELECT_CUSTOM_DEPENDENCY_VERSION_FILE = 'gumbyCustomDependencyVersionTransformFormConfirm',
2423
CONTINUE_TRANSFORMATION_FORM = 'gumbyTransformFormContinue',

packages/core/src/codewhisperer/commands/startTransformByQ.ts

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import {
2727
downloadHilResultArchive,
2828
findDownloadArtifactStep,
2929
getArtifactsFromProgressUpdate,
30-
getTransformationPlan,
3130
getTransformationSteps,
3231
pollTransformationJob,
3332
resumeTransformationJob,
@@ -554,28 +553,6 @@ export async function pollTransformationStatusUntilPlanReady(jobId: string, prof
554553
// for now, no plan shown with SQL conversions. later, we may add one
555554
return
556555
}
557-
let plan = undefined
558-
try {
559-
plan = await getTransformationPlan(jobId, profile)
560-
} catch (error) {
561-
// means API call failed
562-
getLogger().error(`CodeTransformation: ${CodeWhispererConstants.failedToCompleteJobNotification}`, error)
563-
transformByQState.setJobFailureErrorNotification(
564-
`${CodeWhispererConstants.failedToGetPlanNotification} ${(error as Error).message}`
565-
)
566-
transformByQState.setJobFailureErrorChatMessage(
567-
`${CodeWhispererConstants.failedToGetPlanChatMessage} ${(error as Error).message}`
568-
)
569-
throw new Error('Get plan failed')
570-
}
571-
572-
if (plan !== undefined) {
573-
const planFilePath = path.join(transformByQState.getProjectPath(), 'transformation-plan.md')
574-
fs.writeFileSync(planFilePath, plan)
575-
await vscode.commands.executeCommand('markdown.showPreview', vscode.Uri.file(planFilePath))
576-
transformByQState.setPlanFilePath(planFilePath)
577-
await setContext('gumby.isPlanAvailable', true)
578-
}
579556
jobPlanProgress['generatePlan'] = StepProgress.Succeeded
580557
throwIfCancelled()
581558
}
@@ -699,11 +676,10 @@ export async function postTransformationJob() {
699676
}
700677

701678
let chatMessage = transformByQState.getJobFailureErrorChatMessage()
702-
const diffMessage = CodeWhispererConstants.diffMessage(transformByQState.getMultipleDiffs())
703679
if (transformByQState.isSucceeded()) {
704-
chatMessage = CodeWhispererConstants.jobCompletedChatMessage(diffMessage)
680+
chatMessage = CodeWhispererConstants.jobCompletedChatMessage
705681
} else if (transformByQState.isPartiallySucceeded()) {
706-
chatMessage = CodeWhispererConstants.jobPartiallyCompletedChatMessage(diffMessage)
682+
chatMessage = CodeWhispererConstants.jobPartiallyCompletedChatMessage
707683
}
708684

709685
transformByQState.getChatControllers()?.transformationFinished.fire({
@@ -732,13 +708,13 @@ export async function postTransformationJob() {
732708
}
733709

734710
if (transformByQState.isSucceeded()) {
735-
void vscode.window.showInformationMessage(CodeWhispererConstants.jobCompletedNotification(diffMessage), {
711+
void vscode.window.showInformationMessage(CodeWhispererConstants.jobCompletedNotification, {
736712
title: localizedText.ok,
737713
})
738714
} else if (transformByQState.isPartiallySucceeded()) {
739715
void vscode.window
740716
.showInformationMessage(
741-
CodeWhispererConstants.jobPartiallyCompletedNotification(diffMessage),
717+
CodeWhispererConstants.jobPartiallyCompletedNotification,
742718
CodeWhispererConstants.amazonQFeedbackText
743719
)
744720
.then((choice) => {

0 commit comments

Comments
 (0)