Skip to content

fix(editor): watch hidden files and re-sync on reopen#392

Merged
Anton-Horn merged 3 commits into
mainfrom
fix/editor-watch-hidden-files
Jun 15, 2026
Merged

fix(editor): watch hidden files and re-sync on reopen#392
Anton-Horn merged 3 commits into
mainfrom
fix/editor-watch-hidden-files

Conversation

@Anton-Horn

Copy link
Copy Markdown
Contributor

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

  • Matcher: prune excluded entries and hidden directories only (so node_modules, .git, .cate stay 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.
  • Reopen: track each model's disk baseline in the model cache. On reopen, a clean stale buffer silently catches up; a buffer with unsaved edits raises a conflict instead of being clobbered.

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, all resyncFromDisk cases.
  • modelCache.test.ts: baseline get/remember/evict.

Full suite green (1613 tests), typecheck clean.

Note: also bundles the regenerated skills index (registry/).

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.
@Anton-Horn Anton-Horn merged commit 68e5611 into main Jun 15, 2026
3 of 6 checks passed
@Anton-Horn Anton-Horn deleted the fix/editor-watch-hidden-files branch June 15, 2026 17:24
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.

1 participant