Skip to content

Commit 0e3fe0e

Browse files
committed
fix: preserve OpenAI-like provider settings when switching modes
- Save current provider configuration when switching to a mode without saved config - Re-activate custom OpenAI provider profiles to ensure settings persist - Fixes issue where Jan.ai and other OpenAI-compatible provider settings were lost Fixes #8583
1 parent 507a600 commit 0e3fe0e

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/core/webview/ClineProvider.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,14 +1211,20 @@ export class ClineProvider
12111211
await this.activateProviderProfile({ name: profile.name })
12121212
}
12131213
} else {
1214-
// If no saved config for this mode, save current config as default.
1214+
// If no saved config exists for this mode, handle the current configuration
12151215
const currentApiConfigName = this.getGlobalState("currentApiConfigName")
1216-
1217-
if (currentApiConfigName) {
1218-
const config = listApiConfig.find((c) => c.name === currentApiConfigName)
1219-
1220-
if (config?.id) {
1221-
await this.providerSettingsManager.setModeConfig(newMode, config.id)
1216+
const currentConfig = listApiConfig.find(({ name }) => name === currentApiConfigName)
1217+
1218+
if (currentApiConfigName && currentConfig?.id) {
1219+
// Always save the current config as the default for the new mode
1220+
// This ensures that custom OpenAI providers (and all other providers) persist across mode switches
1221+
await this.providerSettingsManager.setModeConfig(newMode, currentConfig.id)
1222+
1223+
// For custom OpenAI providers, we need to ensure the configuration is properly loaded
1224+
// The "openai" provider is the customizable one that users configure for OpenAI-compatible endpoints
1225+
if (currentConfig.apiProvider === "openai") {
1226+
// Re-activate the profile to ensure all settings are properly loaded
1227+
await this.activateProviderProfile({ name: currentConfig.name })
12221228
}
12231229
}
12241230
}

0 commit comments

Comments
 (0)