File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments