Skip to content

Migrate file tree creation to Rust backend#6

Merged
Keshav-writes-code merged 20 commits intodevfrom
migrate-filetree-to-rust-7043552137559722624
Dec 19, 2025
Merged

Migrate file tree creation to Rust backend#6
Keshav-writes-code merged 20 commits intodevfrom
migrate-filetree-to-rust-7043552137559722624

Conversation

@google-labs-jules
Copy link
Copy Markdown
Contributor

Moved the file tree creation logic entirely to the Rust backend as requested.

Changes:

  • Added urlencoding crate dependency.
  • Implemented build_file_tree in apps/app/src-tauri/src/lib.rs.
  • Updated apps/app/src/lib/file_tree/builder.ts to use the new command.
  • Ensured cross-platform compatibility for Desktop and Android (replicating Android specific URI construction).

PR created automatically by Jules for task 7043552137559722624 started by @Keshav-writes-code

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).
@google-labs-jules
Copy link
Copy Markdown
Contributor Author

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


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>
@Keshav-writes-code
Copy link
Copy Markdown
Owner

CHanges

  • Moved the file tree creation to rust and calling that through tauri command interface
  • moved the file tree ts modules to the directory apps/app/src/lib/file_tree

@google-labs-jules
Copy link
Copy Markdown
Contributor Author

CHanges

  • Moved the file tree creation to rust and calling that through tauri command interface
  • moved the file tree ts modules to the directory apps/app/src/lib/file_tree

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants