Skip to content

Commit a3b6258

Browse files
committed
Fix 1: Removed early _setupGitHeadWatcher call
Fix 2: Added _setupGitHeadWatcher to _recreateServices Fix 3: Removed redundant call in handleSettingsChange Fix 4: Ensured watcher disposal when feature disabled
1 parent c0806b2 commit a3b6258

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/services/code-index/manager.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ export class CodeIndexManager {
153153
await this._cacheManager.initialize()
154154
}
155155

156-
// Ensure Git branch watcher is set up (when branch isolation is enabled)
157-
await this._setupGitHeadWatcher()
158-
159-
160156
// 4. Determine if Core Services Need Recreation
161157
const needsServiceRecreation = !this._serviceFactory || requiresRestart
162158

@@ -397,6 +393,9 @@ export class CodeIndexManager {
397393

398394
// Clear any error state after successful recreation
399395
this._stateManager.setSystemState("Standby", "")
396+
397+
// Ensure Git branch watcher is set up with current branch after service recreation
398+
await this._setupGitHeadWatcher()
400399
}
401400

402401
// --- Git branch watcher (Phase 1: auto branch switch handling) ---
@@ -458,6 +457,8 @@ export class CodeIndexManager {
458457
if (this._orchestrator) {
459458
this._orchestrator.stopWatcher()
460459
}
460+
// Dispose Git branch watcher if it exists
461+
await this._setupGitHeadWatcher()
461462
// Set state to indicate service is disabled
462463
this._stateManager.setSystemState("Standby", "Code indexing is disabled")
463464
return
@@ -486,9 +487,6 @@ export class CodeIndexManager {
486487
}
487488
}
488489

489-
// Ensure Git branch watcher reflects latest settings
490-
await this._setupGitHeadWatcher()
491-
492490
}
493491
}
494492
}

0 commit comments

Comments
 (0)