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(app): skip redundant pipe reloads on token saves (#5412)
Louis Beaumont1cc8813cadad
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs b/apps/screenpipe-app-tauri/src-tauri/src/commands.rsindex d86cb4b70..511dbc429 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs@@ -639,11 +639,12 @@ pub async fn set_cloud_token(if let Some((pipe_manager, enforce_free_plan_retention)) = server_handles {enforce_free_plan_retention.store(is_free_plan, std::sync::atomic::Ordering::SeqCst);let mut pipe_manager = pipe_manager.lock().await;- pipe_manager.set_max_non_template_pipes(restrict_paid_features.then_some(2));- pipe_manager- .load_pipes()- .await- .map_err(|e| format!("failed to reload pipes after plan change: {e}"))?;+ if pipe_manager.set_max_non_template_pipes(restrict_paid_features.then_some(2)) {+ pipe_manager+ .load_pipes()+ .await+ .map_err(|e| format!("failed to reload pipes after plan change: {e}"))?;+ }}// #3943: persist to the encrypted secret store (authoritative at-rest copy)diff --git a/crates/screenpipe-core/src/pipes/mod.rs b/crates/screenpipe-core/src/pipes/mod.rsindex f9900fe89..ea1ddffef 100644--- a/crates/screenpipe-core/src/pipes/mod.rs+++ b/crates/screenpipe-core/src/pipes/mod.rs@@ -2192,8 +2192,14 @@ impl PipeManager {////// Setting it never deletes pipe files. Over-limit pipes are kept on disk/// but omitted from the runtime until the limit is raised or a slot opens.- pub fn set_max_non_template_pipes(&mut self, limit: Option<usize>) {+ /// Returns whether the effective limit changed, so live policy refreshes+ /// can avoid rebuilding the full pipe catalog when nothing changed.+ pub fn set_max_non_template_pipes(&mut self, limit: Option<usize>) -> bool {+ if self.max_non_template_pipes == limit {+ return false;+ }self.max_non_template_pipes = limit;+ true}/// Set extra context that gets appended to every pipe prompt.@@ -6988,6 +6994,16 @@ mod tests {path}+ #[test]+ fn unchanged_pipe_limit_does_not_require_catalog_reload() {+ let mut manager = test_pipe_manager();++ assert!(manager.set_max_non_template_pipes(Some(2)));+ assert!(!manager.set_max_non_template_pipes(Some(2)));+ assert!(manager.set_max_non_template_pipes(None));+ assert!(!manager.set_max_non_template_pipes(None));+ }+#[tokio::test]async fn install_limit_counts_user_templates_but_exempts_bundled_builtins() {let installed = tempfile::tempdir().unwrap();