@@ -355,27 +355,30 @@ def load_environment(self, name: str, persist: bool = True) -> bool:
355355 return False
356356
357357 def update_current_environment_file (self ) -> None :
358- """Update the current environment's saved file with current config"""
359- if self .current_environment != "production" :
360- # Only update custom environments, not the built-in production
361- try :
362- sanitized_name = self ._sanitize_environment_name (self .current_environment )
363- env_file = self .environments_dir / f"{ sanitized_name } .json"
364- if env_file .exists ():
365- env_config = {
366- "api_key" : self .api_key ,
367- "team_id" : self .team_id ,
368- "team_name" : None if self .team_id_from_env else self .team_name ,
369- "team_role" : None if self .team_id_from_env else self .team_role ,
370- "user_id" : self .user_id ,
371- "base_url" : self .base_url ,
372- "frontend_url" : self .frontend_url ,
373- "inference_url" : self .inference_url ,
374- }
375- env_file .write_text (json .dumps (env_config , indent = 2 ))
376- except ValueError :
377- # Skip updating if environment name is invalid
378- pass
358+ """Update the active saved environment with the persisted config values."""
359+ if self .current_environment == "production" :
360+ return
361+
362+ try :
363+ sanitized_name = self ._sanitize_environment_name (self .current_environment )
364+ except ValueError :
365+ return
366+
367+ env_file = self .environments_dir / f"{ sanitized_name } .json"
368+ if not env_file .exists ():
369+ return
370+
371+ env_config = {
372+ "api_key" : self .config .get ("api_key" , "" ),
373+ "team_id" : self .config .get ("team_id" ),
374+ "team_name" : self .config .get ("team_name" ),
375+ "team_role" : self .config .get ("team_role" ),
376+ "user_id" : self .config .get ("user_id" ),
377+ "base_url" : self .config .get ("base_url" , self .DEFAULT_BASE_URL ),
378+ "frontend_url" : self .config .get ("frontend_url" , self .DEFAULT_FRONTEND_URL ),
379+ "inference_url" : self .config .get ("inference_url" , self .DEFAULT_INFERENCE_URL ),
380+ }
381+ env_file .write_text (json .dumps (env_config , indent = 2 ))
379382
380383 def list_environments (self ) -> list [str ]:
381384 """List all saved environment names"""
0 commit comments