mirror of
https://github.com/neovide/neovide.git
synced 2026-09-10 07:16:25 -04:00
handoff: return the listener version in responses (#3423)
when we are debugging the reuse-instance behavior, the version is helpful to troubleshoot.
This commit is contained in:
parent
5c4054db46
commit
75be80885e
|
|
@ -79,6 +79,7 @@ impl Drop for ListenerGuard {
|
|||
#[serde(deny_unknown_fields)]
|
||||
struct HandoffResponse {
|
||||
accepted: bool,
|
||||
version: String,
|
||||
error: Option<String>,
|
||||
}
|
||||
|
||||
|
|
@ -228,6 +229,7 @@ fn handle_request(
|
|||
if let Err(error) = proxy.send_event(payload) {
|
||||
return HandoffResponse {
|
||||
accepted: false,
|
||||
version: BUILD_VERSION.to_owned(),
|
||||
error: Some(format!(
|
||||
"failed to forward handoff request to app event loop: {error}"
|
||||
)),
|
||||
|
|
@ -235,7 +237,7 @@ fn handle_request(
|
|||
}
|
||||
}
|
||||
|
||||
HandoffResponse { accepted: true, error: None }
|
||||
HandoffResponse { accepted: true, version: BUILD_VERSION.to_owned(), error: None }
|
||||
}
|
||||
|
||||
fn endpoint_path() -> std::path::PathBuf {
|
||||
|
|
@ -274,7 +276,7 @@ where
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{HandoffRequest, read_message, write_message};
|
||||
use super::{HandoffRequest, HandoffResponse, read_message, write_message};
|
||||
use crate::version::BUILD_VERSION;
|
||||
use std::io::Cursor;
|
||||
|
||||
|
|
@ -308,4 +310,18 @@ mod tests {
|
|||
|
||||
assert_eq!(decoded, request);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn json_line_roundtrip_preserves_response() {
|
||||
let response =
|
||||
HandoffResponse { accepted: true, version: BUILD_VERSION.to_owned(), error: None };
|
||||
|
||||
let mut encoded = Vec::new();
|
||||
write_message(&mut encoded, &response).unwrap();
|
||||
|
||||
let mut cursor = Cursor::new(encoded);
|
||||
let decoded: HandoffResponse = read_message(&mut cursor).unwrap();
|
||||
|
||||
assert_eq!(decoded, response);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue