MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / startSourceWatcher

Method startSourceWatcher

src/ui-server/api/events.ts:329–354  ·  view source on GitHub ↗

* The project tree, through the engine's watcher with the sync taken out. * * The `syncFn` is the whole trick: the watcher calls it with exactly the * paths it would have handed to a scoped sync (or `undefined` when the events * could not describe the change), we announce them and report

()

Source from the content-addressed store, hash-verified

327 * layer itself, which is precisely the part we do want.
328 */
329 private startSourceWatcher(): void {
330 if (this.sourceWatcher) return;
331 const watcher = new FileWatcher(
332 this.projectRoot,
333 async (paths?: string[]) => {
334 this.announceChanged(paths);
335 return { filesChanged: 0, durationMs: 0 };
336 },
337 {
338 debounceMs: SOURCE_DEBOUNCE_MS,
339 onDegraded: (reason) => {
340 this.degraded = reason;
341 this.sourceUp = false;
342 this.broadcast({ type: 'degraded', reason, at: Date.now() });
343 },
344 }
345 );
346 this.sourceWatcher = watcher;
347 this.sourceUp = watcher.start();
348 if (!this.sourceUp) {
349 // Watching is off by policy (CODEGRAPH_NO_WATCH, a WSL2 /mnt drive) or
350 // the OS refused. The stream stays — the index watcher is independent —
351 // and `hello` already told the client which half is live.
352 this.sourceWatcher = null;
353 }
354 }
355
356 private announceChanged(paths?: string[]): void {
357 const all = paths ?? [];

Callers 1

ensureWatchingMethod · 0.95

Calls 3

announceChangedMethod · 0.95
broadcastMethod · 0.95
startMethod · 0.95

Tested by

no test coverage detected