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(meetings): keep calls alive on deferred output audio (#3778)

Divanshu89cb899d75b4
diff --git a/crates/screenpipe-db/src/db.rs b/crates/screenpipe-db/src/db.rs
index 0748b1266..abb493bd3 100644
--- a/crates/screenpipe-db/src/db.rs
+++ b/crates/screenpipe-db/src/db.rs
@@ -1190,18 +1190,25 @@ impl DatabaseManager {
})
}
- /// Returns true if there are audio transcriptions from output devices
- /// within the given number of seconds. Used by meeting detection to keep
- /// browser-based meetings alive when the user switches tabs but audio is
- /// still flowing (i.e. the meeting is still going).
+ /// Returns true if output audio was recently captured. Used by meeting
+ /// detection to keep meetings alive when controls disappear but call audio
+ /// still flows.
+ ///
+ /// Important: batch mode defers `audio_transcriptions` while the meeting is
+ /// active, so this must also inspect durable `audio_chunks` file paths.
pub async fn has_recent_output_audio(&self, within_secs: i64) -> Result<bool, sqlx::Error> {
- // EXISTS short-circuits on the first matching row instead of scanning
- // every transcription in the window like COUNT(*) would.
+ // EXISTS short-circuits on the first matching row. Match both old
+ // transcribed output rows and fresh persisted chunks that have not been
+ // transcribed yet (batch/live meeting path).
let exists = sqlx::query_scalar::<_, i64>(
"SELECT EXISTS(
SELECT 1 FROM audio_transcriptions
WHERE is_input_device = 0
AND timestamp >= strftime('%Y-%m-%dT%H:%M:%S+00:00', 'now', ?1)
+ UNION ALL
+ SELECT 1 FROM audio_chunks
+ WHERE lower(file_path) LIKE '%(output)%'
+ AND timestamp >= strftime('%Y-%m-%dT%H:%M:%S+00:00', 'now', ?1)
)",
)
.bind(format!("-{} seconds", within_secs))
diff --git a/crates/screenpipe-db/tests/db.rs b/crates/screenpipe-db/tests/db.rs
index 7737ad088..1d3dae9dd 100644
--- a/crates/screenpipe-db/tests/db.rs
+++ b/crates/screenpipe-db/tests/db.rs
@@ -95,6 +95,28 @@ mod tests {
}
}
+ #[tokio::test]
+ async fn test_recent_output_audio_detects_deferred_output_chunk() {
+ let db = setup_test_db().await;
+
+ db.insert_audio_chunk("System Audio (output)_recent.mp4", Some(Utc::now()))
+ .await
+ .unwrap();
+
+ assert!(db.has_recent_output_audio(30).await.unwrap());
+ }
+
+ #[tokio::test]
+ async fn test_recent_output_audio_ignores_input_chunk() {
+ let db = setup_test_db().await;
+
+ db.insert_audio_chunk("Ruark’s AirPods (input)_recent.mp4", Some(Utc::now()))
+ .await
+ .unwrap();
+
+ assert!(!db.has_recent_output_audio(30).await.unwrap());
+ }
+
#[tokio::test]
async fn test_insert_and_search_audio() {
let db = setup_test_db().await;