From aeec47d1762e73148f012ddd994e4b60eb9a863e Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Thu, 30 Oct 2025 00:48:14 +0100 Subject: [PATCH] Revert "Allowed add_language to be issued asynchronously" This reverts commit 2c2fcc6a07cd26d6e36e0fddf29061e9beb04020. --- src/serena/agent.py | 11 ++--------- src/serena/dashboard.py | 2 +- src/serena/project.py | 7 ++++--- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/serena/agent.py b/src/serena/agent.py index 2d95225d..811994a8 100644 --- a/src/serena/agent.py +++ b/src/serena/agent.py @@ -544,22 +544,15 @@ class SerenaAgent: ls_specific_settings=self.serena_config.ls_specific_settings, ) - def add_language(self, language: Language, wait_for_ls_startup: bool = False) -> None: + def add_language(self, language: Language) -> None: """ Adds a new language to the active project, spawning the respective language server and updating the project configuration. The addition is scheduled via the agent's task executor and executed synchronously, i.e. the method returns when the addition is complete. :param language: the language to add - :param wait_for_ls_startup: whether to wait for the language server to start up before returning (synchronous execution) - or to just issue the addition task and return immediately (asynchronous execution) """ - task = lambda: self.get_active_project_or_raise().add_language(language) - task_name = f"AddLanguage:{language.value}" - if wait_for_ls_startup: - self.execute_task(task, name=task_name) - else: - self.issue_task(task, name=task_name) + self.execute_task(lambda: self.get_active_project_or_raise().add_language(language), name=f"AddLanguage:{language.value}") def remove_language(self, language: Language) -> None: """ diff --git a/src/serena/dashboard.py b/src/serena/dashboard.py index 2325af90..be7a7214 100644 --- a/src/serena/dashboard.py +++ b/src/serena/dashboard.py @@ -331,7 +331,7 @@ class SerenaDashboardAPI: raise ValueError(f"Invalid language: {request_add_language.language}") # Add the language to the active project - self._agent.add_language(language, wait_for_ls_startup=False) + self._agent.add_language(language) def _remove_language(self, request_remove_language: RequestRemoveLanguage) -> None: from solidlsp.ls_config import Language diff --git a/src/serena/project.py b/src/serena/project.py index 46a9d5f7..662a87f8 100644 --- a/src/serena/project.py +++ b/src/serena/project.py @@ -405,9 +405,6 @@ class Project(ToStringMixin): if language in self.project_config.languages: log.info(f"Language {language.value} is already present in the project configuration.") return - # update the project configuration - self.project_config.languages.append(language) - self.save_config() # start the language server (if the LS manager is active) if self.language_server_manager is None: @@ -416,6 +413,10 @@ class Project(ToStringMixin): log.info("Adding and starting the language server for new language %s ...", language.value) self.language_server_manager.add_language_server(language) + # update the project configuration + self.project_config.languages.append(language) + self.save_config() + def remove_language(self, language: Language) -> None: """ Removes a programming language from the project configuration, stopping the corresponding