Skip to content

feat(amazonq): remove option to select multiple diffs #7327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Removal",
"description": "/transform: remove option to select multiple diffs"
}
27 changes: 3 additions & 24 deletions packages/amazonq/test/e2e/amazonq/transformByQ.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,29 +123,8 @@ describe('Amazon Q Code Transformation', function () {
formItemValues: skipTestsFormValues,
})

// 3 additional chat messages (including message with 3rd form) get sent after 2nd form submitted; wait for all of them
await tab.waitForEvent(() => tab.getChatItems().length > 9, {
waitTimeoutInMs: 5000,
waitIntervalInMs: 1000,
})
const multipleDiffsForm = tab.getChatItems().pop()
assert.strictEqual(
multipleDiffsForm?.formItems?.[0]?.id ?? undefined,
'GumbyTransformOneOrMultipleDiffsForm'
)

const oneOrMultipleDiffsFormItemValues = {
GumbyTransformOneOrMultipleDiffsForm: 'One diff',
}
const oneOrMultipleDiffsFormValues: Record<string, string> = { ...oneOrMultipleDiffsFormItemValues }
tab.clickCustomFormButton({
id: 'gumbyTransformOneOrMultipleDiffsFormConfirm',
text: 'Confirm',
formItemValues: oneOrMultipleDiffsFormValues,
})

