Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(rust): silence remaining platform warnings

Louis Beaumont3c3ccdf51aa2
diff --git a/crates/screenpipe-audio/src/core/stream.rs b/crates/screenpipe-audio/src/core/stream.rs
index dee11ca90..23a541fe2 100644
--- a/crates/screenpipe-audio/src/core/stream.rs
+++ b/crates/screenpipe-audio/src/core/stream.rs
@@ -81,10 +81,12 @@ pub struct AudioStream {
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
enum StopMode {
Immediate,
+ #[cfg(any(not(all(target_os = "linux", feature = "pulseaudio")), test))]
DeferredDeviceDisconnect,
}
impl StopMode {
+ #[cfg(any(not(all(target_os = "linux", feature = "pulseaudio")), test))]
fn teardown_delay(self) -> Option<std::time::Duration> {
match self {
StopMode::Immediate => None,
@@ -98,15 +100,21 @@ impl StopMode {
enum StreamControl {
Stop {
- response: oneshot::Sender<()>,
- mode: StopMode,
+ _response: oneshot::Sender<()>,
+ _mode: StopMode,
},
}
impl StreamControl {
fn stop(mode: StopMode) -> (Self, oneshot::Receiver<()>) {
let (tx, rx) = oneshot::channel();
- (Self::Stop { response: tx, mode }, rx)
+ (
+ Self::Stop {
+ _response: tx,
+ _mode: mode,
+ },
+ rx,
+ )
}
fn stop_without_wait(mode: StopMode) -> Self {
@@ -503,7 +511,11 @@ impl AudioStream {
);
}
- if let Ok(StreamControl::Stop { response, mode }) = stream_control_rx.recv() {
+ if let Ok(StreamControl::Stop {
+ _response: response,
+ _mode: mode,
+ }) = stream_control_rx.recv()
+ {
if let Some(delay) = mode.teardown_delay() {
std::thread::sleep(delay);
}
@@ -945,7 +957,7 @@ mod from_wav_tests {
#[test]
fn stop_without_wait_preserves_requested_mode() {
match StreamControl::stop_without_wait(StopMode::DeferredDeviceDisconnect) {
- StreamControl::Stop { mode, .. } => {
+ StreamControl::Stop { _mode: mode, .. } => {
assert_eq!(mode, StopMode::DeferredDeviceDisconnect);
}
}
diff --git a/crates/screenpipe-engine/src/meeting_detector.rs b/crates/screenpipe-engine/src/meeting_detector.rs
index b1388a7c2..47898a692 100644
--- a/crates/screenpipe-engine/src/meeting_detector.rs
+++ b/crates/screenpipe-engine/src/meeting_detector.rs
@@ -601,8 +601,10 @@ pub struct ScanResult {
/// controls (text areas, scroll areas, etc.).
pub struct MeetingUiScanner {
/// Maximum depth to walk in the AX tree.
+ #[cfg(any(target_os = "macos", target_os = "windows"))]
max_depth: usize,
/// Timeout for scanning ALL windows of a single process.
+ #[cfg(any(target_os = "macos", target_os = "windows"))]
scan_timeout: Duration,
}
@@ -616,15 +618,30 @@ impl MeetingUiScanner {
/// Create a new scanner with default settings (depth=25, timeout=5s).
pub fn new() -> Self {
Self {
+ #[cfg(any(target_os = "macos", target_os = "windows"))]
max_depth: 25,
+ #[cfg(any(target_os = "macos", target_os = "windows"))]
scan_timeout: Duration::from_millis(5000),
}
}
/// Create a scanner with custom settings.
- pub fn with_config(max_depth: usize, scan_timeout: Duration) -> Self {
+ pub fn with_config(
+ #[cfg_attr(
+ not(any(target_os = "macos", target_os = "windows")),
+ allow(unused_variables)
+ )]
+ max_depth: usize,
+ #[cfg_attr(
+ not(any(target_os = "macos", target_os = "windows")),
+ allow(unused_variables)
+ )]
+ scan_timeout: Duration,
+ ) -> Self {
Self {
+ #[cfg(any(target_os = "macos", target_os = "windows"))]
max_depth,
+ #[cfg(any(target_os = "macos", target_os = "windows"))]
scan_timeout,
}
}
@@ -926,6 +943,7 @@ struct PrecomputedSignal {
/// through `walk_for_signals` so per-node AX IPC calls (each a cross-process
/// roundtrip) are only paid for attrs at least one signal might match against.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+#[cfg(any(target_os = "macos", test))]
struct AttrNeeds {
title: bool,
desc: bool,
@@ -933,6 +951,8 @@ struct AttrNeeds {
}
#[cfg(target_os = "macos")]
+#[cfg(any(target_os = "macos", test))]
+#[cfg(any(target_os = "macos", test))]
impl AttrNeeds {
fn from_signals(signals: &[PrecomputedSignal]) -> Self {
Self::from_call_signals(signals.iter().map(|ps| &ps.signal))
@@ -1146,6 +1166,7 @@ fn check_signal_match_precomputed(
}
/// Format a human-readable label for a matched signal (used in debug logging).
+#[cfg(any(target_os = "macos", target_os = "windows", test))]
fn format_signal_match(
signal: &CallSignal,
role: &str,
diff --git a/crates/screenpipe-screen/src/capture_screenshot_by_window.rs b/crates/screenpipe-screen/src/capture_screenshot_by_window.rs
index 4ac396bcb..eec827dbe 100644
--- a/crates/screenpipe-screen/src/capture_screenshot_by_window.rs
+++ b/crates/screenpipe-screen/src/capture_screenshot_by_window.rs
@@ -881,7 +881,7 @@ fn get_all_windows() -> Result<Vec<WindowData>, Box<dyn Error>> {
Ok(windows
.into_iter()
.filter_map(|window| {
- let mut app_name = match window.app_name() {
+ let app_name = match window.app_name() {
Ok(name) => name.to_string(),
Err(e) => {
debug!("Failed to get app_name for window: {}", e);
@@ -892,14 +892,22 @@ fn get_all_windows() -> Result<Vec<WindowData>, Box<dyn Error>> {
// On Windows, xcap returns empty string when OpenProcess fails
// (elevated/system processes). Fall back to exe filename.
#[cfg(target_os = "windows")]
- if app_name.is_empty() {
- if let Some(pid) = window.pid().ok() {
- if let Some(exe_name) = get_process_exe_name(pid as u32) {
- debug!("app_name was empty, using exe name: {}", exe_name);
- app_name = exe_name;
+ let app_name = {
+ if app_name.is_empty() {
+ if let Some(pid) = window.pid().ok() {
+ if let Some(exe_name) = get_process_exe_name(pid as u32) {
+ debug!("app_name was empty, using exe name: {}", exe_name);
+ exe_name
+ } else {
+ app_name
+ }
+ } else {
+ app_name
}
+ } else {
+ app_name
}
- }
+ };
let title = match window.title() {
Ok(title) => title.to_string(),
diff --git a/crates/screenpipe-screen/src/monitor.rs b/crates/screenpipe-screen/src/monitor.rs
index 152d9ea01..b95f925fc 100644
--- a/crates/screenpipe-screen/src/monitor.rs
+++ b/crates/screenpipe-screen/src/monitor.rs
@@ -498,7 +498,7 @@ impl SafeMonitor {
}
/// Per-frame xcap capture fallback (no index caching).
- #[cfg(not(target_os = "macos"))]
+ #[cfg(target_os = "windows")]
fn per_frame_capture(monitor_id: u32) -> Result<DynamicImage> {
let monitors = XcapMonitor::all().map_err(Error::from)?;
let monitor = monitors