From 304d5bc3b010018af3714a9ac0fb2f24b6c0c18c Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Tue, 18 Mar 2025 10:23:26 +1100 Subject: [PATCH 1/2] fix: check if working direction has changed before asking --- crates/goose-cli/src/session/builder.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/goose-cli/src/session/builder.rs b/crates/goose-cli/src/session/builder.rs index 390db571476a..0de384c4b269 100644 --- a/crates/goose-cli/src/session/builder.rs +++ b/crates/goose-cli/src/session/builder.rs @@ -76,13 +76,16 @@ pub async fn build_session( process::exit(1); }); - // Ask user if they want to change the working directory - let change_workdir = cliclack::confirm(format!("{} The working directory of this session was set to {}. It does not match the current working directory. Would you like to change it?", style("WARNING:").yellow(), style(metadata.working_dir.display()).cyan())) - .initial_value(true) - .interact().expect("Failed to get user input"); - - if change_workdir { - std::env::set_current_dir(metadata.working_dir).unwrap(); + let current_workdir = std::env::current_dir().expect("Failed to get current working directory"); + if current_workdir != metadata.working_dir { + // Ask user if they want to change the working directory + let change_workdir = cliclack::confirm(format!("{} The working directory of this session was set to {}. It does not match the current working directory. Would you like to change it?", style("WARNING:").yellow(), style(metadata.working_dir.display()).cyan())) + .initial_value(true) + .interact().expect("Failed to get user input"); + + if change_workdir { + std::env::set_current_dir(metadata.working_dir).unwrap(); + } } } From dc02e079467b219af0a6b7535b53e392eed30937 Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Tue, 18 Mar 2025 10:36:44 +1100 Subject: [PATCH 2/2] fix: rust code format --- crates/goose-cli/src/session/builder.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/goose-cli/src/session/builder.rs b/crates/goose-cli/src/session/builder.rs index 0de384c4b269..c89c7dbcce66 100644 --- a/crates/goose-cli/src/session/builder.rs +++ b/crates/goose-cli/src/session/builder.rs @@ -76,7 +76,8 @@ pub async fn build_session( process::exit(1); }); - let current_workdir = std::env::current_dir().expect("Failed to get current working directory"); + let current_workdir = + std::env::current_dir().expect("Failed to get current working directory"); if current_workdir != metadata.working_dir { // Ask user if they want to change the working directory let change_workdir = cliclack::confirm(format!("{} The working directory of this session was set to {}. It does not match the current working directory. Would you like to change it?", style("WARNING:").yellow(), style(metadata.working_dir.display()).cyan()))