Migrate file tree creation to Rust backend#6
Conversation
Migrates the recursive file tree building logic from the TypeScript frontend to the Rust backend to improve performance, especially for large directories. - Implements `build_file_tree` Tauri command in Rust. - Adds Desktop implementation using `std::fs` and `spawn_blocking`. - Adds Android implementation using `tauri-plugin-android-fs` and `urlencoding`. - Updates frontend `builder.ts` to invoke the Rust command. - Preserves existing filtering logic (markdown files only, ignore hidden dirs).
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
- Move sorting logic inside `spawn_blocking` to avoid blocking the main thread on large directories. - Fix compiler warnings (unused imports/variables). - Ensure correct recursion and sorting on both Desktop and Android. - Refactor argument names to avoid unused variable warnings across platforms.
Migrates file tree logic to Rust to improve performance and prevent UI freezes. - Implements `build_file_tree` and `sort_file_tree` Tauri commands in `src-tauri/src/lib.rs`. - Uses `spawn_blocking` to offload heavy operations from the main thread. - Ensures compatibility with Android FS plugin (fixing compilation issues) and Desktop `std::fs`. - Updates frontend to invoke Rust commands and safely handle auto-sorting in `$effect` without infinite loops. - Adds `urlencoding` dependency for Android path handling. - Cleans up deprecated JS logic.
…y and less flexibility so, calling rust sort function everytime for subsequent sorting seems to have incresed latency. also on rename or any file tree changes, the sorting was commented out.
Co-authored-by: Keshav-writes-code <95571677+Keshav-writes-code@users.noreply.github.com>
… not in the $effect block which slows down speed
…m stays selected after mutate the name and path of a node
CHanges
|
Acknowledged. I have implemented these changes. I have moved the file tree creation to Rust backend, implementing both Desktop and Android support with optimizations (parallelism on Android). I also ensured that sorting is handled in Rust initially but subsequent updates are handled synchronously in JS as requested. |
- Move file tree generation to Rust backend using `tauri-plugin-android-fs` for Android and `std::fs` for Desktop. - Optimize Android implementation by using `read_dir_with_options` to fetch minimal metadata and parallelizing recursion with `futures::future::join_all`. - Use `spawn_blocking` on Desktop to avoid blocking the main thread. - Perform initial tree sorting in Rust. - Keep subsequent UI sorting in JavaScript to ensure instant feedback and avoid round-trips for small updates (renames, etc.). - Fix Android compilation issues and unused variable warnings. - Add `urlencoding` and `futures` crate dependencies.
Moved the file tree creation logic entirely to the Rust backend as requested.
Changes:
urlencodingcrate dependency.build_file_treeinapps/app/src-tauri/src/lib.rs.apps/app/src/lib/file_tree/builder.tsto use the new command.PR created automatically by Jules for task 7043552137559722624 started by @Keshav-writes-code