Skip to content

fix: warn, instead of locking Socket, for a language server whose template lists only stdio - #2087

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/warn-instead-of-locking-socket-for-a-stdio-template
Nov 23, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/warn-instead-of-locking-socket-for-a-stdio-template

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Part of #1947.

What

A template whose transports lists only stdio locked Socket, in the New Language Server dialog and on the settings page of a language server created from it. But a template is also a starting point: someone whose own language server talks over a socket can start from the TypeScript template for its mappings and settings, and then couldn't choose Socket.

Change

  • Socket stays enabled, and the grey hint "This language server talks LSP only over its standard input and output." stays as it is.
  • The warning: once Socket is chosen for such a server, LanguageServerPanel.validateFields() gives a warning on the Socket button: "The template says this language server talks LSP only over its standard input and output". It is asWarning().withOKEnabled():
  • Next to a transport error: the warning also shows next to an error such as "With an Auto port, the command must take the port as ${port}", which it explains: the template has no socket argument to swap into the command.
  • No warning for a template without transports, or with a socket mode.
  • Saved settings with a socket mode, for a server whose template lists only stdio, load with Socket selected and the warning, and still save.
  • Unchanged: how a language server starts or connects, the template format, and UserDefinedTransport.
  • Docs: the Transports section of UserDefinedLanguageServerTemplate.md.

Test

  • TransportFieldsTest: for a stdio-only template, Socket is enabled, choosing it gives the warning with OK enabled, and stdio gives none. A saved socket stays chosen with the warning. A template with a socket mode, only a socket, or no transports gives no warning.
  • NewLanguageServerDialogTransportTest:
    • the warning shows on the Socket button and below the fields, next to the ${port} error;
    • once the command takes ${port}, only warnings remain;
    • the CSS template and a template without transports give none;
    • a template's own socket is kept, with the warning.
  • LanguageServerViewTransportTest: a saved socket of a server made from the TypeScript template loads with Socket selected and enabled, the hint and the warning, and Apply saves. Choosing Socket there gives the warning and saves. A server without a template gets no warning.
  • Results: the settings and launching test packages pass (119 tests, 0 failures, 0 skipped). With the lock back and the warning dropped, the six new stdio-only tests fail.

…plate lists only stdio

A template is also a starting point: a language server of one's own that talks over a socket may
start from the TypeScript template, whose transports list only stdio, and then couldn't get Socket
in the New Language Server dialog or on the settings page.

