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

feat: add --retention-days CLI flag for local data retention

Louis Beaumontac45be264c21
diff --git a/crates/screenpipe-engine/src/bin/screenpipe-engine.rs b/crates/screenpipe-engine/src/bin/screenpipe-engine.rs
index b4fb61f79..9857e2bd6 100644
--- a/crates/screenpipe-engine/src/bin/screenpipe-engine.rs
+++ b/crates/screenpipe-engine/src/bin/screenpipe-engine.rs
@@ -1296,12 +1296,18 @@ async fn main() -> anyhow::Result<()> {
let server_future = server.start();
pin_mut!(server_future);
- // Auto-enable local data retention (14 days) for CLI users.
+ // Auto-enable local data retention for CLI users.
// The Tauri app does this via auto_start_retention(); for CLI we hit the
// same HTTP endpoint after a short delay to let the server bind.
{
let port = config.port;
+ let retention_days = record_args.retention_days;
+ let retention_enabled = retention_days > 0;
tokio::spawn(async move {
+ if !retention_enabled {
+ tracing::info!("local retention disabled (--retention-days 0)");
+ return;
+ }
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
let client = reqwest::Client::new();
let url = format!("http://localhost:{}/retention/configure", port);
@@ -1309,13 +1315,13 @@ async fn main() -> anyhow::Result<()> {
.post(&url)
.json(&serde_json::json!({
"enabled": true,
- "retention_days": 14,
+ "retention_days": retention_days,
}))
.send()
.await
{
Ok(r) if r.status().is_success() => {
- tracing::info!("local retention auto-enabled (14 days)");
+ tracing::info!("local retention auto-enabled ({} days)", retention_days);
}
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.rs
index b11fd7d54..35fdfbae7 100644
--- a/crates/screenpipe-engine/src/cli/mod.rs
+++ b/crates/screenpipe-engine/src/cli/mod.rs
@@ -366,6 +366,11 @@ pub struct RecordArgs {
/// Localhost requests are always allowed.
#[arg(long, default_value_t = true)]
pub api_auth: bool,
+
+ /// Local data retention in days. Old screen/audio data is auto-deleted after this period.
+ /// Set to 0 to disable retention (keep data forever).
+ #[arg(long, default_value_t = 14)]
+ pub retention_days: u32,
}
impl RecordArgs {