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
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: handle edge cases in audio pause on screen lock
Louis Beaumontd6fa5dd3631c
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lockindex 594befa88..25ec2e1b4 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -9727,7 +9727,7 @@ dependencies = [[[package]]name = "screenpipe-app"-version = "2.3.79"+version = "2.3.81"dependencies = ["anyhow","arboard",diff --git a/crates/screenpipe-audio/src/core/run_record_and_transcribe.rs b/crates/screenpipe-audio/src/core/run_record_and_transcribe.rsindex 30924556e..835f38763 100644--- a/crates/screenpipe-audio/src/core/run_record_and_transcribe.rs+++ b/crates/screenpipe-audio/src/core/run_record_and_transcribe.rs@@ -67,17 +67,41 @@ pub async fn run_record_and_transcribe(let stream_start = std::time::Instant::now();let mut segment_count: u64 = 0;+ let mut was_paused_for_lock = false;+while is_running.load(Ordering::Relaxed)&& !audio_stream.is_disconnected.load(Ordering::Relaxed){// Skip recording while the screen is locked (unless record_while_locked is enabled).// This avoids wasting CPU/disk on audio captured during lock screen.if screenpipe_config::should_pause_audio_for_lock() {- debug!("screen is locked, pausing audio recording for {}", device_name);+ if !was_paused_for_lock {+ info!("screen locked, pausing audio recording for {}", device_name);+ was_paused_for_lock = true;+ }tokio::time::sleep(Duration::from_secs(1)).await;continue;}+ // Transitioning from locked → unlocked: discard stale audio and reset segment timing.+ // The broadcast channel accumulated data while we were paused — drain it to avoid+ // transcribing audio from the lock screen period.+ if was_paused_for_lock {+ info!("screen unlocked, resuming audio recording for {}", device_name);+ was_paused_for_lock = false;+ collected_audio.clear();+ segment_start_time = now_epoch_secs();+ // Drain stale audio from the broadcast channel.+ // Lagged means messages were dropped (channel full) — also fine, keep draining.+ loop {+ match receiver.try_recv() {+ Ok(_) => continue,+ Err(broadcast::error::TryRecvError::Lagged(_)) => continue,+ Err(_) => break, // Empty or Closed+ }+ }+ }+while collected_audio.len() < max_samples && is_running.load(Ordering::Relaxed) {match recv_audio_chunk(&mut receiver,