From a709df609fc7b431daba4a1199057201df5ab685 Mon Sep 17 00:00:00 2001 From: Tristan Michael Date: Sun, 5 Apr 2026 14:49:55 -0700 Subject: [PATCH] Prevent workspace name collisions Adding explicit duplicate-name checks to the Tauri commands that create workspaces prevents a new workspace from silently overwriting an existing one. The change returns an error if a workspace with the given name already exists. Also set sane defaults in the setup UI: default workspace name to "Onyx" for both local and WebDAV flows, default the local folder to the user's Documents directory via documentDir(), and ensure the create flow resets the name to the "Onyx" default when starting creation. --- apps/tauri/src-tauri/src/lib.rs | 6 ++++++ apps/tauri/src/lib/screens/SetupScreen.svelte | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/tauri/src-tauri/src/lib.rs b/apps/tauri/src-tauri/src/lib.rs index 8a3ad72..b8b059b 100644 --- a/apps/tauri/src-tauri/src/lib.rs +++ b/apps/tauri/src-tauri/src/lib.rs @@ -120,6 +120,9 @@ fn add_workspace( state: State<'_, Mutex>, ) -> Result<(), String> { let mut s = lock_state(&state)?; + if s.config.workspaces.contains_key(&name) { + return Err(format!("A workspace named '{}' already exists", name)); + } let ws = WorkspaceConfig::new(PathBuf::from(&path)); s.config.add_workspace(name.clone(), ws); s.config @@ -569,6 +572,9 @@ fn add_webdav_workspace( state: State<'_, Mutex>, ) -> Result<(), String> { let mut s = lock_state(&state)?; + if s.config.workspaces.contains_key(&name) { + return Err(format!("A workspace named '{}' already exists", name)); + } let managed_dir = s.app_data_dir.join("workspaces").join(&name); std::fs::create_dir_all(&managed_dir).map_err(|e| e.to_string())?; TaskRepository::init(managed_dir.clone()).map(|_| ()).map_err(|e| e.to_string())?; diff --git a/apps/tauri/src/lib/screens/SetupScreen.svelte b/apps/tauri/src/lib/screens/SetupScreen.svelte index 9ab3658..6976740 100644 --- a/apps/tauri/src/lib/screens/SetupScreen.svelte +++ b/apps/tauri/src/lib/screens/SetupScreen.svelte @@ -1,5 +1,6 @@