diff --git a/src/sharer.rs b/src/sharer.rs index 513e4a5..01ecd9d 100644 --- a/src/sharer.rs +++ b/src/sharer.rs @@ -154,16 +154,15 @@ pub enum SessionSourceType { }, } -/// Internal helper that mirrors all wire representations of SessionSourceType -/// (both legacy and new) so we don't recursively call SessionSourceType's -/// custom Deserialize impl. +/// Mirrors the legacy unit-variant form and the new struct-variant form so +/// the custom `Deserialize` impl can accept both shapes. #[derive(Deserialize)] #[serde(untagged)] enum SessionSourceTypeWire { - /// Legacy representation: "User" or "AmbientAgent". + /// Legacy representation: bare `"User"` or `"AmbientAgent"`. Legacy(LegacySessionSourceType), - /// New representation: externally tagged AmbientAgent with fields, e.g. - /// { "AmbientAgent": { "task_id": "..." } }. + /// New representation: externally tagged `AmbientAgent` with fields, e.g. + /// `{ "AmbientAgent": { "task_id": "..." } }`. New { #[serde(rename = "AmbientAgent")] ambient_agent: AmbientAgentFields, @@ -263,6 +262,13 @@ pub struct InitPayload { #[serde(default)] pub source_type: SessionSourceType, + /// Optional orchestrator `task_id` carried alongside `source_type`. + /// Set when the sharer wants downstream orchestration discovery to find + /// this share's children regardless of variant kind. Sidecar so the + /// `User` variant can stay a unit and old viewers ignore it. + #[serde(default)] + pub source_task_id: Option, + /// Client feature support declaration. #[serde(default)] pub feature_support: FeatureSupport, @@ -474,6 +480,10 @@ impl DownstreamMessage { } /// The possible messages sent from client (sharer) to server. +// `Initialize(InitPayload)` is much larger than the other variants because +// `InitPayload` carries scrollback and feature-support data. Boxing it would +// be wire-compatible but churn every call site; suppress the lint instead. +#[allow(clippy::large_enum_variant)] #[derive(Debug, Deserialize, Serialize)] pub enum UpstreamMessage { /// The client sends this message to start a shared session. diff --git a/src/viewer.rs b/src/viewer.rs index 16fbfd2..5295378 100644 --- a/src/viewer.rs +++ b/src/viewer.rs @@ -142,6 +142,13 @@ pub enum DownstreamMessage { /// The detailed source type for this shared session. #[serde(default)] detailed_source_type: SessionSourceType, + + /// Optional orchestrator `task_id` carried alongside the source + /// type, mirroring `sharer::InitPayload::source_task_id`. Lets + /// viewers find this share's orchestrator task without keying + /// off the source-type variant kind. + #[serde(default)] + source_task_id: Option, }, /// The server sends this message when the session was successfully rejoined.