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
Bump app to v2.4.217 - release-app
Louis Beaumont6819985647ff
diff --git a/.github/scripts/assert_windows_audio_rms.ps1 b/.github/scripts/assert_windows_audio_rms.ps1index d37edbeb8..aad99a632 100644--- a/.github/scripts/assert_windows_audio_rms.ps1+++ b/.github/scripts/assert_windows_audio_rms.ps1@@ -6,6 +6,7 @@ param([string]$HealthUrl = "http://127.0.0.1:3030/health",[double]$MinRms = 0.002,[int]$TimeoutSeconds = 45,+ [int]$HealthRequestTimeoutSeconds = 10,[int]$ToneSeconds = 25,[string]$DeviceNamePattern = "",[string]$TonePath = "windows-audio-smoke.wav"@@ -15,7 +16,7 @@ $ErrorActionPreference = "Stop"function Get-HealthSnapshot {try {- return Invoke-RestMethod -Uri $HealthUrl -TimeoutSec 5+ return Invoke-RestMethod -Uri $HealthUrl -TimeoutSec $HealthRequestTimeoutSeconds} catch {Write-Host "health poll failed: $($_.Exception.Message)"return $nulldiff --git a/.github/workflows/windows-integration-test.yml b/.github/workflows/windows-integration-test.ymlindex f99ab04d1..6b92608ba 100644--- a/.github/workflows/windows-integration-test.yml+++ b/.github/workflows/windows-integration-test.yml@@ -176,7 +176,8 @@ jobs:& .\.github\scripts\assert_windows_audio_rms.ps1 `-HealthUrl "http://127.0.0.1:3030/health" `-MinRms 0.002 `- -TimeoutSeconds 120 `+ -TimeoutSeconds 180 `+ -HealthRequestTimeoutSeconds 10 `-ToneSeconds 30Start-Sleep -Seconds 30 # Allow more time for processingdiff --git a/apps/screenpipe-app-tauri/components/settings/privacy-section.tsx b/apps/screenpipe-app-tauri/components/settings/privacy-section.tsxindex 521c6015e..7baf7062a 100644--- a/apps/screenpipe-app-tauri/components/settings/privacy-section.tsx+++ b/apps/screenpipe-app-tauri/components/settings/privacy-section.tsx@@ -154,8 +154,22 @@ function EncryptDataCard({toast({ title: "Keychain access denied", description: "Could not enable encryption. Try again later.", variant: "destructive" });}} else {- // Disable: just turn off store.bin encryption (credentials stay encrypted, which is fine)- onEncryptStoreChange(false);+ // Disable: decrypt credentials first, then turn off store.bin encryption.+ const res = await commands.disableKeychainEncryption();+ if (res.status === "ok" && res.data.state === "disabled") {+ setKeychainState("disabled");+ onEncryptStoreChange(false);+ toast({+ title: "Encryption disabled",+ description: "Credentials and settings are now stored without keychain encryption.",+ });+ } else {+ toast({+ title: "Could not disable encryption",+ description: "Encrypted credentials could not be decrypted. Check keychain access and try again.",+ variant: "destructive",+ });+ }}setToggling(false);diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lockindex d77f87fe2..09e4ac9ea 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -10580,7 +10580,7 @@ dependencies = [[[package]]name = "screenpipe-app"-version = "2.4.215"+version = "2.4.217"dependencies = ["aes","anyhow",diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 8cba490b1..5e9bacff9 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "screenpipe-app"-version = "2.4.216"+version = "2.4.217"description = "24/7 memory for your desktop. 100% local."authors = ["you"]license = ""diff --git a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs b/apps/screenpipe-app-tauri/src-tauri/src/commands.rsindex 9ecfa1647..6de393231 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs@@ -1632,6 +1632,57 @@ pub async fn enable_keychain_encryption() -> Result<KeychainStatus, String> {#[specta::specta]pub async fn disable_keychain_encryption() -> Result<KeychainStatus, String> {let data_dir = screenpipe_core::paths::default_screenpipe_data_dir();+ let db_path = data_dir.join("db.sqlite");+ let db_url = format!("sqlite:{}?mode=rwc", db_path.display());++ if db_path.exists() {+ let pool = sqlx::SqlitePool::connect(&db_url).await.map_err(|e| {+ format!("failed to open secret database before disabling encryption: {e}")+ })?;+ let plain_store = screenpipe_secrets::SecretStore::new(pool.clone(), None)+ .await+ .map_err(|e| format!("failed to open secret store: {e}"))?;+ let encrypted_count = plain_store+ .encrypted_secret_count()+ .await+ .map_err(|e| format!("failed to inspect encrypted secrets: {e}"))?;++ if encrypted_count > 0 {+ let key = match crate::secrets::get_key() {+ crate::secrets::KeyResult::Found(key) => key,+ crate::secrets::KeyResult::AccessDenied => {+ return Err(format!(+ "Cannot disable encryption yet: {encrypted_count} stored secret(s) are encrypted, but keychain access was denied."+ ));+ }+ crate::secrets::KeyResult::NotFound => {+ return Err(format!(+ "Cannot disable encryption yet: {encrypted_count} stored secret(s) are encrypted, but the keychain key was not found."+ ));+ }+ crate::secrets::KeyResult::Unavailable => {+ return Err(format!(+ "Cannot disable encryption yet: {encrypted_count} stored secret(s) are encrypted, but the keychain is unavailable."+ ));+ }+ };++ let encrypted_store = screenpipe_secrets::SecretStore::new(pool, Some(key))+ .await+ .map_err(|e| format!("failed to open encrypted secret store: {e}"))?;+ match encrypted_store.decrypt_encrypted_secrets().await {+ Ok(count) => {+ tracing::info!("decrypted {} secrets before keychain opt-out", count);+ }+ Err(e) => {+ return Err(format!(+ "Cannot disable encryption until encrypted secrets are decrypted: {e}"+ ));+ }+ }+ }+ }+screenpipe_secrets::mark_encryption_disabled(&data_dir).map_err(|e| format!("failed to remove .encrypt-store flag: {e}"))?;if let Err(e) = crate::secrets::delete_key() {diff --git a/crates/screenpipe-engine/src/bin/screenpipe-engine.rs b/crates/screenpipe-engine/src/bin/screenpipe-engine.rsindex 17cbe33d6..6dcaf4b41 100644--- a/crates/screenpipe-engine/src/bin/screenpipe-engine.rs+++ b/crates/screenpipe-engine/src/bin/screenpipe-engine.rs@@ -7,7 +7,7 @@#[global_allocator]static ALLOC: dhat::Alloc = dhat::Alloc;-use clap::Parser;+use clap::{CommandFactory, FromArgMatches};#[allow(unused_imports)]use colored::Colorize;use futures::pin_mut;@@ -29,7 +29,7 @@ use screenpipe_engine::{status::handle_status_command,sync::{handle_sync_command, start_sync_service},vision::handle_vision_command,- Cli, CliAudioTranscriptionEngine, Command,+ Cli, Command, RecordArgSources,},hot_frame_cache::HotFrameCache,start_meeting_watcher, start_power_manager, start_sleep_monitor, start_speaker_identification,@@ -252,7 +252,9 @@ async fn main() -> anyhow::Result<()> {set_fd_limit();debug!("starting screenpipe server");- let cli = Cli::parse();+ let matches = Cli::command().get_matches();+ let record_arg_sources = RecordArgSources::from_cli_matches(&matches);+ let cli = Cli::from_arg_matches(&matches)?;// Dispatch subcommands — non-recording commands return earlylet record_args = match cli.command {@@ -371,6 +373,22 @@ async fn main() -> anyhow::Result<()> {Command::Record(args) => args,};+ let local_data_dir = get_base_dir(&record_args.data_dir)?;+ let local_data_dir_clone = local_data_dir.clone();++ // Build unified RecordingConfig from shared app settings plus explicit CLI args.+ let config = record_args+ .clone()+ .into_recording_config(local_data_dir.clone(), &record_arg_sources)+ .await?;++ // Store the guard in a variable that lives for the entire main function+ let _log_guard = Some(setup_logging(+ &local_data_dir,+ record_args.debug,+ !config.analytics_enabled,+ )?);+// Non-blocking update check — runs in background, prints banner if outdatedtokio::spawn(async {check_for_updates().await;@@ -380,7 +398,7 @@ async fn main() -> anyhow::Result<()> {screenpipe_engine::cli_reminder::spawn();// Initialize Sentry only if telemetry is enabled- let _sentry_guard = if !record_args.disable_telemetry {+ let _sentry_guard = if config.analytics_enabled {let sentry_release_name_append = env::var("SENTRY_RELEASE_NAME_APPEND").unwrap_or_default();let release_name = format!("{}{}",@@ -471,29 +489,19 @@ async fn main() -> anyhow::Result<()> {let mut map = std::collections::BTreeMap::new();map.insert("audio_chunk_duration".into(),- json!(record_args.audio_chunk_duration),+ json!(config.audio_chunk_duration),);- map.insert("port".into(), json!(record_args.port));- map.insert("disable_audio".into(), json!(record_args.disable_audio));+ map.insert("port".into(), json!(config.port));+ map.insert("disable_audio".into(), json!(config.disable_audio));map.insert("audio_transcription_engine".into(),- json!(format!("{:?}", record_args.audio_transcription_engine)),- );- map.insert("monitor_ids".into(), json!(record_args.monitor_id));- map.insert(- "use_all_monitors".into(),- json!(record_args.use_all_monitors),- );- map.insert(- "languages".into(),- json!(record_args- .language- .iter()- .map(|l| format!("{:?}", l))- .collect::<Vec<_>>()),+ json!(format!("{:?}", config.audio_transcription_engine)),);- map.insert("use_pii_removal".into(), json!(record_args.use_pii_removal));- map.insert("disable_vision".into(), json!(record_args.disable_vision));+ map.insert("monitor_ids".into(), json!(config.monitor_ids));+ map.insert("use_all_monitors".into(), json!(config.use_all_monitors));+ map.insert("languages".into(), json!(config.languages));+ map.insert("use_pii_removal".into(), json!(config.use_pii_removal));+ map.insert("disable_vision".into(), json!(config.disable_vision));map.insert("vad_engine".into(), json!("Silero"));map.insert("enable_sync".into(), json!(record_args.enable_sync));map.insert(@@ -501,26 +509,26 @@ async fn main() -> anyhow::Result<()> {json!(record_args.sync_interval_secs),);map.insert("debug".into(), json!(record_args.debug));- map.insert("api_auth".into(), json!(record_args.api_auth));- map.insert("encrypt_secrets".into(), json!(record_args.encrypt_secrets));+ map.insert("api_auth".into(), json!(config.api_auth));+ map.insert("encrypt_secrets".into(), json!(config.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(),- json!(record_args.audio_device.len()),+ json!(config.audio_devices.len()),);map.insert("ignored_windows_count".into(),- json!(record_args.ignored_windows.len()),+ json!(config.ignored_windows.len()),);map.insert("included_windows_count".into(),- json!(record_args.included_windows.len()),+ json!(config.included_windows.len()),);map.insert("ignored_urls_count".into(),- json!(record_args.ignored_urls.len()),+ json!(config.ignored_urls.len()),);map}),@@ -532,22 +540,6 @@ async fn main() -> anyhow::Result<()> {None};- let local_data_dir = get_base_dir(&record_args.data_dir)?;- let local_data_dir_clone = local_data_dir.clone();-- // Store the guard in a variable that lives for the entire main function- let _log_guard = Some(setup_logging(- &local_data_dir,- record_args.debug,- record_args.disable_telemetry,- )?);-- // Build unified RecordingConfig from CLI args- let config = record_args- .clone()- .into_recording_config(local_data_dir.clone())- .await;-// Replace the current conditional check with:let ffmpeg_path = find_ffmpeg_path();if ffmpeg_path.is_none() {@@ -678,7 +670,10 @@ async fn main() -> anyhow::Result<()> {let mut audio_devices = Vec::new();if !config.disable_audio {- if config.audio_devices.is_empty() {+ if config.audio_devices.is_empty()+ || config.use_system_default_audio+ || config.audio_devices == vec!["default".to_string()]+ {// Use default devicesif let Ok(input_device) = default_input_device() {audio_devices.push(input_device.to_string());@@ -703,11 +698,11 @@ async fn main() -> anyhow::Result<()> {let audio_devices_clone = audio_devices.clone();- let resource_monitor = ResourceMonitor::new(!record_args.disable_telemetry);+ let resource_monitor = ResourceMonitor::new(config.analytics_enabled);resource_monitor.start_monitoring(Duration::from_secs(30), Some(Duration::from_secs(60)));// Initialize analytics for API tracking- analytics::init(!record_args.disable_telemetry);+ analytics::init(config.analytics_enabled);// Check macOS version and send telemetry if below supported versions// This helps track users who may have screen capture issues due to old macOS@@ -756,7 +751,8 @@ async fn main() -> anyhow::Result<()> {let db_server = db.clone();- let warning_audio_transcription_engine_clone = record_args.audio_transcription_engine.clone();+ let warning_audio_transcription_engine_clone =+ format!("{:?}", config.audio_transcription_engine);let monitor_ids: Vec<u32> = if config.use_all_monitors || config.monitor_ids.is_empty() {all_monitors.iter().map(|m| m.id()).collect::<Vec<_>>()} else if config.monitor_ids == vec!["default"] {@@ -793,8 +789,8 @@ async fn main() -> anyhow::Result<()> {let output_path_clone = Arc::new(local_data_dir.join("data").to_string_lossy().into_owned());let shutdown_tx_clone = shutdown_tx.clone();- let ignored_windows_clone = record_args.ignored_windows.clone();- let included_windows_clone = record_args.included_windows.clone();+ let ignored_windows_clone = config.ignored_windows.clone();+ let included_windows_clone = config.included_windows.clone();// Create UI recorder config early before cli is movedlet ui_recorder_config = config.to_ui_recorder_config();@@ -1001,6 +997,10 @@ async fn main() -> anyhow::Result<()> {match screenpipe_secrets::keychain::get_or_create_key() {Some(k) => {info!("keychain: encryption key ready (--encrypt-secrets)");+ if let Err(e) = screenpipe_secrets::mark_encryption_enabled(&local_data_dir)+ {+ warn!("keychain: failed to persist encryption opt-in flag: {}", e);+ }Some(k)}None => {@@ -1199,20 +1199,14 @@ async fn main() -> anyhow::Result<()> {println!("├────────────────────────┼────────────────────────────────────┤");println!("│ audio chunk duration │ {:<34} │",- format!("{} seconds", record_args.audio_chunk_duration)- );- println!("│ port │ {:<34} │", record_args.port);- println!(- "│ audio disabled │ {:<34} │",- record_args.disable_audio- );- println!(- "│ vision disabled │ {:<34} │",- record_args.disable_vision+ format!("{} seconds", config.audio_chunk_duration));+ println!("│ port │ {:<34} │", config.port);+ println!("│ audio disabled │ {:<34} │", config.disable_audio);+ println!("│ vision disabled │ {:<34} │", config.disable_vision);println!("│ pause on DRM content │ {:<34} │",- record_args.pause_on_drm_content+ config.pause_on_drm_content);println!("│ audio engine │ {:<34} │",@@ -1226,15 +1220,15 @@ async fn main() -> anyhow::Result<()> {println!("│ debug mode │ {:<34} │", record_args.debug);println!("│ telemetry │ {:<34} │",- !record_args.disable_telemetry+ config.analytics_enabled);println!("│ use pii removal │ {:<34} │",- record_args.use_pii_removal+ config.use_pii_removal);println!("│ use all monitors │ {:<34} │",- record_args.use_all_monitors+ config.use_all_monitors);println!("│ ignored windows │ {:<34} │",@@ -1265,7 +1259,7 @@ async fn main() -> anyhow::Result<()> {// For security reasons, you might want to mask the API key if displayedprintln!("│ deepgram key │ {:<34} │",- if record_args.deepgram_api_key.is_some() {+ if config.deepgram_api_key.is_some() {"set (masked)"} else {"not set"@@ -1273,7 +1267,7 @@ async fn main() -> anyhow::Result<()> {);println!("│ api auth │ {:<34} │",- if record_args.api_auth {+ if config.api_auth {"enabled"} else {"disabled"@@ -1333,10 +1327,10 @@ async fn main() -> anyhow::Result<()> {println!("│ languages │ │");const MAX_ITEMS_TO_DISPLAY: usize = 5;- if record_args.language.is_empty() {+ if config.languages.is_empty() {println!("│ {:<22} │ {:<34} │", "", "all languages");} else {- let total_languages = record_args.language.len();+ let total_languages = config.languages.len();for (_, language) in languages.iter().enumerate().take(MAX_ITEMS_TO_DISPLAY) {let language_str = format!("id: {}", language);let formatted_language = format_cell(&language_str, VALUE_WIDTH);@@ -1355,7 +1349,7 @@ async fn main() -> anyhow::Result<()> {println!("├────────────────────────┼────────────────────────────────────┤");println!("│ monitors │ │");- if record_args.disable_vision {+ if config.disable_vision {println!("│ {:<22} │ {:<34} │", "", "vision disabled");} else if monitor_ids.is_empty() {println!("│ {:<22} │ {:<34} │", "", "no monitors available");@@ -1379,7 +1373,7 @@ async fn main() -> anyhow::Result<()> {println!("├────────────────────────┼────────────────────────────────────┤");println!("│ audio devices │ │");- if record_args.disable_audio {+ if config.disable_audio {println!("│ {:<22} │ {:<34} │", "", "disabled");} else if audio_devices_clone.is_empty() {println!("│ {:<22} │ {:<34} │", "", "no devices available");@@ -1406,7 +1400,7 @@ async fn main() -> anyhow::Result<()> {println!("└────────────────────────┴────────────────────────────────────┘");// Add warning for cloud arguments and telemetry- if warning_audio_transcription_engine_clone == CliAudioTranscriptionEngine::Deepgram {+ if warning_audio_transcription_engine_clone == "Deepgram" {println!("{}","warning: you are using cloud now. make sure to understand the data privacy risks."@@ -1421,7 +1415,7 @@ async fn main() -> anyhow::Result<()> {}// Add warning for telemetry- if !record_args.disable_telemetry {+ if config.analytics_enabled {println!("{}","warning: telemetry is enabled. only error-level data will be sent.\n\@@ -1469,7 +1463,7 @@ async fn main() -> anyhow::Result<()> {db.clone(),ui_recorder_config,capture_trigger_tx,- record_args.ignored_windows.clone(),+ config.ignored_windows.clone(),).await{@@ -1555,14 +1549,14 @@ async fn main() -> anyhow::Result<()> {// Spawn the async PII reconciliation worker (issue #3185).// Off by default — only runs when `--async-pii-redaction` is set.// The capture path is unaffected either way.- if !record_args.async_pii_redaction {+ if !config.async_pii_redaction {info!("text-PII worker skipped at startup — async_pii_redaction=false. \OPF model (~2.8 GB) will NOT be downloaded or loaded. \Toggle via Settings → Privacy → AI PII removal.");}- if record_args.async_pii_redaction {+ if config.async_pii_redaction {use screenpipe_redact::{adapters::{opf::{OpfAdapter, OpfConfig},@@ -1644,14 +1638,14 @@ async fn main() -> anyhow::Result<()> {// Independent of the text worker — users can toggle either one// without the other. Requires the rfdetr_v9 model present and at// least one of the `onnx-*` or `mlx-mac` cargo features built.- if !record_args.async_image_pii_redaction {+ if !config.async_image_pii_redaction {info!("image-PII worker skipped at startup — async_image_pii_redaction=false. \rfdetr_v9 model (~108 MB) will NOT be downloaded or loaded. \Toggle via Settings → Privacy → AI PII removal.");}- if record_args.async_image_pii_redaction {+ if config.async_image_pii_redaction {use screenpipe_redact::adapters::rfdetr::{RfdetrConfig, RfdetrRedactor};use screenpipe_redact::image::worker::{ImageWorker, ImageWorkerConfig};use screenpipe_redact::ImageRedactor;diff --git a/crates/screenpipe-engine/src/cli/mod.rs b/crates/screenpipe-engine/src/cli/mod.rsindex dad7308d6..5d752774f 100644--- a/crates/screenpipe-engine/src/cli/mod.rs+++ b/crates/screenpipe-engine/src/cli/mod.rs@@ -18,14 +18,15 @@ pub mod sync;pub mod vault;pub mod vision;-use clap::ValueEnum;+use clap::parser::ValueSource;+use clap::{ArgMatches, ValueEnum};use clap::{Parser, Subcommand, ValueHint};use screenpipe_audio::{audio_manager::builder::TranscriptionMode,core::engine::AudioTranscriptionEngine as CoreAudioTranscriptionEngine,};use screenpipe_core::Language;-use std::path::PathBuf;+use std::path::{Path, PathBuf};#[derive(Clone, Debug, ValueEnum, PartialEq)]pub enum CliAudioTranscriptionEngine {@@ -476,6 +477,121 @@ pub struct RecordArgs {pub disable_meeting_detector: bool,}+#[derive(Clone, Debug, Default)]+pub struct RecordArgSources {+ pub audio_chunk_duration: bool,+ pub port: bool,+ pub disable_audio: bool,+ pub audio_device: bool,+ pub use_system_default_audio: bool,+ pub experimental_coreaudio_system_audio: bool,+ pub audio_transcription_engine: bool,+ pub monitor_id: bool,+ pub use_all_monitors: bool,+ pub language: bool,+ pub use_pii_removal: bool,+ pub async_pii_redaction: bool,+ pub async_image_pii_redaction: bool,+ pub pii_backend: bool,+ pub filter_music: bool,+ pub disable_vision: bool,+ pub ignored_windows: bool,+ pub included_windows: bool,+ pub ignored_urls: bool,+ pub deepgram_api_key: bool,+ pub transcription_mode: bool,+ pub disable_telemetry: bool,+ pub video_quality: bool,+ pub pause_on_drm_content: bool,+ pub disable_clipboard_capture: bool,+ pub api_auth: bool,+ pub listen_on_lan: bool,+ pub encrypt_secrets: bool,+ pub disable_snapshot_compaction: bool,+ pub disable_meeting_detector: bool,+}++impl RecordArgSources {+ pub fn from_cli_matches(matches: &ArgMatches) -> Self {+ let Some(("record", record)) = matches.subcommand() else {+ return Self::default();+ };++ Self {+ audio_chunk_duration: from_command_line(record, "audio_chunk_duration"),+ port: from_command_line(record, "port"),+ disable_audio: from_command_line(record, "disable_audio"),+ audio_device: from_command_line(record, "audio_device"),+ use_system_default_audio: from_command_line(record, "use_system_default_audio"),+ experimental_coreaudio_system_audio: from_command_line(+ record,+ "experimental_coreaudio_system_audio",+ ),+ audio_transcription_engine: from_command_line(record, "audio_transcription_engine"),+ monitor_id: from_command_line(record, "monitor_id"),+ use_all_monitors: from_command_line(record, "use_all_monitors"),+ language: from_command_line(record, "language"),+ use_pii_removal: from_command_line(record, "use_pii_removal"),+ async_pii_redaction: from_command_line(record, "async_pii_redaction"),+ async_image_pii_redaction: from_command_line(record, "async_image_pii_redaction"),+ pii_backend: from_command_line(record, "pii_backend"),+ filter_music: from_command_line(record, "filter_music"),+ disable_vision: from_command_line(record, "disable_vision"),+ ignored_windows: from_command_line(record, "ignored_windows"),+ included_windows: from_command_line(record, "included_windows"),+ ignored_urls: from_command_line(record, "ignored_urls"),+ deepgram_api_key: from_command_line(record, "deepgram_api_key"),+ transcription_mode: from_command_line(record, "transcription_mode"),+ disable_telemetry: from_command_line(record, "disable_telemetry"),+ video_quality: from_command_line(record, "video_quality"),+ pause_on_drm_content: from_command_line(record, "pause_on_drm_content"),+ disable_clipboard_capture: from_command_line(record, "disable_clipboard_capture"),+ api_auth: from_command_line(record, "api_auth"),+ listen_on_lan: from_command_line(record, "listen_on_lan"),+ encrypt_secrets: from_command_line(record, "encrypt_secrets"),+ disable_snapshot_compaction: from_command_line(record, "disable_snapshot_compaction"),+ disable_meeting_detector: from_command_line(record, "disable_meeting_detector"),+ }+ }++ fn has_recording_override(&self) -> bool {+ self.audio_chunk_duration+ || self.port+ || self.disable_audio+ || self.audio_device+ || self.use_system_default_audio+ || self.experimental_coreaudio_system_audio+ || self.audio_transcription_engine+ || self.monitor_id+ || self.use_all_monitors+ || self.language+ || self.use_pii_removal+ || self.async_pii_redaction+ || self.async_image_pii_redaction+ || self.pii_backend+ || self.filter_music+ || self.disable_vision+ || self.ignored_windows+ || self.included_windows+ || self.ignored_urls+ || self.deepgram_api_key+ || self.transcription_mode+ || self.disable_telemetry+ || self.video_quality+ || self.pause_on_drm_content+ || self.disable_clipboard_capture+ || self.api_auth+ || self.listen_on_lan+ || self.encrypt_secrets+ || self.disable_snapshot_compaction+ || self.disable_meeting_detector+ }+}++fn from_command_line(matches: &ArgMatches, id: &str) -> bool {+ matches.value_source(id) == Some(ValueSource::CommandLine)+}+impl RecordArgs {pub fn unique_languages(&self) -> Result<Vec<Language>, String> {let mut unique_langs = std::collections::HashSet::new();@@ -561,12 +677,35 @@ impl RecordArgs {pub async fn into_recording_config(self,data_dir: PathBuf,- ) -> crate::recording_config::RecordingConfig {+ sources: &RecordArgSources,+ ) -> anyhow::Result<crate::recording_config::RecordingConfig> {+ let cli_encryption_ready = if self.encrypt_secrets {+ match screenpipe_secrets::keychain::get_or_create_key() {+ Some(_) => {+ screenpipe_secrets::mark_encryption_enabled(&data_dir)?;+ true+ }+ None => {+ tracing::warn!(+ "keychain: failed to create encryption key — secrets will be stored unencrypted"+ );+ false+ }+ }+ } else {+ false+ };+// Preserve explicit CLI monitor flags so tier defaults don't clobber them.let cli_monitor_ids = self.monitor_id.clone();let cli_use_all_monitors = self.use_all_monitors;- let mut settings = self.to_recording_settings();+ let persisted_settings = load_recording_settings_from_store(&data_dir)?;+ let loaded_from_store = persisted_settings.is_some();+ let mut settings = persisted_settings.unwrap_or_else(|| self.to_recording_settings());+ if loaded_from_store {+ self.apply_explicit_overrides(&mut settings, sources);+ }// First-launch tier detection for CLI usersif settings.device_tier.is_none() {@@ -587,7 +726,7 @@ impl RecordArgs {eprintln!("detected hardware tier: {:?}", tier);// Only apply capture defaults (video_quality, power_mode) for truly fresh installs.// Existing config without tier = upgrade — just set the tier for DB/channel tuning.- let is_fresh = !config_path.exists();+ let is_fresh = !config_path.exists() && !loaded_from_store;if is_fresh {screenpipe_config::apply_tier_defaults(&mut settings, tier);@@ -655,8 +794,187 @@ impl RecordArgs {config.encrypt_secrets = self.encrypt_secrets;- config+ if !loaded_from_store || sources.has_recording_override() {+ persist_recording_settings_to_store(+ &config.data_dir,+ &settings,+ sources.encrypt_secrets && cli_encryption_ready,+ )?;+ }++ Ok(config)+ }++ fn apply_explicit_overrides(+ &self,+ settings: &mut screenpipe_config::RecordingSettings,+ sources: &RecordArgSources,+ ) {+ if sources.audio_chunk_duration {+ settings.audio_chunk_duration = self.audio_chunk_duration as i32;+ }+ if sources.port {+ settings.port = self.port;+ }+ if sources.disable_audio {+ settings.disable_audio = self.disable_audio;+ }+ if sources.audio_device {+ settings.audio_devices = self.audio_device.clone();+ settings.use_system_default_audio = false;+ }+ if sources.use_system_default_audio {+ settings.use_system_default_audio = self.use_system_default_audio;+ }+ if sources.experimental_coreaudio_system_audio {+ settings.experimental_coreaudio_system_audio = self.experimental_coreaudio_system_audio;+ }+ if sources.audio_transcription_engine {+ settings.audio_transcription_engine =+ cli_engine_to_str(&self.audio_transcription_engine).to_string();+ }+ if sources.monitor_id {+ settings.monitor_ids = self.monitor_id.iter().map(|id| id.to_string()).collect();+ settings.use_all_monitors = false;+ } else if sources.use_all_monitors {+ settings.use_all_monitors = self.use_all_monitors;+ if self.use_all_monitors {+ settings.monitor_ids.clear();+ }+ }+ if sources.language {+ settings.languages = self+ .language+ .iter()+ .map(|l| l.as_lang_code().to_string())+ .collect();+ }+ if sources.use_pii_removal {+ settings.use_pii_removal = self.use_pii_removal;+ }+ if sources.async_pii_redaction {+ settings.async_pii_redaction = self.async_pii_redaction;+ }+ if sources.async_image_pii_redaction {+ settings.async_image_pii_redaction = self.async_image_pii_redaction;+ }+ if sources.pii_backend {+ settings.pii_backend = self.pii_backend.clone();+ }+ if sources.filter_music {+ settings.filter_music = self.filter_music;+ }+ if sources.disable_vision {+ settings.disable_vision = self.disable_vision;+ }+ if sources.ignored_windows {+ settings.ignored_windows = self.ignored_windows.clone();+ }+ if sources.included_windows {+ settings.included_windows = self.included_windows.clone();+ }+ if sources.ignored_urls {+ settings.ignored_urls = self.ignored_urls.clone();+ }+ if sources.deepgram_api_key {+ settings.deepgram_api_key = self.deepgram_api_key.clone().unwrap_or_default();+ }+ if sources.transcription_mode {+ settings.transcription_mode = match self.transcription_mode {+ CliTranscriptionMode::Realtime => "realtime".to_string(),+ CliTranscriptionMode::Batch => "batch".to_string(),+ };+ }+ if sources.disable_telemetry {+ settings.analytics_enabled = !self.disable_telemetry;+ }+ if sources.video_quality {+ settings.video_quality = self.video_quality.clone();+ }+ if sources.pause_on_drm_content {+ settings.pause_on_drm_content = self.pause_on_drm_content;+ }+ if sources.disable_clipboard_capture {+ settings.disable_clipboard_capture = self.disable_clipboard_capture;+ }+ if sources.api_auth {+ settings.api_auth = self.api_auth;+ }+ if sources.listen_on_lan {+ settings.listen_on_lan = self.listen_on_lan;+ }+ if sources.disable_snapshot_compaction {+ settings.disable_snapshot_compaction = self.disable_snapshot_compaction;+ }+ if sources.disable_meeting_detector {+ settings.disable_meeting_detector = self.disable_meeting_detector;+ }+ }+}++fn load_recording_settings_from_store(+ data_dir: &Path,+) -> anyhow::Result<Option<screenpipe_config::RecordingSettings>> {+ let path = store_file::store_path_for(data_dir);+ if !path.exists() {+ return Ok(None);+ }++ let store = store_file::read_store_for(data_dir).map_err(|e| {+ e.context(format!(+ "reading shared app settings from {}",+ path.display()+ ))+ })?;+ let Some(settings_value) = store.get("settings") else {+ return Ok(None);+ };+ if settings_value.is_null() {+ return Ok(None);}++ let settings = serde_json::from_value(settings_value.clone())+ .map_err(|e| anyhow::anyhow!("parsing recording settings from {}: {e}", path.display()))?;+ Ok(Some(settings))+}++fn persist_recording_settings_to_store(+ data_dir: &Path,+ settings: &screenpipe_config::RecordingSettings,+ enable_encryption: bool,+) -> anyhow::Result<()> {+ let mut store = store_file::read_store_for(data_dir)?;+ if !store.is_object() {+ store = serde_json::json!({});+ }++ let store_obj = store.as_object_mut().unwrap();+ let settings_entry = store_obj+ .entry("settings")+ .or_insert_with(|| serde_json::json!({}));+ if !settings_entry.is_object() {+ *settings_entry = serde_json::json!({});+ }++ let settings_obj = settings_entry.as_object_mut().unwrap();+ let recording_value = serde_json::to_value(settings)?;+ let recording_obj = recording_value+ .as_object()+ .ok_or_else(|| anyhow::anyhow!("recording settings did not serialize to an object"))?;+ for (key, value) in recording_obj {+ settings_obj.insert(key.clone(), value.clone());+ }+ if enable_encryption {+ settings_obj.insert("encryptStore".to_string(), serde_json::json!(true));+ screenpipe_secrets::mark_encryption_enabled(data_dir)?;+ }++ store_file::write_store_for(data_dir, &store).map_err(|e| {+ e.context(format!(+ "writing shared app settings to {}",+ data_dir.display()+ ))+ })}// =============================================================================@@ -1087,8 +1405,14 @@ pub fn get_or_create_machine_id(override_id: Option<String>) -> String {#[cfg(test)]mod tests {use super::*;+ use clap::CommandFactory;use clap::Parser;+ fn record_sources<const N: usize>(args: [&str; N]) -> RecordArgSources {+ let matches = Cli::command().try_get_matches_from(args).unwrap();+ RecordArgSources::from_cli_matches(&matches)+ }+#[test]fn test_pause_on_drm_content_default_false() {let cli = Cli::try_parse_from(["screenpipe", "record"]).unwrap();@@ -1191,4 +1515,43 @@ mod tests {_ => panic!("expected Record command"),}}++ #[test]+ fn test_record_arg_sources_only_mark_explicit_cli_args() {+ let matches = Cli::command()+ .try_get_matches_from(["screenpipe", "record", "--port", "4040"])+ .unwrap();+ let sources = RecordArgSources::from_cli_matches(&matches);++ assert!(sources.port);+ assert!(!sources.disable_audio);+ assert!(!sources.use_pii_removal);+ assert!(!sources.audio_transcription_engine);+ }++ #[test]+ fn test_explicit_cli_overrides_preserve_app_settings_for_absent_defaults() {+ let cli =+ Cli::try_parse_from(["screenpipe", "record", "--port", "4040", "--disable-audio"])+ .unwrap();+ let sources = record_sources(["screenpipe", "record", "--port", "4040", "--disable-audio"]);+ let mut settings = screenpipe_config::RecordingSettings::default();+ settings.port = 3030;+ settings.disable_audio = false;+ settings.use_pii_removal = false;++ match cli.command {+ Command::Record(args) => {+ args.apply_explicit_overrides(&mut settings, &sources);+ }+ _ => panic!("expected Record command"),+ }++ assert_eq!(settings.port, 4040);+ assert!(settings.disable_audio);+ assert!(+ !settings.use_pii_removal,+ "absent CLI defaults must not overwrite app settings"+ );+ }}diff --git a/crates/screenpipe-engine/src/cli/store_file.rs b/crates/screenpipe-engine/src/cli/store_file.rsindex 14930aa56..4effb3ad1 100644--- a/crates/screenpipe-engine/src/cli/store_file.rs+++ b/crates/screenpipe-engine/src/cli/store_file.rs@@ -12,16 +12,30 @@ pub fn store_path() -> PathBuf {screenpipe_core::paths::default_screenpipe_data_dir().join("store.bin")}+pub fn store_path_for(data_dir: &Path) -> PathBuf {+ data_dir.join("store.bin")+}+pub fn read_store() -> Result<Value> {read_store_from(&store_path())}+pub fn read_store_for(data_dir: &Path) -> Result<Value> {+ read_store_from(&store_path_for(data_dir))+}+pub fn write_store(store: &Value) -> Result<()> {let path = store_path();let encrypt = should_encrypt_on_write(&path)?;write_store_to(&path, store, encrypt)}+pub fn write_store_for(data_dir: &Path, store: &Value) -> Result<()> {+ let path = store_path_for(data_dir);+ let encrypt = should_encrypt_on_write(&path)?;+ write_store_to(&path, store, encrypt)+}+fn read_store_from(path: &Path) -> Result<Value> {read_store_from_with_key(path, store_encryption_key)}diff --git a/crates/screenpipe-secrets/src/store.rs b/crates/screenpipe-secrets/src/store.rsindex b6ba0e746..2db500bc1 100644--- a/crates/screenpipe-secrets/src/store.rs+++ b/crates/screenpipe-secrets/src/store.rs@@ -190,6 +190,62 @@ impl SecretStore {Ok(count)}++ /// Decrypt all encrypted secrets back to base64/plaintext rows.+ /// Called before disabling keychain encryption so CLI/app transitions do+ /// not strand older encrypted OAuth tokens behind a removed opt-in flag.+ pub async fn decrypt_encrypted_secrets(&self) -> Result<usize> {+ let enc_key = self+ .key+ .as_ref()+ .ok_or_else(|| anyhow::anyhow!("cannot decrypt secrets without an encryption key"))?;++ let rows: Vec<(String, Vec<u8>, Vec<u8>)> =+ sqlx::query_as("SELECT key, value, nonce FROM secrets")+ .fetch_all(&self.pool)+ .await+ .context("failed to fetch secrets for decryption")?;++ let mut count = 0;+ for (secret_key, stored_value, nonce) in rows {+ if nonce.iter().all(|&b| b == 0) {+ continue; // already plaintext+ }++ let nonce_arr: [u8; 12] = nonce+ .try_into()+ .map_err(|_| anyhow::anyhow!("invalid nonce length"))?;+ let plaintext = crypto::decrypt(&stored_value, &nonce_arr, enc_key)+ .with_context(|| format!("failed to decrypt secret '{}'", secret_key))?;+ let encoded = BASE64.encode(&plaintext).into_bytes();+ let zero_nonce = vec![0u8; 12];++ sqlx::query(+ "UPDATE secrets SET value = ?, nonce = ?, updated_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now') WHERE key = ?",+ )+ .bind(&encoded)+ .bind(&zero_nonce)+ .bind(&secret_key)+ .execute(&self.pool)+ .await+ .context("failed to update secret during decryption")?;++ count += 1;+ }++ Ok(count)+ }++ /// Count rows that still require the keychain key to read.+ pub async fn encrypted_secret_count(&self) -> Result<usize> {+ let row: (i64,) = sqlx::query_as(+ "SELECT COUNT(*) FROM secrets WHERE hex(nonce) != '000000000000000000000000'",+ )+ .fetch_one(&self.pool)+ .await+ .context("failed to count encrypted secrets")?;+ Ok(row.0.max(0) as usize)+ }}#[cfg(test)]@@ -363,4 +419,34 @@ mod tests {let count2 = enc_store.reencrypt_unencrypted_secrets(&key).await.unwrap();assert_eq!(count2, 0);}++ #[tokio::test]+ async fn test_decrypt_encrypted_secrets() {+ let pool = SqlitePool::connect(":memory:").await.unwrap();++ let key = [11u8; 32];+ let enc_store = SecretStore::new(pool.clone(), Some(key)).await.unwrap();+ enc_store.set("a", b"alpha").await.unwrap();+ enc_store.set("b", b"bravo").await.unwrap();++ assert_eq!(enc_store.encrypted_secret_count().await.unwrap(), 2);++ let count = enc_store.decrypt_encrypted_secrets().await.unwrap();+ assert_eq!(count, 2);+ assert_eq!(enc_store.encrypted_secret_count().await.unwrap(), 0);++ let plain_store = SecretStore::new(pool.clone(), None).await.unwrap();+ assert_eq!(plain_store.get("a").await.unwrap().unwrap(), b"alpha");+ assert_eq!(plain_store.get("b").await.unwrap().unwrap(), b"bravo");++ let count2 = enc_store.decrypt_encrypted_secrets().await.unwrap();+ assert_eq!(count2, 0);+ }++ #[tokio::test]+ async fn test_decrypt_encrypted_secrets_requires_key() {+ let store = make_store(None).await;+ let result = store.decrypt_encrypted_secrets().await;+ assert!(result.is_err());+ }}