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§
- Watch
Handle - A running watch. Dropping it does not stop the watch; call
WatchHandle::closeto stop it deterministically (nativecloseWatcher).
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
pathsfor mtime changes, invokingon_changewhenever any watched path changes (content or existence). Missing paths are tracked too: creating or deleting a watched path fireson_change.