@@ -184,9 +184,17 @@ export class GumbyController {
184184
185185 private async transformInitiated ( message : any ) {
186186 // Start /transform chat flow
187- const session : Session = this . sessionStorage . getSession ( )
188187 CodeTransformTelemetryState . instance . setSessionId ( )
189188
189+ this . sessionStorage . getSession ( ) . conversationState = ConversationState . WAITING_FOR_OBJECTIVE
190+ this . messenger . sendStaticTextResponse ( 'choose-transformation-objective' , 'ai-prompt' , message . tabID )
191+ this . messenger . sendChatInputEnabled ( message . tabID , true )
192+ this . messenger . sendUpdatePlaceholder ( message . tabID , "Enter 'language upgrade' or 'SQL conversion'" )
193+ }
194+
195+ private async handleLanguageUpgrade ( message : any ) {
196+ const session : Session = this . sessionStorage . getSession ( )
197+ this . messenger . sendStaticTextResponse ( 'language-upgrade-selected' , 'prompt' , message . tabID )
190198 try {
191199 await telemetry . codeTransform_initiateTransform . run ( async ( ) => {
192200 const authType = await getAuthType ( )
@@ -195,14 +203,6 @@ export class GumbyController {
195203 credentialSourceId : authType ,
196204 } )
197205
198- // check that a project is open
199- const workspaceFolders = vscode . workspace . workspaceFolders
200- if ( workspaceFolders === undefined || workspaceFolders . length === 0 ) {
201- this . messenger . sendUnrecoverableErrorResponse ( 'no-project-found' , message . tabID )
202- telemetry . record ( { result : MetadataResult . Fail , reason : 'no-project-found' } )
203- return
204- }
205-
206206 // check that the session is authenticated
207207 const authState = await AuthUtil . instance . getChatAuthState ( )
208208 if ( authState . amazonQ !== 'connected' ) {
@@ -212,8 +212,17 @@ export class GumbyController {
212212 return
213213 }
214214
215+ // check that a project is open
216+ const workspaceFolders = vscode . workspace . workspaceFolders
217+ if ( workspaceFolders === undefined || workspaceFolders . length === 0 ) {
218+ this . messenger . sendUnrecoverableErrorResponse ( 'no-project-found' , message . tabID )
219+ telemetry . record ( { result : MetadataResult . Fail , reason : 'no-project-found' } )
220+ return
221+ }
222+
215223 // If previous transformation was already running
216224 switch ( this . sessionStorage . getSession ( ) . conversationState ) {
225+ // TODO: figure out if/when to set these states for SQL conversions
217226 case ConversationState . JOB_SUBMITTED :
218227 this . messenger . sendAsyncEventProgress (
219228 message . tabID ,
@@ -236,8 +245,8 @@ export class GumbyController {
236245 this . messenger . sendTransformationIntroduction ( message . tabID )
237246 } )
238247 } catch ( e : any ) {
239- // if there was an issue getting the list of valid projects, the error message will be shown here
240248 this . messenger . sendErrorMessage ( e . message , message . tabID )
249+ return
241250 }
242251
243252 try {
@@ -247,11 +256,16 @@ export class GumbyController {
247256 await this . messenger . sendProjectPrompt ( validProjects , message . tabID )
248257 }
249258 } catch ( err : any ) {
250- // if there was an issue getting the list of valid projects, the error message will be shown here
259+ // if there was an issue showing the list of valid projects, the error message will be shown here
251260 this . messenger . sendErrorMessage ( err . message , message . tabID )
261+ return
252262 }
253263 }
254264
265+ private async handleSQLConversion ( message : any ) {
266+ this . messenger . sendStaticTextResponse ( 'sql-conversion-selected' , 'prompt' , message . tabID )
267+ }
268+
255269 private async validateProjectsWithReplyOnError ( message : any ) : Promise < TransformationCandidateProject [ ] > {
256270 let telemetryJavaVersion = JDKToTelemetryValue ( JDKVersion . UNSUPPORTED ) as CodeTransformJavaSourceVersionsAllowed
257271 try {
@@ -443,7 +457,7 @@ export class GumbyController {
443457 } catch ( err : any ) {
444458 if ( err instanceof JavaHomeNotSetError ) {
445459 this . sessionStorage . getSession ( ) . conversationState = ConversationState . PROMPT_JAVA_HOME
446- this . messenger . sendStaticTextResponse ( 'java-home-not-set' , message . tabID )
460+ this . messenger . sendStaticTextResponse ( 'java-home-not-set' , 'ai-prompt' , message . tabID )
447461 this . messenger . sendChatInputEnabled ( message . tabID , true )
448462 this . messenger . sendUpdatePlaceholder ( message . tabID , 'Enter the path to your Java installation.' )
449463 // const fileUri = await vscode.window.showOpenDialog({
@@ -478,7 +492,7 @@ export class GumbyController {
478492 }
479493
480494 private startHILIntervention ( data : { tabID : string ; codeSnippet : string } ) {
481- this . sessionStorage . getSession ( ) . conversationState = ConversationState . WAITING_FOR_INPUT
495+ this . sessionStorage . getSession ( ) . conversationState = ConversationState . WAITING_FOR_HIL_INPUT
482496 this . messenger . sendHumanInTheLoopInitialMessage ( data . tabID , data . codeSnippet )
483497 }
484498
@@ -500,7 +514,6 @@ export class GumbyController {
500514 switch ( session . conversationState ) {
501515 case ConversationState . PROMPT_JAVA_HOME : {
502516 const pathToJavaHome = extractPath ( data . message )
503-
504517 if ( pathToJavaHome ) {
505518 await this . prepareProjectForSubmission ( {
506519 pathToJavaHome,
@@ -509,6 +522,23 @@ export class GumbyController {
509522 } else {
510523 this . messenger . sendUnrecoverableErrorResponse ( 'invalid-java-home' , data . tabID )
511524 }
525+ break
526+ }
527+
528+ case ConversationState . WAITING_FOR_OBJECTIVE : {
529+ const objective = data . message . trim ( ) . toLowerCase ( )
530+ if ( objective === 'language upgrade' ) {
531+ vscode . window . showInformationMessage ( 'You chose language upgrade!' )
532+ this . handleLanguageUpgrade ( data )
533+ } else if ( objective === 'sql conversion' ) {
534+ vscode . window . showInformationMessage ( 'You chose SQL conversion!' )
535+ this . handleSQLConversion ( data )
536+ } else {
537+ vscode . window . showInformationMessage ( 'You did not enter a valid objective' )
538+ // keep prompting user until they enter a valid option
539+ this . transformInitiated ( data )
540+ }
541+ break
512542 }
513543 }
514544 }
@@ -557,7 +587,7 @@ export class GumbyController {
557587 this . transformationFinished ( { tabID : message . tabID , message : ( err as Error ) . message } )
558588 }
559589
560- this . messenger . sendStaticTextResponse ( 'end-HIL-early' , message . tabID )
590+ this . messenger . sendStaticTextResponse ( 'end-HIL-early' , 'ai-prompt' , message . tabID )
561591 }
562592}
563593
0 commit comments