Skip to content

Refactor: Define Webview RPC Contracts Using JSON-RPC syntax to added typings #19613

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

Merged
merged 16 commits into from
Jun 17, 2025

Conversation

aasimkhan30
Copy link
Contributor

Pull Request Template – vscode-mssql

Description

This PR updates our webview communication to follow a more structured JSON-RPC style by introducing strongly typed contracts.

We now support bidirectional communication between webviews and their controllers via:

  • onRequest
  • sendRequest
  • onNotification
  • sendNotification

This change brings our webview architecture closer to the existing STS ↔ extension communication model. It unifies the syntax, improves type safety, and makes development and debugging much easier.

One of the biggest benefits is improved discoverability. You can now easily trace who is calling or handling a request just by checking the references of the request type:

example

In this screenshot, GetPlatformRequest clearly shows both the caller and the handler, making things more maintainable.

I'll explore a similar pattern for refactoring reducers in a future PR.

Code Changes Checklist

  • New or updated unit tests added
  • All existing tests pass (npm run test)
  • Code follows contributing guidelines
  • Telemetry/logging updated if relevant
  • No regressions or UX breakage

Reviewers: Please read our reviewer guidelines

aasimkhan30 and others added 7 commits June 12, 2025 23:35
…quest and notification types for improved communication and state management
…n structure

- Updated VscodeWebviewProvider to utilize sendRequest and sendNotification for theme, state, and localization retrieval.
- Refactored ConnectionDialogStateProvider to replace call with sendRequest for getting connection display names.
- Modified CommandBar and QueryResultPane to use sendRequest for saving results and loading rows.
- Enhanced table plugins to adopt sendRequest for clipboard operations and filter management.
- Updated SchemaDesignerStateProvider to utilize sendRequest for initializing and managing schema sessions.
- Introduced new request types in sharedInterfaces for better type safety and clarity in RPC communication.
…otification structure for improved communication and state management
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review this file more carefully as it actually defines the new architecture.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review this file more carefully as it actually defines the new architecture.

Copy link

github-actions bot commented Jun 16, 2025

PR Changes

Category Main Branch PR Branch Difference
Code Coverage 59.29% 59.35% ⚪ 0.00%
VSIX Size 15387 KB 15437 KB ⚪ 50 KB ( 0% )
Webview Bundle Size 3712 KB 3768 KB 🔴 56 KB ( 1% )

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { ExpandParams } from "./expandNodeRequest";
import { RequestType } from "vscode-jsonrpc";
import { RequestType } from "vscode-languageclient";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping it consistent with other mssql contracts.

…c to improve clarity and consistency in request resolution
…roved accessibility in ReactWebviewBaseController
…e arrow function syntax for improved consistency and readability
Copy link
Member

@caohai caohai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall, I did extensive testing in query result area and there's no issue found other the ones I mentioned earlier.

@aasimkhan30 aasimkhan30 merged commit 8d45001 into main Jun 17, 2025
5 checks passed
@aasimkhan30 aasimkhan30 deleted the aasim/fix/webviewContStrongTypings branch June 17, 2025 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants