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(obsidian): improvements to obsidian sync
Louis Beaumont48c61721e037
diff --git a/Cargo.toml b/Cargo.tomlindex 2cf9a98d0..6d082eba8 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -6,7 +6,7 @@ exclude = ["apps/screenpipe-app-tauri/src-tauri"]resolver = "2"[workspace.package]-version = "0.3.45"+version = "0.3.46"authors = ["louis030195 <[email protected]>"]description = ""repository = "https://github.com/screenpipe/screenpipe"diff --git a/apps/screenpipe-app-tauri/components/settings/obsidian-sync-card.tsx b/apps/screenpipe-app-tauri/components/settings/obsidian-sync-card.tsxindex 031ee7710..0bc8e9439 100644--- a/apps/screenpipe-app-tauri/components/settings/obsidian-sync-card.tsx+++ b/apps/screenpipe-app-tauri/components/settings/obsidian-sync-card.tsx@@ -230,20 +230,30 @@ export function ObsidianSyncCard() {return () => clearTimeout(timeoutId);}, [settings, settingsLoaded]);- // Only restart scheduler when interval changes (not on every settings change)- const prevIntervalRef = React.useRef(settings.syncIntervalMinutes);- const prevEnabledRef = React.useRef(settings.enabled);+ // Only restart scheduler when interval changes via user action (not on initial load)+ const prevIntervalRef = React.useRef<number | null>(null);+ const prevEnabledRef = React.useRef<boolean | null>(null);+ const isInitialLoadRef = React.useRef(true);useEffect(() => {if (!settingsLoaded) return;+ // Skip the first render after settings are loaded from localStorage+ // to avoid killing the auto-started scheduler from Rust+ if (isInitialLoadRef.current) {+ isInitialLoadRef.current = false;+ prevIntervalRef.current = settings.syncIntervalMinutes;+ prevEnabledRef.current = settings.enabled;+ return;+ }+const intervalChanged = prevIntervalRef.current !== settings.syncIntervalMinutes;const enabledChanged = prevEnabledRef.current !== settings.enabled;prevIntervalRef.current = settings.syncIntervalMinutes;prevEnabledRef.current = settings.enabled;- // Only restart if interval or enabled status changed+ // Only restart if interval or enabled status changed by user actionif ((intervalChanged || enabledChanged) && settings.enabled && settings.vaultPath && settings.syncIntervalMinutes > 0 && appSettings?.user?.token) {invoke("obsidian_start_scheduler", {settings,diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex c46168f16..1212bf66c 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.0.251"+version = "2.0.252"description = "24/7 memory for your desktop. 100% local."authors = ["you"]license = ""diff --git a/apps/screenpipe-app-tauri/src-tauri/src/obsidian_sync.rs b/apps/screenpipe-app-tauri/src-tauri/src/obsidian_sync.rsindex 249e1c0ba..3ea787556 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/obsidian_sync.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/obsidian_sync.rs@@ -446,11 +446,11 @@ pub async fn obsidian_start_scheduler(let interval_duration = tokio::time::Duration::from_secs(interval_mins as u64 * 60);+ // First sync: wait the full interval (user just started/restarted the scheduler)+ info!("Obsidian scheduler: waiting {}min for first sync...", interval_mins);+ tokio::time::sleep(interval_duration).await;+loop {- // Wait for the interval- info!("Obsidian scheduler: waiting {}min for next sync...", interval_mins);- tokio::time::sleep(interval_duration).await;-let now = chrono::Utc::now();info!("Obsidian scheduler: tick received at {:?}", now);@@ -459,6 +459,7 @@ pub async fn obsidian_start_scheduler(let status = status_arc.lock().await;if status.is_syncing {info!("Obsidian scheduler: skipping - already syncing");+ tokio::time::sleep(interval_duration).await;continue;}}@@ -483,6 +484,10 @@ pub async fn obsidian_start_scheduler(warn!("Scheduled obsidian sync failed: {}", e);}}++ // Wait for next interval+ info!("Obsidian scheduler: waiting {}min for next sync...", interval_mins);+ tokio::time::sleep(interval_duration).await;}});@@ -614,6 +619,15 @@ pub async fn auto_start_scheduler(app: AppHandle, state: &ObsidianSyncState) {warn!("Failed to save next_scheduled_run on auto-start: {}", e);}+ // Stop any existing scheduler before starting (prevents duplicate tasks)+ {+ let mut handle = state.scheduler_handle.lock().await;+ if let Some(h) = handle.take() {+ h.abort();+ info!("Stopped existing obsidian scheduler before auto-start");+ }+ }+info!("Auto-starting obsidian scheduler with {}min interval, initial delay: {:?}, next run at {}", interval_mins, initial_delay, next_run_time);let handle = tokio::spawn(async move {