From dbf600c1f59b91807cd6be153ff336fb7a834b04 Mon Sep 17 00:00:00 2001 From: Anders Olsson Date: Fri, 7 Aug 2026 15:37:12 +0200 Subject: [PATCH] feat(protocol): Waiting state and WaitInfo on StatusDetail --- crates/xy-protocol/src/rpc.rs | 9 +++++++++ crates/xy-protocol/src/state.rs | 12 ++++++++++++ crates/xy/src/daemon/handlers.rs | 1 + 3 files changed, 22 insertions(+) diff --git a/crates/xy-protocol/src/rpc.rs b/crates/xy-protocol/src/rpc.rs index 6a17a82..397fecd 100644 --- a/crates/xy-protocol/src/rpc.rs +++ b/crates/xy-protocol/src/rpc.rs @@ -20,6 +20,15 @@ pub struct StatusDetail { #[serde(flatten)] pub summary: ServerSummary, pub recent_transitions: Vec, + #[serde(default)] + pub wait_for: Option, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct WaitInfo { + pub description: String, + pub elapsed_secs: u64, + pub timeout_secs: u64, } #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/crates/xy-protocol/src/state.rs b/crates/xy-protocol/src/state.rs index 3fced82..bab3d17 100644 --- a/crates/xy-protocol/src/state.rs +++ b/crates/xy-protocol/src/state.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; #[serde(rename_all = "kebab-case")] pub enum ServerState { Stopped, + Waiting, Starting, Running, Restarting, @@ -28,4 +29,15 @@ mod tests { let s: ServerState = serde_json::from_str("\"failed\"").unwrap(); assert_eq!(s, ServerState::Failed); } + + #[test] + fn waiting_state_round_trips_as_json() { + let json = serde_json::to_string(&ServerState::Waiting).unwrap(); + + assert_eq!(json, "\"waiting\""); + + let back: ServerState = serde_json::from_str(&json).unwrap(); + + assert_eq!(back, ServerState::Waiting); + } } diff --git a/crates/xy/src/daemon/handlers.rs b/crates/xy/src/daemon/handlers.rs index ad0c888..c81296e 100644 --- a/crates/xy/src/daemon/handlers.rs +++ b/crates/xy/src/daemon/handlers.rs @@ -200,6 +200,7 @@ async fn status(reg: &Registry, name: &str) -> Result { last_exit: s.last_exit, }, recent_transitions: Vec::new(), + wait_for: None, }) }