Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle responses for show window request and delegate to add-ons #2803

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

vinistock
Copy link
Member

Motivation

Add-ons won't have a lot of flexibility when it comes to UI elements since the LSP specification doesn't prescribe that. However, we can still allow for a certain degree of interactions by delegating responses of the window/showMessageRequest request.

This request made by the server allows LSPs to show a dialog with buttons to the user. The response includes which button was clicked and any other attributes (as long as the client supports additional properties).

We can use this to allow for more interactivity for add-ons. The current use case we will use this for is letting the Rails add-on inform the user there's a pending migration with a button to run it.

Implementation

Started handling responses for window/showMessageRequest. We enforce the add-ons must provide their name as part of the original request in order to receive the response delegated appropriately.

Also, started remembering if the client supports additional properties. Add-ons can only use this mechanism in such cases because otherwise they don't have the means to inform us of their name for delegation.

Automated Tests

Added a test.

@vinistock vinistock added enhancement New feature or request server This pull request should be included in the server gem's release notes labels Oct 30, 2024
@vinistock vinistock self-assigned this Oct 30, 2024
@vinistock vinistock requested a review from a team as a code owner October 30, 2024 17:22
@vinistock vinistock force-pushed the vs-handle-show-window-request-response branch 2 times, most recently from c89859c to 5d16fb4 Compare October 30, 2024 18:40
test/server_test.rb Outdated Show resolved Hide resolved
@vinistock vinistock force-pushed the vs-handle-show-window-request-response branch from 5d16fb4 to f17561c Compare October 30, 2024 19:01
@vinistock vinistock enabled auto-merge (squash) October 30, 2024 19:01
@vinistock vinistock merged commit 33fd4e9 into main Oct 30, 2024
36 checks passed
@vinistock vinistock deleted the vs-handle-show-window-request-response branch October 30, 2024 19:26
@st0012
Copy link
Member

st0012 commented Oct 31, 2024

How can we trigger the request in the first place? Through the VS Code extension?

@vinistock
Copy link
Member Author

No, the server sends a request to the client and it returns a response once something was clicked.

It's the window/showMessageRequest. Essentially, you would do this:

# Send the request to the client
outgoing_queue << Request.new(
  id: @current_request_id,
  method: "window/showMessageRequest",
  params: ...
)

# Then once the user clicks on one of the buttons, we receive the response and delegate it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request server This pull request should be included in the server gem's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants