summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhaoyuren <13851610112@163.com>2026-03-13 17:28:32 -0500
committerhaoyuren <13851610112@163.com>2026-03-13 17:28:32 -0500
commit56b216fdf73c166ead83231074e3573983b7de51 (patch)
treec27a752f39bc21079db24602812b82206fc6915a /src/main
parente377dabf99595a6783fd962a8765d2214a635ac2 (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>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/fileSyncBridge.ts7
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!)