Skip to content

Commit 9336a98

Browse files
committed
style: apply rustfmt to the tunnel rework
1 parent 93edcda commit 9336a98

5 files changed

Lines changed: 60 additions & 42 deletions

File tree

src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,6 @@ fn open_setup_hub(setup_url: &str, mcp_url: &str) {
12701270
}
12711271
}
12721272

1273-
12741273
#[cfg(unix)]
12751274
fn spawn_replacement() -> Result<()> {
12761275
use std::os::unix::process::CommandExt;

src/runtime/tunnel.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,10 @@ async fn start_tailscale_funnel_once(local_url: &str) -> Result<(Child, String)>
449449
Err(error) => bail!("tailscale funnel status check failed: {error}"),
450450
Ok(None) => {}
451451
}
452-
let logs = recent_logs.lock().expect("tunnel log lock poisoned").clone();
452+
let logs = recent_logs
453+
.lock()
454+
.expect("tunnel log lock poisoned")
455+
.clone();
453456
if logs
454457
.iter()
455458
.any(|line| line.to_lowercase().contains("not enabled"))
@@ -463,9 +466,7 @@ async fn start_tailscale_funnel_once(local_url: &str) -> Result<(Child, String)>
463466
Some(line[start..].trim().to_owned())
464467
})
465468
.unwrap_or_default();
466-
bail!(
467-
"tailscale Funnel is not enabled on your tailnet; enable it at {enable_url}"
468-
);
469+
bail!("tailscale Funnel is not enabled on your tailnet; enable it at {enable_url}");
469470
}
470471
if funnel_serving(&public_url).await {
471472
return Ok((child, public_url));

src/ui/monitor.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,10 @@ pub struct MonitorConfig {
198198

199199
impl MonitorConfig {
200200
pub(crate) fn public_url(&self) -> String {
201-
self.public_url.read().expect("public url lock poisoned").clone()
201+
self.public_url
202+
.read()
203+
.expect("public url lock poisoned")
204+
.clone()
202205
}
203206

204207
pub(crate) fn mcp_url(&self) -> String {
@@ -1124,7 +1127,10 @@ fn render_header(
11241127
Line::from(vec![
11251128
Span::styled("MCP ", Style::default().fg(DIM)),
11261129
Span::styled(
1127-
truncate_middle(&config.mcp_url(), columns[0].width.saturating_sub(9) as usize),
1130+
truncate_middle(
1131+
&config.mcp_url(),
1132+
columns[0].width.saturating_sub(9) as usize,
1133+
),
11281134
Style::default().fg(BLUE),
11291135
),
11301136
]),
@@ -1910,7 +1916,7 @@ mod tests {
19101916
version: "0.1.0".to_owned(),
19111917
instance_id: "instance-one".to_owned(),
19121918
local_health_url: "http://127.0.0.1:8765/healthz".to_owned(),
1913-
public_url: Arc::new(std::sync::RwLock::new(
1919+
public_url: Arc::new(std::sync::RwLock::new(
19141920
"https://example.trycloudflare.com".to_owned(),
19151921
)),
19161922
intelligence_url: "http://127.0.0.1:8765/intelligence#token=test".to_owned(),
@@ -1995,7 +2001,7 @@ mod tests {
19952001
version: "0.1.0".to_owned(),
19962002
instance_id: "instance-one".to_owned(),
19972003
local_health_url: "http://127.0.0.1:8765/healthz".to_owned(),
1998-
public_url: Arc::new(std::sync::RwLock::new(
2004+
public_url: Arc::new(std::sync::RwLock::new(
19992005
"https://example.trycloudflare.com".to_owned(),
20002006
)),
20012007
intelligence_url: "http://127.0.0.1:8765/intelligence#token=test".to_owned(),
@@ -2035,7 +2041,7 @@ mod tests {
20352041
version: "0.1.0".to_owned(),
20362042
instance_id: "instance-one".to_owned(),
20372043
local_health_url: "http://127.0.0.1:8765/healthz".to_owned(),
2038-
public_url: Arc::new(std::sync::RwLock::new(
2044+
public_url: Arc::new(std::sync::RwLock::new(
20392045
"https://example.trycloudflare.com".to_owned(),
20402046
)),
20412047
intelligence_url: "https://example.trycloudflare.com/intelligence#token=fixture"
@@ -2200,7 +2206,7 @@ mod tests {
22002206
version: "0.1.0".to_owned(),
22012207
instance_id: "instance-one".to_owned(),
22022208
local_health_url: "http://127.0.0.1:8765/healthz".to_owned(),
2203-
public_url: Arc::new(std::sync::RwLock::new(
2209+
public_url: Arc::new(std::sync::RwLock::new(
22042210
"https://example.trycloudflare.com".to_owned(),
22052211
)),
22062212
intelligence_url: "https://example.trycloudflare.com/intelligence#token=fixture"

src/ui/monitor_detail.rs

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -128,34 +128,36 @@ pub(super) fn render_setup(
128128
.border_style(Style::default().fg(BORDER))
129129
.padding(Padding::new(0, 2, 0, 0));
130130
frame.render_widget(
131-
Paragraph::new(vec![
132-
Line::from(Span::styled(
133-
"GET CONNECTED",
134-
Style::default().fg(WHITE).add_modifier(Modifier::BOLD),
135-
)),
136-
setup_step(1, language.tr("Open this setup page · press O")),
137-
setup_step(2, language.tr("Choose a compatible AI client")),
138-
setup_step(3, language.tr("Add MCP URL · Auth: OAuth")),
139-
Line::from(vec![
140-
Span::styled(" VERIFY CODE ", Style::default().fg(DIM)),
141-
Span::styled(
142-
&config.pairing_code,
143-
Style::default().fg(YELLOW).add_modifier(Modifier::BOLD),
144-
),
145-
Span::styled(" press O to reopen setup", Style::default().fg(GRAY)),
146-
]),
147-
]
148-
.into_iter()
149-
.chain(if snapshot.tunnels.is_empty() {
150-
endpoint_link_lines(
151-
snapshot,
152-
config,
153-
columns[0].width.saturating_sub(10) as usize,
154-
)
155-
} else {
156-
tunnel_lines(snapshot, columns[0].width.saturating_sub(10) as usize)
157-
})
158-
.collect::<Vec<_>>())
131+
Paragraph::new(
132+
vec![
133+
Line::from(Span::styled(
134+
"GET CONNECTED",
135+
Style::default().fg(WHITE).add_modifier(Modifier::BOLD),
136+
)),
137+
setup_step(1, language.tr("Open this setup page · press O")),
138+
setup_step(2, language.tr("Choose a compatible AI client")),
139+
setup_step(3, language.tr("Add MCP URL · Auth: OAuth")),
140+
Line::from(vec![
141+
Span::styled(" VERIFY CODE ", Style::default().fg(DIM)),
142+
Span::styled(
143+
&config.pairing_code,
144+
Style::default().fg(YELLOW).add_modifier(Modifier::BOLD),
145+
),
146+
Span::styled(" press O to reopen setup", Style::default().fg(GRAY)),
147+
]),
148+
]
149+
.into_iter()
150+
.chain(if snapshot.tunnels.is_empty() {
151+
endpoint_link_lines(
152+
snapshot,
153+
config,
154+
columns[0].width.saturating_sub(10) as usize,
155+
)
156+
} else {
157+
tunnel_lines(snapshot, columns[0].width.saturating_sub(10) as usize)
158+
})
159+
.collect::<Vec<_>>(),
160+
)
159161
.block(left),
160162
columns[0],
161163
);
@@ -1031,7 +1033,11 @@ pub(super) fn render_help_overlay(
10311033
help_hint_line("^C", language.tr("stop wcode")),
10321034
help_link_line(language.tr("Project"), &config.project_url, inner.width),
10331035
help_link_line(language.tr("Author"), &config.author_url, inner.width),
1034-
help_link_line(language.tr("Setup"), config.setup_url().as_str(), inner.width),
1036+
help_link_line(
1037+
language.tr("Setup"),
1038+
config.setup_url().as_str(),
1039+
inner.width,
1040+
),
10351041
help_link_line(language.tr("Health"), &config.local_health_url, inner.width),
10361042
]),
10371043
inner,
@@ -1115,7 +1121,11 @@ pub(super) fn render_help_overlay(
11151121
columns[1].width,
11161122
),
11171123
help_link_line(language.tr("Author"), &config.author_url, columns[1].width),
1118-
help_link_line(language.tr("Setup"), config.setup_url().as_str(), columns[1].width),
1124+
help_link_line(
1125+
language.tr("Setup"),
1126+
config.setup_url().as_str(),
1127+
columns[1].width,
1128+
),
11191129
help_link_line(
11201130
language.tr("Health"),
11211131
&config.local_health_url,

src/ui/monitor_state.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ impl TaskMonitor {
225225
{
226226
return;
227227
}
228-
state.tunnels.push((provider.to_owned(), public_url.to_owned()));
228+
state
229+
.tunnels
230+
.push((provider.to_owned(), public_url.to_owned()));
229231
}
230232

231233
pub fn tunnel_links(&self) -> Vec<(String, String)> {

0 commit comments

Comments
 (0)