File tree Expand file tree Collapse file tree
apps/array/src/main/services/file-watcher Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,8 +14,9 @@ import {
1414
1515const log = logger . scope ( "file-watcher" ) ;
1616
17- const IGNORE_PATTERNS = [ "**/node_modules/**" , "**/.git/**" ] ;
18- const DEBOUNCE_MS = 100 ;
17+ const IGNORE_PATTERNS = [ "**/node_modules/**" , "**/.git/**" , "**/.jj/**" ] ;
18+ const DEBOUNCE_MS = 500 ;
19+ const BULK_THRESHOLD = 100 ;
1920
2021interface PendingChanges {
2122 dirs : Set < string > ;
@@ -177,6 +178,18 @@ export class FileWatcherService extends TypedEventEmitter<FileWatcherEvents> {
177178 }
178179
179180 private flushPending ( repoPath : string , pending : PendingChanges ) : void {
181+ const totalChanges = pending . files . size + pending . deletes . size ;
182+
183+ // For bulk changes, emit a single event instead of per-file events
184+ if ( totalChanges > BULK_THRESHOLD ) {
185+ this . emit ( FileWatcherEvent . GitStateChanged , { repoPath } ) ;
186+ pending . dirs . clear ( ) ;
187+ pending . files . clear ( ) ;
188+ pending . deletes . clear ( ) ;
189+ pending . timer = null ;
190+ return ;
191+ }
192+
180193 for ( const dirPath of pending . dirs ) {
181194 this . emit ( FileWatcherEvent . DirectoryChanged , { repoPath, dirPath } ) ;
182195 }
You can’t perform that action at this time.
0 commit comments