Socket now stays enabled, and the grey hint stays as it is. Once Socket is chosen for such a server,
the panel's validation gives a warning on the Socket button, "The template says this language server
talks LSP only over its standard input and output", with OK enabled: the dialog shows it on the
button and below the fields, and Apply on the settings page saves, as for the warning of a stdio
command that takes ${port} (redhat-developer#2010). The settings page doesn't show warnings yet (redhat-developer#2009).

A template without transports, or with a socket mode, gives no warning. Saved settings with a socket
for such a server load with Socket selected and the warning, and still save; how a language server
starts or connects doesn't change.

Validated: TransportFieldsTest, NewLanguageServerDialogTransportTest, LanguageServerViewTransportTest
and the settings and launching test packages, 119 tests, 0 failures, 0 skipped. With the lock back and
the warning dropped, the six new stdio-only tests fail.

Part of redhat-developer#1947
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • Socket transport remains selectable for language server templates that list only standard input/output (stdio).
    • Selecting socket in this case displays a warning, but does not prevent saving settings or proceeding in the New Language Server dialog.
    • The warning clears when switching to stdio; templates that support socket transport or do not specify transports show no warning.
  • Documentation
    • Updated transport guidance to describe socket selection and its warning behavior.

Socket transport remains selectable for templates that list only stdio. Selecting socket for such a template produces a non-blocking warning in the New Language Server dialog and settings. Tests cover these behaviors and cases where no warning appears.

Changes: Socket transport handling

Layer / File(s) Summary
Selectable socket transport and template warning
src/main/java/com/redhat/devtools/lsp4ij/settings/ui/TransportFields.java, src/main/resources/messages/LanguageServerBundle.properties, src/test/java/com/redhat/devtools/lsp4ij/settings/ui/TransportFieldsTest.java, docs/UserDefinedLanguageServerTemplate.md
Socket remains selectable when a template lists only stdio. Selecting it produces an OK-enabled warning. Templates that list a socket transport or have no transport list do not produce this warning. The documentation describes the selection and warning behavior.
Warning propagation in dialogs and settings
src/main/java/com/redhat/devtools/lsp4ij/settings/ui/LanguageServerPanel.java, src/main/java/com/redhat/devtools/lsp4ij/settings/LanguageServerView.java, src/test/java/com/redhat/devtools/lsp4ij/launching/ui/NewLanguageServerDialogTransportTest.java, src/test/java/com/redhat/devtools/lsp4ij/settings/LanguageServerViewTransportTest.java
Language server field validation includes the template warning. Tests cover warning display, saving, and transport selection in the New Language Server dialog and settings.

Estimated code review effort: 3 (Moderate) | ~18 minutes

Change: Bug fix

Suggested reviewers: angelozerr, muescha

Merge Risk: Minimal · up to 70040

Socket stays selectable for templates that list only stdio, and choosing it shows a non-blocking warning. The change is confined to settings and dialog validation, so there is little risk to existing behavior. No merge-blocking concern was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a stdio-only template no longer locks Socket, and choosing Socket now gives a warning. It matches the changeset's core behavior (TransportFields, LanguageServerPanel v…
Description check Passed The description explains the problem (a stdio-only template locked Socket), the new behavior (Socket stays enabled, warning with OK/Apply enabled), the cases with no warning, saved-settings handling, …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: a stdio-only template no longer locks Socket, and choosing Socket now gives a warning. It matches the changeset's core behavior (TransportFields, LanguageServerPanel validation, tests, docs).

Full details: Description check

Explanation

The description explains the problem (a stdio-only template locked Socket), the new behavior (Socket stays enabled, warning with OK/Apply enabled), the cases with no warning, saved-settings handling, docs, and the tests added. It matches the changeset.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ce247c40-c87d-4561-b4d6-0fa38100372d
Commits

Reviewing files that changed from the base of the PR and between 9b3dd91 and 700407a.

Files selected for processing: 8

  • docs/UserDefinedLanguageServerTemplate.md
  • src/main/java/com/redhat/devtools/lsp4ij/settings/LanguageServerView.java
  • src/main/java/com/redhat/devtools/lsp4ij/settings/ui/LanguageServerPanel.java
  • src/main/java/com/redhat/devtools/lsp4ij/settings/ui/TransportFields.java
  • src/main/resources/messages/LanguageServerBundle.properties
  • src/test/java/com/redhat/devtools/lsp4ij/launching/ui/NewLanguageServerDialogTransportTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/settings/LanguageServerViewTransportTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/settings/ui/TransportFieldsTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@lagergren lagergren added this to the 0.30.2 milestone Nov 22, 2026
@codecov

codecov Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 50.43%. Comparing base (cff452a) to head (700407a).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...vtools/lsp4ij/settings/ui/LanguageServerPanel.java 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2087      +/-   ##
==========================================
+ Coverage   50.24%   50.43%   +0.19%     
==========================================
  Files         816      816              
  Lines       33699    33794      +95     
  Branches     6935     5278    -1657     
==========================================
+ Hits        16931    17045     +114     
+ Misses      14127    14110      -17     
+ Partials     2641     2639       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

lagergren added a commit that referenced this pull request Nov 22, 2026
…cument again (#2095)

## What

`FileDocumentMoveTest.testAMoveReconnectsTheFileOfALanguageServerWithoutFileOperations` fails now and then on CI: on main at 36a8efe (run 45033794640) and on #2087 (run 45032590151, 2025.3). It waits 10 seconds for the moved file to be closed and opened again, and the `didOpen` at the new place never comes. It started after #2076.

## Cause

A move disconnects the document of the moved file, which sends `didClose`, and connects it again once the write action is done. Until then, the language server has no document.

#2076 takes a lease on the language server until the server has been told of the move. With no document left, the end of that lease stops the server, and in unit-test mode the stop comes at once. So every move of an open file stopped the server and started it again. Traces showed the stop 0.3 ms after the move scheduled its reconnection, and the reconnection reaching the server about 21 ms later.

When the stop comes after the reconnection has taken the running server, but before it has registered the document, `connectDocument` drops the connection, and the file stays disconnected at its new place. Locally, code vision connected it again about 250 ms later, and restarted the server. On CI, nothing did within the 10 seconds.

Outside unit-test mode, the stop waits for `lastDocumentDisconnectedTimeout`, and the reconnection cancels it. The effect there is a stop timer set for nothing, and a restart if a document matcher takes longer than the timeout to answer.

## Change

`LSPFileListener.reconnectMovedDocument` holds a keep-alive lease on the language server, from the moment that the move disconnects the document until the document is connected again, or it's clear that it won't be: closed, no longer matched, left out by the client features, a failed matcher, moved to another instance, or a connection that throws. Where it called `stopIfIdle` on its own server before, it now ends the lease. Ending the lease stops the server if it has no document left, so a server whose last document doesn't come back still stops, after it's told of the move, as #2076 intends.

`FileDocumentMoveTest`:
- `reconnectAfter` checks that the move didn't stop the language server, and its timeout message says which notification is missing.
- `testALanguageServerKeepsRunningUntilTheMoveOfItsLastDocumentConnectsItAgain` ends a lease while the reconnection of the moved document waits for its connection: the window that CI hit.

## Test

- **Before the change:** the new check fails in all 5 tests that use `reconnectAfter`, and the new test fails too. With the `AbstractLSPFileListener` from before #2076, the 5 pass, and only the new test fails.
- **After the change:**
  - `FileDocumentMoveTest`, `DirectoryDocumentMoveTest`, `FileOperationEditSaveTest` and `FileOperationRefactoringTest` passed 30 times on 2024.2 (990 tests) and 15 times on 2025.3 (495 tests), with 0 failures.
  - All the tests under `com.redhat.devtools.lsp4ij` pass: 1,845 tests, 0 failures, 0 errors, 7 skipped.
@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

lagergren added a commit that referenced this pull request Nov 22, 2026
…IJ has them now (#2094)

## What

The pages on templates, installers and transports no longer matched the code:
- they missed keys and files;
- they said that a socket mode which the transports don't list gets no warning;
- they called the choice of a template a combo box;
- they showed a `void` method returning a future;
- they described the GitHub lookup without its window of 100 releases.

This checks every key that the template deserializers and the installer task factories read, and documents each with its default. The per-server pages are in #2092.

## Change

**`docs/UserDefinedLanguageServerTemplate.md`**
- All the files of a template folder.
- A Fields table for `template.json`, and a Command section: OS keys, macro expansion, quoting.
- The warning for a socket mode that the transports don't list, and how the argument of the transport is swapped.
- The keys of an installer, the task object with `onSuccess` and `onFail`, and the properties.
- When the installer runs: first start, `executeOnStartServer`, Install if Needed, Reinstall, the links of the Installer tab, and debug adapters.
- The `showMessage` task, and the keys of `exec` and `download`.
- The GitHub and Maven lookups, the OS and architecture keys, and the output of a download.

**`docs/UserDefinedLanguageServer.md`**
- When the installer runs, and the links of the Installer tab.
- The stdio warning for `${port}`, the error for a fixed port 0, the retries and the disabling after failed starts, and the warning when an installer switches a socket to stdio.
- `Choose template...` and `Import template...`, the README help button, what an export writes, and the templates that were missing from the list.

**`docs/dap/UserGuide.md`**
- The Server and Installer tabs, the buildx-dockerfile template, and the fields and files of a DAP template.

**`docs/DeveloperGuide.md`**
- `install()` returns nothing, and the options of `ServerInstallationContext`.
- Both loopback addresses for a socket.
- The environment of the working directory for a plugin's command line.
- What happens to `workspaceFolderSettings.json`.

**`docs/dap/DeveloperGuide.md`**
- When the installer of a DAP server is checked, and the right link for writing one.

## How it was checked

- Each statement was read against the code on `main`: the template deserializers and managers, `InstallerTaskRegistry`, `ServerInstallerManager`, the task factories and tasks, the fetchers, `NewLanguageServerDialog`, `LanguageServerPanel`, `UICommandLineUpdater`, `SocketStreamConnectionProvider` and `LanguageServerWrapper`, and the bundled `template.json` and `installer.json` files.
- A script checked every relative link and anchor in the changed pages, and the anchors of the docs that `plugin.xml` and the installer's error messages link to.
- It merges without conflicts with #2087, #2089, #2091 and #2092.
- No test reads these pages.
@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren
lagergren merged commit decd518 into redhat-developer:main Nov 23, 2026
13 of 14 checks passed
lagergren added a commit that referenced this pull request Nov 23, 2026
…#2131)

Part of #1947.

## What

A language server keeps only its own transport, not the `transports` that its template lists. Its export wrote `socket` but never `transports`, so a language server created from the export allowed every transport again. The template's hint and warning were gone: since #2087, the TypeScript template gives "The template says this language server talks LSP only over its standard input and output" when Socket is chosen. So was the argument that a change of the transport swaps in the command (#1969).

## Change

- **The export writes the `transports` of the template** that the language server was created from (`LanguageServerDefinitionSerializer`). The template is found as the settings page finds it since #1962: by the server's template id, among the bundled templates. Each entry has its `mode`, and its `argument` when the template has one, as the template has them; an empty one is kept, as in cpp_ls's stdio.
- **No `transports`, as before,** for a language server without a template, one created from a custom template (an imported template has no `id`), or one whose template LSP4IJ no longer bundles.
- **Import is unchanged:** "Import template..." already reads `transports` as it does for a bundled template, so the New Language Server dialog gives the import the template's hint, warning and argument swap.
- **A socket from a stdio-only template:** a language server over a socket, created from a template whose `transports` list only `stdio`, exports both. Its import also lists #1981's "The socket mode startAndAccept of the template isn't one of its transports" next to the Socket warning. Both are warnings, so OK stays enabled.
- **Unchanged:** the definition and its settings (nothing new is persisted), the template format, the settings page, and how a language server starts.
- **Still open:** a language server created from an imported export has no template id, so its settings page has no hint or warning, and its own export has no `transports`, as for any custom template. That would need `transports` in the settings, which this leaves out.
- **Docs:** the export section of `UserDefinedLanguageServer.md`; the `id` field, and the Transports and Socket and transports sections of `UserDefinedLanguageServerTemplate.md`.

## Behaviour change

An exported language server created from a bundled template now includes that template's `transports`, so a language server created from the export gets the same transport hint, warning and command-argument swap as the template.

| Exported language server | Before | After |
|---|---|---|
| From the TypeScript template (stdio only) | No `transports`: the import allows every transport, without a hint | `[stdio --stdio]`: the stdio-only hint, and the warning when Socket is chosen |
| From the CSS template (stdio, startAndAccept) | No `transports`: no socket hint, no argument swap | Both: the socket hint names `--socket=${port}`, and Socket swaps `--stdio` for it |
| Over a socket, from the TypeScript template | `socket` only | `socket` and `transports`: Socket stays chosen, with the Socket warning and "The socket mode … isn't one of its transports" |
| Without a template, from a custom template, or whose template is gone | No `transports` | No `transports` |

## Backward compatibility

- **Settings:** unchanged; nothing new is persisted.
- **Export format:** `transports` has the shape that bundled templates have used since 0.30.0 (`mode`, optional `argument`).
- **An older LSP4IJ importing a new export:**
  - before 0.30.0, the template deserializer reads only the fields it knows, so `transports` is ignored, as `socket` is (checked on 0.21.0);
  - 0.30.0 and 0.30.1 read `transports` as they do for a bundled template, so the import behaves as the template does in that version: for a stdio-only template, Socket is locked with the hint, the lock that #2087 replaces.
- **A new LSP4IJ importing an old export:** no `transports`, as before.

## Test

- `NewLanguageServerDialogTransportTest` exports a language server with `exportLsTemplates`, unzips it, imports it with `importServerTemplate`, and loads it in the New Language Server dialog:
  - from the TypeScript template: `[stdio --stdio]`, no template problem, the stdio-only hint, Socket enabled, and choosing it gives the warning on the Socket button and below the fields, with OK enabled;
  - from the CSS template: both transports, the socket hint with `--socket=${port}`, and Socket swaps `--stdio` for it;
  - over a socket, from the TypeScript template: the socket and `transports` are kept, the socket mode that isn't listed is reported, and the dialog shows the Socket warning; every warning keeps OK enabled;
  - without a template, and with a template id that LSP4IJ doesn't have: no `transports` in `template.json`, and no hint or warning.
- `LanguageServerSocketTemplateTest`: for every bundled template with `transports`, the exported `transports` equal the template's JSON, and read back to the same list.
- Without the serializer change, the 4 new behaviour tests fail. The 2 no-template tests pass either way, as they check what stays the same.
- The template, export, import and transport tests (11 classes, 103 tests) pass on IC 2024.2, IC 2025.3 and IU 2026.3. The full suite passes on IC 2024.2: 1952 tests, 0 failures, 7 skipped (the Windows-only, Docker Bake and Perl tests).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant