Skip to content

Commit 62691f9

Browse files
committed
initial view transformation summary button attempt
1 parent 525181b commit 62691f9

File tree

8 files changed

+82
-44
lines changed

8 files changed

+82
-44
lines changed

packages/core/src/amazonqGumby/app.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Messenger } from './chat/controller/messenger/messenger'
1313
import { UIMessageListener } from './chat/views/actions/uiMessageListener'
1414
import { debounce } from 'lodash'
1515
import { AuthUtil } from '../codewhisperer/util/authUtil'
16-
import { showTransformationHub } from './commands'
16+
import { showTransformationHub, showTransformationSummary } from './commands'
1717
import { transformByQState } from '../codewhisperer/models/model'
1818
import { ChatSessionManager } from './chat/storages/chatSession'
1919

@@ -69,6 +69,7 @@ export function init(appContext: AmazonQAppInitContext) {
6969
})
7070

7171
showTransformationHub.register()
72+
showTransformationSummary.register()
7273

7374
transformByQState.setChatControllers(gumbyChatControllerEventEmitters)
7475
transformByQState.setChatMessenger(messenger)

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { featureName } from '../../models/constants'
1717
import { AuthUtil } from '../../../codewhisperer/util/authUtil'
1818
import {
1919
cleanupTransformationJob,
20-
compileProject,
20+
// compileProject,
2121
finishHumanInTheLoop,
2222
getValidLanguageUpgradeCandidateProjects,
2323
postTransformationJob,
@@ -395,6 +395,17 @@ export class GumbyController {
395395
this.messenger.sendCommandMessage({ ...message, command: GumbyCommands.CLEAR_CHAT })
396396
await this.transformInitiated(message)
397397
break
398+
case ButtonActions.CONFIRM_VIEW_TRANSFORMATION_SUMMARY:
399+
await vscode.commands.executeCommand(
400+
GumbyCommands.SHOW_TRANSFORMATION_SUMMARY,
401+
CancelActionPositions.Chat
402+
)
403+
this.messenger.sendJobFinishedMessage(
404+
message.tabID,
405+
CodeWhispererConstants.viewProposedChangesChatMessage
406+
)
407+
telemetry.ui_click.emit({ elementId: 'transformationHub_viewSummary' })
408+
break
398409
case ButtonActions.CONFIRM_DEPENDENCY_FORM:
399410
await this.continueJobWithSelectedDependency(message)
400411
break
@@ -523,7 +534,7 @@ export class GumbyController {
523534
try {
524535
this.sessionStorage.getSession().conversationState = ConversationState.COMPILING
525536
this.messenger.sendCompilationInProgress(message.tabID)
526-
await compileProject()
537+
// await compileProject()
527538
} catch (err: any) {
528539
this.messenger.sendUnrecoverableErrorResponse('could-not-compile-project', message.tabID)
529540
// reset state to allow "Start a new transformation" button to work

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,14 @@ export class Messenger {
509509

510510
public sendJobFinishedMessage(tabID: string, message: string, includeStartNewTransformationButton: boolean = true) {
511511
const buttons: ChatItemButton[] = []
512+
// We only want to show this button when the proposed changes were downloaded (ie the summary is available)
513+
if (transformByQState.getSummaryFilePath() !== '') {
514+
buttons.push({
515+
keepCardAfterClick: false,
516+
text: CodeWhispererConstants.viewTransformationSummaryButtonText,
517+
id: ButtonActions.CONFIRM_VIEW_TRANSFORMATION_SUMMARY,
518+
})
519+
}
512520
if (includeStartNewTransformationButton) {
513521
buttons.push({
514522
keepCardAfterClick: false,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export enum ButtonActions {
2626
CONFIRM_JAVA_HOME_FORM = 'gumbyJavaHomeFormConfirm',
2727
CANCEL_JAVA_HOME_FORM = 'gumbyJavaHomeFormCancel',
2828
CONFIRM_START_TRANSFORMATION_FLOW = 'gumbyStartTransformation',
29+
CONFIRM_VIEW_TRANSFORMATION_SUMMARY = 'gumbyViewSummary',
2930
OPEN_FILE = 'gumbyOpenFile',
3031
OPEN_BUILD_LOG = 'gumbyOpenBuildLog',
3132
}
@@ -34,6 +35,7 @@ export enum GumbyCommands {
3435
CLEAR_CHAT = 'aws.awsq.clearchat',
3536
START_TRANSFORMATION_FLOW = 'aws.awsq.transform',
3637
FOCUS_TRANSFORMATION_HUB = 'aws.amazonq.showTransformationHub',
38+
SHOW_TRANSFORMATION_SUMMARY = 'aws.amazonq.transformationHub.summary.reveal',
3739
}
3840

3941
export default class MessengerUtils {

packages/core/src/amazonqGumby/commands.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,23 @@
55

66
import * as vscode from 'vscode'
77
import { Commands } from '../shared/vscode/commands2'
8+
import { transformByQState } from '../codewhisperer'
89

910
export const showTransformationHub = Commands.declare(
1011
{ id: 'aws.amazonq.showTransformationHub', compositeKey: { 0: 'source' } },
1112
() => async (source: string) => {
1213
await vscode.commands.executeCommand('workbench.view.extension.aws-codewhisperer-transformation-hub')
1314
}
1415
)
16+
17+
export const showTransformationSummary = Commands.declare(
18+
{ id: 'aws.amazonq.transformationHub.summary.reveal', compositeKey: { 0: 'source' } },
19+
() => async (source: string) => {
20+
if (transformByQState.getSummaryFilePath() !== '') {
21+
await vscode.commands.executeCommand(
22+
'markdown.showPreview',
23+
vscode.Uri.file(String(transformByQState.getSummaryFilePath()))
24+
)
25+
}
26+
}
27+
)

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ import { dependencyNoAvailableVersions } from '../../amazonqGumby/models/constan
7676
import { HumanInTheLoopManager } from '../service/transformByQ/humanInTheLoopManager'
7777
import { setContext } from '../../shared/vscode/setContext'
7878
import { makeTemporaryToolkitFolder } from '../../shared'
79-
import globals from '../../shared/extensionGlobals'
79+
// import globals from '../../shared/extensionGlobals'
8080
import { convertDateToTimestamp } from '../../shared/datetime'
8181
import { findStringInDirectory } from '../../shared/utilities/workspaceUtils'
8282

@@ -164,24 +164,24 @@ export function startInterval() {
164164

165165
export async function startTransformByQ() {
166166
// Set the default state variables for our store and the UI
167-
const transformStartTime = globals.clock.Date.now()
167+
// const transformStartTime = globals.clock.Date.now()
168168
await setTransformationToRunningState()
169169

170170
try {
171171
// Set webview UI to poll for progress
172172
startInterval()
173173

174174
// step 1: CreateUploadUrl and upload code
175-
const uploadId = await preTransformationUploadCode()
175+
// const uploadId = await preTransformationUploadCode()
176176

177177
// step 2: StartJob and store the returned jobId in TransformByQState
178-
const jobId = await startTransformationJob(uploadId, transformStartTime)
178+
// const jobId = await startTransformationJob(uploadId, transformStartTime)
179179

180180
// step 3 (intermediate step): show transformation-plan.md file
181-
await pollTransformationStatusUntilPlanReady(jobId)
181+
// await pollTransformationStatusUntilPlanReady(jobId)
182182

183183
// step 4: poll until artifacts are ready to download
184-
await humanInTheLoopRetryLogic(jobId)
184+
await humanInTheLoopRetryLogic('jobId')
185185
} catch (error: any) {
186186
await transformationJobErrorHandler(error)
187187
} finally {
@@ -200,7 +200,8 @@ export async function startTransformByQ() {
200200
export async function humanInTheLoopRetryLogic(jobId: string) {
201201
let status = ''
202202
try {
203-
status = await pollTransformationStatusUntilComplete(jobId)
203+
// status = await pollTransformationStatusUntilComplete(jobId)
204+
status = 'COMPLETED'
204205
if (status === 'PAUSED') {
205206
const hilStatusFailure = await initiateHumanInTheLoopPrompt(jobId)
206207
if (hilStatusFailure) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,8 @@ export const openTransformationHubButtonText = 'Open Transformation Hub'
563563

564564
export const startTransformationButtonText = 'Start a new transformation'
565565

566+
export const viewTransformationSummaryButtonText = 'View transformation summary'
567+
566568
export const stopTransformationButtonText = 'Stop transformation'
567569

568570
export const checkingForProjectsChatMessage = 'Checking for eligible projects...'

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

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import AdmZip from 'adm-zip'
6+
// import AdmZip from 'adm-zip'
77
import os from 'os'
88
import fs from 'fs' // eslint-disable-line no-restricted-imports
99
import { parsePatch, applyPatches, ParsedDiff } from 'diff'
1010
import path from 'path'
1111
import vscode from 'vscode'
12-
import { ExportIntent } from '@amzn/codewhisperer-streaming'
12+
// import { ExportIntent } from '@amzn/codewhisperer-streaming'
1313
import {
1414
TransformByQReviewStatus,
1515
transformByQState,
1616
PatchInfo,
1717
DescriptionContent,
1818
TransformationType,
1919
} from '../../models/model'
20-
import { ExportResultArchiveStructure, downloadExportResultArchive } from '../../../shared/utilities/download'
20+
import { ExportResultArchiveStructure } from '../../../shared/utilities/download'
2121
import { getLogger } from '../../../shared/logger'
2222
import { telemetry } from '../../../shared/telemetry/telemetry'
2323
import { CodeTransformTelemetryState } from '../../../amazonqGumby/telemetry/codeTransformTelemetryState'
2424
import { MetadataResult } from '../../../shared/telemetry/telemetryClient'
2525
import * as CodeWhispererConstants from '../../models/constants'
26-
import { createCodeWhispererChatStreamingClient } from '../../../shared/clients/codewhispererChatClient'
26+
// import { createCodeWhispererChatStreamingClient } from '../../../shared/clients/codewhispererChatClient'
2727
import { ChatSessionManager } from '../../../amazonqGumby/chat/storages/chatSession'
2828
import { setContext } from '../../../shared/vscode/setContext'
2929
import * as codeWhisperer from '../../client/codewhisperer'
@@ -364,28 +364,28 @@ export class ProposedTransformationExplorer {
364364
}
365365
})
366366

367-
vscode.commands.registerCommand('aws.amazonq.transformationHub.summary.reveal', async () => {
368-
if (transformByQState.getSummaryFilePath() !== '') {
369-
await vscode.commands.executeCommand(
370-
'markdown.showPreview',
371-
vscode.Uri.file(transformByQState.getSummaryFilePath())
372-
)
373-
telemetry.ui_click.emit({ elementId: 'transformationHub_viewSummary' })
374-
}
375-
})
367+
// vscode.commands.registerCommand('aws.amazonq.transformationHub.summary.reveal', async () => {
368+
// if (transformByQState.getSummaryFilePath() !== '') {
369+
// await vscode.commands.executeCommand(
370+
// 'markdown.showPreview',
371+
// vscode.Uri.file(transformByQState.getSummaryFilePath())
372+
// )
373+
// telemetry.ui_click.emit({ elementId: 'transformationHub_viewSummary' })
374+
// }
375+
// })
376376

377377
vscode.commands.registerCommand('aws.amazonq.transformationHub.reviewChanges.startReview', async () => {
378378
await setContext('gumby.reviewState', TransformByQReviewStatus.PreparingReview)
379379

380-
const pathToArchive = path.join(
381-
ProposedTransformationExplorer.TmpDir,
382-
transformByQState.getJobId(),
383-
'ExportResultsArchive.zip'
384-
)
385-
let exportResultsArchiveSize = 0
380+
// const pathToArchive = path.join(
381+
// ProposedTransformationExplorer.TmpDir,
382+
// transformByQState.getJobId(),
383+
// 'ExportResultsArchive.zip'
384+
// )
385+
const exportResultsArchiveSize = 0
386386
let downloadErrorMessage = undefined
387387

388-
const cwStreamingClient = await createCodeWhispererChatStreamingClient()
388+
// const cwStreamingClient = await createCodeWhispererChatStreamingClient()
389389
try {
390390
await telemetry.codeTransform_downloadArtifact.run(async () => {
391391
telemetry.record({
@@ -394,17 +394,17 @@ export class ProposedTransformationExplorer {
394394
codeTransformJobId: transformByQState.getJobId(),
395395
})
396396

397-
await downloadExportResultArchive(
398-
cwStreamingClient,
399-
{
400-
exportId: transformByQState.getJobId(),
401-
exportIntent: ExportIntent.TRANSFORMATION,
402-
},
403-
pathToArchive
404-
)
397+
// await downloadExportResultArchive(
398+
// cwStreamingClient,
399+
// {
400+
// exportId: transformByQState.getJobId(),
401+
// exportIntent: ExportIntent.TRANSFORMATION,
402+
// },
403+
// pathToArchive
404+
// )
405405

406406
// Update downloaded artifact size
407-
exportResultsArchiveSize = (await fs.promises.stat(pathToArchive)).size
407+
// exportResultsArchiveSize = (await fs.promises.stat(pathToArchive)).size
408408

409409
telemetry.record({ codeTransformTotalByteSize: exportResultsArchiveSize })
410410
})
@@ -425,17 +425,17 @@ export class ProposedTransformationExplorer {
425425
getLogger().error(`CodeTransformation: ExportResultArchive error = ${downloadErrorMessage}`)
426426
throw new Error('Error downloading diff')
427427
} finally {
428-
cwStreamingClient.destroy()
428+
// cwStreamingClient.destroy()
429429
}
430430

431431
let deserializeErrorMessage = undefined
432432
let pathContainingArchive = ''
433433
patchFiles = [] // reset patchFiles if there was a previous transformation
434434
try {
435435
// Download and deserialize the zip
436-
pathContainingArchive = path.dirname(pathToArchive)
437-
const zip = new AdmZip(pathToArchive)
438-
zip.extractAllTo(pathContainingArchive)
436+
// pathContainingArchive = path.dirname(pathToArchive)
437+
// const zip = new AdmZip(pathToArchive)
438+
// zip.extractAllTo(pathContainingArchive)
439439
const files = fs.readdirSync(path.join(pathContainingArchive, ExportResultArchiveStructure.PathToPatch))
440440
if (files.length === 1) {
441441
singlePatchFile = path.join(
@@ -491,7 +491,7 @@ export class ProposedTransformationExplorer {
491491
message: CodeWhispererConstants.viewProposedChangesChatMessage,
492492
tabID: ChatSessionManager.Instance.getSession().tabID,
493493
})
494-
await vscode.commands.executeCommand('aws.amazonq.transformationHub.summary.reveal')
494+
// await vscode.commands.executeCommand('aws.amazonq.transformationHub.summary.reveal')
495495
} catch (e: any) {
496496
deserializeErrorMessage = (e as Error).message
497497
getLogger().error(`CodeTransformation: ParseDiff error = ${deserializeErrorMessage}`)

0 commit comments

Comments
 (0)