Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions src/services/code-index/__tests__/config-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ describe("CodeIndexConfigManager", () => {
searchMinScore: 0.4,
})
expect(result.requiresRestart).toBe(false)
expect(result.requiresClear).toBe(false)
})

it("should load configuration from globalState and secrets", async () => {
Expand Down Expand Up @@ -98,29 +97,6 @@ describe("CodeIndexConfigManager", () => {
const result = await configManager.loadConfiguration()
expect(result.requiresRestart).toBe(true)
})

it("should detect clear requirement when model dimensions change", async () => {
// Initial state with a model
mockContextProxy.getGlobalState.mockReturnValue({
codebaseIndexEnabled: true,
codebaseIndexQdrantUrl: "http://qdrant.local",
codebaseIndexEmbedderProvider: "openai",
codebaseIndexEmbedderModelId: "text-embedding-3-small",
})

await configManager.loadConfiguration()

// Change to a model with different dimensions
mockContextProxy.getGlobalState.mockReturnValue({
codebaseIndexEnabled: true,
codebaseIndexQdrantUrl: "http://qdrant.local",
codebaseIndexEmbedderProvider: "openai",
codebaseIndexEmbedderModelId: "text-embedding-3-large",
})

const result = await configManager.loadConfiguration()
expect(result.requiresClear).toBe(true)
})
})

describe("isConfigured", () => {
Expand Down
13 changes: 0 additions & 13 deletions src/services/code-index/config-manager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ApiHandlerOptions } from "../../shared/api"
import { ContextProxy } from "../../core/config/ContextProxy"
import { EmbedderProvider } from "./interfaces/manager"
import { getModelDimension, getDefaultModelId } from "../../shared/embeddingModels"
import { CodeIndexConfig, PreviousConfigSnapshot } from "./interfaces/config"
import { SEARCH_MIN_SCORE } from "./constants"

Expand Down Expand Up @@ -38,7 +37,6 @@ export class CodeIndexConfigManager {
searchMinScore?: number
}
requiresRestart: boolean
requiresClear: boolean
}> {
const previousConfigSnapshot: PreviousConfigSnapshot = {
enabled: this.isEnabled,
Expand Down Expand Up @@ -84,16 +82,6 @@ export class CodeIndexConfigManager {
ollamaBaseUrl: codebaseIndexEmbedderBaseUrl,
}

const previousModelId =
previousConfigSnapshot.modelId ?? getDefaultModelId(previousConfigSnapshot.embedderProvider)
const currentModelId = this.modelId ?? getDefaultModelId(this.embedderProvider)
const previousDimension = previousModelId
? getModelDimension(previousConfigSnapshot.embedderProvider, previousModelId)
: undefined
const currentDimension = currentModelId ? getModelDimension(this.embedderProvider, currentModelId) : undefined
const requiresClear =
previousDimension !== undefined && currentDimension !== undefined && previousDimension !== currentDimension

return {
configSnapshot: previousConfigSnapshot,
currentConfig: {
Expand All @@ -108,7 +96,6 @@ export class CodeIndexConfigManager {
searchMinScore: this.searchMinScore,
},
requiresRestart: this._didConfigChangeRequireRestart(previousConfigSnapshot),
requiresClear,
}
}

Expand Down
17 changes: 4 additions & 13 deletions src/services/code-index/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class CodeIndexManager {
public async initialize(contextProxy: ContextProxy): Promise<{ requiresRestart: boolean }> {
// 1. ConfigManager Initialization and Configuration Loading
this._configManager = new CodeIndexConfigManager(contextProxy)
const { requiresRestart, requiresClear } = await this._configManager.loadConfiguration()
const { requiresRestart } = await this._configManager.loadConfiguration()

// 2. Check if feature is enabled
if (!this.isFeatureEnabled) {
Expand Down Expand Up @@ -170,20 +170,11 @@ export class CodeIndexManager {
)
}

// 5. Handle Data Clearing
if (requiresClear) {
if (this._orchestrator) {
await this._orchestrator.clearIndexData()
}
if (this._cacheManager) {
await this._cacheManager.clearCacheFile()
}
}

// Handle Indexing Start/Restart
// 5. Handle Indexing Start/Restart
// The enhanced vectorStore.initialize() in startIndexing() now handles dimension changes automatically
// by detecting incompatible collections and recreating them, so we rely on that for dimension changes
const shouldStartOrRestartIndexing =
requiresRestart ||
requiresClear ||
(needsServiceRecreation && (!this._orchestrator || this._orchestrator.state !== "Indexing"))

if (shouldStartOrRestartIndexing) {
Expand Down
Loading
Loading