@@ -280,7 +280,7 @@ pub fn set_evolve_model<R: Runtime>(app: &AppHandle<R>, model: &str) -> Result<(
280280
281281/// Gets the stored OpenRouter API key.
282282pub fn get_openrouter_api_key < R : Runtime > ( app : & AppHandle < R > ) -> Result < Option < String > > {
283- get_secret_pref ( app, "openrouterApiKey" )
283+ get_secret_pref_normalized ( app, "openrouterApiKey" )
284284}
285285
286286pub fn set_openrouter_api_key < R : Runtime > ( app : & AppHandle < R > , key : & str ) -> Result < ( ) > {
@@ -289,7 +289,7 @@ pub fn set_openrouter_api_key<R: Runtime>(app: &AppHandle<R>, key: &str) -> Resu
289289
290290/// Gets the stored OpenAI API key (for direct OpenAI access).
291291pub fn get_openai_api_key < R : Runtime > ( app : & AppHandle < R > ) -> Result < Option < String > > {
292- get_secret_pref ( app, "openaiApiKey" )
292+ get_secret_pref_normalized ( app, "openaiApiKey" )
293293}
294294
295295pub fn set_openai_api_key < R : Runtime > ( app : & AppHandle < R > , key : & str ) -> Result < ( ) > {
@@ -322,7 +322,7 @@ pub fn set_vllm_api_base_url<R: Runtime>(app: &AppHandle<R>, url: &str) -> Resul
322322
323323/// Gets the stored vLLM API key (optional — vllm direct endpoint may not require one).
324324pub fn get_vllm_api_key < R : Runtime > ( app : & AppHandle < R > ) -> Result < Option < String > > {
325- get_secret_pref ( app, "vllmApiKey" )
325+ get_secret_pref_normalized ( app, "vllmApiKey" )
326326}
327327
328328pub fn set_vllm_api_key < R : Runtime > ( app : & AppHandle < R > , key : & str ) -> Result < ( ) > {
@@ -496,14 +496,18 @@ fn keychain_store_for<R: Runtime>(app: &AppHandle<R>, key: &str) -> KeychainStor
496496
497497fn get_secret_pref < R : Runtime > ( app : & AppHandle < R > , key : & ' static str ) -> Result < Option < String > > {
498498 if e2e_mock_system_enabled ( ) {
499- return Ok ( normalize_secret ( get_string_pref_raw ( app, key) ? ) ) ;
499+ return get_string_pref_raw ( app, key) ;
500500 }
501501
502502 let keychain = keychain_store_for ( app, key) ;
503- keychain
504- . get ( )
505- . map ( normalize_secret)
506- . map_err ( anyhow:: Error :: from)
503+ keychain. get ( ) . map_err ( anyhow:: Error :: from)
504+ }
505+
506+ fn get_secret_pref_normalized < R : Runtime > (
507+ app : & AppHandle < R > ,
508+ key : & ' static str ,
509+ ) -> Result < Option < String > > {
510+ Ok ( normalize_secret ( get_secret_pref ( app, key) ?) )
507511}
508512
509513fn set_secret_pref < R : Runtime > ( app : & AppHandle < R > , key : & ' static str , value : & str ) -> Result < ( ) > {
@@ -599,7 +603,7 @@ pub fn delete_sync_account<R: Runtime>(app: &AppHandle<R>) -> Result<()> {
599603
600604/// Gets the per-device HMAC secret from the keychain.
601605pub fn get_sync_secret < R : Runtime > ( app : & AppHandle < R > ) -> Result < Option < String > > {
602- get_secret_pref ( app, SYNC_SECRET_KEYCHAIN_KEY )
606+ get_secret_pref_normalized ( app, SYNC_SECRET_KEYCHAIN_KEY )
603607}
604608
605609/// Stores the per-device HMAC secret in the keychain.
0 commit comments