diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-31 03:02:45 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-31 03:04:20 +0300 |
| commit | 77819797385c5538f624a8881208921342911db0 (patch) | |
| tree | 931a03aa3825a10d6b6d73b63e4ce80e19ecbf56 /src/server | |
| parent | 3acd499ffb1119e8032bbcba3f1f46d4ff5f3da9 (diff) | |
fix: clarify update restart guidance
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/autodetect.rs | 28 | ||||
| -rw-r--r-- | src/server/headless.rs | 8 |
2 files changed, 23 insertions, 13 deletions
diff --git a/src/server/autodetect.rs b/src/server/autodetect.rs index c278329d..c012aa03 100644 --- a/src/server/autodetect.rs +++ b/src/server/autodetect.rs @@ -85,11 +85,10 @@ fn read_server_status() -> io::Result<Option<crate::api::RuntimeStatus>> { } fn validate_running_server_compatibility() -> io::Result<()> { - let stop_command = crate::session::local_stop_command(); - let attach_command = crate::session::local_attach_command(); let Some(status) = read_server_status()? else { return Err(io::Error::other(format!( - "a herdr server is listening, but its status API is unavailable. Try `{stop_command}`; if that fails, stop the old server process manually, then run `{attach_command}` again." + "a herdr server is listening, but its status API is unavailable.\n\n{}\nIf that fails, stop the old server process manually.", + crate::session::active_restart_after_update_guidance() ))); }; @@ -98,14 +97,15 @@ fn validate_running_server_compatibility() -> io::Result<()> { } Err(io::Error::other(format!( - "herdr server is running from v{} / protocol {}, but this client is v{} / protocol {}.\nStop the old server with `{stop_command}`, then run `{attach_command}` again.", + "Herdr was updated, but this session is still running the old server.\n\nserver: v{} protocol {}\nclient: v{} protocol {}\n\n{}", status.version.as_deref().unwrap_or("unknown"), status .protocol .map(|value| value.to_string()) .unwrap_or_else(|| "unknown".to_string()), env!("CARGO_PKG_VERSION"), - crate::protocol::PROTOCOL_VERSION + crate::protocol::PROTOCOL_VERSION, + crate::session::active_restart_after_update_guidance() ))) } @@ -432,12 +432,13 @@ mod tests { fn validate_running_server_compatibility_names_session_commands_for_protocol_mismatch() { let _guard = env_lock().lock().unwrap(); let dir = unique_test_dir("named-protocol"); - std::fs::create_dir_all(&dir).unwrap(); - let path = dir.join("api.sock"); - let listener = UnixListener::bind(&path).unwrap(); - std::env::set_var(crate::api::SOCKET_PATH_ENV_VAR, &path); + std::env::set_var("XDG_CONFIG_HOME", &dir); std::env::set_var(crate::session::SESSION_ENV_VAR, "work"); + std::env::remove_var(crate::api::SOCKET_PATH_ENV_VAR); crate::session::clear_explicit_session_for_test(); + let path = crate::session::api_socket_path_for(Some("work")); + std::fs::create_dir_all(path.parent().unwrap()).unwrap(); + let listener = UnixListener::bind(&path).unwrap(); let handle = std::thread::spawn(move || { let (mut stream, _) = listener.accept().unwrap(); let mut request = String::new(); @@ -458,15 +459,20 @@ mod tests { let _ = handle.join(); assert!( - message.contains("Stop the old server with `herdr session stop work`"), + message.contains("Stop the old server to use the new version"), + "unexpected error: {message}" + ); + assert!( + message.contains("Run `herdr session stop work`"), "unexpected error: {message}" ); assert!( message.contains("then run `herdr session attach work` again"), "unexpected error: {message}" ); - std::env::remove_var(crate::api::SOCKET_PATH_ENV_VAR); + std::env::remove_var("XDG_CONFIG_HOME"); std::env::remove_var(crate::session::SESSION_ENV_VAR); + std::env::remove_var(crate::api::SOCKET_PATH_ENV_VAR); crate::session::clear_explicit_session_for_test(); let _ = std::fs::remove_dir_all(dir); } diff --git a/src/server/headless.rs b/src/server/headless.rs index 3d273b1c..2bf8fa15 100644 --- a/src/server/headless.rs +++ b/src/server/headless.rs @@ -1359,7 +1359,8 @@ impl HeadlessServer { .map(|toast| format!("{}: {}", toast.title, toast.context)) } else { Some(format!( - "v{version} available: detach, then run `{install_command}`" + "v{version} available: {}", + crate::update::update_install_instruction(&install_command) )) } } else { @@ -5062,7 +5063,10 @@ next_tab = "" ) { ServerMessage::Notify { kind, message } => { assert_eq!(kind, protocol::NotifyKind::SystemToast); - assert_eq!(message, "v9.9.9 available: detach, then run `herdr update`"); + assert_eq!( + message, + "v9.9.9 available: detach, run `herdr update`, then follow its restart guidance" + ); } other => panic!("expected system toast notify, got {other:?}"), } |
