use std::net::SocketAddr;
use std::path::PathBuf;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct BrowserTranscript {
pub latest_seq: u64,
pub presentation_key: String,
pub window_start_seq: u64,
pub reset: bool,
pub entries: Vec<BrowserTranscriptEntry>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct BrowserTranscriptEntry {
pub id: u64,
pub updated_seq: u64,
pub role: &'static str,
pub label: String,
pub recorded_at_ms: Option<i64>,
pub lines: Vec<String>,
pub glyph: &'static str,
pub tone: &'static str,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub tool_status: Option<&'static str>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub diffstats: Vec<BrowserDiffStat>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
pub struct BrowserDiffStat {
pub path: String,
pub insertions: u32,
pub deletions: u32,
}
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum WebViewerAccess {
Starting,
Ready {
viewer_url: String,
viewer_code: String,
qr_login_url: Option<String>,
fallback_reason: Option<String>,
},
Failed {
address: SocketAddr,
message: String,
port_conflict: bool,
},
Unavailable(String),
}
impl std::fmt::Debug for WebViewerAccess {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Starting => formatter.write_str("Starting"),
Self::Ready {
viewer_url,
fallback_reason,
..
} => formatter
.debug_struct("Ready")
.field("viewer_url", viewer_url)
.field("credentials", &"[redacted]")
.field("fallback_reason", fallback_reason)
.finish(),
Self::Failed {
address,
message,
port_conflict,
} => formatter
.debug_struct("Failed")
.field("address", address)
.field("message", message)
.field("port_conflict", port_conflict)
.finish(),
Self::Unavailable(message) => {
formatter.debug_tuple("Unavailable").field(message).finish()
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct WebListenerProcess {
pub pid: u32,
pub name: String,
pub executable: PathBuf,
pub started_at: u64,
pub stop_disabled_reason: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum WebViewerRecovery {
Retry,
AnotherPort,
StopAndRetry(WebListenerProcess),
}