@@ -51,11 +51,11 @@ import { encodeHTML } from '../../../shared/utilities/textUtilities'
5151import { convertToTimeString } from '../../../shared/datetime'
5252import { getAuthType } from '../../../auth/utils'
5353import { UserWrittenCodeTracker } from '../../tracker/userWrittenCodeTracker'
54+ import { setContext } from '../../../shared/vscode/setContext'
5455import { AuthUtil } from '../../util/authUtil'
5556import { DiffModel } from './transformationResultsViewProvider'
5657import { spawnSync } from 'child_process' // eslint-disable-line no-restricted-imports
5758import { isClientSideBuildEnabled } from '../../../dev/config'
58- import { openTransformationPlan } from '../../commands/startTransformByQ'
5959
6060export function getSha256 ( buffer : Buffer ) {
6161 const hasher = crypto . createHash ( 'sha256' )
@@ -758,6 +758,31 @@ export async function pollTransformationJob(jobId: string, validStates: string[]
758758 return status
759759}
760760
761+ async function openTransformationPlan ( jobId : string , profile ?: RegionProfile ) {
762+ let plan = undefined
763+ try {
764+ plan = await getTransformationPlan ( jobId , profile )
765+ } catch ( error ) {
766+ // means API call failed
767+ getLogger ( ) . error ( `CodeTransformation: ${ CodeWhispererConstants . failedToCompleteJobNotification } ` , error )
768+ transformByQState . setJobFailureErrorNotification (
769+ `${ CodeWhispererConstants . failedToGetPlanNotification } ${ ( error as Error ) . message } `
770+ )
771+ transformByQState . setJobFailureErrorChatMessage (
772+ `${ CodeWhispererConstants . failedToGetPlanChatMessage } ${ ( error as Error ) . message } `
773+ )
774+ throw new Error ( 'Get plan failed' )
775+ }
776+
777+ if ( plan ) {
778+ const planFilePath = path . join ( transformByQState . getProjectPath ( ) , 'transformation-plan.md' )
779+ nodefs . writeFileSync ( planFilePath , plan )
780+ await vscode . commands . executeCommand ( 'markdown.showPreview' , vscode . Uri . file ( planFilePath ) )
781+ transformByQState . setPlanFilePath ( planFilePath )
782+ await setContext ( 'gumby.isPlanAvailable' , true )
783+ }
784+ }
785+
761786async function attemptLocalBuild ( ) {
762787 const jobId = transformByQState . getJobId ( )
763788 let artifactId
0 commit comments