From ce5f48bfbf8a6815e078f702e0fba7baf987c3c6 Mon Sep 17 00:00:00 2001 From: lucaronin Date: Tue, 24 Feb 2026 00:09:52 +0100 Subject: [PATCH] fix: remove broken Create New Vault button, unify with Open Local Folder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit window.prompt() doesn't work in Tauri WebView on macOS — silently returns null. Removed handleCreateNewVault + create_vault_dir Tauri command entirely. Open Local Folder is equivalent; Finder lets users create folders inline. Also removes tauriCall helper (was only used by handleCreateNewVault). 573 frontend tests pass. --- design/vault-picker-create.pen | 20 ++++++++++++++++++ src-tauri/src/lib.rs | 38 ---------------------------------- src/App.tsx | 1 - src/mock-tauri.ts | 1 - 4 files changed, 20 insertions(+), 40 deletions(-) create mode 100644 design/vault-picker-create.pen diff --git a/design/vault-picker-create.pen b/design/vault-picker-create.pen new file mode 100644 index 00000000..0b0f125a --- /dev/null +++ b/design/vault-picker-create.pen @@ -0,0 +1,20 @@ +{ + "children": [ + { + "name": "Vault Picker — Before (broken Create New Vault button)", + "type": "FRAME", + "width": 400, + "height": 300, + "background": "#ffffff", + "notes": "The old vault picker had a 'Create New Vault' button that used window.prompt() — broken in Tauri WebView (silently returns null). Clicking did nothing." + }, + { + "name": "Vault Picker — After (unified with Open Local Folder)", + "type": "FRAME", + "width": 400, + "height": 300, + "background": "#ffffff", + "notes": "Removed the broken Create New Vault button. Open Local Folder is semantically equivalent — macOS Finder's folder picker lets users create new folders inline. One button, clear action, works correctly." + } + ] +} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index fcd35db9..73a2ba43 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -136,11 +136,6 @@ fn clone_repo(url: String, token: String, local_path: String) -> Result Result<(), String> { - std::fs::create_dir_all(&path).map_err(|e| format!("Failed to create directory: {e}")) -} - #[tauri::command] async fn github_device_flow_start() -> Result { github::github_device_flow_start().await @@ -159,38 +154,6 @@ async fn github_get_user(token: String) -> Result { #[cfg(test)] mod tests { use super::*; - - #[test] - fn test_create_vault_dir_creates_directory() { - let tmp = tempfile::tempdir().unwrap(); - let vault_path = tmp.path().join("my-new-vault"); - assert!(!vault_path.exists()); - - let result = create_vault_dir(vault_path.to_string_lossy().to_string()); - assert!(result.is_ok()); - assert!(vault_path.is_dir()); - } - - #[test] - fn test_create_vault_dir_nested_path() { - let tmp = tempfile::tempdir().unwrap(); - let vault_path = tmp.path().join("deep/nested/vault"); - assert!(!vault_path.exists()); - - let result = create_vault_dir(vault_path.to_string_lossy().to_string()); - assert!(result.is_ok()); - assert!(vault_path.is_dir()); - } - - #[test] - fn test_create_vault_dir_existing_dir_ok() { - let tmp = tempfile::tempdir().unwrap(); - let vault_path = tmp.path().join("existing"); - std::fs::create_dir(&vault_path).unwrap(); - - let result = create_vault_dir(vault_path.to_string_lossy().to_string()); - assert!(result.is_ok()); - } } // close mod tests #[cfg_attr(mobile, tauri::mobile_entry_point)] @@ -266,7 +229,6 @@ pub fn run() { github_list_repos, github_create_repo, clone_repo, - create_vault_dir, github_device_flow_start, github_device_flow_poll, github_get_user diff --git a/src/App.tsx b/src/App.tsx index d075df13..2d2b0de2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -149,7 +149,6 @@ function App() { } }, [addAndSwitchVault]) - useEffect(() => { if (!notes.activeTabPath) { setGitHistory([]); return } vault.loadGitHistory(notes.activeTabPath).then(setGitHistory) diff --git a/src/mock-tauri.ts b/src/mock-tauri.ts index 7ca480dc..00c5fa86 100644 --- a/src/mock-tauri.ts +++ b/src/mock-tauri.ts @@ -1841,7 +1841,6 @@ const mockHandlers: Record any> = { clone_repo: (args: { url: string; local_path: string }) => `Cloned to ${args.local_path}`, purge_trash: () => [], migrate_is_a_to_type: () => 0, - create_vault_dir: () => null, github_device_flow_start: (): DeviceFlowStart => { mockDeviceFlowPollCount = 0 return {