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 jev_notice: bool,
29 #[serde(skip_serializing_if = "Option::is_none")]
31 pub command_id: Option<String>,
32 pub id: u64,
33 pub updated_seq: u64,
34 pub role: &'static str,
35 pub label: String,
36 pub recorded_at_ms: Option<i64>,
37 pub lines: Vec<String>,
38 pub glyph: &'static str,
42 pub tone: &'static str,
45 #[serde(default, skip_serializing_if = "Option::is_none")]
47 pub tool_status: Option<&'static str>,
48 #[serde(default, skip_serializing_if = "Vec::is_empty")]
53 pub diffstats: Vec<BrowserDiffStat>,
54}
55
56#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
58pub struct BrowserDiffStat {
59 pub path: String,
60 pub insertions: u32,
61 pub deletions: u32,
62}
63
64#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
65pub enum WebViewerAccess {
66 Starting,
67 Ready {
68 viewer_url: String,
69 viewer_code: String,
70 qr_login_url: Option<String>,
71 fallback_reason: Option<String>,
72 },
73 Failed {
74 address: SocketAddr,
75 message: String,
76 port_conflict: bool,
77 },
78 Unavailable(String),
79}
80
81impl std::fmt::Debug for WebViewerAccess {
82 fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
83 match self {
84 Self::Starting => formatter.write_str("Starting"),
85 Self::Ready {
86 viewer_url,
87 fallback_reason,
88 ..
89 } => formatter
90 .debug_struct("Ready")
91 .field("viewer_url", viewer_url)
92 .field("credentials", &"[redacted]")
93 .field("fallback_reason", fallback_reason)
94 .finish(),
95 Self::Failed {
96 address,
97 message,
98 port_conflict,
99 } => formatter
100 .debug_struct("Failed")
101 .field("address", address)
102 .field("message", message)
103 .field("port_conflict", port_conflict)
104 .finish(),
105 Self::Unavailable(message) => {
106 formatter.debug_tuple("Unavailable").field(message).finish()
107 }
108 }
109 }
110}
111
112#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
114pub struct WebListenerProcess {
115 pub pid: u32,
116 pub name: String,
117 pub executable: PathBuf,
118 pub started_at: u64,
119 pub stop_disabled_reason: Option<String>,
120}
121
122#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
123pub enum WebViewerRecovery {
124 Retry,
125 AnotherPort,
126 StopAndRetry(WebListenerProcess),
127}