@@ -298,6 +298,7 @@ pub async fn launch_chat(database: &mut Database, telemetry: &TelemetryThread, a
298298 telemetry,
299299 args. input ,
300300 args. no_interactive ,
301+ args. new ,
301302 args. accept_all ,
302303 args. profile ,
303304 args. trust_all_tools ,
@@ -306,12 +307,13 @@ pub async fn launch_chat(database: &mut Database, telemetry: &TelemetryThread, a
306307 . await
307308}
308309
309- #[ allow( clippy:: too_many_arguments) ]
310+ #[ allow( clippy:: too_many_arguments, clippy :: fn_params_excessive_bools ) ]
310311pub async fn chat (
311312 database : & mut Database ,
312313 telemetry : & TelemetryThread ,
313314 input : Option < String > ,
314315 no_interactive : bool ,
316+ new_conversation : bool ,
315317 accept_all : bool ,
316318 profile : Option < String > ,
317319 trust_all_tools : bool ,
@@ -440,6 +442,7 @@ pub async fn chat(
440442 input,
441443 InputSource :: new ( database, prompt_request_sender, prompt_response_receiver) ?,
442444 interactive,
445+ new_conversation,
443446 client,
444447 || terminal:: window_size ( ) . map ( |s| s. columns . into ( ) ) . ok ( ) ,
445448 tool_manager,
@@ -526,6 +529,7 @@ impl ChatContext {
526529 mut input : Option < String > ,
527530 input_source : InputSource ,
528531 interactive : bool ,
532+ new_conversation : bool ,
529533 client : StreamingClient ,
530534 terminal_width_provider : fn ( ) -> Option < usize > ,
531535 tool_manager : ToolManager ,
@@ -537,31 +541,48 @@ impl ChatContext {
537541 let output_clone = output. clone ( ) ;
538542
539543 let mut existing_conversation = false ;
540- let conversation_state = match std:: env:: current_dir ( )
541- . ok ( )
542- . and_then ( |cwd| database. get_conversation_by_path ( cwd) . ok ( ) )
543- . flatten ( )
544- {
545- Some ( mut prior) => {
546- existing_conversation = true ;
547- prior
548- . reload_serialized_state ( Arc :: clone ( & ctx) , Some ( output. clone ( ) ) )
549- . await ;
550- input = Some ( input. unwrap_or ( "In a few words, summarize our conversation so far." . to_owned ( ) ) ) ;
551- prior. tool_manager = tool_manager;
552- prior
553- } ,
554- None => {
555- ConversationState :: new (
556- ctx_clone,
557- conversation_id,
558- tool_config,
559- profile,
560- Some ( output_clone) ,
561- tool_manager,
562- )
563- . await
564- } ,
544+ let conversation_state = if new_conversation {
545+ let new_state = ConversationState :: new (
546+ ctx_clone,
547+ conversation_id,
548+ tool_config,
549+ profile,
550+ Some ( output_clone) ,
551+ tool_manager,
552+ )
553+ . await ;
554+
555+ std:: env:: current_dir ( )
556+ . ok ( )
557+ . and_then ( |cwd| database. set_conversation_by_path ( cwd, & new_state) . ok ( ) ) ;
558+ new_state
559+ } else {
560+ match std:: env:: current_dir ( )
561+ . ok ( )
562+ . and_then ( |cwd| database. get_conversation_by_path ( cwd) . ok ( ) )
563+ . flatten ( )
564+ {
565+ Some ( mut prior) => {
566+ existing_conversation = true ;
567+ prior
568+ . reload_serialized_state ( Arc :: clone ( & ctx) , Some ( output. clone ( ) ) )
569+ . await ;
570+ input = Some ( input. unwrap_or ( "In a few words, summarize our conversation so far." . to_owned ( ) ) ) ;
571+ prior. tool_manager = tool_manager;
572+ prior
573+ } ,
574+ None => {
575+ ConversationState :: new (
576+ ctx_clone,
577+ conversation_id,
578+ tool_config,
579+ profile,
580+ Some ( output_clone) ,
581+ tool_manager,
582+ )
583+ . await
584+ } ,
585+ }
565586 } ;
566587
567588 Ok ( Self {
@@ -3692,6 +3713,7 @@ mod tests {
36923713 "exit" . to_string( ) ,
36933714 ] ) ,
36943715 true ,
3716+ false ,
36953717 test_client,
36963718 || Some ( 80 ) ,
36973719 tool_manager,
@@ -3837,6 +3859,7 @@ mod tests {
38373859 "exit" . to_string( ) ,
38383860 ] ) ,
38393861 true ,
3862+ false ,
38403863 test_client,
38413864 || Some ( 80 ) ,
38423865 tool_manager,
@@ -3935,6 +3958,7 @@ mod tests {
39353958 "exit" . to_string( ) ,
39363959 ] ) ,
39373960 true ,
3961+ false ,
39383962 test_client,
39393963 || Some ( 80 ) ,
39403964 tool_manager,
@@ -4012,6 +4036,7 @@ mod tests {
40124036 "exit" . to_string( ) ,
40134037 ] ) ,
40144038 true ,
4039+ false ,
40154040 test_client,
40164041 || Some ( 80 ) ,
40174042 tool_manager,
0 commit comments