From 56b216fdf73c166ead83231074e3573983b7de51 Mon Sep 17 00:00:00 2001 From: haoyuren <13851610112@163.com> Date: Fri, 13 Mar 2026 17:28:32 -0500 Subject: 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 --- src/main/fileSyncBridge.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') 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!) -- cgit v1.2.3