Skip to main content

muse_code_sdk/msp/view/
health.rs

1// @generated from the MSP stable schema and protocol sources; do not edit by hand.
2
3use crate::msp::method::lifecycle::HistoryNoneReason;
4use serde::Deserialize;
5use serde::Serialize;
6
7/// `session/viewHealthChanged` params: the named session's live view stream
8/// became unavailable, and why, or it is back after the host re-loaded the
9/// view, so the client re-reads and re-subscribes.
10///
11/// Best-effort: ordered after already-queued view frames and may be dropped
12/// (for example when the connection is closing), so a client MUST NOT assume a
13/// guaranteed push and still reads `history.noneReason` on its next
14/// resume/read.
15#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
16#[serde(rename_all = "camelCase")]
17#[non_exhaustive]
18pub struct SessionViewHealthChangedParams {
19    /// The session whose live view health changed.
20    pub session_id: String,
21    /// The new view-health state: `Unavailable`, or `Healthy` once the host
22    /// re-loaded a failed view.
23    pub health: SessionViewHealth,
24    /// Why the view is unavailable — the SAME typed `HistoryNoneReason`
25    /// vocabulary the pull path stamps on `history.noneReason`, so a client
26    /// reuses one handler for push and pull. `projectionUnavailable` when the
27    /// view fails, then `projectionRebuildFailed`, which the pull path never
28    /// stamps: it rides only a `session/viewHealthChanged` notification, after
29    /// the host's one re-load of a failed live view fails or right after a fork
30    /// child's live fail-close; present only when `health` is `Unavailable`.
31    /// Open on the client side: an unknown reason decodes conservatively and
32    /// renders generically.
33    #[serde(default, skip_serializing_if = "Option::is_none")]
34    pub none_reason: Option<HistoryNoneReason>,
35}
36
37/// The view-health state. Open enum (`x-msp-openness: open`): a client MUST
38/// ignore an unrecognized value. `Healthy` is the re-arm value reserved by the
39/// governing rules, emitted after a host re-load; openness still reserves
40/// additive room for the durable-degraded axis.
41#[derive(Debug, Clone, PartialEq, Eq)]
42#[non_exhaustive]
43pub enum SessionViewHealth {
44    /// The live view stream is unavailable — see `noneReason`.
45    Unavailable,
46    /// The live view stream is back: the host re-loaded the view, whose
47    /// numbering may differ from the cursors the client holds, so the client
48    /// re-reads (`session/read`, `view/page`) and re-subscribes. Carries no
49    /// `noneReason`.
50    Healthy,
51    /// A value from a newer host, kept verbatim so an older client decodes the
52    /// rest of the message. Excluded from the generated schema while the enum
53    /// stays declared open; never construct it with a known word.
54    Unknown(String),
55}