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: filter bulky NDJSON events before storing pipe stdout
Louis Beaumontd3b1f9ec63c9
diff --git a/crates/screenpipe-core/src/pipes/mod.rs b/crates/screenpipe-core/src/pipes/mod.rsindex 58aa9f0a7..45f762c76 100644--- a/crates/screenpipe-core/src/pipes/mod.rs+++ b/crates/screenpipe-core/src/pipes/mod.rs@@ -958,12 +958,13 @@ impl PipeManager {} else {"failed"};+ let filtered_stdout = filter_ndjson_stdout(&output.stdout);if let (Some(ref store), Some(id)) = (&store_ref, exec_id) {let _ = store.finish_execution(id,status,- &truncate_string(&output.stdout, 50_000),+ &truncate_string(&filtered_stdout, 50_000),&truncate_string(&output.stderr, 10_000),None,error_type.as_deref(),@@ -981,7 +982,7 @@ impl PipeManager {started_at,finished_at,success: output.success,- stdout: truncate_string(&output.stdout, 10_000),+ stdout: truncate_string(&filtered_stdout, 10_000),stderr: truncate_string(&output.stderr, 5_000),}}@@ -2421,6 +2422,37 @@ fn parse_duration_str(s: &str) -> Option<std::time::Duration> {// Utility helpers// ---------------------------------------------------------------------------+/// Filter NDJSON stdout to remove bulky streaming events before storage.+/// `toolcall_delta` and `thinking_delta` events are only useful for live+/// streaming — they dominate the output and push useful `text_delta` /+/// `message_end` / `agent_end` events past the truncation limit.+fn filter_ndjson_stdout(s: &str) -> String {+ // Quick check: if it doesn't look like NDJSON, return as-is+ if !s.starts_with('{') {+ return s.to_string();+ }++ let mut out = String::with_capacity(s.len() / 2);+ for line in s.split('\n') {+ let trimmed = line.trim();+ if trimmed.is_empty() {+ continue;+ }+ // Only filter JSON lines that are complete objects+ if trimmed.starts_with('{') && trimmed.ends_with('}') {+ // Fast substring check before paying for a full JSON parse+ if trimmed.contains("\"toolcall_delta\"") || trimmed.contains("\"thinking_delta\"") {+ continue;+ }+ }+ if !out.is_empty() {+ out.push('\n');+ }+ out.push_str(line);+ }+ out+}+fn truncate_string(s: &str, max_len: usize) -> String {if s.len() <= max_len {s.to_string()diff --git a/crates/screenpipe-server/src/bin/screenpipe-server.rs b/crates/screenpipe-server/src/bin/screenpipe-server.rsindex 96c039f51..73ee262c3 100644--- a/crates/screenpipe-server/src/bin/screenpipe-server.rs+++ b/crates/screenpipe-server/src/bin/screenpipe-server.rs@@ -574,10 +574,6 @@ async fn main() -> anyhow::Result<()> {// This helps track users who may have screen capture issues due to old macOSanalytics::check_macos_version();- // Start sleep/wake monitor for telemetry (macOS only)- // This tracks sleep/wake events and checks if recording is degraded after wake- start_sleep_monitor();-let db = Arc::new(DatabaseManager::new(&format!("{}/db.sqlite", local_data_dir.to_string_lossy())).await@@ -587,6 +583,13 @@ async fn main() -> anyhow::Result<()> {})?,);+ // Start sleep/wake monitor for telemetry (macOS only)+ // This tracks sleep/wake events and checks if recording is degraded after wake+ // NOTE: must be started AFTER database init — the monitor spawns background+ // threads with ObjC run loops that segfault during process teardown if an+ // earlier init step (like DB) fails and the process exits.+ start_sleep_monitor();+// Start cloud sync service if enabledlet sync_service_handle = if cli.enable_sync {match start_sync_service(&cli, db.clone()).await {