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
feat(retention): --retention-mode CLI flag, default media everywhere
Louis Beaumont1f17cb6d5a04
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/sync.rs b/apps/screenpipe-app-tauri/src-tauri/src/sync.rsindex e0dae6b20..fa2d2271f 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/sync.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/sync.rs@@ -731,11 +731,13 @@ pub async fn auto_start_retention(app: &AppHandle) {_ => return,};+ // Default to enabled+media for users on stores that haven't seen the+ // setting yet — matches the default in createDefaultSettingsObject.let enabled = settings.extra.get("localRetentionEnabled").and_then(|v| v.as_bool())- .unwrap_or(false);+ .unwrap_or(true);if !enabled {return;@@ -747,11 +749,19 @@ pub async fn auto_start_retention(app: &AppHandle) {.and_then(|v| v.as_u64()).unwrap_or(14) as u32;+ let mode = settings+ .extra+ .get("localRetentionMode")+ .and_then(|v| v.as_str())+ .filter(|s| *s == "media" || *s == "all")+ .unwrap_or("media");+let client = reqwest::Client::new();let api = local_api_context_from_app(app);let configure_req = serde_json::json!({"enabled": true,"retention_days": days,+ "mode": mode,});match apply_local_api_auth(&api, client.post(api.url("/retention/configure")))@@ -760,7 +770,10 @@ pub async fn auto_start_retention(app: &AppHandle) {.await{Ok(response) if response.status().is_success() => {- info!("local retention auto-started (retention={}d)", days);+ info!(+ "local retention auto-started (retention={}d, mode={})",+ days, mode+ );}Ok(response) => {let status = response.status();diff --git a/crates/screenpipe-engine/src/bin/screenpipe-engine.rs b/crates/screenpipe-engine/src/bin/screenpipe-engine.rsindex 6f7fa419e..078323b3f 100644--- a/crates/screenpipe-engine/src/bin/screenpipe-engine.rs+++ b/crates/screenpipe-engine/src/bin/screenpipe-engine.rs@@ -466,6 +466,7 @@ async fn main() -> anyhow::Result<()> {map.insert("api_auth".into(), json!(record_args.api_auth));map.insert("encrypt_secrets".into(), json!(record_args.encrypt_secrets));map.insert("retention_days".into(), json!(record_args.retention_days));+ map.insert("retention_mode".into(), json!(record_args.retention_mode));// Only send counts for privacy-sensitive lists (not actual values)map.insert("audio_device_count".into(),@@ -1236,6 +1237,19 @@ async fn main() -> anyhow::Result<()> {format!("{}", record_args.retention_days)});+ println!(+ "│ retention mode │ {:<34} │",+ if record_args.retention_days == 0 {+ "n/a".to_string()+ } else {+ match record_args.retention_mode {+ screenpipe_engine::retention::RetentionMode::Media => {+ "media-only (keep transcripts)".to_string()+ }+ screenpipe_engine::retention::RetentionMode::All => "all (full delete)".to_string(),+ }+ }+ );const VALUE_WIDTH: usize = 34;@@ -1441,6 +1455,7 @@ async fn main() -> anyhow::Result<()> {{let port = config.port;let retention_days = record_args.retention_days;+ let retention_mode = record_args.retention_mode;let retention_enabled = retention_days > 0;tokio::spawn(async move {if !retention_enabled {@@ -1455,12 +1470,17 @@ async fn main() -> anyhow::Result<()> {.json(&serde_json::json!({"enabled": true,"retention_days": retention_days,+ "mode": retention_mode,})).send().await{Ok(r) if r.status().is_success() => {- tracing::info!("local retention auto-enabled ({} days)", retention_days);+ tracing::info!(+ "local retention auto-enabled ({} days, mode={:?})",+ retention_days,+ retention_mode+ );}Ok(r) => {tracing::debug!("retention configure returned {}", r.status());diff --git a/crates/screenpipe-engine/src/cli/mod.rs b/crates/screenpipe-engine/src/cli/mod.rsindex 45144e8f6..0c9437e19 100644--- a/crates/screenpipe-engine/src/cli/mod.rs+++ b/crates/screenpipe-engine/src/cli/mod.rs@@ -416,6 +416,13 @@ pub struct RecordArgs {/// Set to 0 to disable retention (keep data forever).#[arg(long, default_value_t = 14)]pub retention_days: u32,++ /// What gets cleaned up past the retention cutoff.+ /// `media` (default) reclaims mp4/wav/jpeg files but keeps transcripts,+ /// ocr text, and the timeline searchable. `all` permanently deletes+ /// everything (legacy behavior).+ #[arg(long, value_enum, default_value_t = crate::retention::RetentionMode::Media)]+ pub retention_mode: crate::retention::RetentionMode,}impl RecordArgs {diff --git a/crates/screenpipe-engine/src/retention.rs b/crates/screenpipe-engine/src/retention.rsindex 6a2b0f29e..92dd229a5 100644--- a/crates/screenpipe-engine/src/retention.rs+++ b/crates/screenpipe-engine/src/retention.rs@@ -11,6 +11,7 @@ use axum::{response::Json as JsonResponse,};use chrono::{DateTime, Duration, Utc};+use clap::ValueEnum;use oasgen::{oasgen, OaSchema};use screenpipe_db::DatabaseManager;use serde::{Deserialize, Serialize};@@ -55,8 +56,9 @@ struct RetentionRuntime {/// What old data gets cleaned up. `Media` (default) keeps DB rows (search,/// timeline, transcripts) and only reclaims mp4/wav/jpeg files; `All` is the/// legacy behavior that wipes everything past the cutoff.-#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, OaSchema)]+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, OaSchema, ValueEnum)]#[serde(rename_all = "lowercase")]+#[clap(rename_all = "lowercase")]pub enum RetentionMode {Media,All,