diff options
| author | haoyuren <13851610112@163.com> | 2026-03-13 17:28:32 -0500 |
|---|---|---|
| committer | haoyuren <13851610112@163.com> | 2026-03-13 17:28:32 -0500 |
| commit | 56b216fdf73c166ead83231074e3573983b7de51 (patch) | |
| tree | c27a752f39bc21079db24602812b82206fc6915a | |
| parent | e377dabf99595a6783fd962a8765d2214a635ac2 (diff) | |
Use polling for file watcher to reliably detect external edits
chokidar FSEvents is unreliable in macOS temp dirs and misses atomic
writes (write temp + rename) used by Claude Code and other editors.
Switch to usePolling with 500ms interval and atomic: true.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| -rw-r--r-- | src/main/fileSyncBridge.ts | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/fileSyncBridge.ts b/src/main/fileSyncBridge.ts index e49b86d..5a7d92e 100644 --- a/src/main/fileSyncBridge.ts +++ b/src/main/fileSyncBridge.ts @@ -123,9 +123,14 @@ export class FileSyncBridge { this.socket.on('serverEvent', this.serverEventHandler) // Start watching the temp dir + // usePolling: FSEvents is unreliable in macOS temp dirs (/var/folders/...) + // atomic: Claude Code and other editors use atomic writes (write temp + rename) + // which macOS FSEvents doesn't detect as 'change' by default this.watcher = chokidar.watch(this.tmpDir, { ignoreInitial: true, - awaitWriteFinish: { stabilityThreshold: 100, pollInterval: 50 }, + usePolling: true, + interval: 500, + atomic: true, ignored: [ /(^|[/\\])\../, // dotfiles /\.(aux|log|fls|fdb_latexmk|synctex\.gz|bbl|blg|out|toc|lof|lot|nav|snm|vrb)$/ // LaTeX output files (not pdf!) |
