@@ -637,6 +637,8 @@ export class StashGitCommand extends QuickCommand<State> {
637637 value : state . message ,
638638 prompt : 'Enter stash message' ,
639639 buttons : [ QuickInputButtons . Back , generateMessageButton ] ,
640+ // Needed to clear any validation errors because of AI generation
641+ validate : ( _value : string | undefined ) : [ boolean , string | undefined ] => [ true , undefined ] ,
640642 onDidClickButton : async ( input , button ) => {
641643 if ( button === generateMessageButton ) {
642644 using resume = step . freeze ?.( ) ;
@@ -649,6 +651,7 @@ export class StashGitCommand extends QuickCommand<State> {
649651 ) ;
650652 if ( ! diff ?. contents ) {
651653 void window . showInformationMessage ( 'No changes to generate a stash message from.' ) ;
654+ return ;
652655 }
653656
654657 const generating = defer < AIModel > ( ) ;
@@ -668,7 +671,7 @@ export class StashGitCommand extends QuickCommand<State> {
668671
669672 const result = await (
670673 await this . container . ai
671- ) ?. generateStashMessage ( diff ! . contents , { source : 'quick-wizard' } , { generating : generating } ) ;
674+ ) ?. generateStashMessage ( diff . contents , { source : 'quick-wizard' } , { generating : generating } ) ;
672675
673676 input . validationMessage = undefined ;
674677
@@ -679,11 +682,11 @@ export class StashGitCommand extends QuickCommand<State> {
679682 }
680683 } catch ( ex ) {
681684 Logger . error ( ex , scope , 'generateStashMessage' ) ;
682- if ( ex instanceof Error && ex . message . startsWith ( 'No changes' ) ) {
683- void window . showInformationMessage ( 'No changes to generate a stash message from.' ) ;
684- } else {
685- void showGenericErrorMessage ( ex . message ) ;
686- }
685+
686+ input . validationMessage = {
687+ severity : InputBoxValidationSeverity . Error ,
688+ message : ex . message ,
689+ } ;
687690 }
688691 }
689692 } ,
0 commit comments