From 420936687ba570b038e761a3fc25d94044a08fc1 Mon Sep 17 00:00:00 2001 From: BuriKizilkaya Date: Tue, 1 Dec 2026 09:32:21 +0100 Subject: [PATCH] fix: reset options when changing space provider --- src/commands/config.rs | 3 +++ tests/cli.rs | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/commands/config.rs b/src/commands/config.rs index 0d77dc7..d48e951 100644 --- a/src/commands/config.rs +++ b/src/commands/config.rs @@ -56,6 +56,9 @@ async fn set_config(context: AppContext, command: SetConfig) -> Result() .map_err(|error| error.to_string())?; + if config::provider_for_space(&config, &context.active_space) != command.value { + config["spaces"][&context.active_space]["options"] = serde_json::json!({}); + } let key = format!("spaces.{}.provider", context.active_space); config::set_value(&mut config, &key, command.value.clone()) .map_err(|error| error.to_string())?; diff --git a/tests/cli.rs b/tests/cli.rs index 661f581..e27ba6e 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -186,6 +186,18 @@ fn spaces_isolate_entries_and_provider_configuration() { ); assert!(config.get("environmentUrl").is_none()); + stdout(psa( + &home, + &["--space", "klab", "config", "set", "provider", "local"], + )); + let config: serde_json::Value = serde_json::from_slice( + &std::fs::read(AppPaths::for_home(home.path().to_path_buf()).config_file) + .expect("updated config is saved"), + ) + .expect("updated config is valid JSON"); + assert_eq!(config["spaces"]["klab"]["provider"], "local"); + assert_eq!(config["spaces"]["klab"]["options"], serde_json::json!({})); + stdout(psa(&home, &["--use-space", "klab"])); assert!(stdout(psa(&home, &["space", "current"])).contains("Klab (klab)")); assert!(