fix(watch): skip ignored directories when watching#142
fix(watch): skip ignored directories when watching#142andrewgazelka wants to merge 1 commit intomixedbread-ai:mainfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| watchDirectory(path.join(dirPath, entry.name)); | ||
| } | ||
| } catch (error) { | ||
| console.warn(`Warning: failed to read directory ${dirPath}:`, error); |
There was a problem hiding this comment.
New directories' existing files are never uploaded
Medium Severity
When handleFileEvent discovers a new directory, it calls watchDirectory which sets up watchers and recurses into subdirectories — but only for directory entries. The readdirSync loop filters with !entry.isDirectory() and skips all files. This means when a directory tree appears with files already inside (e.g., git checkout, git stash pop, mv, or archive extraction), those existing files are silently never uploaded. Only files created after the watcher is installed are detected. At initial startup this is fine because initialSync handles existing files, but for directories discovered mid-watch it's a gap.


Summary
fs.watchwith per-directory non-recursive watchers.git/, hidden paths, and ignore-pattern matchesTesting
pnpm typecheckpnpm buildpnpm exec biome lint src/commands/watch.tspnpm test(fails on existing unrelated test:Config maxFileCount via YAML)Notes
pnpm lintcurrently fails in this repo because the script runsbiome lint --check ., and this installed Biome version rejects--checkforlint.src/commands/watch.ts; the failing dry-run config test exits before live watcher setup.Note
Medium Risk
Moderate risk because it rewrites the file watching mechanism that drives incremental upload/delete behavior, and platform-specific
fs.watchedge cases could cause missed events or orphaned watchers.Overview
Replaces the single recursive
fs.watchwatcher with per-directory, non-recursive watchers that are created only for non-ignored paths, preventing inotify exhaustion on large repos (e.g., skipping.git/,node_modules/, and ignore-pattern matches).Adds watcher lifecycle management: dynamically starts watching newly discovered directories, and closes watchers for deleted directories/subtrees while keeping existing upload-on-change and delete-on-missing behavior intact (now with safer stat/error handling and warning logs).
Written by Cursor Bugbot for commit 9ca0798. This will update automatically on new commits. Configure here.