Skip to content

Commit 196de6f

Browse files
dhasani23David Hasani
andauthored
feat(amazonq): remove option to select multiple diffs (#7327)
## Problem Prompting users to select one or multiple diffs is a very infrequently used feature. ## Solution Remove it. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: David Hasani <davhasan@amazon.com>
1 parent 3d30dcd commit 196de6f

File tree

12 files changed

+40
-354
lines changed

12 files changed

+40
-354
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
@@ -157,47 +157,6 @@ export class Messenger {
157157
)
158158
}
159159

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

504-
public sendJobFinishedMessage(tabID: string, message: string, includeStartNewTransformationButton: boolean = true) {
463+
public sendJobFinishedMessage(tabID: string, message: string) {
505464
const buttons: ChatItemButton[] = []
506-
if (includeStartNewTransformationButton) {
507-
buttons.push({
508-
keepCardAfterClick: false,
509-
text: CodeWhispererConstants.startTransformationButtonText,
510-
id: ButtonActions.CONFIRM_START_TRANSFORMATION_FLOW,
511-
disabled: false,
512-
})
513-
}
465+
buttons.push({
466+
keepCardAfterClick: false,
467+
text: CodeWhispererConstants.startTransformationButtonText,
468+
id: ButtonActions.CONFIRM_START_TRANSFORMATION_FLOW,
469+
disabled: false,
470+
})
514471

515472
if (transformByQState.isPartiallySucceeded() || transformByQState.isSucceeded()) {
516473
buttons.push({
@@ -598,11 +555,6 @@ export class Messenger {
598555
this.dispatcher.sendChatMessage(new ChatMessage({ message, messageType: 'ai-prompt' }, tabID))
599556
}
600557

601-
public sendOneOrMultipleDiffsMessage(selectiveTransformationSelection: string, tabID: string) {
602-
const message = `Okay, I will create ${selectiveTransformationSelection.toLowerCase()} with my proposed changes.`
603-
this.dispatcher.sendChatMessage(new ChatMessage({ message, messageType: 'ai-prompt' }, tabID))
604-
}
605-
606558
public sendHumanInTheLoopInitialMessage(tabID: string, codeSnippet: string) {
607559
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.`
608560

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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -676,11 +676,10 @@ export async function postTransformationJob() {
676676
}
677677

678678
let chatMessage = transformByQState.getJobFailureErrorChatMessage()
679-
const diffMessage = CodeWhispererConstants.diffMessage(transformByQState.getMultipleDiffs())
680679
if (transformByQState.isSucceeded()) {
681-
chatMessage = CodeWhispererConstants.jobCompletedChatMessage(diffMessage)
680+
chatMessage = CodeWhispererConstants.jobCompletedChatMessage
682681
} else if (transformByQState.isPartiallySucceeded()) {
683-
chatMessage = CodeWhispererConstants.jobPartiallyCompletedChatMessage(diffMessage)
682+
chatMessage = CodeWhispererConstants.jobPartiallyCompletedChatMessage
684683
}
685684

686685
transformByQState.getChatControllers()?.transformationFinished.fire({
@@ -709,13 +708,13 @@ export async function postTransformationJob() {
709708
}
710709

711710
if (transformByQState.isSucceeded()) {
712-
void vscode.window.showInformationMessage(CodeWhispererConstants.jobCompletedNotification(diffMessage), {
711+
void vscode.window.showInformationMessage(CodeWhispererConstants.jobCompletedNotification, {
713712
title: localizedText.ok,
714713
})
715714
} else if (transformByQState.isPartiallySucceeded()) {
716715
void vscode.window
717716
.showInformationMessage(
718-
CodeWhispererConstants.jobPartiallyCompletedNotification(diffMessage),
717+
CodeWhispererConstants.jobPartiallyCompletedNotification,
719718
CodeWhispererConstants.amazonQFeedbackText
720719
)
721720
.then((choice) => {

0 commit comments

Comments
 (0)