Skip to content

Conversation

@aseemxs
Copy link
Contributor

@aseemxs aseemxs commented Mar 6, 2025

These changes are related to an attempt of moving notifications to a common approach. This will be done in integration with Flare server.

Notification-poc

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@aseemxs aseemxs requested a review from breedloj March 6, 2025 22:48
@aseemxs aseemxs changed the title Notifications poc aseem feature/Notifications Mar 10, 2025
message,
checked -> {
if (checked) {
Activator.getPluginStore().put("notificationSkipFlag", "true");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we will need this to be more granular - e.g. per notification type.

@breedloj
Copy link
Contributor

Please add additional details to your PR title & description, including screenshots of the various notification types.

@aseemxs aseemxs marked this pull request as draft March 14, 2025 18:08
void ssoTokenChanged(SsoTokenChangedParams params);

@JsonNotification("aws/window/showNotification")
void showNotification(NotificationParams params);

Choose a reason for hiding this comment

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

Nothing to worry about now, but I may try to convert this to showNotifications (if Flare will agree) and send an array of Notification instead of just one.

});
}

private NotificationSeverity determineNotificationSeverity(final MessageType type) {

Choose a reason for hiding this comment

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

Severity will be moved to a PresentationHint, which means you'll be able to define the string values however you want. Does Java have a way of parsing strings into enums? If so, this can probably be simplified when the notification protocol changes are made and the server starts sending the updated notification format.

Or based on breedloj@ comment below, maybe Severity isn't needed at all.

List<String> commands = new ArrayList<>();
commands.add(serverCommand.toString());
commands.add(lspInstallResult.getServerCommandArgs());
//commands.add(lspInstallResult.getServerCommandArgs());

Choose a reason for hiding this comment

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

Be sure to add a comment here about you're doing this for development on the feature branch and this should not be checked into main. We don't want this making it into prod.

@@ -0,0 +1,3 @@
package software.aws.toolkits.eclipse.amazonq.lsp.model;

public record NotificationAction(String text, String type) { }

Choose a reason for hiding this comment

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

Notification actions may include a URI property (wait for the Flare protocol updates).

* @param lspClient The LSP client to use for communication with the server
* @return The NotificationConfiguration instance
*/
public static synchronized NotificationConfiguration getInstance(AmazonQLspClient lspClient) {

Choose a reason for hiding this comment

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

Consider splitting this to explicit instantiation instead of lazy instantiation so that not all code that wants to call getInstance must also have an instance of AmazonQLspClient easily available as well.

* Initialize static client states that won't change during the Eclipse session.
*/
private void initializeStaticClientStates() {
clientStates.put("IDE/VERSION", Collections.singletonList(getEclipseVersion()));

Choose a reason for hiding this comment

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

Consider defining these as constants in a single location (e.g. constants at the top of this class or a separate NotificationClientStates class) so they're easily discoverable and documentable in the code. The runbook will want to link to the code for explicit client state definitions and descriptions rather than being reproduced (yet another place to keep in sync) in the runbook.

Also consider camelCase for the literal client state names as people tend not to like SCREAMING_SNAKE_CASE anymore.


private final AmazonQLspClient lspClient;

private final List<String> contexts = new ArrayList<>();

Choose a reason for hiding this comment

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

Consider using a HashSet for contexts.

*
* @return A map representing the current notification configuration
*/
public synchronized Map<String, Object> getConfiguration() {

Choose a reason for hiding this comment

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

Not sure this needs to be public. Will client code need this?

The format of this will be a little different, but doesn't need to be updated now.

scheduler.schedule(() -> {
try {
lspClient.didChangeConfiguration(null);
Activator.getLogger().info("sent didChangeConfiguration notification");

Choose a reason for hiding this comment

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

typo: Capitalize "sent"

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