From 7980b09ddb2165b128a7a2bd761879dab5f4c8d1 Mon Sep 17 00:00:00 2001 From: Sam & Claude Date: Thu, 25 Jun 2026 21:01:12 +0200 Subject: [PATCH] =?UTF-8?q?style:=20rustfmt=20=E2=80=94=20fix=20fmt=20drif?= =?UTF-8?q?t=20introduced=20by=20terminal-capture=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cargo fmt --all --check flagged 10 drift sites across 4 files, all from the terminal-capture commit (0509ed7): config.rs (env_bool matches! one-liner), socket.rs (serde_json! block), signatures.rs + terminal.rs (long arg lists and json! blocks). Pure line-wrapping — no logic changes. Unblocks the fmt half of the workspace gate (fmt/clippy/test/release) for PR #193. Verified: fmt clean, clippy -D warnings clean, config tests pass (env_bool + defaults + from_env_vars). (Sam & Claude) --- crates/colibri-daemon/src/config.rs | 7 ++++- crates/colibri-daemon/src/socket.rs | 14 +++++----- crates/colibri-glasspane/src/signatures.rs | 7 +++-- crates/colibri-glasspane/src/terminal.rs | 31 +++++++++++++++++----- 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/crates/colibri-daemon/src/config.rs b/crates/colibri-daemon/src/config.rs index ef7bc2d..ca117b9 100644 --- a/crates/colibri-daemon/src/config.rs +++ b/crates/colibri-daemon/src/config.rs @@ -142,7 +142,12 @@ fn env_parse(name: &str) -> Option { /// `true`/`false` and would silently treat `=1` as false. fn env_bool(name: &str) -> bool { std::env::var(name) - .map(|v| matches!(v.trim().to_ascii_lowercase().as_str(), "1" | "true" | "yes" | "on")) + .map(|v| { + matches!( + v.trim().to_ascii_lowercase().as_str(), + "1" | "true" | "yes" | "on" + ) + }) .unwrap_or(false) } diff --git a/crates/colibri-daemon/src/socket.rs b/crates/colibri-daemon/src/socket.rs index 9d6b9b9..fd3d5db 100644 --- a/crates/colibri-daemon/src/socket.rs +++ b/crates/colibri-daemon/src/socket.rs @@ -482,12 +482,14 @@ async fn cmd_terminal_poll(state: &SharedState, target: Option) -> Colib "target": target, "status": "unchanged", }), - Ok(colibri_glasspane::Observation::Recorded { uuid, new_alerts }) => serde_json::json!({ - "target": target, - "status": "recorded", - "uuid": uuid, - "new_alerts": new_alerts, - }), + Ok(colibri_glasspane::Observation::Recorded { uuid, new_alerts }) => { + serde_json::json!({ + "target": target, + "status": "recorded", + "uuid": uuid, + "new_alerts": new_alerts, + }) + } Err(e) => serde_json::json!({ "target": target, "status": "error", diff --git a/crates/colibri-glasspane/src/signatures.rs b/crates/colibri-glasspane/src/signatures.rs index 8dd9184..f6b031e 100644 --- a/crates/colibri-glasspane/src/signatures.rs +++ b/crates/colibri-glasspane/src/signatures.rs @@ -295,7 +295,8 @@ mod tests { #[test] fn detect_classifies_into_buckets() { let set = SignatureSet::linux_default(); - let text = "● nginx.service\n Active: failed (Result: exit-code)\nnet.ipv4.ip_forward = 1"; + let text = + "● nginx.service\n Active: failed (Result: exit-code)\nnet.ipv4.ip_forward = 1"; let d = set.detect(text); assert_eq!(d.failures.len(), 1); assert_eq!(d.failures[0].id, "systemd_unit_failed"); @@ -346,7 +347,9 @@ mod tests { fn empty_set_matches_nothing() { let set = SignatureSet::empty(); assert!(set.is_empty()); - assert!(set.detect("Active: failed\nout of memory: killed process").is_empty()); + assert!(set + .detect("Active: failed\nout of memory: killed process") + .is_empty()); } #[test] diff --git a/crates/colibri-glasspane/src/terminal.rs b/crates/colibri-glasspane/src/terminal.rs index 39be5a5..f3d9425 100644 --- a/crates/colibri-glasspane/src/terminal.rs +++ b/crates/colibri-glasspane/src/terminal.rs @@ -148,7 +148,11 @@ impl TerminalRecorder { /// Recorder with the Linux default signature set and default capacity. pub fn linux(pane_id: impl Into) -> Self { - Self::new(pane_id, SignatureSet::linux_default(), DEFAULT_HISTORY_CAPACITY) + Self::new( + pane_id, + SignatureSet::linux_default(), + DEFAULT_HISTORY_CAPACITY, + ) } pub fn pane_id(&self) -> &str { @@ -194,8 +198,7 @@ impl TerminalRecorder { let detection = self.signatures.detect(&text); // Edge-trigger: alertable signatures not firing as of the last frame. - let current: BTreeSet = - detection.alertable().map(|m| m.id.clone()).collect(); + let current: BTreeSet = detection.alertable().map(|m| m.id.clone()).collect(); let new_alerts: Vec = detection .alertable() .filter(|m| !self.active.contains(&m.id)) @@ -221,7 +224,11 @@ impl TerminalRecorder { /// Capture the named tmux target and record it. Convenience wrapper over /// [`capture_tmux_pane`] + [`observe`](Self::observe) for the daemon's /// poll loop. Errors propagate the tmux capture failure. - pub fn observe_tmux(&mut self, target: &str, observed_at: SystemTime) -> io::Result { + pub fn observe_tmux( + &mut self, + target: &str, + observed_at: SystemTime, + ) -> io::Result { let raw = capture_tmux_pane(target)?; Ok(self.observe(&raw, observed_at)) } @@ -281,7 +288,10 @@ mod tests { // Same text, different coloring → same frame id (dedup works on content). let plain = "\x1b[31mALERT\x1b[0m"; let other = "\x1b[33mALERT\x1b[0m"; - assert_eq!(frame_uuid(&strip_ansi(plain)), frame_uuid(&strip_ansi(other))); + assert_eq!( + frame_uuid(&strip_ansi(plain)), + frame_uuid(&strip_ansi(other)) + ); } #[test] @@ -301,7 +311,10 @@ mod tests { rec.observe("frame two\n", t(2)); assert_eq!(rec.len(), 2); assert_eq!(rec.latest().unwrap().text, "frame two\n"); - assert_eq!(rec.latest().unwrap().observed_at, "1970-01-01T00:00:02.000Z"); + assert_eq!( + rec.latest().unwrap().observed_at, + "1970-01-01T00:00:02.000Z" + ); } #[test] @@ -316,7 +329,11 @@ mod tests { // Different screen, failure still present → no repeat alert. let o2 = rec.observe("boot log\nActive: failed\nstill broken\n", t(2)); assert!(o2.is_recorded()); - assert_eq!(o2.new_alerts().len(), 0, "persisting failure must not re-alert"); + assert_eq!( + o2.new_alerts().len(), + 0, + "persisting failure must not re-alert" + ); // Condition clears. let o3 = rec.observe("Active: active (running)\n", t(3));