codegraph
codegraph copied to clipboard
fix(watcher): retain pending files on zero-result sync
Summary
- treat zero-result watcher syncs as no progress when pending files still exist
- preserve pending files instead of clearing them
- let the existing retry path reschedule sync automatically
- add a regression test covering the zero-result retry path
Problem
FileWatcher.flush() currently treats any resolved syncFn() result as a successful sync.
When CodeGraph.sync() cannot acquire the file lock, it can return a zero-result no-op instead of throwing. In that
case, the watcher may clear pendingFiles even though nothing was actually indexed.
This can incorrectly mark edited files as fresh until a later file event happens to trigger another sync.
Test plan
- run
__tests__/watcher.test.ts - verify pending files remain after a zero-result sync
- verify
onSyncCompleteis not called for the zero-result no-op - verify the watcher retries automatically and clears pending files only after a real successful sync
Closes #449