fix(editor): watch hidden files and re-sync on reopen#392
Merged
Conversation
The shared chokidar ignore matcher dropped every dot-prefixed path, so a dotfile open in an editor (.gitignore, .env) never got external-change events and never live-reloaded. Prune excluded entries and hidden directories only; let hidden files through using chokidar v4's stats arg. One matcher, used by both the local and daemon watchers. Also reconcile the warm Monaco model on reopen: track each model's disk baseline so a clean stale buffer catches up while a buffer with unsaved edits raises a conflict instead of being clobbered. Adds matcher unit + live-chokidar tests, resyncFromDisk tests, and modelCache baseline tests.
chokidar hands the predicate POSIX-style paths even on Windows while the root is OS-native, so startsWith never matched and the matcher ignored nothing (whole tree watched). Normalize both to forward slashes. Adds a Windows-path unit case and makes the live chokidar test wait on events.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A file open in an editor that was hidden (e.g.
.gitignore,.env) never picked up external changes and never live-reloaded. Reopening the panel didn't help either: it showed the stale cached buffer.Root cause:
createFsIgnoreMatcher(the single chokidar ignore predicate shared by the local watcher and the daemon watcher) dropped every dot-prefixed path, so chokidar never emitted events for hidden files. The editor already subscribes to the root watcher, so it just never got the events.Fix
node_modules,.git,.catestay pruned, no perf change, no echo from our own state writes), but let hidden files through, using chokidar v4's(path, stats)arg to tell files from dirs. Still one unified watcher.Tests
file.test.ts: matcher unit cases + a live chokidar test over a real tree (hidden files fire, hidden/excluded dirs stay silent).useFileSync.test.tsx: watches the root, dotfile reloads, allresyncFromDiskcases.modelCache.test.ts: baseline get/remember/evict.Full suite green (1613 tests), typecheck clean.
Note: also bundles the regenerated skills index (
registry/).