Skip to content

Commit 09fce96

Browse files
committed
addressing comments to add to models and minor edits
1 parent 0152346 commit 09fce96

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@ export class Messenger {
178178
options: [
179179
{
180180
value: JDKVersion.JDK8,
181-
label: JDKVersion.JDK8.toString(),
181+
label: JDKVersion.JDK8,
182182
},
183183
{
184184
value: JDKVersion.JDK11,
185-
label: JDKVersion.JDK11.toString(),
185+
label: JDKVersion.JDK11,
186186
},
187187
{
188188
value: JDKVersion.JDK17,
189-
label: JDKVersion.JDK17.toString(),
189+
label: JDKVersion.JDK17,
190190
},
191191
{
192192
value: JDKVersion.UNSUPPORTED,

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ export type CrossFileStrategy = 'OpenTabs_BM25'
5050

5151
export type SupplementalContextStrategy = CrossFileStrategy | UtgStrategy | 'Empty'
5252

53+
export type PatchInfo = {
54+
name: string
55+
fileName: string
56+
isSuccessful: boolean
57+
}
58+
5359
export interface CodeWhispererSupplementalContext {
5460
isUtg: boolean
5561
isProcessTimeout: boolean

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

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { parsePatch, applyPatches, ParsedDiff } from 'diff'
1010
import path from 'path'
1111
import vscode from 'vscode'
1212
// import { ExportIntent } from '@amzn/codewhisperer-streaming'
13-
import { TransformByQReviewStatus, transformByQState } from '../../models/model'
13+
import { TransformByQReviewStatus, transformByQState, PatchInfo } from '../../models/model'
1414
import { ExportResultArchiveStructure } from '../../../shared/utilities/download'
1515
import { getLogger } from '../../../shared/logger'
1616
import { telemetry } from '../../../shared/telemetry/telemetry'
@@ -21,12 +21,6 @@ import * as CodeWhispererConstants from '../../models/constants'
2121
import { ChatSessionManager } from '../../../amazonqGumby/chat/storages/chatSession'
2222
import { setContext } from '../../../shared/vscode/setContext'
2323

24-
type PatchDescription = {
25-
name: string
26-
fileName: string
27-
isSuccessful: boolean
28-
}
29-
3024
export abstract class ProposedChangeNode {
3125
abstract readonly resourcePath: string
3226

@@ -160,7 +154,7 @@ export class DiffModel {
160154
* @param pathToWorkspace Path to the project that was transformed
161155
* @returns List of nodes containing the paths of files that were modified, added, or removed
162156
*/
163-
public parseDiff(pathToDiff: string, pathToWorkspace: string, diffDescription: PatchDescription): PatchFileNode {
157+
public parseDiff(pathToDiff: string, pathToWorkspace: string, diffDescription: PatchInfo): PatchFileNode {
164158
this.patchFileNodes = []
165159
const diffContents = fs.readFileSync(pathToDiff, 'utf8')
166160
const changedFiles = parsePatch(diffContents)
@@ -241,9 +235,6 @@ export class DiffModel {
241235

242236
public clearChanges() {
243237
this.patchFileNodes = []
244-
// transformByQState.setSummaryFilePath('')
245-
// transformByQState.setProjectCopyFilePath('')
246-
// transformByQState.setResultArchiveFilePath('')
247238
}
248239
}
249240

@@ -320,7 +311,7 @@ export class ProposedTransformationExplorer {
320311
getLogger().error(err)
321312
} else {
322313
files.forEach((file) => {
323-
const filePath = path.join(path.join(pathContainingArchive, 'patch'), file)
314+
const filePath = path.join(pathContainingArchive, 'patch', file)
324315
if (file.endsWith('.patch')) {
325316
patchFiles.push(filePath)
326317
}
@@ -331,7 +322,7 @@ export class ProposedTransformationExplorer {
331322
const pathContainingPatchFileDescriptions = path.join(pathContainingArchive, 'patch', 'diff.json')
332323

333324
const jsonData = fs.readFileSync(pathContainingPatchFileDescriptions, 'utf-8')
334-
const patchFilesDescriptions: PatchDescription[] = JSON.parse(jsonData)
325+
const patchFilesDescriptions: PatchInfo[] = JSON.parse(jsonData)
335326

336327
const reset = async () => {
337328
await setContext('gumby.transformationProposalReviewInProgress', false)
@@ -346,6 +337,7 @@ export class ProposedTransformationExplorer {
346337
}
347338

348339
diffModel.clearChanges()
340+
diffModel.currentPatchIndex = 0
349341
transformByQState.setSummaryFilePath('')
350342
transformByQState.setProjectCopyFilePath('')
351343
transformByQState.setResultArchiveFilePath('')
@@ -439,7 +431,7 @@ export class ProposedTransformationExplorer {
439431
// const zip = new AdmZip(pathToArchive)
440432
// zip.extractAllTo(pathContainingArchive)
441433

442-
getLogger().info('descriptions', patchFilesDescriptions.toString())
434+
//Because multiple patches are returned once the ZIP is downloaded, we want to show the first one to start
443435
diffModel.parseDiff(patchFiles[0], transformByQState.getProjectPath(), patchFilesDescriptions[0])
444436

445437
await setContext('gumby.reviewState', TransformByQReviewStatus.InReview)
@@ -474,7 +466,8 @@ export class ProposedTransformationExplorer {
474466
diffModel.saveChanges()
475467
telemetry.ui_click.emit({ elementId: 'transformationHub_acceptChanges' })
476468
void vscode.window.showInformationMessage(CodeWhispererConstants.changesAppliedNotification)
477-
if (!diffModel.currentPatchIndex) {
469+
//We do this to ensure that the changesAppliedChatMessage is only sent to user when they accept the first diff.patch
470+
if (diffModel.currentPatchIndex === 0) {
478471
transformByQState.getChatControllers()?.transformationFinished.fire({
479472
message: CodeWhispererConstants.changesAppliedChatMessage,
480473
tabID: ChatSessionManager.Instance.getSession().tabID,
@@ -506,7 +499,6 @@ export class ProposedTransformationExplorer {
506499

507500
vscode.commands.registerCommand('aws.amazonq.transformationHub.reviewChanges.rejectChanges', async () => {
508501
diffModel.rejectChanges()
509-
diffModel.currentPatchIndex = 0
510502
await reset()
511503
telemetry.ui_click.emit({ elementId: 'transformationHub_rejectChanges' })
512504

0 commit comments

Comments
 (0)