Skip to content

feat: live rendering of updates in the file explorer#231

Open
Neil-urk12 wants to merge 4 commits into
crynta:mainfrom
Neil-urk12:feat/live-filestructure-render
Open

feat: live rendering of updates in the file explorer#231
Neil-urk12 wants to merge 4 commits into
crynta:mainfrom
Neil-urk12:feat/live-filestructure-render

Conversation

@Neil-urk12
Copy link
Copy Markdown

@Neil-urk12 Neil-urk12 commented May 13, 2026

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:

  • watch the root plus expanded/loaded directories only
  • or unwatch collapsed directories
  • avoid recursive failures on unreadable folders
  • and avoid exhausting Linux inotify limits on large roots

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 --noEmit clean
  • Manual smoke-test of the affected feature
  • (If you touched src-tauri/) cargo check clean
  • (If UI) tested in pnpm tauri dev

Screenshots / 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.

1778703771169476799

… 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
@Neil-urk12 Neil-urk12 requested a review from crynta as a code owner May 13, 2026 20:35
@Neil-urk12
Copy link
Copy Markdown
Author

Also created tests locally but didn't commit them or vitest since we don't have testing infra yet. I can setup testing for the frontend in another PR if you want.

The tests are for the pure functions that have been extracted from the useFileTree hook. this also reduces bug risk

image image

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.

Render updates in file structure in real-time

1 participant