Files
orca/config/scripts
NeilandClaude d10626876e Watch only the files Orca needs in its settings folder and .git, instead of the whole folders (#32410)
* perf(watch): stop watching all of userData and .git for a handful of files

On macOS a directory fs.watch is a recursive FSEvents stream. Two watches used
that to notice a few files:

- The Active Server preference watched the whole userData directory for
  orca-environments.json, so Orca's own writes there (agent-hooks status,
  terminal history, browser caches; ~10 events/s measured) were routed back
  to it.
- The shallow git metadata watch ran fs.watch on each repo's whole common
  .git dir (and .git/logs), receiving objects/, refs/, lfs/ and every linked
  worktree's churn to see six files.

Both now watch the individual files (kqueue on macOS, no fseventsd) through a
new rebinding file watch: events and a 30s sweep re-stat the path, rebind when
a rename-replace or deletion moved it, and pick up files created later. Events
are confirmed by a stat (size/mtime/ctime/inode) because macOS raises an
attribute event for every mmap read of the index and packed-refs; the watch is
one-shot with a backing-off window so a file every git process maps costs about
one rebind a second instead of a wakeup per read. The registry path is
unchanged, so CLI/serve readers and older peers are unaffected. Linux and
Windows keep the non-recursive directory watch for shallow subscriptions.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(watch): don't hang unsubscribing an errored watcher; find late metadata files sooner

- Node closes an errored fs.watch handle without emitting 'close', and a later
  close() is a no-op, so awaiting 'close' could hang a watcher-child unsubscribe
  and every subscribe queued behind it. Errored watchers are now dropped without
  a close, and closeFileSystemWatcher also settles on 'error' or after 1s.
  Applies to both the macOS file watch and the Linux/Windows directory watch.
- Missing metadata files (packed-refs from pack-refs/gc) are re-statted every
  2s instead of waiting for the 30s rebind sweep.
- On macOS the delivery probe watches a file, matching the kqueue path the
  shallow subscriptions now use.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-23 05:29:47 -07:00
..
2026-05-15 05:44:25 -04:00