@@ -105,9 +105,12 @@ const HELP_TEXT: &str = color_print::cstr! {"
105105
106106<em>!{command}</em> <black!>Quickly execute a command in your current session</black!>
107107
108+ <black!>Use the following dangerous command at your own discretion.</black!>
109+ <em>/acceptall</em> <black!>Disables acceptance prompting for the session.</black!>
110+
108111" } ;
109112
110- pub async fn chat ( input : Option < String > ) -> Result < ExitCode > {
113+ pub async fn chat ( input : Option < String > , accept_all : bool ) -> Result < ExitCode > {
111114 if !fig_util:: system_info:: in_cloudshell ( ) && !fig_auth:: is_logged_in ( ) . await {
112115 bail ! (
113116 "You are not logged in, please log in with {}" ,
@@ -136,9 +139,16 @@ pub async fn chat(input: Option<String>) -> Result<ExitCode> {
136139 _ => StreamingClient :: new ( ) . await ?,
137140 } ;
138141
139- let mut chat = ChatContext :: new ( ctx, output, input, InputSource :: new ( ) ?, interactive, client, || {
140- terminal:: window_size ( ) . map ( |s| s. columns . into ( ) ) . ok ( )
141- } ) ?;
142+ let mut chat = ChatContext :: new (
143+ ctx,
144+ output,
145+ input,
146+ InputSource :: new ( ) ?,
147+ interactive,
148+ client,
149+ || terminal:: window_size ( ) . map ( |s| s. columns . into ( ) ) . ok ( ) ,
150+ accept_all,
151+ ) ?;
142152
143153 let result = chat. try_chat ( ) . await . map ( |_| ExitCode :: SUCCESS ) ;
144154 drop ( chat) ; // Explicit drop for clarity
@@ -191,9 +201,11 @@ pub struct ChatContext<W: Write> {
191201 tool_use_telemetry_events : HashMap < String , ToolUseEventBuilder > ,
192202 /// State used to keep track of tool use relation
193203 tool_use_status : ToolUseStatus ,
204+ accept_all : bool ,
194205}
195206
196207impl < W : Write > ChatContext < W > {
208+ #[ allow( clippy:: too_many_arguments) ]
197209 pub fn new (
198210 ctx : Arc < Context > ,
199211 output : W ,
@@ -202,6 +214,7 @@ impl<W: Write> ChatContext<W> {
202214 interactive : bool ,
203215 client : StreamingClient ,
204216 terminal_width_provider : fn ( ) -> Option < usize > ,
217+ accept_all : bool ,
205218 ) -> Result < Self > {
206219 Ok ( Self {
207220 ctx,
@@ -215,6 +228,7 @@ impl<W: Write> ChatContext<W> {
215228 conversation_state : ConversationState :: new ( load_tools ( ) ?) ,
216229 tool_use_telemetry_events : HashMap :: new ( ) ,
217230 tool_use_status : ToolUseStatus :: Idle ,
231+ accept_all,
218232 } )
219233 }
220234}
@@ -429,7 +443,7 @@ where
429443 style:: Print ( "y" ) ,
430444 style:: SetForegroundColor ( Color :: DarkGrey ) ,
431445 style:: Print ( format!(
432- " to run {}, otherwise continue without .\n \n " ,
446+ " to run {}, otherwise continue chatting .\n \n " ,
433447 match tool_uses. len( ) == 1 {
434448 true => "this tool" ,
435449 false => "these tools" ,
@@ -499,7 +513,7 @@ where
499513 execute ! (
500514 self . output,
501515 style:: SetForegroundColor ( Color :: Green ) ,
502- style:: Print ( "\n Conversation history cleared\n \n " ) ,
516+ style:: Print ( "\n Conversation history cleared. \n \n " ) ,
503517 style:: SetForegroundColor ( Color :: Reset )
504518 ) ?;
505519
@@ -509,6 +523,21 @@ where
509523 execute ! ( self . output, style:: Print ( HELP_TEXT ) ) ?;
510524 ChatState :: PromptUser { tool_uses : None }
511525 } ,
526+ Command :: AcceptAll => {
527+ self . accept_all = !self . accept_all ;
528+
529+ execute ! (
530+ self . output,
531+ style:: SetForegroundColor ( Color :: Green ) ,
532+ style:: Print ( format!( "\n {} acceptance prompting.\n \n " , match self . accept_all {
533+ true => "Disabled" ,
534+ false => "Enabled" ,
535+ } ) ) ,
536+ style:: SetForegroundColor ( Color :: Reset )
537+ ) ?;
538+
539+ ChatState :: PromptUser { tool_uses : None }
540+ } ,
512541 Command :: Quit => ChatState :: Exit ,
513542 } )
514543 }
@@ -851,20 +880,16 @@ where
851880 return Ok ( ChatState :: HandleResponseStream ( response) ) ;
852881 }
853882
854- let skip_consent = self
855- . ctx
856- . env ( )
857- . get ( "Q_CHAT_SKIP_TOOL_CONSENT" )
858- . is_ok_and ( |s| !s. is_empty ( ) && !queued_tools. is_empty ( ) )
859- || queued_tools. iter ( ) . all ( |tool| !tool. 1 . requires_consent ( & self . ctx ) ) ;
883+ let skip_acceptance = self . accept_all || queued_tools. iter ( ) . all ( |tool| !tool. 1 . requires_acceptance ( & self . ctx ) ) ;
860884
861- if skip_consent {
862- self . print_tool_descriptions ( & queued_tools) ?;
863- Ok ( ChatState :: ExecuteTools ( queued_tools) )
864- } else {
865- Ok ( ChatState :: PromptUser {
885+ match skip_acceptance {
886+ true => {
887+ self . print_tool_descriptions ( & queued_tools) ?;
888+ Ok ( ChatState :: ExecuteTools ( queued_tools) )
889+ } ,
890+ false => Ok ( ChatState :: PromptUser {
866891 tool_uses : Some ( queued_tools) ,
867- } )
892+ } ) ,
868893 }
869894 }
870895
@@ -1080,6 +1105,7 @@ mod tests {
10801105 true ,
10811106 test_client,
10821107 || Some ( 80 ) ,
1108+ false ,
10831109 )
10841110 . unwrap ( )
10851111 . try_chat ( )
0 commit comments