Skip to content

Commit 5a4faeb

Browse files
committed
feat: add handling for external settings changes
1 parent be9195c commit 5a4faeb

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

src/core/webview/ClineProvider.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,11 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
824824
this.contextProxy.setProviderSettings(providerSettings),
825825
])
826826

827+
// Notify CodeIndexManager about the settings change
828+
if (this.codeIndexManager) {
829+
await this.codeIndexManager.handleExternalSettingsChange()
830+
}
831+
827832
// Change the provider for the current task.
828833
// TODO: We should rename `buildApiHandler` for clarity (e.g. `getProviderClient`).
829834
const task = this.getCurrentCline()

src/services/code-index/config-manager.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class CodeIndexConfigManager {
1414
private modelId?: string
1515
private openAiOptions?: ApiHandlerOptions
1616
private ollamaOptions?: ApiHandlerOptions
17-
private qdrantUrl?: string
17+
private qdrantUrl?: string = "http://localhost:6333"
1818
private qdrantApiKey?: string
1919
private searchMinScore?: number
2020

@@ -103,11 +103,19 @@ export class CodeIndexConfigManager {
103103
* Checks if the service is properly configured based on the embedder type.
104104
*/
105105
public isConfigured(): boolean {
106+
console.log("[CodeIndexConfigManager.isConfigured] Entry. EmbedderProvider:", this.embedderProvider)
107+
106108
if (this.embedderProvider === "openai") {
107-
return !!(this.openAiOptions?.openAiNativeApiKey && this.qdrantUrl)
109+
const openAiKey = this.openAiOptions?.openAiNativeApiKey
110+
const qdrantUrl = this.qdrantUrl
111+
const isConfigured = !!(openAiKey && qdrantUrl)
112+
return isConfigured
108113
} else if (this.embedderProvider === "ollama") {
109114
// Ollama model ID has a default, so only base URL is strictly required for config
110-
return !!(this.ollamaOptions?.ollamaBaseUrl && this.qdrantUrl)
115+
const ollamaBaseUrl = this.ollamaOptions?.ollamaBaseUrl
116+
const qdrantUrl = this.qdrantUrl
117+
const isConfigured = !!(ollamaBaseUrl && qdrantUrl)
118+
return isConfigured
111119
}
112120
return false // Should not happen if embedderProvider is always set correctly
113121
}

src/services/code-index/manager.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,15 @@ export class CodeIndexManager {
244244
this.assertInitialized()
245245
return this._searchService!.searchIndex(query, directoryPrefix)
246246
}
247+
248+
/**
249+
* Handles external settings changes by reloading configuration.
250+
* This method should be called when API provider settings are updated
251+
* to ensure the CodeIndexConfigManager picks up the new configuration.
252+
*/
253+
public async handleExternalSettingsChange(): Promise<void> {
254+
if (this._configManager) {
255+
await this._configManager.loadConfiguration()
256+
}
257+
}
247258
}

webview-ui/src/components/settings/CodeIndexSettings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ export const CodeIndexSettings: React.FC<CodeIndexSettingsProps> = ({
300300
</div>
301301
<div>
302302
<VSCodeTextField
303-
value={codebaseIndexConfig.codebaseIndexQdrantUrl}
303+
value={codebaseIndexConfig.codebaseIndexQdrantUrl || "http://localhost:6333"}
304304
onInput={(e: any) =>
305305
setCachedStateField("codebaseIndexConfig", {
306306
...codebaseIndexConfig,

0 commit comments

Comments
 (0)