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));