When an identity becomes the active default, automatically activate the server profile bound to it (if any). Looks for a named profile in `~/.atomic/config.toml` whose `identity` field matches `identity_name`. If found, sets `default_server` to that profile name and saves the config. Emits a hint so the user knows the server switched alongside the identity. This is intentionally non-fatal: if th
(identity_name: &str)
| 358 | /// a debug log is emitted and the command still succeeds — the identity |
| 359 | /// switch itself is the important operation. |
| 360 | pub fn activate_server_for_identity(identity_name: &str) { |
| 361 | let mut config = match GlobalConfig::load() { |
| 362 | Ok(c) => c, |
| 363 | Err(e) => { |
| 364 | log::debug!("Could not load config for server auto-activation: {}", e); |
| 365 | return; |
| 366 | } |
| 367 | }; |
| 368 | |
| 369 | // Find a named server profile whose identity binding matches. |
| 370 | let matching_profile = config |
| 371 | .servers |
| 372 | .iter() |
| 373 | .find(|(_, srv)| srv.identity.as_deref() == Some(identity_name)) |
| 374 | .map(|(name, _)| name.clone()); |
| 375 | |
| 376 | if let Some(profile_name) = matching_profile { |
| 377 | // Only update + print if it's actually changing. |
| 378 | if config.default_server.as_deref() != Some(&profile_name) { |
| 379 | config.default_server = Some(profile_name.clone()); |
| 380 | if let Err(e) = config.save() { |
| 381 | log::debug!("Could not save config for server auto-activation: {}", e); |
| 382 | return; |
| 383 | } |
| 384 | crate::output::print_hint(&format!( |
| 385 | "Server profile '{}' activated (bound to identity '{}')", |
| 386 | profile_name, identity_name |
| 387 | )); |
| 388 | } |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | /// Format an identity type for display. |
| 393 | pub fn format_identity_type(identity_type: &atomic_identity::IdentityType) -> &'static str { |