From e3ce3712b5062b85251e5974eb90a33551147cba Mon Sep 17 00:00:00 2001 From: josedario87 Date: Sat, 14 Feb 2026 11:25:16 -0600 Subject: [PATCH] fix: Filter noisy git watcher events Only react to meaningful changes (refs, HEAD, index, objects). Ignore lock files, FETCH_HEAD, fsmonitor, and other noisy files. --- server/services/terminal.ts | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/server/services/terminal.ts b/server/services/terminal.ts index dcd7181..6fb9858 100644 --- a/server/services/terminal.ts +++ b/server/services/terminal.ts @@ -270,16 +270,42 @@ function broadcastGitChange() { } } +// Files to ignore (noisy or irrelevant) +const GIT_IGNORE_PATTERNS = [ + 'FETCH_HEAD', + 'gc.log', + '.lock', + 'COMMIT_EDITMSG', + 'ORIG_HEAD', + 'gitk.cache', + 'sourcetreeconfig', + '.DS_Store', + 'fsmonitor', + 'packed-refs' +] + export function startGitWatcher() { const gitDir = join(WORKING_DIR, '.git') try { // Watch .git directory recursively gitWatcher = watch(gitDir, { recursive: true }, (eventType, filename) => { - // Ignore some noisy files - if (filename?.includes('FETCH_HEAD') || filename?.includes('gc.log')) { - return - } + if (!filename) return + + // Ignore noisy files + const shouldIgnore = GIT_IGNORE_PATTERNS.some(pattern => + filename.includes(pattern) + ) + if (shouldIgnore) return + + // Only react to meaningful changes + const isRelevant = + filename.includes('refs/') || // branch/tag changes + filename === 'HEAD' || // checkout + filename === 'index' || // staging area + filename.includes('objects/') // new commits/blobs + + if (!isRelevant) return // Debounce to avoid flooding if (gitDebounceTimer) { @@ -287,6 +313,7 @@ export function startGitWatcher() { } gitDebounceTimer = setTimeout(() => { + console.log(`[Git] Change: ${filename}`) broadcastGitChange() }, GIT_DEBOUNCE_MS) })