Skip to content

sidebar: ignore Access events in config watcher - #218

Merged
raine merged 2 commits into
raine:mainfrom
alebiscotto:fix/sidebar-config-access-loop
Aug 4, 2026
Merged

sidebar: ignore Access events in config watcher#218
raine merged 2 commits into
raine:mainfrom
alebiscotto:fix/sidebar-config-access-loop

Conversation

@alebiscotto

Copy link
Copy Markdown
Contributor

Fixes #217

Problem

spawn_config_watcher filters fs events only by basename, not by event kind. On Linux, notify's inotify backend also delivers Access events (open/read/close-nowrite) — and a config reload reads the watched file itself. So every reload scheduled the next one after the 200 ms debounce: config_version bumped ~5×/s forever, re-rendering every sidebar client on each bump (visible flicker; 180k+ bump lines in my log over a day). Details and repro in #217.

Fix

Extract the filter into config_event_triggers_reload() and reject EventKind::Access(_). Mutations (create/modify/remove/rename) still trigger reloads, so atomic-rename editor saves keep working.

Testing

  • Two new unit tests: mutation kinds on config basenames trigger a reload; Access kinds and unrelated files don't.
  • cargo test (1397 passed), cargo fmt --check clean, cargo clippy introduces no new warnings.
  • Verified live on the affected machine (Linux, tmux 3.6): with the patched daemon, touch config.yaml produces exactly one config_version bump followed by silence; before the patch it bumped every ~203 ms indefinitely.

alebiscotto and others added 2 commits August 4, 2026 17:48
On Linux the notify backend also reports reads (open/access/close) of
watched files, and a config reload reads the very file being watched:
every reload scheduled the next one, bumping config_version and
re-rendering every sidebar client once per debounce interval (5/s),
forever. Filter out EventKind::Access so only mutations (create,
modify, remove, rename) trigger a reload.
The config watcher still allowed ignored access events to fill its bounded
channel and trigger reloads through overflow. The git status watcher also
subscribed to read events, so each status refresh could schedule another one
without producing a visible sidebar update.

Configure both mutation-driven watchers with notify's CORE event mask and
filter irrelevant config events before enqueueing them. Preserve rescan events
as reload signals because their path lists may be incomplete.

Cover the Linux access event shapes, atomic rename paths, rescan recovery, and
the shared watcher mask in regression tests.
@raine
raine force-pushed the fix/sidebar-config-access-loop branch from f11820b to b776fc0 Compare August 4, 2026 19:16
@raine
raine merged commit 658c767 into raine:main Aug 4, 2026
3 checks passed
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.

Sidebar daemon gets stuck in an infinite config-reload loop on Linux (Access events re-trigger the watcher)

2 participants