Commit Graph
2175 Commits
Author SHA1 Message Date
TJ Kolleh 1ea5f0c25f feat(scala): Add stale lock detection for Metals H2 database (#1012)
* feat(scala): Add stale lock detection for Metals H2 database

Add detection and automatic cleanup of stale Metals H2 database locks
to improve multi-instance support. When a Metals process crashes without
proper cleanup, it can leave a lock file that prevents proper AUTO_SERVER
coordination with new instances.

Changes:
- Add metals_db_utils.py with detection logic for stale locks
- Add StaleLockMode enum (auto-clean/warn/fail) for configurable behavior
- Add MetalsStaleLockError exception for fail mode
- Integrate stale lock checking into ScalaLanguageServer init
- Add configuration options: on_stale_lock, log_multi_instance_notice
- Add comprehensive unit tests for detection logic

This enhancement allows Serena's Metals to coexist with VS Code or other
editors running Metals on the same project, with proper handling of edge
cases like crashed processes.

* test(scala): Add integration tests for stale lock handling modes

Add 7 integration tests for ScalaLanguageServer stale lock detection:
- AUTO_CLEAN mode cleans stale locks and proceeds
- WARN mode logs warning without cleanup
- FAIL mode raises MetalsStaleLockError
- ACTIVE_INSTANCE logs info when notice enabled
- ACTIVE_INSTANCE silent when notice disabled
- NO_DATABASE proceeds silently
- NO_LOCK proceeds silently

Tests use mocking to avoid requiring Java/Coursier/Metals.

* docs(scala): Add multi-instance and stale lock documentation

Document Metals multi-instance support via H2 AUTO_SERVER:
- Explain how multiple Metals instances share database and Bloop
- Document memory considerations (~500MB per JVM)
- Add stale lock detection configuration options
- Document on_stale_lock modes (auto-clean, warn, fail)
- Add YAML configuration examples

* docs: Clean up docs

Removed memory considerations and additional configuration sections from the Scala setup guide.

* refactor(scala): Extract settings helper and add module-level constants

- Add DEFAULT_METALS_VERSION, DEFAULT_CLIENT_NAME, DEFAULT_ON_STALE_LOCK,
  DEFAULT_LOG_MULTI_INSTANCE_NOTICE constants to eliminate duplication
- Extract _get_scala_settings() pure function for centralized settings parsing
- Remove redundant cleanup_stale_lock import
- Add warning log when AUTO_CLEAN mode fails to remove stale lock
- Simplify lock path handling with ternary expression

This refactoring improves code maintainability by centralizing Scala
settings extraction and applying functional programming principles.

* chore(scala): fix typo in docstring and comments
2026-02-19 13:30:05 +01:00
Dominik Jain 547a938832 Make thinking tools optional (disabled by default) 2026-02-17 14:52:45 +01:00
Dominik Jain f117196989 Add section on logs to usage documentation 2026-02-17 14:05:54 +01:00
Dominik Jain 16c2124feb Disable other TestSwiftLanguageServerBasics::test_request_references_* tests in CI #1039 2026-02-15 22:39:30 +01:00
Dominik Jain 7f8c6311fb Merge pull request #1046 from oraios/robust-plugin-path-matching
JetBrainsPluginClient: Generalise path matching
2026-02-15 21:27:45 +01:00
Dominik Jain 4a0812972f JetBrainsPluginClient: Generalise path matching
* Account for additional prefixes
  * Account for WSL vs. Windows path mismatch

Add a test for path matching
2026-02-15 18:41:10 +01:00
Dominik Jain 448b3693bc Merge pull request #1036 from oraios/generic-symbol-output-grouping
Implement generic SymbolDictGrouper
2026-02-15 13:19:08 +01:00
Dominik Jain b7ce737599 Disable TestSwiftLanguageServerBasics::test_request_references_calculator_class in CI #1039 2026-02-15 12:44:31 +01:00
Dominik Jain 52cc9729d2 Disable TestFSharpLanguageServer::test_hover_information in CI #1039 2026-02-15 00:57:55 +01:00
Dominik Jain 070b0ae5ac Fix mypy issues 2026-02-14 23:34:43 +01:00
Dominik Jain 629bc75b97 Make test_find_symbol_references support both grouped and ungrouped output format 2026-02-14 23:34:43 +01:00
Dominik Jain be288214c1 Merge remote-tracking branch 'origin/main' into generic-symbol-output-grouping 2026-02-14 21:22:37 +01:00
Dominik Jain 15f60a0b1f Merge pull request #1043 from oraios/mypy-test
Enable mypy for test/
2026-02-14 21:14:29 +01:00
Dominik Jain e23800bea4 Disable TestSerenaAgent::test_find_symbol for FSHARP in CI #1039
Use apply instead of apply_ex in test to make exceptions visible
2026-02-14 20:26:20 +01:00
Dominik Jain 0edfcb20ed Merge remote-tracking branch 'origin/main' into generic-symbol-output-grouping 2026-02-14 19:50:14 +01:00
Dominik Jain 7513800a0f Fix mypy issues in tests 2026-02-14 19:48:07 +01:00
Dominik Jain 177f0f46cb Enable mypy for test/ (allowing untyped defs) 2026-02-14 19:31:41 +01:00
Dominik Jain e20af1a328 Disable TestLanguageServerCommonFunctionality::test_open_file_cache_invalidate in Windows CI #1039 2026-02-14 19:13:02 +01:00
Dominik Jain 2024747e7f Disable TestSerenaAgent::test_find_symbol_references for TYPESCRIPT in CI #1039 2026-02-14 19:10:25 +01:00
Dominik Jain 31d458583f Remove 'on CI' suffix from CI task name [skip ci] 2026-02-14 18:05:08 +01:00
Dominik Jain ee992690f2 Add sleep time to fix flaky test in Windows CI 2026-02-14 17:43:35 +01:00
Dominik Jain f704abefbf Merge pull request #1041 from oraios/skip-flaky-tests
Skip flaky tests in CI
2026-02-14 16:54:41 +01:00
Dominik Jain 3ab0720ff4 Disable TestSerenaAgent::test_find_symbol for FSHARP in CI #1039 2026-02-14 14:20:26 +01:00
Dominik Jain 2e2384020a Disable TestNixLanguageServer::test_hover_information in CI #1039 2026-02-14 14:20:26 +01:00
Dominik Jain 9e95663cd7 Disable TestFSharpLanguageServer::test_find_referencing_symbols_across_files in CI #1039 2026-02-14 14:20:25 +01:00
Dominik Jain 558caa0ad5 Disable Phpactor tests in Windows CI #1039 2026-02-14 14:20:25 +01:00
Dominik Jain a72ca90358 Merge pull request #996 from takeokunn/feature/add-ignore_path-system-global
SerenaConfig: Add system-global ignored_paths for cross-project path exclusion
2026-02-14 13:13:43 +01:00
Dominik Jain d0ec712c13 Merge pull request #1038 from takeokunn/fix/phpactor-test-auto-skip
Skip PHP_PHPACTOR tests when PHP is not installed
2026-02-14 13:01:16 +01:00
takeokunn 614b035621 fix(tests): auto-skip Phpactor tests if PHP is unavailable
- Add check in conftest.py to disable PHP_PHPACTOR tests when php binary
  is not found
- Refactor test_php_basic.py to use dynamic PHP server list based on
  availability
- Ensure tests for PHP_PHPACTOR are only parametrized if PHP is present
2026-02-14 17:30:59 +09:00
Dominik Jain 2139552b0f Fix health check incorrectly checking symbol kind against int instead of SymbolKind.name 2026-02-14 00:48:50 +01:00
Dominik Jain 63377658d7 Improve docstrings 2026-02-13 23:51:55 +01:00
Dominik Jain a0aa3a7205 Fix duplicate computation of included children 2026-02-13 23:46:05 +01:00
Dominik Jain 82d711aeb5 LanguageServerSymbol.to_dict: Remove include_ prefix from params 2026-02-13 23:40:47 +01:00
Dominik Jain cbff50b710 Apply SymbolDictGrouper in FindReferencingSymbolsTool & JetBrainsFindReferencingSymbolsTool
Resolves #1021
2026-02-13 23:22:16 +01:00
Dominik Jain d69f53cd5a Hotfix for serena-jetbrains-plugin/issues/13 2026-02-13 23:05:27 +01:00
Dominik Jain d41b9ec964 Implement dict transformation in symbol overview tools using SymbolDictGrouper,
adding support for the necessary transformations of the final dictionaries
2026-02-13 22:31:32 +01:00
Dominik Jain a1f95902ca Remove _sanitize_symbol_dict, making to_dict fully flexible instead
This fixes a bug: _sanitize_symbol_dict was not recursively applied
to children, causing children to contain superfluous entries
(full location, etc.)

Additional change: Improve factorisation of symbol overview computation
2026-02-13 21:37:08 +01:00
Dominik Jain 2760508269 Add test for symbol key types 2026-02-13 19:20:08 +01:00
Dominik Jain d80c45e7e7 Refactoring: Move jetbrains_plugin_client and jetbrains_types out of tools package
This resolves cyclic import issues
2026-02-13 19:20:08 +01:00
Dominik Jain 798a31b6a7 Implement generic SymbolDictGrouper (and specialisations for LS & JB)
It represents a reasonable compromise between pragmatism and type-safety.
Soundness is checked at runtime, but if the grouper is instantiated statically,
then we immediately detect misspecification.

One example application is implemented in GetSymbolsOverviewTool

Provides basis for #1021
2026-02-13 18:36:05 +01:00
Dominik Jain 66a12eee3c Fix type annotation 2026-02-13 16:38:40 +01:00
Dominik Jain 036a065848 Dashboard: Improve accessibility of logs view
'Overview' and 'Logs' are now tabs instead of menu items
2026-02-13 15:15:26 +01:00
Dominik Jain 88327d6192 Merge pull request #1035 from oraios/limited-log-buffer
Limit the size of the log buffer
2026-02-13 15:02:16 +01:00
Dominik Jain 1ab009ccf5 Limit the size of the log buffer
Fixes #1034
2026-02-13 14:51:10 +01:00
Dominik Jain 21bc996f10 Merge pull request #1028 from oraios/fix-ls-open-file-stale-buffers
LSPFileBuffer: Ensure that file contents are never stale
2026-02-13 12:52:08 +01:00
Dominik Jain 37965666be LSPFileBuffer: Ensure that file contents are never stale by monitoring file modification date
For every read access on .contents, check for external file modification
and re-read if necessary, invalidating the content hash as well.

Fixes #1013
2026-02-13 12:48:12 +01:00
takeokunn 0025402f37 RegisteredProject: pass SerenaConfig through get_project_instance
Remove serena_config storage from RegisteredProject; instead accept it
as an explicit parameter in get_project_instance() for cleaner separation
of concerns.
2026-02-13 15:39:52 +09:00
takeokunn 43902782fa Project.load: accept SerenaConfig instead of global_ignored_paths
Use `serena_config: SerenaConfig | None` without a default value,
requiring callers to explicitly pass the configuration.
2026-02-13 15:37:59 +09:00
takeokunn f2beb3bb16 Project: accept SerenaConfig instead of global_ignored_paths
Replace `global_ignored_paths: Sequence[str]` with `serena_config: SerenaConfig | None`
in Project.__init__ and propagate through RegisteredProject for more general and
future-proof interfaces.
2026-02-13 15:37:29 +09:00
Dominik Jain 1064afceed Merge pull request #1030 from oraios/fix-symbol-body-end
Handle end_col when extracting symbol body
2026-02-13 03:58:23 +01:00