You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR refactors the file system commands to prevent blocking the Tauri IPC threads, aligning with Tauri's best practices for I/O operations. It also introduces seamless loading states on the frontend to improve the UX during large file operations, without cluttering the global store.
Changes Made
Backend (src-tauri/src/commands.rs): Converted synchronous I/O commands (delete_entry, rename_entry, move_entry, create_note, etc.) to async fn. Wrapped the underlying filesystem calls using tauri::async_runtime::spawn_blocking to offload them to a background thread pool, preventing any potential UI or IPC freezes.
Frontend (src/stores/vault.ts): Wrapped the corresponding ipc calls in promises and implemented toast.promise from Sonner. This natively provides loading, success, and error toast notifications immediately when interacting with the vault (e.g. moving to trash, renaming) without the need to introduce additional loading state variables into the UI components.
Motivation
To ensure the application remains highly responsive and doesn't limit performance on modern hardware when handling large vaults or heavy OS-level operations.
Reviewed at 86b4d4d. Moving blocking I/O off the main thread makes sense, but these three issues need addressing before merge:
Build failure: The new @tiptap/core and @tiptap/pm dependencies resolve to 3.30.1 while the existing extensions remain on 3.23.6. A clean bun install --frozen-lockfile followed by bunx tsc --noEmit fails with incompatible Tiptap/ProseMirror types in NoteEditor.tsx and noteFind.ts. The parent commit passes. Please keep the versions aligned and regenerate the lockfile.
Concurrent operations can overwrite notes:spawn_blocking allows note creation to run concurrently, but available_path checks for an unused filename before fs::write without reserving it. Two requests can select the same path and overwrite content while both report success. A temporary test with 32 concurrent same-title creations produced only 16 distinct paths. Please serialize conflicting mutations or reserve filenames atomically, and add regression coverage.
Stale active view after rename/move/delete: These actions now capture view before awaiting IPC. With delayed IPC, switching from A to B during A's rename switches the user back when it completes. Deleting inactive A and opening it while deletion is pending leaves the active view pointing at a removed tab. Please read the current view immediately before applying the final state update.
Validation: all 59 existing Rust tests pass; the added concurrency reproduction fails. The view issues were reproduced with delayed IPC mocks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR refactors the file system commands to prevent blocking the Tauri IPC threads, aligning with Tauri's best practices for I/O operations. It also introduces seamless loading states on the frontend to improve the UX during large file operations, without cluttering the global store.
Changes Made
src-tauri/src/commands.rs): Converted synchronous I/O commands (delete_entry,rename_entry,move_entry,create_note, etc.) toasync fn. Wrapped the underlying filesystem calls usingtauri::async_runtime::spawn_blockingto offload them to a background thread pool, preventing any potential UI or IPC freezes.src/stores/vault.ts): Wrapped the correspondingipccalls in promises and implementedtoast.promisefrom Sonner. This natively providesloading,success, anderrortoast notifications immediately when interacting with the vault (e.g. moving to trash, renaming) without the need to introduce additional loading state variables into the UI components.Motivation
To ensure the application remains highly responsive and doesn't limit performance on modern hardware when handling large vaults or heavy OS-level operations.