From 0ae070533112965290f364e45bae643e3d280e8a Mon Sep 17 00:00:00 2001 From: Tristan Michael Date: Sun, 5 Apr 2026 16:35:22 -0700 Subject: [PATCH] Add per-workspace sync interval and fix download timestamp recording MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a configurable per-workspace sync interval (sync_interval_secs) with Tauri command set_sync_interval, UI dropdown in Settings, and store support to restart auto-sync when changed. Remove the redundant main-panel sync status chip and surface upload/download counts in the drawer footer and Tasks screen. Fix the sync logic to record the remote file's last_modified timestamp when downloading (instead of local mtime) so subsequent diffs don’t falsely trigger downloads. These changes were needed to allow users to control auto-sync frequency per workspace, simplify the UI by moving sync counts to the drawer footer, and correct a bug where downloads were always considered new because the local file mtime was used instead of the authoritative remote timestamp. --- apps/tauri/src-tauri/src/lib.rs | 14 ++++++++++ .../src/lib/screens/SettingsScreen.svelte | 17 ++++++++++++ apps/tauri/src/lib/screens/TasksScreen.svelte | 11 +------- apps/tauri/src/lib/stores/app.svelte.ts | 27 +++++++++++++++++-- apps/tauri/src/lib/types.ts | 1 + crates/onyx-core/src/config.rs | 4 ++- crates/onyx-core/src/sync.rs | 12 +++++---- 7 files changed, 68 insertions(+), 18 deletions(-) diff --git a/apps/tauri/src-tauri/src/lib.rs b/apps/tauri/src-tauri/src/lib.rs index 77204d1..53f5c8e 100644 --- a/apps/tauri/src-tauri/src/lib.rs +++ b/apps/tauri/src-tauri/src/lib.rs @@ -511,6 +511,19 @@ fn set_workspace_theme( s.config.save_to_file(&s.config_path.clone()).map_err(|e| e.to_string()) } +#[tauri::command] +fn set_sync_interval( + workspace_id: String, + interval_secs: Option, + state: State<'_, Mutex>, +) -> Result<(), String> { + let mut s = lock_state(&state)?; + if let Some(ws) = s.config.workspaces.get_mut(&workspace_id) { + ws.sync_interval_secs = interval_secs; + } + s.config.save_to_file(&s.config_path.clone()).map_err(|e| e.to_string()) +} + /// A remote folder entry returned to the frontend. #[derive(Debug, Serialize, Deserialize)] struct RemoteFolderEntry { @@ -862,6 +875,7 @@ pub fn run() { get_group_by_due_date, set_webdav_config, set_workspace_theme, + set_sync_interval, add_webdav_workspace, list_remote_folder, inspect_remote_workspace, diff --git a/apps/tauri/src/lib/screens/SettingsScreen.svelte b/apps/tauri/src/lib/screens/SettingsScreen.svelte index 32b7c98..17f4958 100644 --- a/apps/tauri/src/lib/screens/SettingsScreen.svelte +++ b/apps/tauri/src/lib/screens/SettingsScreen.svelte @@ -202,6 +202,23 @@ +
+ + +
{/if} diff --git a/apps/tauri/src/lib/screens/TasksScreen.svelte b/apps/tauri/src/lib/screens/TasksScreen.svelte index d1aef7f..277ce43 100644 --- a/apps/tauri/src/lib/screens/TasksScreen.svelte +++ b/apps/tauri/src/lib/screens/TasksScreen.svelte @@ -335,7 +335,7 @@ class="inline-block h-2 w-2 rounded-full {app.syncing ? 'animate-pulse bg-primary' : app.syncStatus === 'synced' || app.syncStatus === 'idle' ? 'bg-green-500' : app.syncStatus === 'error' ? 'bg-red-500' : 'bg-gray-400'}" > - {app.syncing ? "Syncing..." : app.syncStatus === "synced" || app.syncStatus === "idle" ? "Synced" : app.syncStatus === "error" ? "Sync error" : "Offline"} + {app.syncing ? "Syncing..." : app.syncStatus === "synced" || app.syncStatus === "idle" ? "Synced" : app.syncStatus === "error" ? "Sync error" : "Offline"}{#if !app.syncing && app.lastSyncResult}  ↑{app.lastSyncResult.uploaded} ↓{app.lastSyncResult.downloaded}{/if}