@@ -170,7 +170,7 @@ pub struct ChatArgs {
170170 #[ arg( long, value_delimiter = ',' , value_name = "TOOL_NAMES" ) ]
171171 pub trust_tools : Option < Vec < String > > ,
172172 /// Whether the command should run without expecting user input
173- #[ arg( long) ]
173+ #[ arg( long, alias = "no-interactive" ) ]
174174 pub non_interactive : bool ,
175175 /// The first question to ask
176176 pub input : Option < String > ,
@@ -179,7 +179,7 @@ pub struct ChatArgs {
179179impl ChatArgs {
180180 pub async fn execute ( self , os : & mut Os ) -> Result < ExitCode > {
181181 if self . non_interactive && self . input . is_none ( ) {
182- bail ! ( "Input must be supplied when -- non-interactive is set " ) ;
182+ bail ! ( "Input must be supplied when running in non-interactive mode " ) ;
183183 }
184184
185185 let stdout = std:: io:: stdout ( ) ;
@@ -353,11 +353,9 @@ const ROTATING_TIPS: [&str; 16] = [
353353
354354const GREETING_BREAK_POINT : usize = 80 ;
355355
356- const POPULAR_SHORTCUTS : & str = color_print:: cstr! { "<black!><green!>/help</green!> all commands <em>•</em>
357- <green!>ctrl + j</green!> new lines <em>•</em>
358- <green!>ctrl + s</green!> fuzzy search <em>•</em>
359- <green!>ctrl + f</green!> accept completion
360- </black!>" } ;
356+ const POPULAR_SHORTCUTS : & str = color_print:: cstr! {
357+ "<black!><green!>/help</green!> all commands <em>•</em> <green!>ctrl + j</green!> new lines
358+ <green!>ctrl + s</green!> fuzzy search <em>•</em> <green!>ctrl + f</green!> accept completion</black!>" } ;
361359const SMALL_SCREEN_POPULAR_SHORTCUTS : & str = color_print:: cstr! { "<black!><green!>/help</green!> all commands
362360<green!>ctrl + j</green!> new lines
363361<green!>ctrl + s</green!> fuzzy search
@@ -650,7 +648,7 @@ impl ChatSession {
650648 ) ?;
651649 }
652650
653- let ( context, report) = match err {
651+ let ( context, report, display_err_message ) = match err {
654652 ChatError :: Interrupted { tool_uses : ref inter } => {
655653 execute ! ( self . stderr, style:: Print ( "\n \n " ) ) ?;
656654
@@ -675,7 +673,7 @@ impl ChatSession {
675673 _ => ( ) ,
676674 }
677675
678- ( "Tool use was interrupted" , Report :: from ( err) )
676+ ( "Tool use was interrupted" , Report :: from ( err) , false )
679677 } ,
680678 ChatError :: Client ( err) => match * err {
681679 // Errors from attempting to send too large of a conversation history. In
@@ -709,9 +707,10 @@ impl ChatSession {
709707 (
710708 "The context window has overflowed, summarizing the history..." ,
711709 Report :: from ( err) ,
710+ true ,
712711 )
713712 } ,
714- ApiClientError :: QuotaBreach { message, .. } => ( message, Report :: from ( err) ) ,
713+ ApiClientError :: QuotaBreach { message, .. } => ( message, Report :: from ( err) , true ) ,
715714 ApiClientError :: ModelOverloadedError { request_id, .. } => {
716715 let err = format ! (
717716 "The model you've selected is temporarily unavailable. Please use '/model' to select a different model and try again.{}\n \n " ,
@@ -721,7 +720,7 @@ impl ChatSession {
721720 }
722721 ) ;
723722 self . conversation . append_transcript ( err. clone ( ) ) ;
724- ( "Amazon Q is having trouble responding right now" , eyre ! ( err) )
723+ ( "Amazon Q is having trouble responding right now" , eyre ! ( err) , true )
725724 } ,
726725 ApiClientError :: MonthlyLimitReached { .. } => {
727726 let subscription_status = get_subscription_status ( os) . await ;
@@ -778,33 +777,44 @@ impl ChatSession {
778777
779778 return Ok ( ( ) ) ;
780779 } ,
781- _ => ( "Amazon Q is having trouble responding right now" , Report :: from ( err) ) ,
780+ _ => (
781+ "Amazon Q is having trouble responding right now" ,
782+ Report :: from ( err) ,
783+ true ,
784+ ) ,
782785 } ,
783- _ => ( "Amazon Q is having trouble responding right now" , Report :: from ( err) ) ,
786+ _ => (
787+ "Amazon Q is having trouble responding right now" ,
788+ Report :: from ( err) ,
789+ true ,
790+ ) ,
784791 } ;
785792
786- // Remove non-ASCII and ANSI characters.
787- let re = Regex :: new ( r"((\x9B|\x1B\[)[0-?]*[ -\/]*[@-~])|([^\x00-\x7F]+)" ) . unwrap ( ) ;
793+ if display_err_message {
794+ // Remove non-ASCII and ANSI characters.
795+ let re = Regex :: new ( r"((\x9B|\x1B\[)[0-?]*[ -\/]*[@-~])|([^\x00-\x7F]+)" ) . unwrap ( ) ;
788796
789- queue ! (
790- self . stderr,
791- style:: SetAttribute ( Attribute :: Bold ) ,
792- style:: SetForegroundColor ( Color :: Red ) ,
793- ) ?;
797+ queue ! (
798+ self . stderr,
799+ style:: SetAttribute ( Attribute :: Bold ) ,
800+ style:: SetForegroundColor ( Color :: Red ) ,
801+ ) ?;
794802
795- let text = re. replace_all ( & format ! ( "{}: {:?}\n " , context, report) , "" ) . into_owned ( ) ;
803+ let text = re. replace_all ( & format ! ( "{}: {:?}\n " , context, report) , "" ) . into_owned ( ) ;
796804
797- queue ! ( self . stderr, style:: Print ( & text) , ) ?;
798- self . conversation . append_transcript ( text) ;
805+ queue ! ( self . stderr, style:: Print ( & text) , ) ?;
806+ self . conversation . append_transcript ( text) ;
799807
800- execute ! (
801- self . stderr,
802- style:: SetAttribute ( Attribute :: Reset ) ,
803- style:: SetForegroundColor ( Color :: Reset ) ,
804- ) ?;
808+ execute ! (
809+ self . stderr,
810+ style:: SetAttribute ( Attribute :: Reset ) ,
811+ style:: SetForegroundColor ( Color :: Reset ) ,
812+ ) ?;
813+ }
805814
806815 self . conversation . enforce_conversation_invariants ( ) ;
807816 self . conversation . reset_next_user_message ( ) ;
817+ self . pending_tool_index = None ;
808818
809819 self . inner = Some ( ChatState :: PromptUser {
810820 skip_printing_tools : false ,
0 commit comments