Expand description
Filesystem watcher for settings.json — detects saves and pushes updated config to all connected WebSocket clients in real time.
Migrated onto the shared fs_watch::FsWatchPool
(SPEC_SHARED_FS_WATCHER_FRAMEWORK_2026_08_07.md) — this module keeps only
its own domain-specific debounce/reload/broadcast logic; the actual
notify construction, refcounting, and recovery-on-failure now live in
the pool, shared with every other watcher that migrates onto it.
Functions§
- broadcast_
full_ config - Push the current
FullConfigTypesnapshot to every connected client, in the same wire shape the initialgetfullconfigRPC response uses. - is_
settings_ 🔒file_ event - Whether a raw fs_watch event refers to a
settings.jsonsave specifically — the pool’s broadcast stream carries events for every currently-watched path in the process, not just this module’s. Matches the pre-migration code’s filter exactly: filename must besettings.json(wasevent.paths.iter().any(|p| p.ends_with("settings.json"))) AND the event must be aCreate/Modify(wasEventKind::Modify(_) | EventKind::Create(_)). ARemovedevent (external delete, or an editor’s unlink+recreate save) is deliberately excluded —read_config_filetreats a missing file as success (defaults, no errors), so reacting toRemovewould reset the live config and broadcast it to every client. - load_
settings_ from_ disk - Load settings.json from disk into the ConfigState. Called once at startup so the backend has the user’s saved settings.
- merge_
settings_ into_ current - Merge new keys into the current in-memory SettingsType and return the result. Used by the setconfig handler to update in-memory state before the fs watcher fires.
- merge_
settings_ to_ disk - Merge a flat map of settings keys into
settings.jsonon disk. Existing keys not present innew_keysare preserved. The fs watcher will detect the write (~300ms) and broadcast the updated config. - reload_
and_ 🔒broadcast - resolve_
settings_ dir - Resolve the directory containing settings.json.
- set_
connection_ values - Change one connection’s settings (
settings.json→connections.<name>, SPEC_REMOTES_PANE_2026_10_05.md §4.3): anullvalue removes a key. Edits the rawconnectionsobject read from disk, so keys AgentMux doesn’t know survive, then writes, updates the live config and broadcasts it, assetconfigdoes. An edit that leaves the entry unreadable is refused before anything is written. Serialized, so two quick edits can’t drop each other’s. - spawn_
settings_ watcher - Subscribe to
settings.jsonvia the sharedFsWatchPooland broadcast config updates to all WebSocket clients on change.