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: resolve all clippy warnings and dead code in screenpipe-audio

Louis Beaumont74d0e03b541d
diff --git a/apps/screenpipe-app-tauri/components/rewind/current-frame-timeline.tsx b/apps/screenpipe-app-tauri/components/rewind/current-frame-timeline.tsx
index 229d986d0..d5ce56564 100644
--- a/apps/screenpipe-app-tauri/components/rewind/current-frame-timeline.tsx
+++ b/apps/screenpipe-app-tauri/components/rewind/current-frame-timeline.tsx
@@ -56,8 +56,15 @@ export const SkeletonLoader: FC = () => {
);
};
-// Debounce delay for frame loading (ms)
+// Debounce delay for frame loading (ms) — reduced for arrow keys
const FRAME_LOAD_DEBOUNCE_MS = 80;
+const FRAME_LOAD_DEBOUNCE_ARROW_MS = 0;
+
+// Number of adjacent frames to preload in each direction
+const PRELOAD_ADJACENT = 3;
+
+// Crossfade duration (ms)
+const CROSSFADE_MS = 120;
// Track which chunks have failed with TTL — entries expire so finished chunks can be retried
const FAILED_CHUNK_TTL_MS = 30_000;
diff --git a/apps/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx b/apps/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx
index 3e8095755..c617791b4 100644
--- a/apps/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx
+++ b/apps/screenpipe-app-tauri/components/rewind/timeline/timeline.tsx
@@ -19,6 +19,61 @@ import { AppContextPopover } from "./app-context-popover";
import { TimelineTagToolbar } from "./timeline-tag-toolbar";
import { extractDomain, FaviconImg } from "./favicon-utils";
+// Global cache: preloads app-icon images so they render instantly on scroll.
+// Maps app name → "loaded" | "error" | Promise (in-flight).
+const appIconCache = new Map<string, "loaded" | "error" | Promise<void>>();
+
+function preloadAppIcon(appName: string): "loaded" | "error" | "loading" {
+ const cached = appIconCache.get(appName);
+ if (cached === "loaded" || cached === "error") return cached;
+ if (cached) return "loading"; // promise in-flight
+ const url = `http://localhost:11435/app-icon?name=${encodeURIComponent(appName)}`;
+ const p = new Promise<void>((resolve) => {
+ const img = new Image();
+ img.onload = () => { appIconCache.set(appName, "loaded"); resolve(); };
+ img.onerror = () => { appIconCache.set(appName, "error"); resolve(); };
+ img.src = url;
+ });
+ appIconCache.set(appName, p);
+ return "loading";
+}
+
+/** App icon with in-memory cache — no flash of fallback letter on fast scroll */
+const CachedAppIcon = React.memo(function CachedAppIcon({ appName, className }: { appName: string; className?: string }) {
+ const [status, setStatus] = useState<"loaded" | "error" | "loading">(() => preloadAppIcon(appName));
+
+ useEffect(() => {
+ const cached = appIconCache.get(appName);
+ if (cached === "loaded" || cached === "error") {
+ setStatus(cached);
+ return;
+ }
+ // Wait for in-flight preload
+ const p = cached || (() => { preloadAppIcon(appName); return appIconCache.get(appName)!; })();
+ if (p instanceof Promise) {
+ p.then(() => {
+ const result = appIconCache.get(appName);
+ if (result === "loaded" || result === "error") setStatus(result);
+ });
+ }
+ }, [appName]);
+
+ if (status === "error") {
+ return null; // let parent's fallback letter show
+ }
+
+ return (
+ // eslint-disable-next-line @next/next/no-img-element
+ <img
+ src={`http://localhost:11435/app-icon?name=${encodeURIComponent(appName)}`}
+ className={className ?? "w-full h-full rounded-sm object-contain scale-110"}
+ alt={appName}
+ decoding="async"
+ style={{ display: status === "loaded" ? undefined : "none" }}
+ />
+ );
+});
+
interface UiEventSummary {
event_type: string;
text_content: string | null;
@@ -550,6 +605,15 @@ export const TimelineSlider = ({
return groups;
}, [visibleFrames]);
+ // Preload app icons for all visible groups so they're cached before scroll
+ useEffect(() => {
+ for (const group of appGroups) {
+ for (const name of group.appNames) {
+ preloadAppIcon(name);
+ }
+ }
+ }, [appGroups]);
+
// Compute time markers for the visible range
const timeMarkers = useMemo(() => {
if (!visibleFrames || visibleFrames.length === 0) return [];
@@ -879,6 +943,8 @@ export const TimelineSlider = ({
dir="rtl"
style={{
// borderLeft removed — caused visible white lines between groups
+ // DEBUG: red outline on groups with topDomains
+ ...(group.topDomains?.length ? { outline: '2px solid red' } : {}),
}}
>
{/* Vertical stacked icons - favicons for browser groups, app icons otherwise */}
@@ -958,18 +1024,7 @@ export const TimelineSlider = ({
}}
transition={{ type: "spring", stiffness: 400, damping: 25 }}
>
- {/* eslint-disable-next-line @next/next/no-img-element */}
- <img
- src={`http://localhost:11435/app-icon?name=${encodeURIComponent(appName)}`}
- className="w-full h-full rounded-sm object-contain scale-110"
- alt={appName}
- loading="lazy"
- decoding="async"
- onError={(e) => {
- // Hide broken img, let fallback letter show
- (e.target as HTMLImageElement).style.display = 'none';
- }}
- />
+ <CachedAppIcon appName={appName} />
<span
className="absolute inset-0 flex items-center justify-center text-[10px] font-bold text-white/90 pointer-events-none"
style={{ zIndex: -1 }}
@@ -1133,14 +1188,7 @@ export const TimelineSlider = ({
if (domain) {
return <FaviconImg domain={domain} fallbackAppName={group.appName} size={16} className="w-4 h-4 rounded" />;
}
- return (
- // eslint-disable-next-line @next/next/no-img-element
- <img
- src={`http://localhost:11435/app-icon?name=${encodeURIComponent(group.appName)}`}
- className="w-4 h-4 rounded"
- alt=""
- />
- );
+ return <CachedAppIcon appName={group.appName} className="w-4 h-4 rounded object-contain" />;
})()}
<p className="font-medium text-popover-foreground">
{(() => {
diff --git a/crates/screenpipe-audio/src/audio_manager/device_monitor.rs b/crates/screenpipe-audio/src/audio_manager/device_monitor.rs
index 7a330e612..12336856b 100644
--- a/crates/screenpipe-audio/src/audio_manager/device_monitor.rs
+++ b/crates/screenpipe-audio/src/audio_manager/device_monitor.rs
@@ -401,6 +401,7 @@ pub async fn stop_device_monitor() -> Result<()> {
/// Sliding-window cooldown tracker for central handler restarts.
/// Extracted for testability.
+#[cfg(test)]
pub(crate) struct RestartCooldown {
timestamps: Vec<Instant>,
max_restarts: usize,
@@ -408,6 +409,7 @@ pub(crate) struct RestartCooldown {
pub exhausted: bool,
}
+#[cfg(test)]
impl RestartCooldown {
pub fn new(max_restarts: usize, window: Duration) -> Self {
Self {
diff --git a/crates/screenpipe-audio/tests/audio_pipeline_benchmark/cross_device_benchmark.rs b/crates/screenpipe-audio/tests/audio_pipeline_benchmark/cross_device_benchmark.rs
index efb44c2a0..4ff3350e6 100644
--- a/crates/screenpipe-audio/tests/audio_pipeline_benchmark/cross_device_benchmark.rs
+++ b/crates/screenpipe-audio/tests/audio_pipeline_benchmark/cross_device_benchmark.rs
@@ -187,7 +187,7 @@ async fn cross_device_coverage_synthetic() {
println!(" Neither: {}", result.neither);
println!(" Capture rate: {:.1}%", result.capture_rate * 100.0);
- metrics::print_cross_device_table(&[result.clone()]);
+ metrics::print_cross_device_table(std::slice::from_ref(&result));
// Test with lower threshold (0.02)
let result_low = analyze_cross_device(&mic_audio, &system_audio, &manifest, 0.02, &mut vad);
diff --git a/crates/screenpipe-audio/tests/audio_pipeline_benchmark/ground_truth.rs b/crates/screenpipe-audio/tests/audio_pipeline_benchmark/ground_truth.rs
index a334419ac..0c395ef25 100644
--- a/crates/screenpipe-audio/tests/audio_pipeline_benchmark/ground_truth.rs
+++ b/crates/screenpipe-audio/tests/audio_pipeline_benchmark/ground_truth.rs
@@ -87,8 +87,8 @@ impl ScenarioManifest {
let start_sec = seg.start_secs.floor() as usize;
let end_sec = (seg.end_secs.ceil() as usize).min(total_seconds);
- for t in start_sec..end_sec {
- labels[t] = true;
+ for label in &mut labels[start_sec..end_sec] {
+ *label = true;
}
}
diff --git a/crates/screenpipe-audio/tests/audio_pipeline_benchmark/meeting_benchmark.rs b/crates/screenpipe-audio/tests/audio_pipeline_benchmark/meeting_benchmark.rs
index 6e873c251..ae5470dfa 100644
--- a/crates/screenpipe-audio/tests/audio_pipeline_benchmark/meeting_benchmark.rs
+++ b/crates/screenpipe-audio/tests/audio_pipeline_benchmark/meeting_benchmark.rs
@@ -38,8 +38,9 @@ async fn replay_scenario(
sorted_events.sort_by(|a, b| a.time_secs.partial_cmp(&b.time_secs).unwrap());
// Replay second by second
- for t in 0..total_seconds {
- let t_secs = t as f64;
+ #[allow(clippy::needless_range_loop)]
+ for sec in 0..total_seconds {
+ let t_secs = sec as f64;
// Fire events at this second
for event in &sorted_events {
@@ -106,7 +107,7 @@ async fn replay_scenario(
detector.check_grace_period().await;
// Sample detection state
- detected_meeting[t] = detector.is_in_meeting();
+ detected_meeting[sec] = detector.is_in_meeting();
}
// Compute metrics against ground truth meeting windows
@@ -115,8 +116,8 @@ async fn replay_scenario(
if w.is_meeting {
let start = w.start_secs as usize;
let end = (w.end_secs as usize).min(total_seconds);
- for t in start..end {
- gt_meeting[t] = true;
+ for val in &mut gt_meeting[start..end] {
+ *val = true;
}
}
}
diff --git a/crates/screenpipe-audio/tests/audio_pipeline_benchmark/pipeline_benchmark.rs b/crates/screenpipe-audio/tests/audio_pipeline_benchmark/pipeline_benchmark.rs
index e0a2abf37..a8e41da8a 100644
--- a/crates/screenpipe-audio/tests/audio_pipeline_benchmark/pipeline_benchmark.rs
+++ b/crates/screenpipe-audio/tests/audio_pipeline_benchmark/pipeline_benchmark.rs
@@ -48,7 +48,7 @@ fn simulate_pipeline(
let mut total_speech_seconds = 0.0f64;
// Count total speech seconds from ground truth
- for (_t, &is_speech) in labels.iter().enumerate() {
+ for &is_speech in labels.iter() {
if is_speech {
total_speech_seconds += 1.0;
}
@@ -84,8 +84,8 @@ fn simulate_pipeline(
let chunk_start_sec = chunk_idx as f64 * CHUNK_DURATION_SECS;
let chunk_end_sec = chunk_start_sec + CHUNK_DURATION_SECS;
- for t in (chunk_start_sec as usize)..(chunk_end_sec as usize).min(labels.len()) {
- if labels[t] {
+ for &is_speech in &labels[(chunk_start_sec as usize)..(chunk_end_sec as usize).min(labels.len())] {
+ if is_speech {
speech_seconds_captured += 1.0;
}
}
diff --git a/crates/screenpipe-audio/tests/audio_pipeline_benchmark/quality_regression.rs b/crates/screenpipe-audio/tests/audio_pipeline_benchmark/quality_regression.rs
index 5fb50e854..847ffb71e 100644
--- a/crates/screenpipe-audio/tests/audio_pipeline_benchmark/quality_regression.rs
+++ b/crates/screenpipe-audio/tests/audio_pipeline_benchmark/quality_regression.rs
@@ -45,7 +45,7 @@ async fn whisper_hallucination_on_silence() {
let text = screenpipe_audio::stt(
&silence,
- SAMPLE_RATE as u32,
+ SAMPLE_RATE,
"test-silence",
engine.clone(),
None,
@@ -91,7 +91,7 @@ async fn whisper_hallucination_on_noise() {
let text = screenpipe_audio::stt(
&noise,
- SAMPLE_RATE as u32,
+ SAMPLE_RATE,
"test-noise",
engine.clone(),
None,
@@ -135,7 +135,7 @@ async fn whisper_hallucination_on_ambient() {
let text = screenpipe_audio::stt(
&ambient,
- SAMPLE_RATE as u32,
+ SAMPLE_RATE,
"test-ambient",
engine.clone(),
None,
@@ -240,7 +240,7 @@ async fn whisper_real_speech_still_works() {
let text = screenpipe_audio::stt(
chunk,
- SAMPLE_RATE as u32,
+ SAMPLE_RATE,
"benchmark",
engine.clone(),
None,
diff --git a/crates/screenpipe-audio/tests/audio_pipeline_benchmark/vad_benchmark.rs b/crates/screenpipe-audio/tests/audio_pipeline_benchmark/vad_benchmark.rs
index 4923f0523..450ffbd70 100644
--- a/crates/screenpipe-audio/tests/audio_pipeline_benchmark/vad_benchmark.rs
+++ b/crates/screenpipe-audio/tests/audio_pipeline_benchmark/vad_benchmark.rs
@@ -377,7 +377,7 @@ async fn vad_debug_single_wav() {
let t = 4.0 + i as f64 * (512.0 / SAMPLE_RATE as f64);
if result.prob > 0.3 { speech_count += 1; }
// Print all frames in speech region and every 10th elsewhere
- if (t >= 4.9 && t <= 7.5) || i % 10 == 0 {
+ if (4.9..=7.5).contains(&t) || i % 10 == 0 {
println!(" frame {:>3} (t={:.3}s): prob={:.4} status={:?}",
i, t, result.prob, if result.prob > 0.5 { "SPEECH" } else if result.prob < 0.35 { "silence" } else { "unknown" });
}
diff --git a/crates/screenpipe-audio/tests/channel_lag_test.rs b/crates/screenpipe-audio/tests/channel_lag_test.rs
index 1c0a4968c..e832be1f1 100644
--- a/crates/screenpipe-audio/tests/channel_lag_test.rs
+++ b/crates/screenpipe-audio/tests/channel_lag_test.rs
@@ -54,7 +54,7 @@ async fn test_broadcast_channel_lag_recovery() {
// Try to receive with graceful lag handling
loop {
match rx.recv().await {
- Ok(chunk) => {
+ Ok(_chunk) => {
received_count.fetch_add(1, Ordering::Relaxed);
// Successfully received a chunk after potential lag
}
@@ -99,7 +99,7 @@ async fn test_slow_consumer_causes_lag() {
// Producer: simulates fast audio input (~44100 samples/sec in chunks)
let producer = tokio::spawn(async move {
- for i in 0..200 {
+ for _i in 0..200 {
if !is_running_producer.load(Ordering::Relaxed) {
break;
}
diff --git a/crates/screenpipe-audio/tests/dedup_benchmark/integration.rs b/crates/screenpipe-audio/tests/dedup_benchmark/integration.rs
index 4a3165bb6..b11524a75 100644
--- a/crates/screenpipe-audio/tests/dedup_benchmark/integration.rs
+++ b/crates/screenpipe-audio/tests/dedup_benchmark/integration.rs
@@ -57,10 +57,8 @@ impl HandleNewTranscriptSimulator {
if let Some((previous, current)) = self.cleanup_overlap(transcription) {
// BUG: This condition fails when both are empty (exact duplicate)
- if !previous.is_empty() && !current.is_empty() {
- if current != transcription {
- current_transcript = Some(current);
- }
+ if !previous.is_empty() && !current.is_empty() && current != transcription {
+ current_transcript = Some(current);
}
// When both are empty, current_transcript stays as original = DUPLICATE INSERTED
}
diff --git a/crates/screenpipe-audio/tests/dedup_benchmark/simulation.rs b/crates/screenpipe-audio/tests/dedup_benchmark/simulation.rs
index 9dfeaafe4..21d0ff4c8 100644
--- a/crates/screenpipe-audio/tests/dedup_benchmark/simulation.rs
+++ b/crates/screenpipe-audio/tests/dedup_benchmark/simulation.rs
@@ -346,6 +346,7 @@ pub struct RecordingSession {
/// Transcription noise generator
pub noise: TranscriptionNoise,
/// Random number generator
+ #[allow(dead_code)]
rng: StdRng,
}
@@ -505,7 +506,7 @@ impl DedupHandler {
return false;
}
- if let Some((prev_idx, cur_idx, match_len)) =
+ if let Some((_prev_idx, cur_idx, match_len)) =
longest_common_word_substring(&self.previous_transcript, transcript)
{
let curr_words: Vec<&str> = transcript.split_whitespace().collect();
diff --git a/crates/screenpipe-audio/tests/onnx_model_test.rs b/crates/screenpipe-audio/tests/onnx_model_test.rs
index 1e33ee3cd..e612ea144 100644
--- a/crates/screenpipe-audio/tests/onnx_model_test.rs
+++ b/crates/screenpipe-audio/tests/onnx_model_test.rs
@@ -4,7 +4,6 @@
///
/// These tests are ignored by default because they require downloading large models.
/// Run them locally with: cargo test -p screenpipe-audio --test onnx_model_test -- --ignored
-
#[cfg(test)]
mod tests {
use anyhow::Result;
diff --git a/crates/screenpipe-audio/tests/overlap_dedup_test.rs b/crates/screenpipe-audio/tests/overlap_dedup_test.rs
index a47b24098..c0387bc78 100644
--- a/crates/screenpipe-audio/tests/overlap_dedup_test.rs
+++ b/crates/screenpipe-audio/tests/overlap_dedup_test.rs
@@ -4,7 +4,6 @@
/// from chunk boundaries and cross-device capture.
///
/// Run with: cargo test --package screenpipe-audio --test overlap_dedup_test -- --nocapture
-
#[cfg(test)]
mod tests {
use screenpipe_audio::transcription::text_utils::longest_common_word_substring;
diff --git a/crates/screenpipe-audio/tests/speaker_identification.rs b/crates/screenpipe-audio/tests/speaker_identification.rs
index a2130c52b..8ef73fcc6 100644
--- a/crates/screenpipe-audio/tests/speaker_identification.rs
+++ b/crates/screenpipe-audio/tests/speaker_identification.rs
@@ -19,14 +19,14 @@ mod tests {
// Create embeddings with different DIRECTIONS (cosine similarity measures angle)
// embedding1: positive in first half, zero in second half
let mut embedding1 = vec![0.0; 512];
- for i in 0..256 {
- embedding1[i] = 1.0;
+ for val in &mut embedding1[..256] {
+ *val = 1.0;
}
// embedding2: zero in first half, positive in second half (orthogonal to embedding1)
let mut embedding2 = vec![0.0; 512];
- for i in 256..512 {
- embedding2[i] = 1.0;
+ for val in &mut embedding2[256..] {
+ *val = 1.0;
}
// Simulate: first audio chunk creates speaker 1
@@ -79,13 +79,13 @@ mod tests {
// Create embeddings with different DIRECTIONS (cosine similarity measures angle)
let mut embedding1 = vec![0.0; 512];
- for i in 0..256 {
- embedding1[i] = 1.0;
+ for val in &mut embedding1[..256] {
+ *val = 1.0;
}
let mut embedding2 = vec![0.0; 512];
- for i in 256..512 {
- embedding2[i] = 1.0;
+ for val in &mut embedding2[256..] {
+ *val = 1.0;
}
// Simulate: first audio chunk creates speaker 1