diff --git a/src/serena/dashboard.py b/src/serena/dashboard.py index 87103460..0165d1c4 100644 --- a/src/serena/dashboard.py +++ b/src/serena/dashboard.py @@ -593,12 +593,12 @@ class SerenaDashboardAPI: self._agent.remove_language(language) @staticmethod - def _find_first_free_port(start_port: int) -> int: + def _find_first_free_port(start_port: int, host: str) -> int: port = start_port while port <= 65535: try: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: - sock.bind(("0.0.0.0", port)) + sock.bind((host, port)) return port except OSError: port += 1 @@ -618,7 +618,7 @@ class SerenaDashboardAPI: return port def run_in_thread(self, host: str) -> tuple[threading.Thread, int]: - port = self._find_first_free_port(0x5EDA) + port = self._find_first_free_port(0x5EDA, host) log.info("Starting dashboard (listen_address=%s, port=%d)", host, port) thread = threading.Thread(target=lambda: self.run(host=host, port=port), daemon=True) thread.start() diff --git a/src/serena/tools/jetbrains_tools.py b/src/serena/tools/jetbrains_tools.py index 6268a6b2..0d8bd6ba 100644 --- a/src/serena/tools/jetbrains_tools.py +++ b/src/serena/tools/jetbrains_tools.py @@ -118,6 +118,8 @@ class JetBrainsGetSymbolsOverviewTool(Tool, ToolMarkerSymbolicRead, ToolMarkerOp Retrieves an overview of the top-level symbols within a specified file using the JetBrains backend """ + USE_COMPACT_FORMAT = True + @staticmethod def _transform_symbols_to_compact_format(symbols: list[jb.SymbolDTO]) -> dict[str, list]: """ @@ -174,12 +176,15 @@ class JetBrainsGetSymbolsOverviewTool(Tool, ToolMarkerSymbolicRead, ToolMarkerOp symbol_overview = client.get_symbols_overview( relative_path=relative_path, depth=depth, include_file_documentation=include_file_documentation ) - symbols = symbol_overview["symbols"] - result: dict[str, Any] = {"symbols": self._transform_symbols_to_compact_format(symbols)} - documentation = symbol_overview.pop("documentation", None) - if documentation: - result["docstring"] = documentation - json_result = self._to_json(result) + if self.USE_COMPACT_FORMAT: + symbols = symbol_overview["symbols"] + result: dict[str, Any] = {"symbols": self._transform_symbols_to_compact_format(symbols)} + documentation = symbol_overview.pop("documentation", None) + if documentation: + result["docstring"] = documentation + json_result = self._to_json(result) + else: + json_result = self._to_json(symbol_overview) return self._limit_length(json_result, max_answer_chars) diff --git a/src/serena/util/file_system.py b/src/serena/util/file_system.py index 784fc2cf..3784a17a 100644 --- a/src/serena/util/file_system.py +++ b/src/serena/util/file_system.py @@ -52,7 +52,11 @@ def scan_directory( entry_path = entry.path if rel_base: - result_path = os.path.relpath(entry_path, rel_base) + try: + result_path = os.path.relpath(entry_path, rel_base) + except: + log.debug(f"Skipping entry due to relative path conversion error: {entry.path}") + continue else: result_path = entry_path