Merge pull request #11588 from Kilo-Org/enormous-yak

fix(vscode): preserve code index across updates
This commit is contained in:
Marius
2026-06-23 18:09:28 +02:00
committed by GitHub
3 changed files with 44 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"kilo-code": patch
---
Preserve unchanged codebase indexes when extension or VS Code updates interrupt an incremental scan.
@@ -277,6 +277,8 @@ export class CodeIndexOrchestrator {
private async _runScan(mode: IndexingTelemetryMode, trigger: IndexingTelemetryTrigger): Promise<void> {
if (this._cancelRequested) {
if (mode === "incremental") await this.vectorStore.markIndexingComplete()
this.stateManager.setSystemState("Standby", "Indexing cancelled.")
log.info("scan skipped: cancellation was requested", { workspacePath: this.workspacePath, mode })
return
}
@@ -319,6 +321,10 @@ export class CodeIndexOrchestrator {
})
if (this._cancelRequested || this.scanner.isCancelled) {
if (mode === "incremental" && result.stats.processed === 0 && batchErrors.length === 0) {
await this.vectorStore.markIndexingComplete()
log.info("preserved unchanged index after cancelled scan", { workspacePath: this.workspacePath })
}
this._isProcessing = false
if (this.stateManager.state !== "Error") {
this.stateManager.setSystemState("Standby", "Indexing cancelled.")
@@ -18,7 +18,9 @@ import { Emitter } from "../../../src/indexing/runtime"
class Store {
public clearCount = 0
public closeCount = 0
public completeCount = 0
public deleteCount = 0
public incompleteCount = 0
constructor(
private readonly existing: boolean,
@@ -57,8 +59,12 @@ class Store {
async hasIndexedData(): Promise<boolean> {
return this.existing
}
async markIndexingComplete(): Promise<void> {}
async markIndexingIncomplete(): Promise<void> {}
async markIndexingComplete(): Promise<void> {
this.completeCount += 1
}
async markIndexingIncomplete(): Promise<void> {
this.incompleteCount += 1
}
}
class Scanner {
@@ -270,6 +276,31 @@ describe("CodeIndexOrchestrator telemetry", () => {
expect(scanner.finished).toBe(true)
expect(store.closeCount).toBe(1)
expect(store.incompleteCount).toBe(1)
expect(store.completeCount).toBe(0)
})
test("preserves an unchanged index when an incremental scan is interrupted", async () => {
const scanner = new BlockingScanner()
const store = new Store(true)
const orchestrator = new CodeIndexOrchestrator(
createConfig(),
new CodeIndexStateManager(),
"/tmp/ws",
{ async clearCacheFile() {}, async flush() {} } as unknown as CacheManager,
store as unknown as IVectorStore,
scanner as unknown as DirectoryScanner,
new Watcher() as unknown as IFileWatcher,
)
const active = orchestrator.startIndexing("background")
await scanner.started.promise
await orchestrator.shutdown()
await active
expect(store.incompleteCount).toBe(1)
expect(store.completeCount).toBe(1)
expect(store.clearCount).toBe(0)
})
test("clears stale vectors and hashes before rebuilding an incomplete store", async () => {