Skip to content

Commit e872015

Browse files
committed
Improves branch isolation and vector store access
Optimizes code index management by: - Providing more direct vector store access via the orchestrator - Enhancing error handling when the vector store is unavailable - Clarifying the branch isolation feature description in settings These changes increase reliability during branch switches and improve user experience through more precise search results.
1 parent ea2df0d commit e872015

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/services/code-index/manager.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,14 +432,21 @@ export class CodeIndexManager {
432432

433433
// Smart re-indexing: only do full scan if collection doesn't exist or is empty
434434
// If collection exists with data, file watcher will handle incremental updates
435-
const collectionExists = await this._serviceFactory?.getVectorStore()?.collectionExists()
435+
const vectorStore = this._orchestrator?.getVectorStore()
436+
if (!vectorStore) {
437+
// No orchestrator yet, just start indexing
438+
this._orchestrator?.startIndexing()
439+
return
440+
}
441+
442+
const collectionExists = await vectorStore.collectionExists()
436443
if (!collectionExists) {
437444
// New branch or first time indexing this branch - do full scan
438445
this._orchestrator?.startIndexing()
439446
} else {
440447
// Collection exists - just validate/initialize without full scan
441448
// File watcher will detect any file changes from the branch switch
442-
await this._serviceFactory?.getVectorStore()?.initialize()
449+
await vectorStore.initialize()
443450
}
444451
} catch (error) {
445452
console.error("Failed to handle Git branch change:", error)

src/services/code-index/orchestrator.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ export class CodeIndexOrchestrator {
2626
private readonly fileWatcher: IFileWatcher,
2727
) {}
2828

29+
/**
30+
* Gets the vector store instance
31+
*/
32+
public getVectorStore(): IVectorStore {
33+
return this.vectorStore
34+
}
35+
2936
/**
3037
* Starts the file watcher if not already running.
3138
*/

webview-ui/src/i18n/locales/en/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
"close": "Close",
125125
"branchIsolation": {
126126
"enableLabel": "Enable Branch Isolation",
127-
"enableDescription": "Index each Git branch separately to prevent conflicts when switching branches. Requires more storage space.",
127+
"enableDescription": "Index each Git branch separately to get better search results and prevent conflicts when switching branches. Requires more storage space.",
128128
"storageWarning": "Each branch will have its own index, increasing storage requirements."
129129
},
130130
"validation": {
@@ -892,4 +892,4 @@
892892
"cacheReads": "Cache reads"
893893
}
894894
}
895-
}
895+
}

0 commit comments

Comments
 (0)