Skip to content

fix: help with a language server whose template lists only socket modes, and name every listed socket mode in the hint - #2132

Merged
lagergren merged 3 commits into
redhat-developer:mainfrom
lagergren:fix/socket-only-template-transports
Nov 23, 2026
Merged

lagergren merged 3 commits into
redhat-developer:mainfrom
lagergren:fix/socket-only-template-transports

Conversation

@lagergren

@lagergren lagergren commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #1947.

Please merge with "Rebase and merge", not "Squash and merge". Each of the three commits is one behaviour change, and its title says what users will notice, so a rebase merge puts each in the release notes.

What

Two sections of #1947:

  • A language server that talks only over a socket. A template can say so by listing only socket modes in transports, but nothing used that:
    • there was no hint, and no warning for stdio;
    • without a socket, the New Language Server dialog selected stdio;
    • an installer whose command has no ${port} switched such a language server to stdio (forInstalledCommand), where it can't talk, so it couldn't start afterwards. That happens both when the server starts and from the dialog, also with a fixed port, where the command may name the port itself.
  • The hint uses only the first socket mode of transports. A template that lists startAndConnect and startAndAccept named only the first. Choosing the second swapped its argument into the command, while the hint kept naming the first one's.

No bundled template lists only socket modes, or two socket modes, so this is for imported and plugin templates.

Change

  1. Socket, a hint, and a stdio warning (3be8ed8):
    • The grey hint "This language server talks LSP only over a socket." below the transport.
    • Stdio gives the warning "The template says this language server talks LSP only over a socket" on its button. It is asWarning().withOKEnabled(), so OK and Apply still save.
    • Without a socket, the dialog selects Socket in the first listed socket mode, with an Auto port (attach: no port yet). This happens in loadFromTemplate only, so saved settings never change.
  2. The installer keeps the socket (67868ae):
    • The new UserDefinedTransport.forInstalledCommand(command, supportedTransports) keeps the transport of a language server whose template lists only socket modes. The one-argument method is unchanged.
    • UICommandLineUpdater finds the template by its id among the bundled ones, as the settings page does. The dialog uses the template it loaded.
    • With an Auto port, the kept socket can't start until the command takes ${port}. A notification says so, with the action that opens the settings, and the dialog shows its existing ${port} error. A fixed port, which the command may name itself, gets no warning.
  3. A hint for every listed socket mode (d7237d7):
    • One hint per socket mode, in the order of the list, with the existing wording.
    • A mode listed twice shows its first entry, which is the argument the command gets.
    • A template with one socket mode shows the same hint as before.

Docs: the Socket and Transports sections of UserDefinedLanguageServerTemplate.md, and the installer paragraph of UserDefinedLanguageServer.md.

Behaviour changes

Change Commit Who sees it
A language server whose template lists only socket modes starts on Socket in the New Language Server dialog, with a hint that it talks LSP only over a socket, and a warning that doesn't block OK or Apply when stdio is chosen. Before: stdio, with no hint or warning. 3be8ed8 templates that list only socket modes; no bundled one does
An installer whose command has no ${port} no longer switches such a language server to stdio, on which it can't talk. It keeps its socket, and with an Auto port a warning says that its command needs ${port}. 67868ae the same
The hint below the socket modes names every socket mode that the template lists, each with its argument, instead of only the first. d7237d7 templates that list several socket modes; no bundled one does

Backward compatibility

  • A template without transports, or with stdio and a socket mode, behaves as before. That is every bundled template.
  • Saved settings keep their transport. A saved stdio of such a language server loads unmodified, with the hint and the warning, and Apply saves it.
  • A template's own socket is kept.
  • The template and settings formats are unchanged. The API only gains forInstalledCommand(String, List<TransportSupport>) and TransportSupport.talksOnlyOverASocket(List).
  • A language server created from an imported template gets this in the New Language Server dialog only: it has no template id, so its settings page and its installer don't find the template. fix: an exported language server keeps the transports of its template #2131 keeps transports in an export, but not with such a server.

