Skip to content

Commit 4b260e1

Browse files
committed
Report only applied watch changes
1 parent 01db66b commit 4b260e1

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

‎command_mcp.go‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,6 @@ Setup: Add to your AI client's MCP config:
421421
if len(changes) == 0 {
422422
continue
423423
}
424-
logChangeSummary(changes, flags.Verbose)
425424
result, applyErr := manager.ApplyChanges(ctx, changes)
426425
if applyErr != nil {
427426
if !isCanceledError(applyErr) {
@@ -432,6 +431,7 @@ Setup: Add to your AI client's MCP config:
432431
emitSynonymWarning(result.SynonymError)
433432
if result.Changed {
434433
if flags.Verbose {
434+
logChangeSummary(result.ChangedPaths, flags.Verbose)
435435
LogInfof("In-memory index updated: %d nodes (%d files, %d directories).", result.Stats.TotalNodes, result.Stats.TotalFiles, result.Stats.TotalDirs)
436436
}
437437
if persistMode == PersistChange {
@@ -527,12 +527,14 @@ Setup: Add to your AI client's MCP config:
527527

528528
remaining := drainPending()
529529
if len(remaining) > 0 {
530-
logChangeSummary(remaining, flags.Verbose)
531530
result, applyErr := manager.ApplyChanges(context.Background(), remaining)
532531
if applyErr != nil {
533532
LogErrorf("Final apply failed: %v", applyErr)
534533
} else {
535534
emitSynonymWarning(result.SynonymError)
535+
if result.Changed && flags.Verbose {
536+
logChangeSummary(result.ChangedPaths, true)
537+
}
536538
}
537539
}
538540
if writeMode {

‎command_watch.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ Examples:
260260
if len(changes) == 0 {
261261
continue
262262
}
263-
logChangeSummary(changes, flags.Verbose)
264263
result, applyErr := manager.ApplyChanges(ctx, changes)
265264
if applyErr != nil {
266265
if !isCanceledError(applyErr) {
@@ -271,6 +270,7 @@ Examples:
271270
emitSynonymWarning(result.SynonymError)
272271
if result.Changed {
273272
if flags.Verbose {
273+
logChangeSummary(result.ChangedPaths, flags.Verbose)
274274
LogInfof("In-memory index updated: %d nodes (%d files, %d directories).", result.Stats.TotalNodes, result.Stats.TotalFiles, result.Stats.TotalDirs)
275275
}
276276
if persistMode == PersistChange {
@@ -300,14 +300,14 @@ Examples:
300300
case <-ctx.Done():
301301
remaining := drainPending()
302302
if len(remaining) > 0 {
303-
logChangeSummary(remaining, flags.Verbose)
304303
result, applyErr := manager.ApplyChanges(context.Background(), remaining)
305304
if applyErr != nil {
306305
LogErrorf("Final apply failed: %v", applyErr)
307306
} else {
308307
emitSynonymWarning(result.SynonymError)
309308
if result.Changed {
310309
if flags.Verbose {
310+
logChangeSummary(result.ChangedPaths, flags.Verbose)
311311
LogInfof("In-memory index updated: %d nodes (%d files, %d directories).", result.Stats.TotalNodes, result.Stats.TotalFiles, result.Stats.TotalDirs)
312312
}
313313
if persistMode == PersistChange {

‎index_manager.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type ApplyResult struct {
4343
Stats IndexStats
4444
SynonymError error
4545
Changed bool
46+
ChangedPaths map[string]fsnotify.Op
4647
}
4748

4849
type IndexManager struct {
@@ -325,7 +326,7 @@ func (m *IndexManager) ApplyChanges(ctx context.Context, changes map[string]fsno
325326
return ApplyResult{}, fmt.Errorf("index manager not bootstrapped")
326327
}
327328

328-
result := ApplyResult{}
329+
result := ApplyResult{ChangedPaths: make(map[string]fsnotify.Op)}
329330
if len(changes) == 0 {
330331
result.Stats = ComputeStats(m.index.Tree)
331332
result.Stats.CollectedNames = len(CollectNamesForLLM(m.index.Tree))
@@ -376,6 +377,7 @@ func (m *IndexManager) ApplyChanges(ctx context.Context, changes map[string]fsno
376377
if op&(fsnotify.Remove|fsnotify.Rename) != 0 {
377378
if removeNodeByRelPath(m.index.Tree, relPath) {
378379
result.Changed = true
380+
result.ChangedPaths[relPath] |= op & (fsnotify.Remove | fsnotify.Rename)
379381
}
380382
}
381383

@@ -394,12 +396,14 @@ func (m *IndexManager) ApplyChanges(ctx context.Context, changes map[string]fsno
394396
if matcher.shouldIgnore(relPath, baseName, isDir) {
395397
if removeNodeByRelPath(m.index.Tree, relPath) {
396398
result.Changed = true
399+
result.ChangedPaths[relPath] |= op & (fsnotify.Create | fsnotify.Write | fsnotify.Chmod)
397400
}
398401
continue
399402
}
400403

401404
if upsertNodeByRelPath(m.index.Tree, m.rootPath, relPath, isDir, mtime, m.cache, m.synonymsMax) {
402405
result.Changed = true
406+
result.ChangedPaths[relPath] |= op & (fsnotify.Create | fsnotify.Write | fsnotify.Chmod)
403407
}
404408
}
405409

0 commit comments

Comments
 (0)