Add handling for external settings changes (#3942)

This commit is contained in:
Daniel 2025-05-24 17:05:28 -05:00 committed by GitHub
parent be9195c1ee
commit 20e7f118bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 27 additions and 4 deletions

View file

@ -824,6 +824,11 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> 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()

View file

@ -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
}

View file

@ -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<void> {
if (this._configManager) {
await this._configManager.loadConfiguration()
}
}
}

View file

@ -300,7 +300,7 @@ export const CodeIndexSettings: React.FC<CodeIndexSettingsProps> = ({
</div>
<div>
<VSCodeTextField
value={codebaseIndexConfig.codebaseIndexQdrantUrl}
value={codebaseIndexConfig.codebaseIndexQdrantUrl || "http://localhost:6333"}
onInput={(e: any) =>
setCachedStateField("codebaseIndexConfig", {
...codebaseIndexConfig,