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

Use vscode-messenger library for vscode messages #299

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bhufmann
Copy link
Collaborator

@bhufmann bhufmann commented Jan 24, 2025

What it does

Use vscode-messenger library for communication of extension and webviews.

The extension returns also a Diagnostic object (appended to the vscode-trace-extension's ExternalAPI so that message exchanges can be logged using the VS Code Messenger Developer Tool. This is purely for trouble shooting purposes.

Fixes #78.

Note: There is a non-backward compatible change for third-party extension using interfacing the vscode-trace-extension with this change. The messenger library is using method instead of command for message keys. Downstream projects will need to update their callback methods (see message.method below).

for (const webview of importedApi.getActiveWebviews()) {
    webview.webview.onDidReceiveMessage((message) => {
        switch (message.method) {
            case "webviewReady":
            console.log("From adopter extension - webviewReady signal received");
            break;
            default:
            break;
        }
    });
}

How to test

Run and use the extension. No change in behavior is expected.

Follow-ups

Use vscode-messenger capabilities to send messages directly webview <-> webview/set of webviews instead of going through the extension host which forwards them is using node signals as described here. This would simplify webview synchronization. However, the implementation for persisting of webview states (e.g. selected experiment) need to be changed. Not using Node signals would affect the external API of the vscode-trace-extension, regarding onSignalManagerSignal and onSignalManagerSignal as described here, and this has to be addressed when implementing it.

We can also use message types Request and Response instead of Notification where applicable.

We also have the possibility to introduce typing of the message data.

Review checklist

  • As an author, I have thoroughly tested my changes and carefully followed the instructions in this template

@bhufmann
Copy link
Collaborator Author

A review is required for npm/npmjs/-/vscode-messenger-webview/0.5.1.
A review request was created https://gitlab.eclipse.org/eclipsefdn/emo-team/iplab/-/issues/19196

A review is required for npm/npmjs/-/vscode-messenger-common/0.5.1.
A review request was created https://gitlab.eclipse.org/eclipsefdn/emo-team/iplab/-/issues/19197

A review is required for npm/npmjs/-/vscode-messenger/0.5.1.
A review request was created https://gitlab.eclipse.org/eclipsefdn/emo-team/iplab/-/issues/19198

Fixes eclipse-cdt-cloud#78

Non-backwards compatible change for downstream project when registering
callbacks for webview messages. The key for the command key is changed
from `message.command` to `method.method`.

Signed-off-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
@bhufmann
Copy link
Collaborator Author

FYI @ngondalia, @GregSavin regarding non-backwards compatible change and future follow-ups.

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.

Use vscode-messenger library for communcation between views and extension
1 participant