diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index a3fef42640..43f56b8fa5 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -824,6 +824,11 @@ export class ClineProvider extends EventEmitter implements this.contextProxy.setProviderSettings(providerSettings), ]) + // Notify CodeIndexManager about the settings change + if (this.codeIndexManager) { + await this.codeIndexManager.handleExternalSettingsChange() + } + // Change the provider for the current task. // TODO: We should rename `buildApiHandler` for clarity (e.g. `getProviderClient`). const task = this.getCurrentCline() diff --git a/src/services/code-index/config-manager.ts b/src/services/code-index/config-manager.ts index 78e6b74431..0b0bf2e7e8 100644 --- a/src/services/code-index/config-manager.ts +++ b/src/services/code-index/config-manager.ts @@ -14,7 +14,7 @@ export class CodeIndexConfigManager { private modelId?: string private openAiOptions?: ApiHandlerOptions private ollamaOptions?: ApiHandlerOptions - private qdrantUrl?: string + private qdrantUrl?: string = "http://localhost:6333" private qdrantApiKey?: string private searchMinScore?: number @@ -103,11 +103,18 @@ export class CodeIndexConfigManager { * Checks if the service is properly configured based on the embedder type. */ public isConfigured(): boolean { + if (this.embedderProvider === "openai") { - return !!(this.openAiOptions?.openAiNativeApiKey && this.qdrantUrl) + const openAiKey = this.openAiOptions?.openAiNativeApiKey + const qdrantUrl = this.qdrantUrl + const isConfigured = !!(openAiKey && qdrantUrl) + return isConfigured } else if (this.embedderProvider === "ollama") { // Ollama model ID has a default, so only base URL is strictly required for config - return !!(this.ollamaOptions?.ollamaBaseUrl && this.qdrantUrl) + const ollamaBaseUrl = this.ollamaOptions?.ollamaBaseUrl + const qdrantUrl = this.qdrantUrl + const isConfigured = !!(ollamaBaseUrl && qdrantUrl) + return isConfigured } return false // Should not happen if embedderProvider is always set correctly } diff --git a/src/services/code-index/manager.ts b/src/services/code-index/manager.ts index bbc26605e8..6922ae90da 100644 --- a/src/services/code-index/manager.ts +++ b/src/services/code-index/manager.ts @@ -244,4 +244,15 @@ export class CodeIndexManager { this.assertInitialized() return this._searchService!.searchIndex(query, directoryPrefix) } + + /** + * Handles external settings changes by reloading configuration. + * This method should be called when API provider settings are updated + * to ensure the CodeIndexConfigManager picks up the new configuration. + */ + public async handleExternalSettingsChange(): Promise { + if (this._configManager) { + await this._configManager.loadConfiguration() + } + } } diff --git a/webview-ui/src/components/settings/CodeIndexSettings.tsx b/webview-ui/src/components/settings/CodeIndexSettings.tsx index 6cd1f76669..5e90679fc1 100644 --- a/webview-ui/src/components/settings/CodeIndexSettings.tsx +++ b/webview-ui/src/components/settings/CodeIndexSettings.tsx @@ -300,7 +300,7 @@ export const CodeIndexSettings: React.FC = ({
setCachedStateField("codebaseIndexConfig", { ...codebaseIndexConfig,