feat: live rendering of updates in the file explorer#231
Open
Neil-urk12 wants to merge 4 commits into
Open
Conversation
… in realtiem - using notify create, file explorer now auto-refreshes when files/directories change on disk (create, rename, and edit) - rust: fs_watch_start/stop/add/remove commands with event debouncing - useFileTree listens to fs://changed, manages per-directory watchers - normalize workspace CWD trailing slashes for watcher stability - watcher only trakcs loaded/root dirs to limit resouce usage
…tils - the three path utilities were unrelated to React state and was just makng the hook complex so extracting them reduces the hook by ~36 lines and makes the watcher refresh loop cleaner (will move the watcher lifecycle out after this too) - i also created test for pathUtils locally but won't commit it since we don't have testing in the frontend yet.
…dicated useFileTreeWatcher hook
- there are no behavioral chagnes or API surface breakage, I just did
the extracted the new watcher behavior into its own hook since it's
unrelated with the useFileTree hook
- it owns all the watcher lifecycle like listen("fs://changed"),
fs_watch_start/stop, 100ms path debouncing via refs, and cleanup on
umount or roto change
- changes in net.rs and secrets.rs were from cargo fmt
… (no behavior changes) - move inline set-toggling logic out of useFileTree's toggle callback into a pure function togglepathExpansion utility - fix react 18 batchin issue whre the old code mutated a let variable inside a setExpanded updater and read it outside, which is unrealible under automatic batching - replaced with a useRef synced via useEffect so isCollapsing is determined from the current expanded state before the updater runs
Author
1 task
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


What
Adds real-time Explorer updates when files or directories change under the active workspace root. Like creation/rename, and deletes.
Explorer now receives backend filesystem invalidation events, batches them, and refreshes affected loaded directories without requiring manual refrresh. Currently, the user has to manually click the refresh button just to see the changes in the project folder when there are new files, renames, or deletes.
Why
The file explorer state became stale when files changed outside explorer actions, such as via touch, rm, or yazi, and even editor saves or git checkout. THe user has to manually click the refresh button just to see the chagnes reflect in the file explorer.
closes #209
How
Implemented a custom Rust notify watcher instead of the Tauri FS plugin because explorer needs bounded, lazy watch lifecycle control like:
The wtcher events only invalidate paths. File listing remains owned by existing fs_read_dir while the Frontend watcher lifecycle is isoled in useFileTreeWatcher, and the useFileTree stays the same and focused on tree state and mutations.
Testing
pnpm exec tsc --noEmitcleansrc-tauri/)cargo checkcleanpnpm tauri devScreenshots / GIFs
No screenshots since it renders instantly now.
Notes for reviewer
Custom watcher is intentionally non-recursive. New changes inside a directory are observed after that directory is loaded/expanded. If it's not expanded or if the directory is closed then it's not watched.