Skip to main content

Module editor_file_watcher

Module editor_file_watcher 

Source
Expand description

Filesystem watcher for files open in editor/preview panes — detects external changes (an agent’s Edit/Write tool, another process, a second AgentMux window) and pushes a per-block “this file changed on disk” wake signal so panes can refresh instead of silently going stale.

Migrated onto the shared fs_watch::FsWatchPool (SPEC_SHARED_FS_WATCHER_FRAMEWORK_2026_08_07.md) — this module keeps only its own domain-specific bookkeeping (which block ids have which paths open, per-path debounce, and the EVENT_EDITOR_FILE_CHANGED publish shape). The actual notify construction, OS-level watch/unwatch, and recovery-on-failure now live in the pool, shared with every other watcher that migrates onto it (config_watcher_fs.rs already has; media_file_watcher.rs, below in the same PR, is the directory-mode sibling migrating alongside this one).

Spec: docs/specs/SPEC_EDITOR_LIVE_FILE_RELOAD_2026_07_18.md

Structs§

EditorFileWatcher
Inner 🔒

Constants§

DEBOUNCE 🔒
EVENT_EDITOR_FILE_CHANGED
MPS event fired when a file open in at least one editor tab changes on disk. Scoped per-block (block:<id>) via MuxEvent::scopes, matching EVENT_CONTROLLER_STATUS/EVENT_BLOCK_ACTIVITY’s existing pattern — never a global broadcast, so panes on unrelated files aren’t notified. Payload is deliberately just the path (a wake signal, not content); the frontend re-fetches via the existing readeditorfile RPC.

Functions§

publish_editor_file_changed 🔒
Publish EVENT_EDITOR_FILE_CHANGED, scoped to every block that has a tab open on path. Mirrors publish_block_activity’s per-block scoping (crates/srv/src/backend/mps.rs) — not a global broadcast.

Type Aliases§

DebounceGens 🔒
Per-path debounce generation counters. A new fs event for a path bumps its counter; the delayed publish task only fires if its captured generation is still current when its sleep completes, so a burst of writes (e.g. an editor’s multi-syscall save) collapses into one event.