| 1 | use serde::{Deserialize, Serialize}; |
| 2 | use uuid::Uuid; |
| 3 | |
| 4 | use crate::common::ServerConversationToken; |
| 5 | |
| 6 | /// A unique id to track control action requests. |
| 7 | #[derive(Clone, Debug, Serialize, Deserialize)] |
| 8 | pub struct ControlActionRequestId(String); |
| 9 | |
| 10 | impl ControlActionRequestId { |
| 11 | #[allow(clippy::new_without_default)] |
| 12 | pub fn new() -> Self { |
| 13 | Self(Uuid::new_v4().to_string()) |
| 14 | } |
| 15 | |
| 16 | /// Returns the underlying opaque id string. |
| 17 | pub fn id(&self) -> &str { |
| 18 | &self.0 |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | /// Higher-level control messages that don't correspond 1:1 to terminal actions/inputs |
| 23 | /// (or imply a warp-specific action outside of their normal terminal use). |
| 24 | #[derive(Clone, Debug, Serialize, Deserialize)] |
| 25 | pub enum ControlAction { |
| 26 | /// Request that a shared-session AI conversation be cancelled by the sharer. |
| 27 | CancelConversation { |
| 28 | server_conversation_token: ServerConversationToken, |
| 29 | }, |
| 30 | } |
| 31 | |
| 32 | /// Reasons a control action request from a viewer might fail. |
| 33 | #[derive(Clone, Copy, Debug, Serialize, Deserialize)] |
| 34 | pub enum ControlActionFailureReason { |
| 35 | /// The viewer does not have permission to perform this control action. |
| 36 | InsufficientPermissions, |
| 37 | /// The session no longer exists. |
| 38 | SessionNotFound, |
| 39 | /// There is no sharer currently connected to handle the action. |
| 40 | SharerUnavailable, |
| 41 | /// Unexpected, something went wrong in the server. |
| 42 | InternalServerError, |
| 43 | } |