Test

  • New tests in TransportFieldsTest, NewLanguageServerDialogTransportTest, LanguageServerViewTransportTest, UICommandLineUpdaterTransportTest and UserDefinedTransportTest: the hint, the stdio warning, the default Socket, a saved stdio, the installer with an Auto and a fixed port, and every listed socket mode. The settings-page and installer tests add a socket-only template to the bundled ones for the test, as none is bundled.
  • With each behaviour put back as on main, its new tests fail: 6 (and the dialog's installer test, which needs the default Socket) for the first commit, 4 for the second, 2 for the third.
  • The settings and launching packages and the transport tests (22 classes, 153 tests) pass on 2024.2, 2025.3 and IU 2026.3. The full suite passes on 2024.2: 1958 tests, 0 failures, 7 skipped (the Windows-only, Docker Bake and Perl tests).

@lagergren lagergren added this to the 0.30.2 milestone Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • Language server templates that support only socket transports now default to a supported socket mode, with hints for each listed mode.
    • Transport selection respects the modes declared by a template. Warnings explain when the chosen mode is unsupported or when a command may not receive the automatically assigned port; these warnings do not prevent saving.
    • Documentation now describes socket-only templates, transport selection, and installer behavior.

The change updates template-aware transport selection for socket-only language servers. New-server creation and installer command updates retain or select a supported socket mode and warn when an automatic port is not passed to the command. Settings now show per-mode hints and non-blocking warnings for transport mismatches.

Changes: Socket-only transport handling

Layer / File(s) Summary
Socket-aware transport selection
src/main/java/com/redhat/devtools/lsp4ij/server/definition/launching/TransportSupport.java, src/main/java/com/redhat/devtools/lsp4ij/server/definition/launching/UserDefinedTransport.java, src/test/java/com/redhat/devtools/lsp4ij/server/definition/launching/UserDefinedTransportTest.java
A new check identifies non-empty transport lists without stdio. The added forInstalledCommand overload retains the current transport for socket-only lists. Tests cover socket and stdio command selection.
Template loading and installer updates
src/main/java/com/redhat/devtools/lsp4ij/launching/ui/NewLanguageServerDialog.java, src/main/java/com/redhat/devtools/lsp4ij/launching/ui/UICommandLineUpdater.java, src/test/java/com/redhat/devtools/lsp4ij/launching/ui/NewLanguageServerDialogTransportTest.java, src/test/java/com/redhat/devtools/lsp4ij/UICommandLineUpdaterTransportTest.java, src/main/resources/messages/LanguageServerBundle.properties, docs/UserDefinedLanguageServer.md, docs/UserDefinedLanguageServerTemplate.md
New-server creation selects a socket mode when the template lists only socket modes. Installer command updates use template transport support and warn when an automatic port is not included in the command. Tests and documentation cover these behaviors.
Settings transport validation and hints
src/main/java/com/redhat/devtools/lsp4ij/settings/ui/TransportFields.java, src/main/java/com/redhat/devtools/lsp4ij/settings/ui/LanguageServerPanel.java, src/test/java/com/redhat/devtools/lsp4ij/settings/LanguageServerViewTransportTest.java, src/test/java/com/redhat/devtools/lsp4ij/settings/ui/TransportFieldsTest.java, src/main/resources/messages/LanguageServerBundle.properties, docs/UserDefinedLanguageServerTemplate.md
Settings show a hint for each distinct listed socket mode and a non-blocking warning when the selected transport conflicts with a socket-only or stdio-only template. Tests cover hint ordering and validation.

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant UICommandLineUpdater
  participant UserDefinedTransport
  participant TransportSupport
  UICommandLineUpdater->>UserDefinedTransport: Select transport using command and supported transports
  UserDefinedTransport->>TransportSupport: Check whether transports are socket-only
  TransportSupport-->>UserDefinedTransport: Return socket-only result
  UserDefinedTransport-->>UICommandLineUpdater: Return selected transport
  UICommandLineUpdater->>UICommandLineUpdater: Warn if port is 0 and command lacks ${port}
Loading

Suggested reviewers: angelozerr, muescha

Merge Risk: Minimal · up to d7237

This change lets templates that list only socket transports select and keep a socket mode, and shows accurate hints and warnings. Existing behavior for other templates is unchanged, and the new behavior is covered by tests. No merge-blocking risk is apparent.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a fix for language servers whose template lists only socket modes, plus the hint naming every listed socket mode. The changeset matches both parts, though the title is…
Description check Passed The description states the purpose, the three behaviour changes, backward compatibility, and test results. It matches the changeset, which covers the socket-only hint, the stdio warning, the installer…
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 fix for language servers whose template lists only socket modes, plus the hint naming every listed socket mode. The changeset matches both parts, though the title is long (118 characters) and combines two behaviours.

Full details: Description check

Explanation

The description states the purpose, the three behaviour changes, backward compatibility, and test results. It matches the changeset, which covers the socket-only hint, the stdio warning, the installer transport handling, the per-mode hints, and the docs.

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: ac9c314b-1446-4b5f-a777-fa2c976ec78a
Commits

Reviewing files that changed from the base of the PR and between 2abaa4a and d7237d7.

Files selected for processing: 14

  • docs/UserDefinedLanguageServer.md
  • docs/UserDefinedLanguageServerTemplate.md
  • src/main/java/com/redhat/devtools/lsp4ij/launching/ui/NewLanguageServerDialog.java
  • src/main/java/com/redhat/devtools/lsp4ij/launching/ui/UICommandLineUpdater.java
  • src/main/java/com/redhat/devtools/lsp4ij/server/definition/launching/TransportSupport.java
  • src/main/java/com/redhat/devtools/lsp4ij/server/definition/launching/UserDefinedTransport.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/UICommandLineUpdaterTransportTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/launching/ui/NewLanguageServerDialogTransportTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/server/definition/launching/UserDefinedTransportTest.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.

@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.20%. Comparing base (2abaa4a) to head (d7237d7).

Files with missing lines Patch % Lines
...s/lsp4ij/launching/ui/NewLanguageServerDialog.java 75.00% 2 Missing and 1 partial ⚠️
...ools/lsp4ij/launching/ui/UICommandLineUpdater.java 75.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2132      +/-   ##
==========================================
+ Coverage   53.16%   53.20%   +0.03%     
==========================================
  Files         826      826              
  Lines       34679    34717      +38     
  Branches     5414     7143    +1729     
==========================================
+ Hits        18438    18471      +33     
- Misses      13471    13475       +4     
- Partials     2770     2771       +1     

☔ 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
lagergren force-pushed the fix/socket-only-template-transports branch from e2b13af to f816b22 Compare November 23, 2026 12:01
…rver whose template lists only socket modes

A template can say that its language server talks LSP only over a socket,
by listing only socket modes in `transports`, but nothing used that: no
hint, no warning for stdio, and without a `socket` the New Language Server
dialog selected stdio, over which such a language server can't talk.

- A grey hint below the transport, "This language server talks LSP only
  over a socket.", in the dialog and on the settings page of a language
  server created from a bundled template.
- Stdio gives the warning "The template says this language server talks
  LSP only over a socket" on the stdio button. It is
  asWarning().withOKEnabled(), so OK and Apply still save.
- Without a `socket`, the dialog selects Socket for it, in the first socket
  mode of `transports`, with an Auto port (attach: no port yet).
- Unchanged: a template without `transports`, or with stdio and a socket
  mode; a template's own `socket`; and saved settings, which keep their
  transport (a saved stdio shows with the warning, and Apply saves it).

Part of redhat-developer#1947.
… lists only socket modes to stdio

An installer's command is taken to be for the standard input and output
unless it takes ${port}, so a language server which LSP4IJ starts over a
socket was switched to stdio by one without it. A language server whose
template lists only socket modes can't talk over stdio, so it couldn't
start at all afterwards.

- forInstalledCommand(command, supportedTransports) keeps the transport of
  such a language server, and switches any other as before. The
  one-argument forInstalledCommand is unchanged.
- The installer of a language server, at its start or from its settings,
  finds its template by its id among the bundled ones, as the settings page
  does. The New Language Server dialog uses the template it loaded,
  imported ones included.
- With an Auto port, the kept socket can't start until the command takes
  ${port}: a warning says so, with the action which opens the settings, and
  the dialog shows its error "With an Auto port, the command must take the
  port as ${port}". A fixed port, which the command may name itself, gets
  no warning.

Part of redhat-developer#1947.
…ly the first

The hint below the socket modes took the first entry of `transports`
which isn't stdio, so a template which lists both startAndConnect and
startAndAccept, each with its own argument, named only the first: after
choosing the other mode, whose argument the command then gets, the hint
still named the first one's.

- Each socket mode which the template lists has its hint, in the order of
  the list, with the wording of the hint as before: "This language server
  takes the port as {argument}, with "{mode}".", or "This language server
  supports "{mode}"." without an argument.
- A mode listed twice has the hint of its first entry, whose argument the
  command gets when the mode is chosen.
- A template which lists one socket mode shows the same hint as before.

Part of redhat-developer#1947.
@lagergren
lagergren force-pushed the fix/socket-only-template-transports branch from f816b22 to d7237d7 Compare November 23, 2026 12:34
@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 d32f014 into redhat-developer:main Nov 23, 2026
10 checks passed
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