// 2 additional chat messages get sent after 3rd form submitted; wait for both of them
await tab.waitForEvent(() => tab.getChatItems().length > 11, {
await tab.waitForEvent(() => tab.getChatItems().length > 8, {
waitTimeoutInMs: 5000,
waitIntervalInMs: 1000,
})
Expand All @@ -172,7 +151,7 @@ describe('Amazon Q Code Transformation', function () {
tab.addChatMessage({ prompt: '/dummy/path/to/jdk8' })

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

await tab.waitForEvent(() => tab.getChatItems().length > 14, {
await tab.waitForEvent(() => tab.getChatItems().length > 11, {
waitTimeoutInMs: 5000,
waitIntervalInMs: 1000,
})
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@
import assert from 'assert'
import sinon from 'sinon'
import { DiffModel, AddedChangeNode, ModifiedChangeNode } from 'aws-core-vscode/codewhisperer/node'
import { DescriptionContent } from 'aws-core-vscode/codewhisperer'
import path from 'path'
import { getTestResourceFilePath } from './amazonQGumbyUtil'
import { fs } from 'aws-core-vscode/shared'
import { createTestWorkspace } from 'aws-core-vscode/test'

describe('DiffModel', function () {
let parsedTestDescriptions: DescriptionContent
beforeEach(async () => {
parsedTestDescriptions = JSON.parse(await fs.readFileText(getTestResourceFilePath('resources/files/diff.json')))
})

afterEach(() => {
sinon.restore()
})
Expand All @@ -34,18 +28,12 @@ describe('DiffModel', function () {

return true
})
testDiffModel.parseDiff(
getTestResourceFilePath('resources/files/addedFile.diff'),
workspacePath,
parsedTestDescriptions.content[0],
1
)
testDiffModel.parseDiff(getTestResourceFilePath('resources/files/addedFile.diff'), workspacePath)

assert.strictEqual(
testDiffModel.patchFileNodes[0].patchFilePath,
getTestResourceFilePath('resources/files/addedFile.diff')
)
assert(testDiffModel.patchFileNodes[0].label.includes(parsedTestDescriptions.content[0].name))
const change = testDiffModel.patchFileNodes[0].children[0]

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

testDiffModel.parseDiff(
getTestResourceFilePath('resources/files/modifiedFile.diff'),
workspaceFolder.uri.fsPath,
parsedTestDescriptions.content[0],
1
)

assert.strictEqual(
testDiffModel.patchFileNodes[0].patchFilePath,
getTestResourceFilePath('resources/files/modifiedFile.diff')
)
assert(testDiffModel.patchFileNodes[0].label.includes(parsedTestDescriptions.content[0].name))
const change = testDiffModel.patchFileNodes[0].children[0]

assert.strictEqual(change instanceof ModifiedChangeNode, true)
})

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 () {
const testDiffModel = new DiffModel()

const fileAmount = 1
const workspaceFolder = await createTestWorkspace(fileAmount, { fileContent: '' })

await fs.writeFile(
path.join(workspaceFolder.uri.fsPath, 'README.md'),
'This guide walks you through using Gradle to build a simple Java project.'
)

testDiffModel.parseDiff(
getTestResourceFilePath('resources/files/modifiedFile.diff'),
workspaceFolder.uri.fsPath,
undefined,
1
workspaceFolder.uri.fsPath
)

assert.strictEqual(
testDiffModel.patchFileNodes[0].patchFilePath,
getTestResourceFilePath('resources/files/modifiedFile.diff')
)
assert(testDiffModel.patchFileNodes[0].label.endsWith('modifiedFile.diff'))
const change = testDiffModel.patchFileNodes[0].children[0]

assert.strictEqual(change instanceof ModifiedChangeNode, true)
Expand Down
33 changes: 2 additions & 31 deletions packages/core/src/amazonqGumby/chat/controller/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,16 +367,12 @@ export class GumbyController {
this.transformationFinished({
message: CodeWhispererConstants.jobCancelledChatMessage,
tabID: message.tabID,
includeStartNewTransformationButton: true,
})
})
break
case ButtonActions.CONFIRM_SKIP_TESTS_FORM:
await this.handleSkipTestsSelection(message)
break
case ButtonActions.CONFIRM_SELECTIVE_TRANSFORMATION_FORM:
await this.handleOneOrMultipleDiffs(message)
break
case ButtonActions.CONFIRM_SQL_CONVERSION_TRANSFORMATION_FORM:
await this.handleUserSQLConversionProjectSelection(message)
break
Expand Down Expand Up @@ -441,25 +437,6 @@ export class GumbyController {
userChoice: skipTestsSelection,
})
this.messenger.sendSkipTestsSelectionMessage(skipTestsSelection, message.tabID)
await this.messenger.sendOneOrMultipleDiffsPrompt(message.tabID)
})
}

private async handleOneOrMultipleDiffs(message: any) {
await telemetry.codeTransform_submitSelection.run(async () => {
const oneOrMultipleDiffsSelection = message.formSelectedValues['GumbyTransformOneOrMultipleDiffsForm']
if (oneOrMultipleDiffsSelection === CodeWhispererConstants.multipleDiffsMessage) {
transformByQState.setMultipleDiffs(true)
} else {
transformByQState.setMultipleDiffs(false)
}

telemetry.record({
codeTransformSessionId: CodeTransformTelemetryState.instance.getSessionId(),
userChoice: oneOrMultipleDiffsSelection,
})

this.messenger.sendOneOrMultipleDiffsMessage(oneOrMultipleDiffsSelection, message.tabID)
this.promptJavaHome('source', message.tabID)
// TO-DO: delete line above and uncomment line below when releasing CSB
// await this.messenger.sendCustomDependencyVersionMessage(message.tabID)
Expand Down Expand Up @@ -618,7 +595,6 @@ export class GumbyController {
this.transformationFinished({
message: CodeWhispererConstants.jobCancelledChatMessage,
tabID: message.tabID,
includeStartNewTransformationButton: true,
})
return
}
Expand Down Expand Up @@ -647,15 +623,11 @@ export class GumbyController {
)
}

private transformationFinished(data: {
message: string | undefined
tabID: string
includeStartNewTransformationButton: boolean
}) {
private transformationFinished(data: { message: string | undefined; tabID: string }) {
this.resetTransformationChatFlow()
// at this point job is either completed, partially_completed, cancelled, or failed
if (data.message) {
this.messenger.sendJobFinishedMessage(data.tabID, data.message, data.includeStartNewTransformationButton)
this.messenger.sendJobFinishedMessage(data.tabID, data.message)
}
}

Expand Down Expand Up @@ -779,7 +751,6 @@ export class GumbyController {
this.transformationFinished({
tabID: message.tabID,
message: (err as Error).message,
includeStartNewTransformationButton: true,
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,47 +157,6 @@ export class Messenger {
)
}

public async sendOneOrMultipleDiffsPrompt(tabID: string) {
const formItems: ChatItemFormItem[] = []
formItems.push({
id: 'GumbyTransformOneOrMultipleDiffsForm',
type: 'select',
title: CodeWhispererConstants.selectiveTransformationFormTitle,
mandatory: true,
options: [
{
value: CodeWhispererConstants.oneDiffMessage,
label: CodeWhispererConstants.oneDiffMessage,
},
{
value: CodeWhispererConstants.multipleDiffsMessage,
label: CodeWhispererConstants.multipleDiffsMessage,
},
],
})

this.dispatcher.sendAsyncEventProgress(
new AsyncEventProgressMessage(tabID, {
inProgress: true,
message: CodeWhispererConstants.userPatchDescriptionChatMessage(
transformByQState.getTargetJDKVersion() ?? ''
),
})
)

this.dispatcher.sendChatPrompt(
new ChatPrompt(
{
message: 'Q Code Transformation',
formItems: formItems,
},
'TransformOneOrMultipleDiffsForm',
tabID,
false
)
)
}

public async sendLanguageUpgradeProjectPrompt(projects: TransformationCandidateProject[], tabID: string) {
const projectFormOptions: { value: any; label: string }[] = []
const detectedJavaVersions = new Array<JDKVersion | undefined>()
Expand Down Expand Up @@ -501,16 +460,14 @@ export class Messenger {
this.dispatcher.sendCommandMessage(new SendCommandMessage(message.command, message.tabID, message.eventId))
}

public sendJobFinishedMessage(tabID: string, message: string, includeStartNewTransformationButton: boolean = true) {
public sendJobFinishedMessage(tabID: string, message: string) {
const buttons: ChatItemButton[] = []
if (includeStartNewTransformationButton) {
buttons.push({
keepCardAfterClick: false,
text: CodeWhispererConstants.startTransformationButtonText,
id: ButtonActions.CONFIRM_START_TRANSFORMATION_FLOW,
disabled: false,
})
}
buttons.push({
keepCardAfterClick: false,
text: CodeWhispererConstants.startTransformationButtonText,
id: ButtonActions.CONFIRM_START_TRANSFORMATION_FLOW,
disabled: false,
})

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

public sendOneOrMultipleDiffsMessage(selectiveTransformationSelection: string, tabID: string) {
const message = `Okay, I will create ${selectiveTransformationSelection.toLowerCase()} with my proposed changes.`
this.dispatcher.sendChatMessage(new ChatMessage({ message, messageType: 'ai-prompt' }, tabID))
}

public sendHumanInTheLoopInitialMessage(tabID: string, codeSnippet: string) {
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.`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export enum ButtonActions {
CONFIRM_SQL_CONVERSION_TRANSFORMATION_FORM = 'gumbySQLConversionTransformFormConfirm',
CANCEL_TRANSFORMATION_FORM = 'gumbyTransformFormCancel', // shared between Language Upgrade & SQL Conversion
CONFIRM_SKIP_TESTS_FORM = 'gumbyTransformSkipTestsFormConfirm',
CONFIRM_SELECTIVE_TRANSFORMATION_FORM = 'gumbyTransformOneOrMultipleDiffsFormConfirm',
SELECT_SQL_CONVERSION_METADATA_FILE = 'gumbySQLConversionMetadataTransformFormConfirm',
SELECT_CUSTOM_DEPENDENCY_VERSION_FILE = 'gumbyCustomDependencyVersionTransformFormConfirm',
CONTINUE_TRANSFORMATION_FORM = 'gumbyTransformFormContinue',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,11 +699,10 @@ export async function postTransformationJob() {
}

let chatMessage = transformByQState.getJobFailureErrorChatMessage()
const diffMessage = CodeWhispererConstants.diffMessage(transformByQState.getMultipleDiffs())
if (transformByQState.isSucceeded()) {
chatMessage = CodeWhispererConstants.jobCompletedChatMessage(diffMessage)
chatMessage = CodeWhispererConstants.jobCompletedChatMessage
} else if (transformByQState.isPartiallySucceeded()) {
chatMessage = CodeWhispererConstants.jobPartiallyCompletedChatMessage(diffMessage)
chatMessage = CodeWhispererConstants.jobPartiallyCompletedChatMessage
}

transformByQState.getChatControllers()?.transformationFinished.fire({
Expand Down Expand Up @@ -732,13 +731,13 @@ export async function postTransformationJob() {
}

if (transformByQState.isSucceeded()) {
void vscode.window.showInformationMessage(CodeWhispererConstants.jobCompletedNotification(diffMessage), {
void vscode.window.showInformationMessage(CodeWhispererConstants.jobCompletedNotification, {
title: localizedText.ok,
})
} else if (transformByQState.isPartiallySucceeded()) {
void vscode.window
.showInformationMessage(
CodeWhispererConstants.jobPartiallyCompletedNotification(diffMessage),
CodeWhispererConstants.jobPartiallyCompletedNotification,
CodeWhispererConstants.amazonQFeedbackText
)
.then((choice) => {
Expand Down
Loading
Loading