1use std::net::SocketAddr;
4use std::path::PathBuf;
5
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
11pub struct BrowserTranscript {
12 pub latest_seq: u64,
13 pub presentation_key: String,
17 pub window_start_seq: u64,
22 pub reset: bool,
23 pub entries: Vec<BrowserTranscriptEntry>,
24}
25
26#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
27pub struct BrowserTranscriptEntry {
28 pub id: u64,
29 pub updated_seq: u64,
30 pub role: &'static str,
31 pub label: String,
32 pub recorded_at_ms: Option<i64>,
33 pub lines: Vec<String>,
34 pub glyph: &'static str,
38 pub tone: &'static str,
41 #[serde(default, skip_serializing_if = "Option::is_none")]
43 pub tool_status: Option<&'static str>,
44 #[serde(default, skip_serializing_if = "Vec::is_empty")]
49 pub diffstats: Vec<BrowserDiffStat>,
50}
51
52#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
54pub struct BrowserDiffStat {
55 pub path: String,
56 pub insertions: u32,
57 pub deletions: u32,
58}
59
60#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
61pub enum WebViewerAccess {
62 Starting,
63 Ready {
64 viewer_url: String,
65 viewer_code: String,
66 qr_login_url: Option<String>,
67 fallback_reason: Option<String>,
68 },
69 Failed {
70 address: SocketAddr,
71 message: String,
72 port_conflict: bool,
73 },
74 Unavailable(String),
75}
76
77impl std::fmt::Debug for WebViewerAccess {
78 fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
79 match self {
80 Self::Starting => formatter.write_str("Starting"),
81 Self::Ready {
82 viewer_url,
83 fallback_reason,
84 ..
85 } => formatter
86 .debug_struct("Ready")
87 .field("viewer_url", viewer_url)
88 .field("credentials", &"[redacted]")
89 .field("fallback_reason", fallback_reason)
90 .finish(),
91 Self::Failed {
92 address,
93 message,
94 port_conflict,
95 } => formatter
96 .debug_struct("Failed")
97 .field("address", address)
98 .field("message", message)
99 .field("port_conflict", port_conflict)
100 .finish(),
101 Self::Unavailable(message) => {
102 formatter.debug_tuple("Unavailable").field(message).finish()
103 }
104 }
105 }
106}
107
108#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
110pub struct WebListenerProcess {
111 pub pid: u32,
112 pub name: String,
113 pub executable: PathBuf,
114 pub started_at: u64,
115 pub stop_disabled_reason: Option<String>,
116}
117
118#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
119pub enum WebViewerRecovery {
120 Retry,
121 AnotherPort,
122 StopAndRetry(WebListenerProcess),
123}