Skip to main content

Module fs_watch

Module fs_watch 

Source
Expand description

Lightweight file watching for live reload.

Port of the upstream packages/coding-agent/src/utils/fs-watch.ts. uses Node’s fs.watch with a retry-on-error wrapper to (a) keep the git footer’s branch/status fresh and (b) hot-reload the active theme file.

rpi watches by polling modification times. That avoids a native watcher dependency and behaves predictably on every platform (network drives, WSL mounts, editors that replace files by rename). The retry delay matches native FS_WATCH_RETRY_DELAY_MS.

Structs§

WatchHandle
A running watch. Dropping it does not stop the watch; call WatchHandle::close to stop it deterministically (native closeWatcher).

Constants§

DEFAULT_POLL_INTERVAL_MS
Default poll interval. Short enough to feel immediate, long enough that a few watched files cost nothing on the main thread.
FS_WATCH_RETRY_DELAY_MS
Native FS_WATCH_RETRY_DELAY_MS: how long to wait after a watch error before retrying.

Functions§

watch_path
Convenience for a single path.
watch_paths
Watch paths for mtime changes, invoking on_change whenever any watched path changes (content or existence). Missing paths are tracked too: creating or deleting a watched path fires on_change.