fix: shows the correct config file update path with cli configure (#5195)

Signed-off-by: Anthony D. Mays <anthony@morganlatimer.com>
This commit is contained in:
Anthony D. Mays
2025-10-29 11:15:07 -07:00
committed by GitHub
parent 565dcb879b
commit 25789415a0
3 changed files with 51 additions and 9 deletions
+44 -7
View File
@@ -10,6 +10,7 @@ use goose::config::extensions::{
get_all_extension_names, get_all_extensions, get_enabled_extensions, get_extension_by_name,
name_to_key, remove_extension, set_extension, set_extension_enabled,
};
use goose::config::paths::Paths;
use goose::config::permission::PermissionLevel;
use goose::config::signup_tetrate::TetrateAuth;
use goose::config::{
@@ -195,15 +196,17 @@ pub async fn handle_configure() -> anyhow::Result<()> {
}
Ok(())
} else {
let config_dir = Paths::config_dir().display().to_string();
println!();
println!(
"{}",
style("This will update your existing config file").dim()
style("This will update your existing config files").dim()
);
println!(
"{} {}",
style(" if you prefer, you can edit it directly at").dim(),
config.path()
style(" if you prefer, you can edit them directly at").dim(),
config_dir
);
println!();
@@ -486,7 +489,7 @@ pub async fn configure_provider_dialog() -> anyhow::Result<bool> {
} else {
config.set_param(&key.name, Value::String(env_value))?;
}
let _ = cliclack::log::info(format!("Saved {} to config file", key.name));
let _ = cliclack::log::info(format!("Saved {} to {}", key.name, config.path()));
}
}
None => {
@@ -648,7 +651,7 @@ pub async fn configure_provider_dialog() -> anyhow::Result<bool> {
// Update config with new values only if the test succeeds
config.set_param("GOOSE_PROVIDER", Value::String(provider_name.to_string()))?;
config.set_param("GOOSE_MODEL", Value::String(model.clone()))?;
cliclack::outro("Configuration saved successfully")?;
print_config_file_saved()?;
Ok(true)
}
Err(e) => {
@@ -709,7 +712,11 @@ pub fn toggle_extensions_dialog() -> anyhow::Result<()> {
);
}
cliclack::outro("Extension settings updated successfully")?;
let config = Config::global();
cliclack::outro(format!(
"Extension settings saved successfully to {}",
config.path()
))?;
Ok(())
}
@@ -1123,6 +1130,8 @@ pub fn configure_extensions_dialog() -> anyhow::Result<()> {
_ => unreachable!(),
};
print_config_file_saved()?;
Ok(())
}
@@ -1178,6 +1187,8 @@ pub fn remove_extension_dialog() -> anyhow::Result<()> {
cliclack::outro(format!("Removed {} extension", style(name).green()))?;
}
print_config_file_saved()?;
Ok(())
}
@@ -1216,6 +1227,8 @@ pub async fn configure_settings_dialog() -> anyhow::Result<()> {
)
.interact()?;
let mut should_print_config_path = true;
match setting_type {
"goose_mode" => {
configure_goose_mode_dialog()?;
@@ -1225,6 +1238,8 @@ pub async fn configure_settings_dialog() -> anyhow::Result<()> {
}
"tool_permission" => {
configure_tool_permissions_dialog().await.and(Ok(()))?;
// No need to print config file path since it's already handled.
should_print_config_path = false;
}
"tool_output" => {
configure_tool_output_dialog()?;
@@ -1241,6 +1256,10 @@ pub async fn configure_settings_dialog() -> anyhow::Result<()> {
_ => unreachable!(),
};
if should_print_config_path {
print_config_file_saved()?;
}
Ok(())
}
@@ -1547,6 +1566,11 @@ pub async fn configure_tool_permissions_dialog() -> anyhow::Result<()> {
tool.name, permission_label
))?;
cliclack::outro(format!(
"Changes saved to {}",
permission_manager.get_config_path().display()
))?;
Ok(())
}
@@ -1893,5 +1917,18 @@ pub fn configure_custom_provider_dialog() -> anyhow::Result<()> {
"add" => add_provider(),
"remove" => remove_provider(),
_ => unreachable!(),
}
}?;
print_config_file_saved()?;
Ok(())
}
fn print_config_file_saved() -> anyhow::Result<()> {
let config = Config::global();
cliclack::outro(format!(
"Configuration saved successfully to {}",
config.path()
))?;
Ok(())
}
+2 -2
View File
@@ -14,11 +14,11 @@ pub fn handle_info(verbose: bool) -> Result<()> {
// Get paths using a stored reference to the global config
let config = Config::global();
let config_file = config.path();
let config_dir = Paths::config_dir().display().to_string();
// Define the labels and their corresponding path values once.
let paths = [
("Config file:", config_file.to_string()),
("Config dir:", config_dir),
("Sessions dir:", sessions_dir.display().to_string()),
("Logs dir:", logs_dir.display().to_string()),
];
+5
View File
@@ -91,6 +91,11 @@ impl PermissionManager {
self.get_permission(SMART_APPROVE_PERMISSION, principal_name)
}
/// Retrieves the config file path.
pub fn get_config_path(&self) -> &Path {
self.config_path.as_path()
}
/// Helper function to retrieve the permission level for a specific permission category and tool.
fn get_permission(&self, name: &str, principal_name: &str) -> Option<PermissionLevel> {
// Check if the permission category exists in the map