From df66e7bc98507effd78c3b6ec742ab87287836c5 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 17 Apr 2026 16:19:03 +0000 Subject: [PATCH] fix(tauri): add_workspace must initialise the target folder The frontend currently calls init_workspace before add_workspace, but the Tauri command itself is trivially breakable by any caller that skips the pre-step or a future frontend refactor: add_workspace would save the workspace entry pointing at a non-existent directory, and every subsequent command would then fail with 'Path does not exist' via TaskRepository::new. Call TaskRepository::init inside the command so it is self-contained and idempotent. --- apps/tauri/src-tauri/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/tauri/src-tauri/src/lib.rs b/apps/tauri/src-tauri/src/lib.rs index 6db3de8..875a3e2 100644 --- a/apps/tauri/src-tauri/src/lib.rs +++ b/apps/tauri/src-tauri/src/lib.rs @@ -179,6 +179,13 @@ fn add_workspace( state: State<'_, Mutex>, ) -> Result<(), String> { validate_workspace_path(&path)?; + // Ensure the path exists and is a valid workspace before persisting the + // config. Without this, calling add_workspace directly on a missing + // directory would save the workspace but every subsequent ensure_repo + // call would fail with "Path does not exist". + TaskRepository::init(PathBuf::from(&path)) + .map(|_| ()) + .map_err(|e| e.to_string())?; let mut s = lock_state(&state)?; let ws = WorkspaceConfig::new(name, PathBuf::from(&path)); let id = s.config.add_workspace(ws);