Skip to content

Commit 31106f0

Browse files
committed
Reinitialize LLM service when Gemini key is saved (fix 'Service not initialized' in onboarding)
1 parent 70e009d commit 31106f0

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

main.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,22 @@ class ApplicationController {
13451345

13461346
const persistedKeys = this.persistEnvUpdates(envUpdates);
13471347

1348+
// If the Gemini key was just saved, reinitialize the LLM service
1349+
// so the new client picks up the key. Without this, the test-
1350+
// connection button in the onboarding wizard fails with
1351+
// "Service not initialized" because the client was first created
1352+
// at app startup, before any key was set.
1353+
if (settings.geminiKey !== undefined && envUpdates.GEMINI_API_KEY !== undefined) {
1354+
try {
1355+
llmService.initializeClient();
1356+
logger.info("LLM service reinitialized after Gemini key update");
1357+
} catch (e) {
1358+
logger.warn("Failed to reinitialize LLM service after Gemini key update", {
1359+
error: e.message
1360+
});
1361+
}
1362+
}
1363+
13481364
// If provider changed, reinitialize speech service so the new provider
13491365
// is picked up immediately without a restart.
13501366
if (settings.speechProvider && speechService.provider !== settings.speechProvider) {

0 commit comments

Comments
 (0)