style: rustfmt — fix fmt drift introduced by terminal-capture commit
Some checks are pending
CI / rust (pull_request) Waiting to run
CI / markdown (pull_request) Waiting to run
CI / port (pull_request) Waiting to run
CI / agent-jail-pkgs (pull_request) Waiting to run

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)
This commit is contained in:
Sam & Claude 2026-06-25 21:01:12 +02:00
parent b2f5d8f355
commit 7980b09ddb
4 changed files with 43 additions and 16 deletions

View file

@ -142,7 +142,12 @@ fn env_parse<T: std::str::FromStr>(name: &str) -> Option<T> {
/// `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)
}

View file

@ -482,12 +482,14 @@ async fn cmd_terminal_poll(state: &SharedState, target: Option<String>) -> 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",

View file

@ -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]

View file

@ -148,7 +148,11 @@ impl TerminalRecorder {
/// Recorder with the Linux default signature set and default capacity.
pub fn linux(pane_id: impl Into<String>) -> 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<String> =
detection.alertable().map(|m| m.id.clone()).collect();
let current: BTreeSet<String> = detection.alertable().map(|m| m.id.clone()).collect();
let new_alerts: Vec<SignatureMatch> = 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<Observation> {
pub fn observe_tmux(
&mut self,
target: &str,
observed_at: SystemTime,
) -> io::Result<Observation> {
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));